!516 add user_crypto_manger feature

Merge pull request !516 from jaychao/master
This commit is contained in:
openharmony_ci 2023-04-21 07:22:36 +00:00 committed by Gitee
commit ba38922ace
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
19 changed files with 262 additions and 53 deletions

View File

@ -90,25 +90,8 @@
}
],
"test": [
"//foundation/filemanagement/storage_service/services/storage_daemon/client/test:storage_daemon_client_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/crypto/test:crypto_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/disk/test:storage_daemon_disk_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/file_sharing/test:file_sharing_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/ipc/test:storage_daemon_ipc_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/netlink/test:storage_daemon_netlink_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/quota/test:storage_daemon_quota_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/user/test:storage_daemon_user_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/utils/test:storage_daemon_utils_test",
"//foundation/filemanagement/storage_service/services/storage_daemon/volume/test:storage_daemon_volume_test",
"//foundation/filemanagement/storage_service/services/storage_manager/client/test:storage_manager_client_test",
"//foundation/filemanagement/storage_service/services/storage_manager/crypto/test:storage_manager_crypto_test",
"//foundation/filemanagement/storage_service/services/storage_manager/ipc/test:storage_manager_ipc_test",
"//foundation/filemanagement/storage_service/services/storage_manager/storage/test:storage_manager_storage_test",
"//foundation/filemanagement/storage_service/services/storage_manager/storage_daemon_communication/test:storage_manager_communication_test",
"//foundation/filemanagement/storage_service/services/storage_manager/user/test:storage_manager_user_test",
"//foundation/filemanagement/storage_service/services/storage_manager/volume/test:storage_manager_volume_test",
"//foundation/filemanagement/storage_service/services/storage_manager/disk/test:storage_manager_disk_test",
"//foundation/filemanagement/storage_service/services/storage_manager/innerkits_impl/test:storage_manager_innerkits_test",
"//foundation/filemanagement/storage_service/services/storage_daemon:storage_daemon_unit_test",
"//foundation/filemanagement/storage_service/services/storage_manager:storage_manager_unit_test",
"//foundation/filemanagement/storage_service/test/fuzztest:storage_service_fuzztest"
]
}

View File

@ -15,12 +15,28 @@
#ifndef STORAGE_SERVICE_CONSTANTS_H
#define STORAGE_SERVICE_CONSTANTS_H
#include <map>
namespace OHOS {
namespace StorageService {
const int START_USER_ID = 100;
const int MAX_USER_ID = 1099;
}
namespace StorageDaemon {
constexpr uint32_t GLOBAL_USER_ID = 0;
static const std::string EL1 = "el1";
static const std::string EL2 = "el2";
enum KeyType {
EL1_KEY = 1,
EL2_KEY = 2,
};
static std::map<std::string, KeyType> EL_DIR_MAP = {
{EL1, EL1_KEY},
{EL2, EL2_KEY},
};
}
}
#endif // STORAGE_SERVICE_CONSTANTS_H

View File

