diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index f40d6412e2ff76cb22ed8d0dd61b11b1e4f855e9..b8f17f7d36e500b6c0785a52e78a92a3f078a082 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 2decdbe77fc45cca2775da3231012b0a24034f6e..a30392ca19704f0a1d54eb694c3be831290c57d5 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 (info.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", info.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", info.GetBundleName().c_str()); + std::vector dirs = GenerateScreenLockProtectionDir(info.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(info.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 6bed807995466d357001cd4888317c54d755b642..19bbc95a191921b3387860d782e69383e43eea0e 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);