From b60f8c23166ac92e2be799d0b2afda2353934985 Mon Sep 17 00:00:00 2001 From: Zhou Shihui Date: Tue, 9 Sep 2025 16:53:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4el5=E5=AF=86=E9=92=A5?= =?UTF-8?q?=E4=B8=8D=E5=88=A4=E6=96=ADkeyId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zhou Shihui --- .../bundlemgr/include/base_bundle_installer.h | 2 +- services/bundlemgr/src/base_bundle_installer.cpp | 16 ++++++++-------- .../bms_bundle_overlay_checker_test.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index f40d6412e2..b8f17f7d36 100644 --- a/services/bundlemgr/include/base_bundle_installer.h +++ b/services/bundlemgr/include/base_bundle_installer.h @@ -759,7 +759,7 @@ private: void CreateScreenLockProtectionDir(); void CreateEl5AndSetPolicy(InnerBundleInfo &info); void DeleteScreenLockProtectionDir(const std::string bundleName) const; - void DeleteEncryptionKeyId(const InnerBundleUserInfo &userInfo, bool isKeepData) const; + void DeleteEncryptionKeyId(const InnerBundleInfo &info, bool isKeepData) const; #ifdef APP_DOMAIN_VERIFY_ENABLED void PrepareSkillUri(const std::vector &skills, std::vector &skillUris) const; #endif diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index 2decdbe77f..09c4225675 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -1844,7 +1844,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUninstall( APP_LOGW("remove group dir failed for %{public}s", oldInfo.GetBundleName().c_str()); } - DeleteEncryptionKeyId(curInnerBundleUserInfo, installParam.isKeepData); + DeleteEncryptionKeyId(oldInfo, installParam.isKeepData); if (!installParam.isRemoveUser && !SaveFirstInstallBundleInfo(bundleName, userId_, oldInfo.IsPreInstallApp(), curInnerBundleUserInfo)) { LOG_E(BMS_TAG_INSTALLER, "save first install bundle info failed"); @@ -3599,28 +3599,28 @@ bool BaseBundleInstaller::CheckInstallOnKeepData(const std::string &bundleName, return true; } -void BaseBundleInstaller::DeleteEncryptionKeyId(const InnerBundleUserInfo &userInfo, bool isKeepData) const +void BaseBundleInstaller::DeleteEncryptionKeyId(const InnerBundleInfo &info, bool isKeepData) const { - if (userInfo.bundleName.empty()) { + if (oldInfo.GetBundleName().empty()) { LOG_W(BMS_TAG_INSTALLER, "bundleName is empty"); return; } if (isKeepData) { - LOG_I(BMS_TAG_INSTALLER, "keep el5 dir -n %{public}s", userInfo.bundleName.c_str()); + LOG_I(BMS_TAG_INSTALLER, "keep el5 dir -n %{public}s", oldInfo.GetBundleName().c_str()); return; } - LOG_D(BMS_TAG_INSTALLER, "delete el5 dir -n %{public}s", userInfo.bundleName.c_str()); - std::vector dirs = GenerateScreenLockProtectionDir(userInfo.bundleName); + LOG_D(BMS_TAG_INSTALLER, "delete el5 dir -n %{public}s", oldInfo.GetBundleName().c_str()); + std::vector dirs = GenerateScreenLockProtectionDir(oldInfo.GetBundleName()); for (const std::string &dir : dirs) { if (InstalldClient::GetInstance()->RemoveDir(dir) != ERR_OK) { LOG_W(BMS_TAG_INSTALLER, "remove Screen Lock Protection dir %{public}s failed", dir.c_str()); } } - if (userInfo.keyId.empty()) { + if (!info.NeedCreateEl5Dir()) { return; } - EncryptionParam encryptionParam(userInfo.bundleName, "", 0, userId_, EncryptionDirType::APP); + EncryptionParam encryptionParam(oldInfo.GetBundleName(), "", 0, userId_, EncryptionDirType::APP); if (InstalldClient::GetInstance()->DeleteEncryptionKeyId(encryptionParam) != ERR_OK) { LOG_W(BMS_TAG_INSTALLER, "delete encryption key id failed"); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp index 6bed807995..19bbc95a19 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/bms_bundle_overlay_checker_test.cpp @@ -3203,7 +3203,7 @@ HWTEST_F(BmsBundleOverlayCheckerTest, BaseBundleInstaller_0300, Function | Small installer->dataMgr_ = nullptr; installer->MarkPreInstallState(bundleName, isUninstalled); - installer->DeleteEncryptionKeyId(userInfo, isKeepData); + installer->DeleteEncryptionKeyId(oldInfo, isKeepData); installer->UpdateExtensionSandboxInfo(newInfos, hapVerifyRes); -- Gitee