@ -93,8 +93,6 @@ ohos_executable("storage_daemon") {
":sdc",
":storage_common_utils",
"${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
"crypto:libsdcrypto",
"libfscrypt:libfscryptutils",
]
external_deps = [
@ -106,12 +104,20 @@ ohos_executable("storage_daemon") {
"c_utils:utils",
"dfs_service:cloud_daemon_kit_inner",
"hiviewdfx_hilog_native:libhilog",
"huks:libhukssdk",
"init:libbegetutil",
"ipc:ipc_core",
"samgr:samgr_proxy",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
deps += [
"crypto:libsdcrypto",
"libfscrypt:libfscryptutils",
]
external_deps += [ "huks:libhukssdk" ]
}
subsystem_name = "filemanagement"
part_name = "storage_service"
install_enable = true
@ -150,9 +156,13 @@ ohos_executable("sdc") {
deps = [
":storage_common_utils",
"${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy",
"libfscrypt:libfscryptutils",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
deps += [ "libfscrypt:libfscryptutils" ]
}
external_deps = [
"c_utils:utils",
"hiviewdfx_hilog_native:libhilog",
@ -238,3 +248,22 @@ group("storage_daemon_third_party") {
]
}
}
group("storage_daemon_unit_test") {
testonly = true
deps = [
"client/test:storage_daemon_client_test",
"disk/test:storage_daemon_disk_test",
"file_sharing/test:file_sharing_test",
"ipc/test:storage_daemon_ipc_test",
"netlink/test:storage_daemon_netlink_test",
"quota/test:storage_daemon_quota_test",
"user/test:storage_daemon_user_test",
"utils/test:storage_daemon_utils_test",
"volume/test:storage_daemon_volume_test",
]
if (user_crypto_manager) {
deps += [ "crypto/test:crypto_test" ]
}
}

View File

@ -325,11 +325,13 @@ int32_t StorageDaemonClient::UpdateKeyContext(uint32_t userId)
int32_t StorageDaemonClient::FscryptEnable(const std::string &fscryptOptions)
{
#ifdef USER_CRYPTO_MANAGER
int ret = SetFscryptSysparam(fscryptOptions.c_str());
if (ret) {
LOGE("Init fscrypt policy failed ret %{public}d", ret);
return ret;
}
#endif
return 0;
}

View File

@ -12,6 +12,7 @@
# limitations under the License.
import("//build/test.gni")
import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
ROOT_DIR = "//foundation/filemanagement/storage_service/services/storage_daemon"
@ -23,6 +24,10 @@ ohos_unittest("storage_daemon_clt_test") {
"LOG_DOMAIN = 0xD004301",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
}
include_dirs = [
"$ROOT_DIR/include",
"$ROOT_DIR/client/include",

View File

@ -24,6 +24,7 @@
#include "libfscrypt/fscrypt_control.h"
#include "libfscrypt/key_control.h"
#include "parameter.h"
#include "storage_service_constant.h"
#include "storage_service_errno.h"
#include "storage_service_log.h"

View File

@ -30,6 +30,7 @@ ohos_moduletest("CryptoSubTest") {
"../../include",
"../../include/crypto",
"//commonlibrary/c_utils/base/include",
"../../../common/include",
]
sources = [ "crypto_key_test.cpp" ]

View File

@ -21,25 +21,13 @@
#include <memory>
#include <mutex>
#include "storage_service_constant.h"
#include "key_blob.h"
#include "base_key.h"
#include "utils/file_utils.h"
namespace OHOS {
namespace StorageDaemon {
constexpr uint32_t GLOBAL_USER_ID = 0;
static const std::string EL1 = "el1";
static const std::string EL2 = "el2";
enum KeyType {
EL1_KEY = 1,
EL2_KEY = 2,
};
static std::map<std::string, KeyType> EL_DIR_MAP = {
{EL1, EL1_KEY},
{EL2, EL2_KEY},
};
class KeyManager {
public:
static KeyManager *GetInstance(void)

View File

@ -15,11 +15,14 @@
#include "ipc/storage_daemon.h"
#ifdef USER_CRYPTO_MANAGER
#include "crypto/key_manager.h"
#endif
#include "disk/disk_manager.h"
#include "file_share.h"
#include "file_sharing/file_sharing.h"
#include "quota/quota_manager.h"
#include "storage_service_constant.h"
#include "storage_service_errno.h"
#include "storage_service_log.h"
#include "user/user_manager.h"
@ -75,11 +78,14 @@ int32_t StorageDaemon::SetVolumeDescription(std::string volId, std::string descr
int32_t StorageDaemon::PrepareUserDirs(int32_t userId, uint32_t flags)
{
#ifdef USER_CRYPTO_MANAGER
int32_t ret = KeyManager::GetInstance()->GenerateUserKeys(userId, flags);
if (ret != 0) {
LOGE("Generate user %{public}d key error", userId);
return ret;
}
#endif
return UserManager::GetInstance()->PrepareUserDirs(userId, flags);
}
@ -89,7 +95,12 @@ int32_t StorageDaemon::DestroyUserDirs(int32_t userId, uint32_t flags)
if (ret != 0) {
LOGW("Destroy user %{public}d dirs failed, please check", userId);
}
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->DeleteUserKeys(userId);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::StartUser(int32_t userId)
@ -104,7 +115,11 @@ int32_t StorageDaemon::StopUser(int32_t userId)
int32_t StorageDaemon::InitGlobalKey(void)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->InitGlobalDeviceKey();
#else
return E_OK;
#endif
}
int32_t StorageDaemon::InitGlobalUserKeys(void)
@ -117,22 +132,33 @@ int32_t StorageDaemon::InitGlobalUserKeys(void)
}
#endif
#ifdef USER_CRYPTO_MANAGER
int ret = KeyManager::GetInstance()->InitGlobalUserKeys();
if (ret) {
LOGE("Init global users els failed");
return ret;
}
#endif
return UserManager::GetInstance()->PrepareUserDirs(GLOBAL_USER_ID, CRYPTO_FLAG_EL1);
}
int32_t StorageDaemon::GenerateUserKeys(uint32_t userId, uint32_t flags)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->GenerateUserKeys(userId, flags);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::DeleteUserKeys(uint32_t userId)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->DeleteUserKeys(userId);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::UpdateUserAuth(uint32_t userId, uint64_t secureUid,
@ -140,24 +166,40 @@ int32_t StorageDaemon::UpdateUserAuth(uint32_t userId, uint64_t secureUid,
const std::vector<uint8_t> &oldSecret,
const std::vector<uint8_t> &newSecret)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->UpdateUserAuth(userId, secureUid, token, oldSecret, newSecret);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::ActiveUserKey(uint32_t userId,
const std::vector<uint8_t> &token,
const std::vector<uint8_t> &secret)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->ActiveUserKey(userId, token, secret);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::InactiveUserKey(uint32_t userId)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->InActiveUserKey(userId);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::UpdateKeyContext(uint32_t userId)
{
#ifdef USER_CRYPTO_MANAGER
return KeyManager::GetInstance()->UpdateKeyContext(userId);
#else
return E_OK;
#endif
}
int32_t StorageDaemon::CreateShareFile(std::string uri, uint32_t tokenId, uint32_t flag)

View File

@ -12,6 +12,7 @@
# limitations under the License.
import("//build/test.gni")
import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
ROOT_DIR = "//foundation/filemanagement/storage_service/services/storage_daemon"
@ -23,6 +24,10 @@ ohos_unittest("storage_daemon_test") {
"LOG_DOMAIN = 0xD004301",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
}
cflags_cc = [ "-Wno-unused-const-variable" ]
include_dirs = [
@ -119,6 +124,10 @@ ohos_unittest("storage_daemon_stub_test") {
"LOG_DOMAIN = 0xD004301",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
}
include_dirs = [
"$ROOT_DIR/include",
"$ROOT_DIR/ipc/test/",

View File

@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
## build sm execute bin file
config("fscrypt_utils_config") {
@ -39,6 +40,10 @@ ohos_static_library("libfscryptutils") {
"src/sysparam_dynamic.c",
]
if (user_crypto_manager) {
defines = [ "USER_CRYPTO_MANAGER" ]
}
configs = [ ":fscrypt_utils_config" ]
deps = [
@ -64,6 +69,10 @@ ohos_static_library("libfscryptutils_static") {
"src/sysparam_static.c",
]
if (user_crypto_manager) {
defines = [ "USER_CRYPTO_MANAGER" ]
}
configs = [ ":fscrypt_utils_config" ]
subsystem_name = "filemanagement"

View File

@ -166,6 +166,7 @@ int FscryptSetSysparam(const char *policy)
return 0;
}
#ifdef USER_CRYPTO_MANAGER
static void PraseOnePloicyValue(uint8_t *value, const char *key,
const FscrtpyItem *table, size_t numbers)
{
@ -179,9 +180,11 @@ static void PraseOnePloicyValue(uint8_t *value, const char *key,
}
FSCRYPT_LOGE("Have not found value for the key!");
}
#endif
int InitFscryptPolicy(void)
{
#ifdef USER_CRYPTO_MANAGER
if (g_fscryptInited) {
FSCRYPT_LOGI("Have been init");
return 0;
@ -215,6 +218,7 @@ int InitFscryptPolicy(void)
FreeStringVector(option, count);
g_fscryptInited = true;
FSCRYPT_LOGI("Fscrypt policy init success");
#endif
return 0;
}

View File

@ -19,20 +19,28 @@
int FscryptPolicyEnable(const char *dir)
{
#ifdef USER_CRYPTO_MANAGER
if (!dir) {
FSCRYPT_LOGE("dir is null");
return -EINVAL;
}
return SetGlobalEl1DirPolicy(dir);
#else
return 0;
#endif
}
int SetFscryptSysparam(const char *policy)
{
#ifdef USER_CRYPTO_MANAGER
if (!policy) {
FSCRYPT_LOGE("policy is null");
return -EINVAL;
}
return FscryptSetSysparam(policy);
#else
return 0;
#endif
}

View File

@ -15,8 +15,11 @@
#include "user/user_manager.h"
#include <cstdlib>
#ifdef USER_CRYPTO_MANAGER
#include "crypto/key_manager.h"
#endif
#include "ipc/istorage_daemon.h"
#include "storage_service_constant.h"
#include "storage_service_errno.h"
#include "storage_service_log.h"
#include "utils/string_utils.h"
@ -223,6 +226,7 @@ int32_t UserManager::DestroyEl1BundleDir(int32_t userId)
int32_t UserManager::SetElDirFscryptPolicy(int32_t userId, const std::string &level,
const std::vector<FileList> &list)
{
#ifdef USER_CRYPTO_MANAGER
if (EL_DIR_MAP.find(level) == EL_DIR_MAP.end()) {
LOGE("el type error");
return E_SET_POLICY;
@ -231,6 +235,7 @@ int32_t UserManager::SetElDirFscryptPolicy(int32_t userId, const std::string &le
LOGE("Set user dir el1 policy error");
return E_SET_POLICY;
}
#endif
return E_OK;
}

View File

@ -12,6 +12,7 @@
# limitations under the License.
import("//build/test.gni")
import("//foundation/filemanagement/storage_service/storage_service_aafwk.gni")
ROOT_DIR = "//foundation/filemanagement/storage_service/services/storage_daemon"
@ -23,6 +24,10 @@ ohos_unittest("user_manager_test") {
"LOG_DOMAIN = 0xD004301",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
}
include_dirs = [
"$ROOT_DIR/include",
"$ROOT_DIR/utils",

View File

@ -31,14 +31,9 @@ config("storage_manager_config") {
ohos_shared_library("storage_manager") {
sources = [
"account_subscriber/account_subscriber.cpp",
"crypto/filesystem_crypto.cpp",
"disk/src/disk_manager_service.cpp",
"ipc/src/storage_manager.cpp",
"ipc/src/storage_manager_stub.cpp",
"storage/src/storage_status_service.cpp",
"storage/src/storage_total_status_service.cpp",
"storage/src/volume_storage_status_service.cpp",
"storage_daemon_communication/src/storage_daemon_communication.cpp",
"user/src/multi_user_manager_service.cpp",
"utils/src/storage_utils.cpp",
@ -51,6 +46,11 @@ ohos_shared_library("storage_manager") {
"LOG_DOMAIN = 0xD004300",
]
if (user_crypto_manager) {
defines += [ "USER_CRYPTO_MANAGER" ]
sources += [ "crypto/filesystem_crypto.cpp" ]
}
configs = [ ":storage_manager_config" ]
deps = [ "${storage_interface_path}/innerkits/storage_manager/native:storage_manager_sa_proxy" ]
@ -58,30 +58,63 @@ ohos_shared_library("storage_manager") {
external_deps = [
"ability_base:base",
"ability_base:want",
"ability_runtime:abilitykit_native",
"ability_runtime:dataobs_manager",
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"data_share:datashare_consumer",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (storage_service_graphic) {
defines += [ "STORAGE_SERVICE_GRAPHIC" ]
external_deps += [
"media_library:media_library",
"media_library:media_library_manager",
if (storage_statistics_manager) {
defines += [ "STORAGE_STATISTICS_MANAGER" ]
sources += [
"account_subscriber/account_subscriber.cpp",
"storage/src/storage_status_service.cpp",
"storage/src/storage_total_status_service.cpp",
"storage/src/volume_storage_status_service.cpp",
]
external_deps += [
"ability_runtime:abilitykit_native",
"ability_runtime:dataobs_manager",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"data_share:datashare_consumer",
"relational_store:native_rdb",
]
if (storage_service_graphic) {
defines += [ "STORAGE_SERVICE_GRAPHIC" ]
external_deps += [
"media_library:media_library",
"media_library:media_library_manager",
]
}
}
subsystem_name = "filemanagement"
part_name = "storage_service"
install_enable = true
}
group("storage_manager_unit_test") {
testonly = true
deps = [
"client/test:storage_manager_client_test",
"disk/test:storage_manager_disk_test",
"innerkits_impl/test:storage_manager_innerkits_test",
"ipc/test:storage_manager_ipc_test",
"storage_daemon_communication/test:storage_manager_communication_test",
"user/test:storage_manager_user_test",
"volume/test:storage_manager_volume_test",
]
if (user_crypto_manager) {
deps += [ "crypto/test:storage_manager_crypto_test" ]
}
if (storage_statistics_manager) {
deps += [ "storage/test:storage_manager_storage_test" ]
}
}

View File

@ -16,12 +16,16 @@
#include "ipc/storage_manager.h"
#include <singleton.h>
#ifdef STORAGE_STATISTICS_MANAGER
#include <storage/storage_status_service.h>
#include <storage/storage_total_status_service.h>
#include <storage/volume_storage_status_service.h>
#include "account_subscriber/account_subscriber.h"
#endif
#ifdef USER_CRYPTO_MANAGER
#include "crypto/filesystem_crypto.h"
#endif
#include "disk/disk_manager_service.h"
#include "storage_daemon_communication/storage_daemon_communication.h"
#include "storage_service_errno.h"
@ -38,7 +42,9 @@ void StorageManager::OnStart()
{
LOGI("StorageManager::OnStart Begin");
bool res = SystemAbility::Publish(this);
#ifdef STORAGE_STATISTICS_MANAGER
AccountSubscriber::Subscriber();
#endif
LOGI("StorageManager::OnStart End, res = %{public}d", res);
}
@ -81,69 +87,105 @@ int32_t StorageManager::StopUser(int32_t userId)
int32_t StorageManager::GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::getFreeSizeOfVolume start, volumeUuid: %{public}s", volumeUuid.c_str());
std::shared_ptr<VolumeStorageStatusService> volumeStatsManager =
DelayedSingleton<VolumeStorageStatusService>::GetInstance();
int32_t err = volumeStatsManager->GetFreeSizeOfVolume(volumeUuid, freeSize);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::getTotalSizeOfVolume start, volumeUuid: %{public}s", volumeUuid.c_str());
std::shared_ptr<VolumeStorageStatusService> volumeStatsManager =
DelayedSingleton<VolumeStorageStatusService>::GetInstance();
int32_t err = volumeStatsManager->GetTotalSizeOfVolume(volumeUuid, totalSize);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetBundleStats(std::string pkgName, BundleStats &bundleStats)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::getBundleStats start, pkgName: %{public}s", pkgName.c_str());
int32_t err = DelayedSingleton<StorageStatusService>::GetInstance()->GetBundleStats(pkgName, bundleStats);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetSystemSize(int64_t &systemSize)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::getSystemSize start");
int32_t err = DelayedSingleton<StorageTotalStatusService>::GetInstance()->GetSystemSize(systemSize);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetTotalSize(int64_t &totalSize)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::getTotalSize start");
int32_t err = DelayedSingleton<StorageTotalStatusService>::GetInstance()->GetTotalSize(totalSize);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetFreeSize(int64_t &freeSize)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::getFreeSize start");
int32_t err = DelayedSingleton<StorageTotalStatusService>::GetInstance()->GetFreeSize(freeSize);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetUserStorageStats(StorageStats &storageStats)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::GetUserStorageStats start");
int32_t err = DelayedSingleton<StorageStatusService>::GetInstance()->GetUserStorageStats(storageStats);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetUserStorageStats(int32_t userId, StorageStats &storageStats)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::GetUserStorageStats start");
int32_t err = DelayedSingleton<StorageStatusService>::GetInstance()->GetUserStorageStats(userId, storageStats);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::GetCurrentBundleStats(BundleStats &bundleStats)
{
#ifdef STORAGE_STATISTICS_MANAGER
LOGI("StorageManger::GetCurrentBundleStats start");
int32_t err = DelayedSingleton<StorageStatusService>::GetInstance()->GetCurrentBundleStats(bundleStats);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::NotifyVolumeCreated(VolumeCore vc)
@ -257,18 +299,26 @@ int32_t StorageManager::GetDiskById(std::string diskId, Disk &disk)
int32_t StorageManager::GenerateUserKeys(uint32_t userId, uint32_t flags)
{
#ifdef USER_CRYPTO_MANAGER
LOGI("UserId: %{public}u, flags: %{public}u", userId, flags);
std::shared_ptr<FileSystemCrypto> fsCrypto = DelayedSingleton<FileSystemCrypto>::GetInstance();
int32_t err = fsCrypto->GenerateUserKeys(userId, flags);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::DeleteUserKeys(uint32_t userId)
{
#ifdef USER_CRYPTO_MANAGER
LOGI("UserId: %{public}u", userId);
std::shared_ptr<FileSystemCrypto> fsCrypto = DelayedSingleton<FileSystemCrypto>::GetInstance();
int32_t err = fsCrypto->DeleteUserKeys(userId);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::UpdateUserAuth(uint32_t userId, uint64_t secureUid,
@ -276,36 +326,52 @@ int32_t StorageManager::UpdateUserAuth(uint32_t userId, uint64_t secureUid,
const std::vector<uint8_t> &oldSecret,
const std::vector<uint8_t> &newSecret)
{
#ifdef USER_CRYPTO_MANAGER
LOGI("UserId: %{public}u", userId);
std::shared_ptr<FileSystemCrypto> fsCrypto = DelayedSingleton<FileSystemCrypto>::GetInstance();
int32_t err = fsCrypto->UpdateUserAuth(userId, secureUid, token, oldSecret, newSecret);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::ActiveUserKey(uint32_t userId,
const std::vector<uint8_t> &token,
const std::vector<uint8_t> &secret)
{
#ifdef USER_CRYPTO_MANAGER
LOGI("UserId: %{public}u", userId);
std::shared_ptr<FileSystemCrypto> fsCrypto = DelayedSingleton<FileSystemCrypto>::GetInstance();
int32_t err = fsCrypto->ActiveUserKey(userId, token, secret);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::InactiveUserKey(uint32_t userId)
{
#ifdef USER_CRYPTO_MANAGER
LOGI("UserId: %{public}u", userId);
std::shared_ptr<FileSystemCrypto> fsCrypto = DelayedSingleton<FileSystemCrypto>::GetInstance();
int32_t err = fsCrypto->InactiveUserKey(userId);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::UpdateKeyContext(uint32_t userId)
{
#ifdef USER_CRYPTO_MANAGER
LOGI("UserId: %{public}u", userId);
std::shared_ptr<FileSystemCrypto> fsCrypto = DelayedSingleton<FileSystemCrypto>::GetInstance();
int32_t err = fsCrypto->UpdateKeyContext(userId);
return err;
#else
return E_OK;
#endif
}
int32_t StorageManager::CreateShareFile(std::string uri, uint32_t tokenId, uint32_t flag)

View File

@ -386,6 +386,7 @@ int32_t StorageManagerStub::HandleGetCurrentBundleStats(MessageParcel &data, Mes
}
return E_OK;
}
int32_t StorageManagerStub::HandleGetAllVolumes(MessageParcel &data, MessageParcel &reply)
{
if (!CheckClientPermission(PERMISSION_STORAGE_MANAGER)) {

View File

@ -15,6 +15,8 @@ ability_runtime_path = "//foundation/ability/ability_runtime"
ability_runtime_kits_path = "${ability_runtime_path}/frameworks/kits"
declare_args() {
storage_service_graphic = true
user_crypto_manager = true
storage_statistics_manager = true
}
storage_manager_path =
"//foundation/filemanagement/storage_service/services/storage_manager"