1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_DATA_MGR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_DATA_MGR_H 18 19 #include <map> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 #include <shared_mutex> 24 #include <set> 25 26 #include "ohos/aafwk/content/want.h" 27 28 #include "ability_info.h" 29 #include "application_info.h" 30 #include "inner_bundle_info.h" 31 #include "bundle_status_callback_interface.h" 32 #include "bundle_data_storage_interface.h" 33 #include "module_usage_record.h" 34 #include "module_usage_data_storage.h" 35 #include "on_permission_changed_callback_interface.h" 36 #include "common_event_manager.h" 37 38 namespace OHOS { 39 namespace AppExecFwk { 40 41 enum class NotifyType { INSTALL, UPDATE, UNINSTALL_BUNDLE, UNINSTALL_MODULE }; 42 43 enum class InstallState { 44 INSTALL_START = 1, 45 INSTALL_SUCCESS, 46 INSTALL_FAIL, 47 UNINSTALL_START, 48 UNINSTALL_SUCCESS, 49 UNINSTALL_FAIL, 50 UPDATING_START, 51 UPDATING_SUCCESS, 52 UPDATING_FAIL, 53 }; 54 55 class BundleDataMgr { 56 public: 57 using Want = OHOS::AAFwk::Want; 58 59 // init state transfer map data. 60 BundleDataMgr(); 61 ~BundleDataMgr(); 62 63 /** 64 * @brief Boot query persistent storage. 65 * @return Returns true if this function is successfully called; returns false otherwise. 66 */ 67 bool LoadDataFromPersistentStorage(); 68 /** 69 * @brief Update internal state for whole bundle. 70 * @param bundleName Indicates the bundle name. 71 * @param state Indicates the install state to be set. 72 * @return Returns true if this function is successfully called; returns false otherwise. 73 */ 74 bool UpdateBundleInstallState(const std::string &bundleName, const InstallState state); 75 /** 76 * @brief Add new InnerBundleInfo. 77 * @param bundleName Indicates the bundle name. 78 * @param info Indicates the InnerBundleInfo object to be save. 79 * @return Returns true if this function is successfully called; returns false otherwise. 80 */ 81 bool AddInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info); 82 /** 83 * @brief Add new module info to an exist InnerBundleInfo. 84 * @param bundleName Indicates the bundle name. 85 * @param newInfo Indicates the new InnerBundleInfo object. 86 * @param oldInfo Indicates the old InnerBundleInfo object. 87 * @return Returns true if this function is successfully called; returns false otherwise. 88 */ 89 bool AddNewModuleInfo(const std::string &bundleName, const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo); 90 /** 91 * @brief Remove module info from an exist InnerBundleInfo. 92 * @param bundleName Indicates the bundle name. 93 * @param modulePackage Indicates the module Package. 94 * @param oldInfo Indicates the old InnerBundleInfo object. 95 * @return Returns true if this function is successfully called; returns false otherwise. 96 */ 97 bool RemoveModuleInfo(const std::string &bundleName, const std::string &modulePackage, InnerBundleInfo &oldInfo); 98 /** 99 * @brief Update module info of an exist module. 100 * @param bundleName Indicates the bundle name. 101 * @param newInfo Indicates the new InnerBundleInfo object. 102 * @param oldInfo Indicates the old InnerBundleInfo object. 103 * @return Returns true if this function is successfully called; returns false otherwise. 104 */ 105 bool UpdateInnerBundleInfo(const std::string &bundleName, const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo); 106 /** 107 * @brief Get an InnerBundleInfo if exist (will change the status to DISABLED). 108 * @param bundleName Indicates the bundle name. 109 * @param deviceId Indicates this device Id corresponding to the bundle name. 110 * @param info Indicates the obtained InnerBundleInfo object. 111 * @return Returns true if this function is successfully called; returns false otherwise. 112 */ 113 bool GetInnerBundleInfo(const std::string &bundleName, const std::string &deviceId, InnerBundleInfo &info); 114 /** 115 * @brief Generate UID and GID for a bundle. 116 * @param info Indicates the InnerBundleInfo object. 117 * @return Returns true if this function is successfully called; returns false otherwise. 118 */ 119 bool GenerateUidAndGid(InnerBundleInfo &info); 120 /** 121 * @brief Query the AbilityInfo by the given Want. 122 * @param want Indicates the information of the ability. 123 * @param abilityInfo Indicates the obtained AbilityInfo object. 124 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 125 */ 126 bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) const; 127 /** 128 * @brief Query a AbilityInfo of list by the given Want. 129 * @param want Indicates the information of the ability. 130 * @param abilityInfo Indicates the obtained AbilityInfo of list. 131 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 132 */ 133 bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfo) const; 134 /** 135 * @brief Query the AbilityInfo by ability.uri in config.json. 136 * @param abilityUri Indicates the uri of the ability. 137 * @param abilityInfo Indicates the obtained AbilityInfo object. 138 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 139 */ 140 bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) const; 141 /** 142 * @brief Obtains the ApplicationInfo based on a given bundle name. 143 * @param appName Indicates the application bundle name to be queried. 144 * @param flag Indicates the flag used to specify information contained 145 * in the ApplicationInfo object that will be returned. 146 * @param userId Indicates the user ID. 147 * @param appInfo Indicates the obtained ApplicationInfo object. 148 * @return Returns true if the application is successfully obtained; returns false otherwise. 149 */ 150 bool GetApplicationInfo( 151 const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) const; 152 /** 153 * @brief Obtains information about all installed applications of a specified user. 154 * @param flag Indicates the flag used to specify information contained 155 * in the ApplicationInfo objects that will be returned. 156 * @param userId Indicates the user ID. 157 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 158 * @return Returns true if the application is successfully obtained; returns false otherwise. 159 */ 160 bool GetApplicationInfos( 161 const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) const; 162 /** 163 * @brief Obtains BundleInfo of all bundles available in the system. 164 * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned. 165 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 166 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 167 */ 168 bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) const; 169 /** 170 * @brief Obtains the BundleInfo based on a given bundle name. 171 * @param bundleName Indicates the application bundle name to be queried. 172 * @param flag Indicates the information contained in the BundleInfo object to be returned. 173 * @param bundleInfo Indicates the obtained BundleInfo object. 174 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 175 */ 176 bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) const; 177 /** 178 * @brief Obtains the BundleInfo of application bundles based on the specified metaData. 179 * @param metaData Indicates the metadata to get in the bundle. 180 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 181 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 182 */ 183 bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) const; 184 /** 185 * @brief Obtains the bundle name of a specified application based on the given UID. 186 * @param uid Indicates the uid. 187 * @param bundleName Indicates the obtained bundle name. 188 * @return Returns true if the bundle name is successfully obtained; returns false otherwise. 189 */ 190 bool GetBundleNameForUid(const int uid, std::string &bundleName) const; 191 /** 192 * @brief Obtains all bundle names of a specified application based on the given application UID. 193 * @param uid Indicates the uid. 194 * @param bundleNames Indicates the obtained bundle names. 195 * @return Returns true if the bundle names is successfully obtained; returns false otherwise. 196 */ 197 bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) const; 198 /** 199 * @brief Obtains the formal name associated with the given UID. 200 * @param uid Indicates the uid. 201 * @param name Indicates the obtained formal name. 202 * @return Returns true if the formal name is successfully obtained; returns false otherwise. 203 */ 204 bool GetNameForUid(const int uid, std::string &name) const; 205 /** 206 * @brief Obtains an array of all group IDs associated with a specified bundle. 207 * @param bundleName Indicates the bundle name. 208 * @param gids Indicates the group IDs associated with the specified bundle. 209 * @return Returns true if the gids is successfully obtained; returns false otherwise. 210 */ 211 bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) const; 212 /** 213 * @brief Obtains the BundleInfo of all keep-alive applications in the system. 214 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 215 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 216 */ 217 bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) const; 218 /** 219 * @brief Obtains the label of a specified ability. 220 * @param bundleName Indicates the bundle name. 221 * @param className Indicates the ability class name. 222 * @return Returns the label of the ability if exist; returns empty string otherwise. 223 */ 224 std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) const; 225 /** 226 * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. 227 * @param bundleName Indicates the bundle name. 228 * @param want Indicates the obtained launch Want object. 229 * @return Returns true if the launch Want object is successfully obtained; returns false otherwise. 230 */ 231 bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) const; 232 /** 233 * @brief Obtain the HAP module info of a specific ability. 234 * @param abilityInfo Indicates the ability. 235 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 236 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 237 */ 238 bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) const; 239 /** 240 * @brief Check whether the app is system app by it's UID. 241 * @param uid Indicates the uid. 242 * @return Returns true if the bundle is a system application; returns false otherwise. 243 */ 244 bool CheckIsSystemAppByUid(const int uid) const; 245 /** 246 * @brief Obtains all bundle names installed. 247 * @param bundleNames Indicates the bundle Names. 248 * @return Returns true if have bundle installed; returns false otherwise. 249 */ 250 bool GetBundleList(std::vector<std::string> &bundleNames) const; 251 /** 252 * @brief Set the bundle status disable. 253 * @param bundleName Indicates the bundle name. 254 * @return Returns true if the bundle status successfully set; returns false otherwise. 255 */ 256 bool DisableBundle(const std::string &bundleName); 257 /** 258 * @brief Set the bundle status enable. 259 * @param bundleName Indicates the bundle name. 260 * @return Returns true if the bundle status successfully set; returns false otherwise. 261 */ 262 bool EnableBundle(const std::string &bundleName); 263 /** 264 * @brief Get whether the application status is enabled. 265 * @param bundleName Indicates the bundle name. 266 * @return Returns true if the bundle status is enabled; returns false otherwise. 267 */ 268 bool IsApplicationEnabled(const std::string &bundleName) const; 269 /** 270 * @brief Set the application status. 271 * @param bundleName Indicates the bundle name. 272 * @param isEnable Indicates the status to set. 273 * @return Returns true if the bundle status successfully set; returns false otherwise. 274 */ 275 bool SetApplicationEnabled(const std::string &bundleName, bool isEnable); 276 /** 277 * @brief Sets whether to enable a specified ability through the proxy object. 278 * @param abilityInfo Indicates information about the ability to check. 279 * @return Returns true if the ability is enabled; returns false otherwise. 280 */ 281 bool IsAbilityEnabled(const AbilityInfo &abilityInfo) const; 282 /** 283 * @brief Sets whether to enable a specified ability through the proxy object. 284 * @param abilityInfo Indicates information about the ability. 285 * @param isEnabled Specifies whether to enable the ability. 286 * The value true means to enable it, and the value false means to disable it. 287 * @return Returns true if the ability is enabled; returns false otherwise. 288 */ 289 bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled); 290 /** 291 * @brief Obtains the icon of a specified ability through the proxy object. 292 * @param bundleName Indicates the bundle name. 293 * @param className Indicates the ability class name. 294 * @return Returns the icon resource string of the ability if exist; returns empty string otherwise. 295 */ 296 std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) const; 297 /** 298 * @brief Register the bundle status callback function. 299 * @param bundleStatusCallback Indicates the callback object that using for notifing the bundle status. 300 * @return Returns true if this function is successfully called; returns false otherwise. 301 */ 302 bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback); 303 /** 304 * @brief Clear the specific bundle status callback. 305 * @param bundleStatusCallback Indicates the callback to be cleared. 306 * @return Returns true if this function is successfully called; returns false otherwise. 307 */ 308 bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback); 309 /** 310 * @brief Unregister all the callbacks of status changed. 311 * @return Returns true if this function is successfully called; returns false otherwise. 312 */ 313 bool UnregisterBundleStatusCallback(); 314 /** 315 * @brief Notify when the installation, update, or uninstall state of an application changes. 316 * @param bundleName Indicates the name of the bundle whose state has changed. 317 * @param modulePackage Indicates the modulePackage name of the bundle whose state has changed. 318 * @param resultCode Indicates the status code returned for the application installation, update, or uninstall 319 * result. 320 * @param type Indicates the NotifyType object. 321 * @param uid Indicates the uid of the application. 322 * @return Returns true if this function is successfully called; returns false otherwise. 323 */ 324 bool NotifyBundleStatus(const std::string &bundleName, const std::string &modulePackage, 325 const std::string &mainAbility, const ErrCode resultCode, const NotifyType type, const int32_t &uid); 326 /** 327 * @brief Get a mutex for locking by bundle name. 328 * @param bundleName Indicates the bundle name. 329 * @return Returns a reference of mutex that for locing by bundle name. 330 */ 331 std::mutex &GetBundleMutex(const std::string &bundleName); 332 /** 333 * @brief Obtains the provision Id based on a given bundle name. 334 * @param bundleName Indicates the application bundle name to be queried. 335 * @param provisionId Indicates the provision Id to be returned. 336 * @return Returns true if the provision Id is successfully obtained; returns false otherwise. 337 */ 338 bool GetProvisionId(const std::string &bundleName, std::string &provisionId) const; 339 /** 340 * @brief Obtains the app feature based on a given bundle name. 341 * @param bundleName Indicates the application bundle name to be queried. 342 * @param provisionId Indicates the app feature to be returned. 343 * @return Returns true if the app feature is successfully obtained; returns false otherwise. 344 */ 345 bool GetAppFeature(const std::string &bundleName, std::string &appFeature) const; 346 /** 347 * @brief Set the flag that indicates whether all applications are installed. 348 * @param flag Indicates the flag to be set. 349 * @return 350 */ 351 void SetAllInstallFlag(bool flag); 352 /** 353 * @brief Checks whether the publickeys of two bundles are the same. 354 * @param firstBundleName Indicates the first bundle name. 355 * @param secondBundleName Indicates the second bundle name. 356 * @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found; 357 * returns SIGNATURE_NOT_MATCHED if their publickeys are different; 358 * returns SIGNATURE_MATCHED if their publickeys are the same. 359 */ 360 int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) const; 361 /** 362 * @brief Get a shared pointer to the IBundleDataStorage object. 363 * @return Returns the pointer of IBundleDataStorage object. 364 */ 365 std::shared_ptr<IBundleDataStorage> GetDataStorage() const; 366 /** 367 * @brief Obtains the FormInfo objects provided by all applications on the device. 368 * @param formInfos List of FormInfo objects if obtained; 369 * @return Returns true if this function is successfully called; returns false otherwise. 370 */ 371 bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) const; 372 /** 373 * @brief Obtains the FormInfo objects provided by a specified application on the device. 374 * @param bundleName Indicates the bundle name of the application. 375 * @param formInfos List of FormInfo objects if obtained; 376 * @return Returns true if this function is successfully called; returns false otherwise. 377 */ 378 bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) const; 379 /** 380 * @brief Obtains the FormInfo objects provided by a specified module name. 381 * @param formInfos List of FormInfo objects if obtained; 382 * @param moduleName Indicates the module name of the application. 383 * @param bundleName Indicates the bundle name of the application. 384 * @return Returns true if this function is successfully called; returns false otherwise. 385 */ 386 bool GetFormsInfoByModule( 387 const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) const; 388 /** 389 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 390 * @param bundleName Indicates the bundle name of the application. 391 * @param shortcutInfos List of ShortcutInfo objects if obtained. 392 * @return Returns true if this function is successfully called; returns false otherwise. 393 */ 394 bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) const; 395 /** 396 * @brief Notify a specified ability for activity. 397 * @param bundleName Indicates the bundle name of the ability to activity. 398 * @param abilityName Indicates the name of the ability to activity. 399 * @param launchTime Indicates the ability launchTime. 400 * @return Returns true if this function is successfully called; returns false otherwise. 401 */ 402 bool NotifyActivityLifeStatus( 403 const std::string &bundleName, const std::string &abilityName, const int64_t launchTime) const; 404 /** 405 * @brief Query ModuleUsageRecord objects ordered by lastLaunchTime desc 406 * @param maxNum Indicates the max number ShortcutInfo objects to get. 407 * @param records List of ModuleUsageRecord objects if obtained. 408 * @return Returns true if this function is successfully called; returns false otherwise. 409 */ 410 bool GetUsageRecords(int32_t maxNum, std::vector<ModuleUsageRecord> &records); 411 /** 412 * @brief Registers a callback for listening for permission changes of all UIDs. 413 * @param callback Indicates the callback method to register. 414 * @return Returns true if this function is successfully called; returns false otherwise. 415 */ 416 bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback); 417 /** 418 * @brief Registers a callback for listening for permission changes of specified UIDs. 419 * @param uids Indicates the list of UIDs whose permission changes will be monitored. 420 * @param callback Indicates the callback method to register. 421 * @return Returns true if this function is successfully called; returns false otherwise. 422 */ 423 bool RegisterPermissionsChanged(const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback); 424 /** 425 * @brief Add death recipient for specified callback registerd. 426 * @param callback Indicates the callback for death recipient. 427 * @return Returns true if this function is successfully called; returns false otherwise. 428 */ 429 bool AddDeathRecipient(const sptr<OnPermissionChangedCallback> &callback); 430 /** 431 * @brief Unregisters a specified callback for listening for permission changes. 432 * @param callback Indicates the callback method to unregister. 433 * @return Returns true if this function is successfully called; returns false otherwise. 434 */ 435 bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback); 436 /** 437 * @brief Call callback for listening the uid permission changes. 438 * @param uid Indicates the bundle uid whose permission changes. 439 * @return Returns true if this function is successfully called; returns false otherwise. 440 */ 441 bool NotifyPermissionsChanged(int32_t uid); 442 /** 443 * @brief Update bundle usage record on bundle removed. 444 * @param keepUsage Indicates the flag record is remove on bundle removed. 445 * @param userId Indicates the user Id of the application. 446 * @param bundleName Indicates the bundle name of the application. 447 * @return Returns true if this function is successfully called; returns false otherwise. 448 */ 449 bool UpdateUsageRecordOnBundleRemoved(bool keepUsage, const int userId, const std::string &bundleName) const; 450 /** 451 * @brief Update bundle usage record on module removed. 452 * @param keepUsage Indicates the flag record is remove on module removed. 453 * @param userId Indicates the user Id of the application. 454 * @param bundleName Indicates the bundle name of the application. 455 * @param moduleName Indicates the module name of the application. 456 * @return Returns true if this function is successfully called; returns false otherwise. 457 */ 458 bool UpdateUsageRecordOnModuleRemoved( 459 bool keepUsage, const int userId, const std::string &bundleName, const std::string &moduleName) const; 460 461 private: 462 /** 463 * @brief Init transferStates. 464 * @return 465 */ 466 void InitStateTransferMap(); 467 /** 468 * @brief Determine whether to delete the data status. 469 * @param state Indicates the InstallState object. 470 * @return Returns true if state is INSTALL_FAIL,UNINSTALL_FAIL,UNINSTALL_SUCCESS,or UPDATING_FAIL; returns false 471 * otherwise. 472 */ 473 bool IsDeleteDataState(const InstallState state) const; 474 /** 475 * @brief Determine whether it is disable. 476 * @param state Indicates the InstallState object. 477 * @return Returns true if install state is UPDATING_START or UNINSTALL_START; returns false otherwise. 478 */ 479 bool IsDisableState(const InstallState state) const; 480 /** 481 * @brief Delete bundle info if InstallState is not INSTALL_FAIL. 482 * @param bundleName Indicates the bundle Names. 483 * @param state Indicates the InstallState object. 484 * @return Returns true if install state is UPDATING_START or UNINSTALL_START; returns false otherwise. 485 */ 486 void DeleteBundleInfo(const std::string &bundleName, const InstallState state); 487 /** 488 * @brief Determine whether app is installed. 489 * @param bundleName Indicates the bundle Names. 490 * @return Returns true if install state is INSTALL_SUCCESS; returns false otherwise. 491 */ 492 bool IsAppOrAbilityInstalled(const std::string &bundleName) const; 493 /** 494 * @brief Restore uid and gid . 495 * @return Returns true if this function is successfully called; returns false otherwise. 496 */ 497 bool RestoreUidAndGid(); 498 /** 499 * @brief Recycle uid and gid . 500 * @param info Indicates the InnerBundleInfo object. 501 * @return Returns true if this function is successfully called; returns false otherwise. 502 */ 503 bool RecycleUidAndGid(const InnerBundleInfo &info); 504 505 private: 506 mutable std::mutex bundleInfoMutex_; 507 mutable std::mutex stateMutex_; 508 mutable std::mutex uidMapMutex_; 509 mutable std::mutex callbackMutex_; 510 mutable std::shared_mutex bundleMutex_; 511 mutable std::mutex allPermissionsChangedLock_; 512 mutable std::mutex permissionsChangedLock_; 513 bool allInstallFlag_ = false; 514 // using for locking by bundleName 515 std::unordered_map<std::string, std::mutex> bundleMutexMap_; 516 // using for generating uid and gid 517 std::map<int, std::string> sysUidMap_; 518 std::map<int, std::string> sysVendorUidMap_; 519 std::map<int, std::string> appUidMap_; 520 // use vector because these functions using for IPC, the bundleName may duplicate 521 std::vector<sptr<IBundleStatusCallback>> callbackList_; 522 // all installed bundles 523 // key:bundleName 524 // value:deviceId-innerbundleinfo pair 525 std::map<std::string, std::map<std::string, InnerBundleInfo>> bundleInfos_; 526 // key:bundle name 527 std::map<std::string, InstallState> installStates_; 528 // current-status:previous-statue pair 529 std::multimap<InstallState, InstallState> transferStates_; 530 std::shared_ptr<IBundleDataStorage> dataStorage_; 531 std::shared_ptr<ModuleUsageRecordStorage> usageRecordStorage_; 532 std::set<sptr<OnPermissionChangedCallback>> allPermissionsCallbacks_; 533 // map<uid, callback>. 534 std::map<int32_t, std::set<sptr<OnPermissionChangedCallback>>> permissionsCallbacks_; 535 }; 536 537 } // namespace AppExecFwk 538 } // namespace OHOS 539 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_DATA_MGR_H 540