create bundle dir in grade scenario

Signed-off-by: gsl_1234 <gaoshunli@huawei.com>
This commit is contained in:
gsl_1234 2024-01-13 16:03:56 +08:00
parent df8296b8d8
commit a623a48ca8
9 changed files with 25 additions and 0 deletions

View File

@ -114,6 +114,7 @@ ohos_executable("storage_daemon") {
"ability_base:want",
"ability_base:zuri",
"app_file_service:fileshare_native",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",

View File

@ -35,6 +35,7 @@ public:
int32_t DestroyUserDirs(int32_t userId, uint32_t flags);
int32_t StartUser(int32_t userId);
int32_t StopUser(int32_t userId);
void CreateBundleDataDir(uint32_t userId);
private:
int32_t PrepareDirsFromIdAndLevel(int32_t userId, const std::string &level);

View File

@ -194,6 +194,9 @@ int32_t StorageDaemon::RestoreUserOneKey(int32_t userId, KeyType type)
return ret;
}
(void)remove(elNeedRestorePath.c_str());
if (type == EL4_KEY) {
UserManager::GetInstance()->CreateBundleDataDir(userId);
}
LOGI("restore User %{public}u el%{public}u success", userId, type);
}
return E_OK;
@ -460,6 +463,7 @@ int32_t StorageDaemon::ActiveUserKey(uint32_t userId,
{
#ifdef USER_CRYPTO_MANAGER
LOGI("userId %{public}u, tok empty %{public}d sec empty %{public}d", userId, token.empty(), secret.empty());
bool updateFlag = false;
int ret = KeyManager::GetInstance()->ActiveCeSceSeceUserKey(userId, EL2_KEY, token, secret);
if (ret != E_OK) {
#ifdef USER_CRYPTO_MIGRATE_KEY
@ -467,6 +471,7 @@ int32_t StorageDaemon::ActiveUserKey(uint32_t userId,
userId, token.empty(), secret.empty());
std::string el2NeedRestorePath = GetNeedRestoreFilePath(userId, USER_EL2_DIR);
if (std::filesystem::exists(el2NeedRestorePath) && (!token.empty() || !secret.empty())) {
updateFlag = true;
ret = PrepareUserDirsAndUpdateUserAuth(userId, EL2_KEY, token, secret);
}
#endif
@ -489,6 +494,9 @@ int32_t StorageDaemon::ActiveUserKey(uint32_t userId,
return ret;
}
if (updateFlag) {
UserManager::GetInstance()->CreateBundleDataDir(userId);
}
return ret;
#else
return E_OK;

View File

@ -72,6 +72,7 @@ ohos_unittest("storage_daemon_test") {
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"app_file_service:fileshare_native",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"dfs_service:cloud_daemon_kit_inner",
"hilog:libhilog",
@ -151,6 +152,7 @@ ohos_unittest("storage_daemon_stub_test") {
external_deps = [
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"huks:libhukssdk",

View File

@ -15,6 +15,7 @@
#include "user/user_manager.h"
#include <cstdlib>
#include "bundle_mgr_client.h"
#ifdef USER_CRYPTO_MANAGER
#include "crypto/key_manager.h"
#endif
@ -367,5 +368,13 @@ int32_t UserManager::CheckUserIdRange(int32_t userId)
}
return E_OK;
}
void UserManager::CreateBundleDataDir(uint32_t userId)
{
OHOS::AppExecFwk::BundleMgrClient client;
LOGI("CreateBundleDataDir start: userId %{public}u", userId);
auto ret = client.CreateBundleDataDir(userId);
LOGI("CreateBundleDataDir end: userId %{public}u, ret %{public}d", userId, ret);
}
} // namespace StorageDaemon
} // namespace OHOS

View File

@ -50,6 +50,7 @@ ohos_unittest("user_manager_test") {
]
external_deps = [
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"huks:libhukssdk",

View File

@ -51,6 +51,7 @@ ohos_fuzztest("StorageDaemonFuzzTest") {
external_deps = [
"ability_runtime:abilitykit_native",
"app_file_service:fileshare_native",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",

View File

@ -53,6 +53,7 @@ ohos_fuzztest("StorageDaemonCreateShareFileFuzzTest") {
external_deps = [
"ability_runtime:abilitykit_native",
"app_file_service:fileshare_native",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",

View File

@ -53,6 +53,7 @@ ohos_fuzztest("StorageDaemonDeleteShareFileFuzzTest") {
external_deps = [
"ability_runtime:abilitykit_native",
"app_file_service:fileshare_native",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",