diff --git a/frameworks/bundle_lite/include/bundlems_slite_client.h b/frameworks/bundle_lite/include/bundlems_slite_client.h index 4e11f9e..5df0768 100755 --- a/frameworks/bundle_lite/include/bundlems_slite_client.h +++ b/frameworks/bundle_lite/include/bundlems_slite_client.h @@ -51,6 +51,8 @@ public: bool RegisterInstallerCallback(InstallerCallback installerCallback) const; + void UpdateBundleInfoList() const; + private: BundleMsClient() = default; diff --git a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp index 4d0f549..f1d2ea4 100755 --- a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp +++ b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp @@ -33,4 +33,9 @@ bool RegisterInstallerCallback(InstallerCallback installerCallback) { return OHOS::BundleMsClient::GetInstance().RegisterInstallerCallback(installerCallback); } + +void UpdateBundleInfoList(void) +{ + OHOS::BundleMsClient::GetInstance().UpdateBundleInfoList(); +} } diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp index 9460733..c6abb20 100755 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -188,4 +188,12 @@ uint32_t BundleMsClient::GetBundleSize (const char *bundleName) const } return bmsProxy_->GetBundleSize(bundleName); } + +void BundleMsClient::UpdateBundleInfoList () const +{ + if (!Initialize()) { + return; + } + bmsProxy_->UpdateBundleInfoList(); +} } // namespace OHOS diff --git a/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h b/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h index 537a014..bde7a0c 100755 --- a/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h +++ b/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h @@ -52,6 +52,7 @@ struct BmsSliteInterface { bool (*GetInstallState)(const char *bundleName, InstallState *installState, uint8_t *installProcess); uint32_t (*GetBundleSize)(const char *bundleName); bool (*RegisterInstallerCallback)(InstallerCallback installerCallback); + void (*UpdateBundleInfoList)(); }; #ifdef __cplusplus #if __cplusplus diff --git a/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h b/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h index 48c9e48..5d59a31 100644 --- a/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h +++ b/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h @@ -75,6 +75,12 @@ uint32_t GetBundleSize(const char *bundleName); */ bool RegisterInstallerCallback(InstallerCallback installerCallback); +/** + * @brief Update bundleInfo when system language has been changed. + * + */ +void UpdateBundleInfoList(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/services/bundlemgr_lite/include/bundle_common.h b/services/bundlemgr_lite/include/bundle_common.h index 1b0e146..2bd2ede 100755 --- a/services/bundlemgr_lite/include/bundle_common.h +++ b/services/bundlemgr_lite/include/bundle_common.h @@ -172,7 +172,7 @@ const uint8_t LONG_LENGTH = 8; const uint16_t MAX_INT = 256; const uint8_t MAX_VERSION_NAME_LEN = 20; const uint8_t MAX_LABLE_LEN = 30; -const uint8_t MAX_THIRD_BUNDLE_NUMBER = 30; +const uint8_t MAX_THIRD_BUNDLE_NUMBER = 50; struct SignatureInfo { char *bundleName; diff --git a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h index 51f7c46..e8aa04a 100755 --- a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h +++ b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h @@ -38,6 +38,7 @@ public: static bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); static uint32_t GetBundleSize (const char *bundleName); static bool RegisterInstallerCallback(InstallerCallback installerCallback); + static void UpdateBundleInfoList(); static BundleMgrSliteFeature *GetInstance() { diff --git a/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/services/bundlemgr_lite/include/gt_bundle_manager_service.h index 0791293..bb4779a 100755 --- a/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -69,6 +69,7 @@ public: uint32_t GetNumOfThirdBundles(); void RemoveBundleResList(const char *bundleName); void AddBundleResList(const BundleRes *bundleRes); + void UpdateBundleInfoList(); void ReportInstallProcess(const char *bundleName, uint8_t bundleStyle, uint8_t process); void AddNumOfThirdBundles(); void ReduceNumOfThirdBundles(); diff --git a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp index 10873b9..cb2bb5c 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp @@ -35,6 +35,7 @@ BundleMgrSliteFeatureImpl g_bmsSliteImpl = { .GetInstallState = BundleMgrSliteFeature::GetInstallState, .GetBundleSize = BundleMgrSliteFeature::GetBundleSize, .RegisterInstallerCallback = BundleMgrSliteFeature::RegisterInstallerCallback, + .UpdateBundleInfoList = BundleMgrSliteFeature::UpdateBundleInfoList, DEFAULT_IUNKNOWN_ENTRY_END }; @@ -138,4 +139,9 @@ bool BundleMgrSliteFeature::RegisterInstallerCallback(InstallerCallback installe { return OHOS::GtManagerService::GetInstance().RegisterInstallerCallback(installerCallback); } + +void BundleMgrSliteFeature::UpdateBundleInfoList() +{ + OHOS::GtManagerService::GetInstance().UpdateBundleInfoList(); +} } // namespace OHOS diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index fff7aaf..c0c0166 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -659,6 +659,46 @@ void GtManagerService::RemoveBundleResList(const char *bundleName) } } +void GtManagerService::UpdateBundleInfoList() +{ + if (bundleResList_ == nullptr) { + return; + } + + for (auto node = bundleResList_->Begin(); node != bundleResList_->End(); node = node->next_) { + BundleRes *res = node->value_; + if (res == nullptr || res->bundleName == nullptr || res->abilityRes == nullptr) { + continue; + } + + BundleInfo *bundleInfo = bundleMap_->Get(res->bundleName); + if (bundleInfo == nullptr) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] get no bundleInfo when change bundle res!"); + continue; + } + + int32_t len = strlen(INSTALL_PATH) + 1 + strlen(res->bundleName); + char *path = reinterpret_cast(UI_Malloc(len + 1)); + if (path == nullptr) { + continue; + } + + if (sprintf_s(path, len + 1, "%s/%s", INSTALL_PATH, res->bundleName) < 0) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] change bundle res failed! because sprintf_s fail"); + UI_Free(path); + continue; + } + + uint8_t errorCode = GtBundleParser::ConvertResInfoToBundleInfo(path, res->abilityRes->labelId, + res->abilityRes->iconId, bundleInfo); + UI_Free(path); + if (errorCode != ERR_OK) { + HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] change bundle res failed! errorCode is %d", errorCode); + return; + } + } +} + void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const char *bundleName) { if (codePath == nullptr) { @@ -872,7 +912,7 @@ int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, uint8_t insta return -1; } bundleInstallMsg->installState = static_cast(installState); - bundleInstallMsg->bundleName = Utils::Strdup(bundleName); + bundleInstallMsg->bundleName = bundleName; bundleInstallMsg->installProcess = process; (*installerCallback)(errCode, bundleInstallMsg); return 0;