diff --git a/services/bundlemgr/include/bundle_data_mgr.h b/services/bundlemgr/include/bundle_data_mgr.h index ec3ce2a1b4eb21f45157ebdb550e69a8d1bebd87..298a8f3918896022dc12962938476bb1b31612fe 100644 --- a/services/bundlemgr/include/bundle_data_mgr.h +++ b/services/bundlemgr/include/bundle_data_mgr.h @@ -908,6 +908,7 @@ private: mutable std::mutex multiUserIdSetMutex_; mutable std::mutex preInstallInfoMutex_; bool initialUserFlag_ = false; + int32_t baseAppUid_ = Constants::BASE_APP_UID; // using for locking by bundleName std::unordered_map bundleMutexMap_; // using for generating bundleId diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 62f6a2db7170a225f8c962ff2aed79f30756173e..1865a377ed71425b10b8ccc908b2de200eb2f6d4 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -49,6 +49,7 @@ #endif #include "nlohmann/json.hpp" #include "free_install_params.h" +#include "parameters.h" #include "singleton.h" namespace OHOS { @@ -68,6 +69,10 @@ BundleDataMgr::BundleDataMgr() #endif sandboxAppHelper_ = DelayedSingleton::GetInstance(); bundleStateStorage_ = std::make_shared(); + baseAppUid_ = system::GetIntParameter("const.product.baseappid", Constants::BASE_APP_UID); + if (baseAppUid_ < Constants::BASE_APP_UID || baseAppUid_ >= Constants::MAX_APP_UID) { + baseAppUid_ = Constants::BASE_APP_UID; + } APP_LOGI("BundleDataMgr instance is created"); } @@ -2501,7 +2506,7 @@ bool BundleDataMgr::GenerateBundleId(const std::string &bundleName, int32_t &bun std::lock_guard lock(bundleIdMapMutex_); if (bundleIdMap_.empty()) { APP_LOGI("first app install"); - bundleId = Constants::BASE_APP_UID; + bundleId = baseAppUid_; bundleIdMap_.emplace(bundleId, bundleName); return true; } @@ -2513,7 +2518,7 @@ bool BundleDataMgr::GenerateBundleId(const std::string &bundleName, int32_t &bun } } - for (int32_t i = Constants::BASE_APP_UID; i < bundleIdMap_.rbegin()->first; ++i) { + for (int32_t i = baseAppUid_; i < bundleIdMap_.rbegin()->first; ++i) { if (bundleIdMap_.find(i) == bundleIdMap_.end()) { APP_LOGI("the %{public}d app install", i); bundleId = i;