storage_daemon异常crash后进入锁屏

Signed-off-by: renguang1116 <renguang@huawei.com>
This commit is contained in:
renguang1116 2024-08-23 09:14:34 +08:00
parent 74c0ee2a0d
commit b5582ba38d
13 changed files with 89 additions and 0 deletions

View File

@ -58,6 +58,7 @@
"relational_store",
"safwk",
"samgr",
"screenlock_mgr",
"selinux_adapter",
"os_account",
"openssl",

View File

@ -113,6 +113,11 @@ ohos_shared_library("storage_manager") {
}
}
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
subsystem_name = "filemanagement"
part_name = "storage_service"
install_enable = true

View File

@ -53,6 +53,11 @@ ohos_unittest("crypto_manager_service_test") {
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
group("storage_manager_crypto_test") {

View File

@ -54,10 +54,16 @@ ohos_unittest("disk_manager_service_test") {
"common_event_service:cesfwk_innerkits",
"hilog:libhilog",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
group("storage_manager_disk_test") {

View File

@ -69,6 +69,7 @@ public:
int32_t SetRecoverKey(const std::vector<uint8_t> &key);
int32_t ResetSdProxy();
void ForceLockUserScreen();
// app file share api
std::vector<int32_t> CreateShareFile(const std::vector<std::string> &uriList, uint32_t tokenId, uint32_t flag);

View File

@ -65,10 +65,16 @@ ohos_unittest("storage_manager_proxy_test") {
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
ohos_unittest("storage_manager_stub_test") {

View File

@ -67,12 +67,18 @@ ohos_unittest("storage_total_status_service_test") {
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"relational_store:native_dataability",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
ohos_unittest("volume_storage_status_service_test") {

View File

@ -21,6 +21,10 @@
#include "ipc/istorage_daemon.h"
#include "ipc/storage_daemon.h"
#include "ipc/storage_daemon_proxy.h"
#include "os_account_manager.h"
#ifdef ENABLE_SCREENLOCK_MANAGER
#include "screenlock_manager.h"
#endif
#include "storage_service_errno.h"
#include "storage_service_log.h"
@ -388,9 +392,35 @@ int32_t StorageDaemonCommunication::ResetSdProxy()
return E_OK;
}
void StorageDaemonCommunication::ForceLockUserScreen()
{
LOGI("StorageDaemonCommunication::ForceLockUserScreen, storage_daemon process maybe has died.");
#ifdef ENABLE_SCREENLOCK_MANAGER
std::vector<int32_t> ids;
int32_t ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
if (ret != ERR_OK || ids.empty()) {
LOGE("Query active userid failed, ret = %{public}u", ret);
return;
}
int reasonFlag = static_cast<int>(ScreenLock::StrongAuthReasonFlags::ACTIVE_REQUEST);
ret = ScreenLock::ScreenLockManager::GetInstance()->RequestStrongAuth(reasonFlag, ids[0]);
if (ret != ScreenLock::E_SCREENLOCK_OK) {
LOGE("Request strong auth by screen lock manager failed.");
return;
}
ret = ScreenLock::ScreenLockManager::GetInstance()->Lock(ids[0]);
if (ret != ScreenLock::E_SCREENLOCK_OK) {
LOGE("Lock user screen by screen lock manager failed.");
}
LOGI("Force lock user screen and request strong auth success for userId = %{public}d.", ids[0]);
#endif
}
void SdDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
{
LOGE("StorageDaemonCommunication::OnRemoteDied, storage_daemon process has died.");
DelayedSingleton<StorageDaemonCommunication>::GetInstance()->ResetSdProxy();
DelayedSingleton<StorageDaemonCommunication>::GetInstance()->ForceLockUserScreen();
}
std::vector<int32_t> StorageDaemonCommunication::CreateShareFile(const std::vector<std::string> &uriList,

View File

@ -58,9 +58,15 @@ ohos_unittest("storage_daemon_communication_test") {
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
group("storage_manager_communication_test") {

View File

@ -50,9 +50,15 @@ ohos_unittest("multi_user_manager_service_test") {
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
group("storage_manager_user_test") {

View File

@ -100,10 +100,16 @@ ohos_unittest("volume_manager_service_test") {
"common_event_service:cesfwk_innerkits",
"hilog:libhilog",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
group("storage_manager_volume_test") {

View File

@ -37,6 +37,12 @@ declare_args() {
} else {
enable_user_auth_framework = false
}
if (defined(global_parts_info) &&
defined(global_parts_info.theme_screenlock_mgr)) {
enable_screenlock_manager = true
} else {
enable_screenlock_manager = false
}
}
storage_manager_path =
"//foundation/filemanagement/storage_service/services/storage_manager"

View File

@ -48,6 +48,11 @@ ohos_fuzztest("FileSystemCryptoFuzzTest") {
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
]
if (enable_screenlock_manager) {
defines += [ "ENABLE_SCREENLOCK_MANAGER" ]
external_deps += [ "screenlock_mgr:screenlock_client" ]
}
}
group("fuzztest") {