diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index de9749f59274625f298f3398ceef5d70e988628b..41a510fb88df1f0d887a9ae73a706b978af0522a 100644 --- a/services/bundlemgr/include/base_bundle_installer.h +++ b/services/bundlemgr/include/base_bundle_installer.h @@ -680,7 +680,7 @@ private: void CreateScreenLockProtectionDir(); void DeleteScreenLockProtectionDir(const std::string bundleName) const; bool SetEncryptionDirPolicy(InnerBundleInfo &info); - void DeleteEncryptionKeyId(const InnerBundleInfo &oldInfo) const; + void DeleteEncryptionKeyId(const InnerBundleInfo &oldInfo, bool isKeepData) const; void CreateScreenLockProtectionExistDirs(const InnerBundleInfo &info, const std::string &dir); #ifdef APP_DOMAIN_VERIFY_ENABLED void PrepareSkillUri(const std::vector &skills, std::vector &skillUris) const; diff --git a/services/bundlemgr/include/installd/installd_host_impl.h b/services/bundlemgr/include/installd/installd_host_impl.h index ddac7fd8cbdc789dbf2266dd1dab3738cec0ee39..426436821675b5ba43029cffe2320afbee74e570 100644 --- a/services/bundlemgr/include/installd/installd_host_impl.h +++ b/services/bundlemgr/include/installd/installd_host_impl.h @@ -218,9 +218,9 @@ public: virtual ErrCode RemoveSignProfile(const std::string &bundleName) override; virtual ErrCode SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) override; + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) override; - virtual ErrCode DeleteEncryptionKeyId(const std::string &keyId) override; + virtual ErrCode DeleteEncryptionKeyId(const uint32_t accessTokenId) override; virtual ErrCode RemoveExtensionDir(int32_t userId, const std::vector &extensionBundleDirs) override; diff --git a/services/bundlemgr/include/installd/installd_operator.h b/services/bundlemgr/include/installd/installd_operator.h index 0b4f788bccde439334f487aae96c8a9cecfe7512..0e763027fde892a6d89d1f4a22863c9653e4e876 100644 --- a/services/bundlemgr/include/installd/installd_operator.h +++ b/services/bundlemgr/include/installd/installd_operator.h @@ -286,9 +286,9 @@ public: #endif static bool GenerateKeyIdAndSetPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId); + const int32_t userId, std::string &keyId, const uint32_t accessTokenId); - static bool DeleteKeyId(const std::string &keyId); + static bool DeleteKeyId(const uint32_t accessTokenId); private: static bool OpenHandle(void **handle); diff --git a/services/bundlemgr/include/installd_client.h b/services/bundlemgr/include/installd_client.h index 1c8c6332503e815d150182b53f1b27050dc2c811..0b7dc5cc23c8bd36dc0d0d169e11bba9b58be480 100644 --- a/services/bundlemgr/include/installd_client.h +++ b/services/bundlemgr/include/installd_client.h @@ -221,9 +221,9 @@ public: ErrCode RemoveSignProfile(const std::string &bundleName); ErrCode SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId); + const int32_t userId, std::string &keyId, const uint32_t accessTokenId); - ErrCode DeleteEncryptionKeyId(const std::string &keyId); + ErrCode DeleteEncryptionKeyId(const uint32_t accessTokenId); ErrCode RemoveExtensionDir(int32_t userId, const std::vector &extensionBundleDirs); diff --git a/services/bundlemgr/include/ipc/installd_interface.h b/services/bundlemgr/include/ipc/installd_interface.h index 97a5d268c24abae1e10e5c701bfd9972ab37a2dc..f64476c5c83dc832bdf094204462e572fe61ffa1 100644 --- a/services/bundlemgr/include/ipc/installd_interface.h +++ b/services/bundlemgr/include/ipc/installd_interface.h @@ -387,12 +387,12 @@ public: } virtual ErrCode SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { return ERR_OK; } - virtual ErrCode DeleteEncryptionKeyId(const std::string &keyId) + virtual ErrCode DeleteEncryptionKeyId(const uint32_t accessTokenId) { return ERR_OK; } diff --git a/services/bundlemgr/include/ipc/installd_proxy.h b/services/bundlemgr/include/ipc/installd_proxy.h index 0456ec3c79cbe9381cee4cfe353fbfceeea6622e..b6170bbcdf8bce73fb453f593e4031b883ad1e60 100644 --- a/services/bundlemgr/include/ipc/installd_proxy.h +++ b/services/bundlemgr/include/ipc/installd_proxy.h @@ -216,9 +216,9 @@ public: virtual ErrCode RemoveSignProfile(const std::string &bundleName) override; virtual ErrCode SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) override; + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) override; - virtual ErrCode DeleteEncryptionKeyId(const std::string &keyId) override; + virtual ErrCode DeleteEncryptionKeyId(const uint32_t accessTokenId) override; virtual ErrCode RemoveExtensionDir(int32_t userId, const std::vector &extensionBundleDirs) override; diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index bd8b141ba61a6a673dd7d66d33d77b90bebda862..c39e318f297a312c489fa534e0443b4db96d0896 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -1439,7 +1439,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUninstall( APP_LOGW("remove group dir failed for %{public}s", oldInfo.GetBundleName().c_str()); } - DeleteEncryptionKeyId(oldInfo); + DeleteEncryptionKeyId(oldInfo, installParam.isKeepData); if (oldInfo.GetInnerBundleUserInfos().size() > 1) { LOG_D(BMS_TAG_INSTALLER, "only delete userinfo %{public}d", userId_); @@ -2834,9 +2834,10 @@ bool BaseBundleInstaller::SetEncryptionDirPolicy(InnerBundleInfo &info) } int32_t uid = userInfo.uid; + uint32_t accessTokenId = userInfo.accessTokenId; std::string bundleName = info.GetBundleName(); std::string keyId = ""; - auto result = InstalldClient::GetInstance()->SetEncryptionPolicy(uid, bundleName, userId_, keyId); + auto result = InstalldClient::GetInstance()->SetEncryptionPolicy(uid, bundleName, userId_, keyId, accessTokenId); if (result != ERR_OK) { LOG_E(BMS_TAG_INSTALLER, "SetEncryptionPolicy failed"); } @@ -2852,13 +2853,14 @@ bool BaseBundleInstaller::SetEncryptionDirPolicy(InnerBundleInfo &info) void BaseBundleInstaller::CreateScreenLockProtectionExistDirs(const InnerBundleInfo &info, const std::string &dir) { - LOG_I(BMS_TAG_INSTALLER, "CreateScreenLockProtectionExistDirs start"); InnerBundleUserInfo newInnerBundleUserInfo; if (!info.GetInnerBundleUserInfo(userId_, newInnerBundleUserInfo)) { LOG_E(BMS_TAG_INSTALLER, "bundle(%{public}s) get user(%{public}d) failed", info.GetBundleName().c_str(), userId_); return; } + LOG_I(BMS_TAG_INSTALLER, "create el5 dir: %{public}s, uid: %{public}d", + dir.c_str(), newInnerBundleUserInfo.uid); int32_t mode = S_IRWXU; int32_t gid = newInnerBundleUserInfo.uid; if (dir.find(ServiceConstants::DATABASE) != std::string::npos) { @@ -2905,30 +2907,26 @@ void BaseBundleInstaller::CreateScreenLockProtectionDir() } return; } - bool dirExist = false; for (const std::string &dir : dirs) { - if (InstalldClient::GetInstance()->IsExistDir(dir, dirExist) != ERR_OK) { - LOG_E(BMS_TAG_INSTALLER, "check if dir existed failed"); - return; - } - if (!dirExist) { - LOG_D(BMS_TAG_INSTALLER, "ScreenLockProtectionDir: %{public}s need to be created", dir.c_str()); - CreateScreenLockProtectionExistDirs(info, dir); - } + LOG_D(BMS_TAG_INSTALLER, "create el5 dir: %{public}s.", dir.c_str()); + CreateScreenLockProtectionExistDirs(info, dir); } - if (!dirExist) { - if (!SetEncryptionDirPolicy(info)) { - LOG_E(BMS_TAG_INSTALLER, "Encryption failed dir"); - } + if (!SetEncryptionDirPolicy(info)) { + LOG_E(BMS_TAG_INSTALLER, "Encryption failed dir"); } } -void BaseBundleInstaller::DeleteEncryptionKeyId(const InnerBundleInfo &oldInfo) const +void BaseBundleInstaller::DeleteEncryptionKeyId(const InnerBundleInfo &oldInfo, bool isKeepData) const { if (oldInfo.GetBundleName().empty()) { LOG_W(BMS_TAG_INSTALLER, "bundleName is empty"); return; } + if (isKeepData) { + LOG_I(BMS_TAG_INSTALLER, "uninstall with keep data, do not delete el5 dir"); + return; + } + LOG_I(BMS_TAG_INSTALLER, "uninstall without keep data, delete el5 dir"); std::vector dirs = GenerateScreenLockProtectionDir(oldInfo.GetBundleName()); for (const std::string &dir : dirs) { if (InstalldClient::GetInstance()->RemoveDir(dir) != ERR_OK) { @@ -2941,7 +2939,7 @@ void BaseBundleInstaller::DeleteEncryptionKeyId(const InnerBundleInfo &oldInfo) LOG_E(BMS_TAG_INSTALLER, "%{public}s get user %{public}d failed", oldInfo.GetBundleName().c_str(), userId_); return; } - if (InstalldClient::GetInstance()->DeleteEncryptionKeyId(userInfo.keyId) != ERR_OK) { + if (InstalldClient::GetInstance()->DeleteEncryptionKeyId(userInfo.accessTokenId) != ERR_OK) { LOG_W(BMS_TAG_INSTALLER, "delete encryption key id failed"); } } diff --git a/services/bundlemgr/src/el5_filekey_callback.cpp b/services/bundlemgr/src/el5_filekey_callback.cpp index e78a9988ae82b35a8bd1d280e63fd9714d03f105..674697a87586065b7012d73760713ef7ab7fba23 100644 --- a/services/bundlemgr/src/el5_filekey_callback.cpp +++ b/services/bundlemgr/src/el5_filekey_callback.cpp @@ -29,7 +29,7 @@ void El5FilekeyCallback::OnRegenerateAppKey(std::vectorSetEncryptionPolicy( - info.uid, info.bundleName, info.userId, keyId); + info.uid, info.bundleName, info.userId, keyId, info.accessTokenId); if (result != ERR_OK) { APP_LOGE("SetEncryptionPolicy failed for %{public}s", info.bundleName.c_str()); } diff --git a/services/bundlemgr/src/installd/installd_host_impl.cpp b/services/bundlemgr/src/installd/installd_host_impl.cpp index c6fd5c46073a2fb00662c065aea15d46939c3c07..a4e617f33d11b235e7e144c46b70da3e5bbbdda0 100644 --- a/services/bundlemgr/src/installd/installd_host_impl.cpp +++ b/services/bundlemgr/src/installd/installd_host_impl.cpp @@ -1513,7 +1513,7 @@ bool InstalldHostImpl::CheckPathValid(const std::string &path, const std::string } ErrCode InstalldHostImpl::SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { if (!InstalldPermissionMgr::VerifyCallingPermission(Constants::FOUNDATION_UID)) { LOG_E(BMS_TAG_INSTALLD, "installd permission denied, only used for foundation process"); @@ -1523,24 +1523,20 @@ ErrCode InstalldHostImpl::SetEncryptionPolicy(int32_t uid, const std::string &bu LOG_E(BMS_TAG_INSTALLD, "Calling the function SetEncryptionPolicy with invalid param"); return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; } - if (!InstalldOperator::GenerateKeyIdAndSetPolicy(uid, bundleName, userId, keyId)) { + if (!InstalldOperator::GenerateKeyIdAndSetPolicy(uid, bundleName, userId, keyId, accessTokenId)) { LOG_E(BMS_TAG_INSTALLD, "EncryptionPaths fail"); return ERR_APPEXECFWK_INSTALLD_GENERATE_KEY_FAILED; } return ERR_OK; } -ErrCode InstalldHostImpl::DeleteEncryptionKeyId(const std::string &keyId) +ErrCode InstalldHostImpl::DeleteEncryptionKeyId(const uint32_t accessTokenId) { if (!InstalldPermissionMgr::VerifyCallingPermission(Constants::FOUNDATION_UID)) { LOG_E(BMS_TAG_INSTALLD, "installd permission denied, only used for foundation process"); return ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED; } - if (keyId.empty()) { - LOG_E(BMS_TAG_INSTALLD, "Calling the function DeleteEncryptionKeyId with invalid param"); - return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; - } - if (!InstalldOperator::DeleteKeyId(keyId)) { + if (!InstalldOperator::DeleteKeyId(accessTokenId)) { LOG_E(BMS_TAG_INSTALLD, "EncryptionPaths fail"); return ERR_APPEXECFWK_INSTALLD_DELETE_KEY_FAILED; } diff --git a/services/bundlemgr/src/installd/installd_operator.cpp b/services/bundlemgr/src/installd/installd_operator.cpp index a3ca0671a124e381d702539f653d8a34cf55b152..2fdb81111da3c9e37bf5d3ec2ec8fd0d667fcc24 100644 --- a/services/bundlemgr/src/installd/installd_operator.cpp +++ b/services/bundlemgr/src/installd/installd_operator.cpp @@ -45,6 +45,7 @@ #include "bundle_service_constants.h" #include "bundle_util.h" #include "directory_ex.h" +#include "el5_filekey_manager_error.h" #include "el5_filekey_manager_kit.h" #include "parameters.h" #include "securec.h" @@ -2127,12 +2128,16 @@ int32_t InstalldOperator::CallIoctl(int32_t flag, int32_t associatedFlag, int32_ #endif bool InstalldOperator::GenerateKeyIdAndSetPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { - LOG_D(BMS_TAG_INSTALLD, "GenerateKeyId uid is %{public}d, bundleName is %{public}s, userId is %{public}d", - uid, bundleName.c_str(), userId); + LOG_D(BMS_TAG_INSTALLD, "GenerateKeyId uid is %{public}d, bundleName is %{public}s, userId is %{public}d, " + "accessTokenId is %{public}d", uid, bundleName.c_str(), userId, accessTokenId); auto ret = Security::AccessToken::El5FilekeyManagerKit::GenerateAppKey( - static_cast(uid), bundleName, keyId); + static_cast(uid), bundleName, accessTokenId, keyId); + if (ret == Security::AccessToken::EFM_ERR_KEYID_EXISTED) { + LOG_I(BMS_TAG_INSTALLD, "key id is existed"); + return true; + } if (ret != 0) { LOG_E(BMS_TAG_INSTALLD, "Call GenerateAppKey failed ret = %{public}d", ret); return false; @@ -2178,10 +2183,10 @@ bool InstalldOperator::GenerateKeyIdAndSetPolicy(int32_t uid, const std::string return true; } -bool InstalldOperator::DeleteKeyId(const std::string &keyId) +bool InstalldOperator::DeleteKeyId(const uint32_t accessTokenId) { - LOG_D(BMS_TAG_INSTALLD, "DeleteKeyId keyId is %{public}s", keyId.c_str()); - auto ret = Security::AccessToken::El5FilekeyManagerKit::DeleteAppKey(keyId); + LOG_D(BMS_TAG_INSTALLD, "DeleteKeyId accessTokenId is %{public}d", accessTokenId); + auto ret = Security::AccessToken::El5FilekeyManagerKit::DeleteAppKey(accessTokenId); if (ret != 0) { LOG_E(BMS_TAG_INSTALLD, "Call DeleteAppKey failed ret = %{public}d", ret); return false; diff --git a/services/bundlemgr/src/installd_client.cpp b/services/bundlemgr/src/installd_client.cpp index 4c7a2b4adc4307163a62017b5d159ac3ce082aab..168a9b5c169e6064b5d982cf841c3af28c36d895 100644 --- a/services/bundlemgr/src/installd_client.cpp +++ b/services/bundlemgr/src/installd_client.cpp @@ -520,22 +520,18 @@ ErrCode InstalldClient::ExtractEncryptedSoFiles(const std::string &hapPath, cons } ErrCode InstalldClient::SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { if (bundleName.empty()) { APP_LOGE("bundleName is empty"); return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; } - return CallService(&IInstalld::SetEncryptionPolicy, uid, bundleName, userId, keyId); + return CallService(&IInstalld::SetEncryptionPolicy, uid, bundleName, userId, keyId, accessTokenId); } -ErrCode InstalldClient::DeleteEncryptionKeyId(const std::string &keyId) +ErrCode InstalldClient::DeleteEncryptionKeyId(const uint32_t accessTokenId) { - if (keyId.empty()) { - APP_LOGE("keyId is empty"); - return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; - } - return CallService(&IInstalld::DeleteEncryptionKeyId, keyId); + return CallService(&IInstalld::DeleteEncryptionKeyId, accessTokenId); } ErrCode InstalldClient::RemoveExtensionDir(int32_t userId, const std::vector &extensionBundleDirs) diff --git a/services/bundlemgr/src/ipc/installd_host.cpp b/services/bundlemgr/src/ipc/installd_host.cpp index f315063955c9f421766bc67253d49e62355f519a..7144844304bf2087440d82b84fcff9c8f607a417 100644 --- a/services/bundlemgr/src/ipc/installd_host.cpp +++ b/services/bundlemgr/src/ipc/installd_host.cpp @@ -804,9 +804,10 @@ bool InstalldHost::HandleSetEncryptionDir(MessageParcel &data, MessageParcel &re int32_t uid = data.ReadInt32(); std::string bundleName = Str16ToStr8(data.ReadString16()); int32_t userId = data.ReadInt32(); + uint32_t accessTokenId = data.ReadUint32(); std::string keyId = ""; - ErrCode result = SetEncryptionPolicy(uid, bundleName, userId, keyId); + ErrCode result = SetEncryptionPolicy(uid, bundleName, userId, keyId, accessTokenId); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result); if (!reply.WriteString(keyId)) { APP_LOGE("write keyId failed"); @@ -817,9 +818,9 @@ bool InstalldHost::HandleSetEncryptionDir(MessageParcel &data, MessageParcel &re bool InstalldHost::HandleDeleteEncryptionKeyId(MessageParcel &data, MessageParcel &reply) { - std::string keyId = Str16ToStr8(data.ReadString16()); + uint32_t accessTokenId = data.ReadUint32(); - ErrCode result = DeleteEncryptionKeyId(keyId); + ErrCode result = DeleteEncryptionKeyId(accessTokenId); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result); return true; } diff --git a/services/bundlemgr/src/ipc/installd_proxy.cpp b/services/bundlemgr/src/ipc/installd_proxy.cpp index 619a69493f80da61a881af83310db713d062e072..0676ef8a8dc57a87617ef1ed978a2533ee0471a5 100644 --- a/services/bundlemgr/src/ipc/installd_proxy.cpp +++ b/services/bundlemgr/src/ipc/installd_proxy.cpp @@ -774,13 +774,14 @@ ErrCode InstalldProxy::RemoveSignProfile(const std::string &bundleName) } ErrCode InstalldProxy::SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { MessageParcel data; INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor())); INSTALLD_PARCEL_WRITE(data, Int32, uid); INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(bundleName)); INSTALLD_PARCEL_WRITE(data, Int32, userId); + INSTALLD_PARCEL_WRITE(data, Uint32, accessTokenId); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); @@ -793,11 +794,11 @@ ErrCode InstalldProxy::SetEncryptionPolicy(int32_t uid, const std::string &bundl return ERR_OK; } -ErrCode InstalldProxy::DeleteEncryptionKeyId(const std::string &keyId) +ErrCode InstalldProxy::DeleteEncryptionKeyId(const uint32_t accessTokenId) { MessageParcel data; INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor())); - INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(keyId)); + INSTALLD_PARCEL_WRITE(data, Uint32, accessTokenId); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); diff --git a/services/bundlemgr/test/mock/src/installd_client.cpp b/services/bundlemgr/test/mock/src/installd_client.cpp index 96cf7d43728692ec6b72bab63ad59299c1f156a1..5267c1839fe2b111e95322c84c65f7aebd47d09e 100644 --- a/services/bundlemgr/test/mock/src/installd_client.cpp +++ b/services/bundlemgr/test/mock/src/installd_client.cpp @@ -419,13 +419,13 @@ ErrCode InstalldClient::RemoveSignProfile(const std::string &bundleName) } ErrCode InstalldClient::SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { if (bundleName.empty()) { APP_LOGE("bundleName is empty"); return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; } - return CallService(&IInstalld::SetEncryptionPolicy, uid, bundleName, userId, keyId); + return CallService(&IInstalld::SetEncryptionPolicy, uid, bundleName, userId, keyId, accessTokenId); } ErrCode InstalldClient::RemoveExtensionDir(int32_t userId, const std::vector &extensionBundleDirs) @@ -457,13 +457,9 @@ ErrCode InstalldClient::CreateExtensionDataDir(const CreateDirParam &createDirPa return CallService(&IInstalld::CreateExtensionDataDir, createDirParam); } -ErrCode InstalldClient::DeleteEncryptionKeyId(const std::string &keyId) +ErrCode InstalldClient::DeleteEncryptionKeyId(const uint32_t accessTokenId) { - if (keyId.empty()) { - APP_LOGE("keyId is empty"); - return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; - } - return CallService(&IInstalld::DeleteEncryptionKeyId, keyId); + return CallService(&IInstalld::DeleteEncryptionKeyId, accessTokenId); } bool InstalldClient::StartInstalldService() diff --git a/services/bundlemgr/test/mock/src/mock_install_client.cpp b/services/bundlemgr/test/mock/src/mock_install_client.cpp index a0e0b13b911a647d68b2750823a6d1ce8b9ad1cb..5274614c649614ee3e68b41575a4a91341f5f0e6 100644 --- a/services/bundlemgr/test/mock/src/mock_install_client.cpp +++ b/services/bundlemgr/test/mock/src/mock_install_client.cpp @@ -275,12 +275,12 @@ ErrCode InstalldClient::RemoveSignProfile(const std::string &bundleName) } ErrCode InstalldClient::SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { return ERR_OK; } -ErrCode InstalldClient::DeleteEncryptionKeyId(const std::string &keyId) +ErrCode InstalldClient::DeleteEncryptionKeyId(const uint32_t accessTokenId) { return ERR_OK; } diff --git a/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp b/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp index 5d45ff59b9dd0d5ea000b27c7e259ab4041767dc..f2f9d16762d9c8a881ff9fe8ea8239190fdb741f 100755 --- a/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp +++ b/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp @@ -271,12 +271,12 @@ ErrCode InstalldHostImpl::RemoveSignProfile(const std::string &bundleName) } ErrCode InstalldHostImpl::SetEncryptionPolicy(int32_t uid, const std::string &bundleName, - const int32_t userId, std::string &keyId) + const int32_t userId, std::string &keyId, const uint32_t accessTokenId) { return ERR_OK; } -ErrCode InstalldHostImpl::DeleteEncryptionKeyId(const std::string &keyId) +ErrCode InstalldHostImpl::DeleteEncryptionKeyId(const uint32_t accessTokenId) { return ERR_OK; } diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp index 4071cef3fc1f92cc53b650a613339c9218874430..bac15b706a5c66b5032fa8efe4ee106e5d327a95 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp @@ -905,7 +905,7 @@ HWTEST_F(BmsInstallDaemonHostImplTest, InstalldHostImplTest_5100, Function | Sma auto hostImpl = GetInstalldHostImpl(); ASSERT_NE(hostImpl, nullptr); std::string keyId = ""; - auto ret = hostImpl->SetEncryptionPolicy(0, "", 100, keyId); + auto ret = hostImpl->SetEncryptionPolicy(0, "", 100, keyId, 0); EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED); } @@ -919,7 +919,7 @@ HWTEST_F(BmsInstallDaemonHostImplTest, InstalldHostImplTest_5200, Function | Sma { auto hostImpl = GetInstalldHostImpl(); ASSERT_NE(hostImpl, nullptr); - auto ret = hostImpl->DeleteEncryptionKeyId(""); + auto ret = hostImpl->DeleteEncryptionKeyId(0); EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED); } diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp index 618c259f7edf71c03b157c3628b95287ba036fcc..18bf8ee54568994a98c209cf187de5f3f3d46598 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp @@ -826,7 +826,7 @@ HWTEST_F(BmsInstallDaemonIpcTest, InstalldProxyTest_4100, Function | SmallTest | std::string bundleName = TEST_STRING; int32_t userId = 100; std::string keyId = ""; - auto ret = proxy->SetEncryptionPolicy(uid, bundleName, userId, keyId); + auto ret = proxy->SetEncryptionPolicy(uid, bundleName, userId, keyId, 0); EXPECT_EQ(ret, ERR_OK); } @@ -840,7 +840,7 @@ HWTEST_F(BmsInstallDaemonIpcTest, InstalldProxyTest_4200, Function | SmallTest | auto proxy = GetInstallProxy(); EXPECT_NE(proxy, nullptr); - auto ret = proxy->DeleteEncryptionKeyId(TEST_STRING); + auto ret = proxy->DeleteEncryptionKeyId(0); EXPECT_EQ(ret, ERR_OK); } } // OHOS \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_operator_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_operator_test.cpp index 0fc73a29365d4dd087c4887c9003c933492d9c23..1be2de42adf0e8b0c87f32626d724e18167410b3 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_operator_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_operator_test.cpp @@ -1237,7 +1237,7 @@ HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_7500, Function | Sma HWTEST_F(BmsInstallDaemonOperatorTest, InstalldOperatorTest_7600, Function | SmallTest | Level0) { std::string keyId = ""; - bool res = InstalldOperator::GenerateKeyIdAndSetPolicy(0, "", 100, keyId); + bool res = InstalldOperator::GenerateKeyIdAndSetPolicy(0, "", 100, keyId, 0); EXPECT_EQ(res, false); } diff --git a/services/bundlemgr/test/unittest/bms_installd_client_test/bms_installd_client_test.cpp b/services/bundlemgr/test/unittest/bms_installd_client_test/bms_installd_client_test.cpp index 7203958ca2b682d76593c239a32b239cc4ce53a1..0065623390c6f294ccba37b90bec951ad63e2299 100644 --- a/services/bundlemgr/test/unittest/bms_installd_client_test/bms_installd_client_test.cpp +++ b/services/bundlemgr/test/unittest/bms_installd_client_test/bms_installd_client_test.cpp @@ -1110,7 +1110,7 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_CopyFiles_0100, TestSize.L HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_SetEncryptionPolicy_0100, TestSize.Level1) { std::string keyId = ""; - ErrCode result = installClient_->SetEncryptionPolicy(0, "", 100, keyId); + ErrCode result = installClient_->SetEncryptionPolicy(0, "", 100, keyId, 0); EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR); } @@ -1121,7 +1121,7 @@ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_SetEncryptionPolicy_0100, */ HWTEST_F(BmsInstalldClientTest, BmsInstalldClientTest_DeleteEncryptionKeyId_0100, TestSize.Level1) { - ErrCode result = installClient_->DeleteEncryptionKeyId(""); + ErrCode result = installClient_->DeleteEncryptionKeyId(0); EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR); }