• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 <atomic>
20 #include <cstdint>
21 #include <map>
22 #include <memory>
23 #include <mutex>
24 #include <optional>
25 #include <set>
26 #include <shared_mutex>
27 #include <string>
28 
29 #include "bundle_dir.h"
30 #include "want.h"
31 
32 #include "ability_info.h"
33 #include "aot/aot_args.h"
34 #include "application_info.h"
35 #include "app_provision_info.h"
36 #ifdef ABILITY_RUNTIME_ENABLE
37 #include "app_mgr_interface.h"
38 #include "running_process_info.h"
39 #endif
40 #include "bundle_data_storage_interface.h"
41 #include "bundle_event_callback_interface.h"
42 #include "bundle_promise.h"
43 #include "bundle_sandbox_app_helper.h"
44 #include "bundle_state_storage.h"
45 #include "bundle_status_callback_interface.h"
46 #include "common_event_data.h"
47 #include "ffrt.h"
48 #include "first_install_data_mgr_storage_rdb.h"
49 #include "inner_bundle_clone_info.h"
50 #include "inner_bundle_info.h"
51 #include "inner_bundle_user_info.h"
52 #include "ipc/create_dir_param.h"
53 #include "uninstall_data_mgr_storage_rdb.h"
54 #include "module_info.h"
55 #include "preinstall_data_storage_interface.h"
56 #include "router_data_storage_interface.h"
57 #include "shortcut_data_storage_interface.h"
58 #ifdef GLOBAL_RESMGR_ENABLE
59 #include "resource_manager.h"
60 #endif
61 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
62 #include "element.h"
63 #endif
64 #include "ohos_account_kits.h"
65 
66 namespace OHOS {
67 namespace AppExecFwk {
68 enum class InstallState {
69     INSTALL_START = 1,
70     INSTALL_SUCCESS,
71     INSTALL_FAIL,
72     UNINSTALL_START,
73     UNINSTALL_SUCCESS,
74     UNINSTALL_FAIL,
75     UPDATING_START,
76     UPDATING_SUCCESS,
77     UPDATING_FAIL,
78     ROLL_BACK,
79     USER_CHANGE,
80 };
81 
82 class BundleDataMgr {
83 public:
84     using Want = OHOS::AAFwk::Want;
85 
86     // init state transfer map data.
87     BundleDataMgr();
88     virtual ~BundleDataMgr();
89 
90     /**
91      * @brief Boot query persistent storage.
92      * @return Returns true if this function is successfully called; returns false otherwise.
93      */
94     bool LoadDataFromPersistentStorage();
95     /**
96      * @brief Update internal state for whole bundle.
97      * @param bundleName Indicates the bundle name.
98      * @param state Indicates the install state to be set.
99      * @return Returns true if this function is successfully called; returns false otherwise.
100      */
101     bool UpdateBundleInstallState(const std::string &bundleName,
102         const InstallState state, const bool isKeepData = false);
103     /**
104      * @brief Add new InnerBundleInfo.
105      * @param bundleName Indicates the bundle name.
106      * @param info Indicates the InnerBundleInfo object to be save.
107      * @return Returns true if this function is successfully called; returns false otherwise.
108      */
109     bool AddInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info, bool checkStatus = true);
110     /**
111      * @brief Add new module info to an exist InnerBundleInfo.
112      * @param bundleName Indicates the bundle name.
113      * @param newInfo Indicates the new InnerBundleInfo object.
114      * @param oldInfo Indicates the old InnerBundleInfo object.
115      * @return Returns true if this function is successfully called; returns false otherwise.
116      */
117     bool AddNewModuleInfo(const std::string &bundleName, const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
118     bool AddNewModuleInfo(const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
119 
120     /**
121      * @brief Remove module info from an exist InnerBundleInfo.
122      * @param bundleName Indicates the bundle name.
123      * @param modulePackage Indicates the module Package.
124      * @param oldInfo Indicates the old InnerBundleInfo object.
125      * @return Returns true if this function is successfully called; returns false otherwise.
126      */
127     bool RemoveModuleInfo(const std::string &bundleName, const std::string &modulePackage, InnerBundleInfo &oldInfo,
128         bool needSaveStorage = true);
129 
130     bool RemoveHspModuleByVersionCode(int32_t versionCode, InnerBundleInfo &info);
131     /**
132      * @brief Update module info of an exist module.
133      * @param bundleName Indicates the bundle name.
134      * @param newInfo Indicates the new InnerBundleInfo object.
135      * @param oldInfo Indicates the old InnerBundleInfo object.
136      * @return Returns true if this function is successfully called; returns false otherwise.
137      */
138     bool UpdateInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
139     bool UpdateInnerBundleInfo(InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
140     void UpdateBaseBundleInfoIntoOld(const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
141     bool UpdateInnerBundleInfo(const InnerBundleInfo &innerBundleInfo, bool needSaveStorage = true);
142     /**
143      * @brief Get an InnerBundleInfo if exist (will change the status to DISABLED).
144      * @param bundleName Indicates the bundle name.
145      * @param info Indicates the obtained InnerBundleInfo object.
146      * @return Returns true if this function is successfully called; returns false otherwise.
147      */
148     bool GetInnerBundleInfoWithDisable(const std::string &bundleName, InnerBundleInfo &info);
149     /**
150      * @brief Generate UID and GID for a bundle.
151      * @param innerBundleUserInfo Indicates the InnerBundleUserInfo object.
152      * @return Returns true if this function is successfully called; returns false otherwise.
153      */
154     bool GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo);
155     /**
156      * @brief Recycle uid and gid .
157      * @param info Indicates the InnerBundleInfo object.
158      */
159     void RecycleUidAndGid(const InnerBundleInfo &info);
160     /**
161      * @brief Query the AbilityInfo by the given Want.
162      * @param want Indicates the information of the ability.
163      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
164      * @param userId Indicates the user ID.
165      * @param abilityInfo Indicates the obtained AbilityInfo object.
166      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
167      */
168     bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo,
169         int32_t appIndex = 0) const;
170     /**
171      * @brief Query a AbilityInfo of list by the given Want.
172      * @param want Indicates the information of the ability.
173      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
174      * @param userId Indicates the user ID.
175      * @param abilityInfos Indicates the obtained AbilityInfo of list.
176      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
177      */
178     bool QueryAbilityInfos(
179         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
180     /**
181      * @brief Query a AbilityInfo of list by the given Want.
182      * @param want Indicates the information of the ability.
183      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
184      * @param userId Indicates the user ID.
185      * @param abilityInfos Indicates the obtained AbilityInfo of list.
186      * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise.
187      */
188     ErrCode QueryAbilityInfosV9(
189         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
190     /**
191      * @brief Query a AbilityInfo of list by the given Want.
192      * @param want Indicates the information of the ability.
193      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
194      * @param userId Indicates the user ID.
195      * @param abilityInfos Indicates the obtained AbilityInfo of list.
196      * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise.
197      */
198     ErrCode BatchQueryAbilityInfos(
199         const std::vector<Want> &wants, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
200     /**
201      * @brief Query Launcher AbilityInfo of list by the given Want.
202      * @param want Indicates the information of the ability.
203      * @param userId Indicates the user ID.
204      * @param abilityInfos Indicates the obtained AbilityInfo of list.
205      * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise.
206      */
207     ErrCode QueryLauncherAbilityInfos(
208         const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
209     /**
210      * @brief Query all match launcher ability infos by given wants.
211      * @param want Indicates the match infomation for abilities.
212      * @param info Indicates the bundleInfo.
213      * @param abilityInfo Indicates the obtained AbilityInfo of list.
214      * @param userId Indicates the user ID.
215      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
216      */
217     void GetMatchLauncherAbilityInfos(const Want& want, const InnerBundleInfo& info,
218         std::vector<AbilityInfo>& abilityInfos, int64_t installTime,
219         int32_t userId = Constants::UNSPECIFIED_USERID) const;
220     /**
221      * @brief Query the AbilityInfo by ability.uri in config.json.
222      * @param abilityUri Indicates the uri of the ability.
223      * @param abilityInfos Indicates the obtained AbilityInfos object.
224      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
225      */
226     bool QueryAbilityInfosByUri(const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos);
227     /**
228      * @brief Query the AbilityInfo by ability.uri in config.json.
229      * @param abilityUri Indicates the uri of the ability.
230      * @param userId Indicates the user ID.
231      * @param abilityInfo Indicates the obtained AbilityInfo object.
232      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
233      */
234     bool QueryAbilityInfoByUri(
235         const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) const;
236     /**
237      * @brief Obtains the ApplicationInfo based on a given bundle name.
238      * @param appName Indicates the application bundle name to be queried.
239      * @param flags Indicates the flag used to specify information contained
240      *             in the ApplicationInfo object that will be returned.
241      * @param userId Indicates the user ID.
242      * @param appInfo Indicates the obtained ApplicationInfo object.
243      * @return Returns true if the application is successfully obtained; returns false otherwise.
244      */
245     bool GetApplicationInfo(
246         const std::string &appName, int32_t flags, const int userId, ApplicationInfo &appInfo) const;
247     /**
248      * @brief Obtains the ApplicationInfo based on a given bundle name.
249      * @param appName Indicates the application bundle name to be queried.
250      * @param flags Indicates the flag used to specify information contained
251      *             in the ApplicationInfo object that will be returned.
252      * @param userId Indicates the user ID.
253      * @param appInfo Indicates the obtained ApplicationInfo object.
254      * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise.
255      */
256     ErrCode GetApplicationInfoV9(
257         const std::string &appName, int32_t flags, int32_t userId,
258         ApplicationInfo &appInfo, const int32_t appIndex = 0) const;
259     /**
260      * @brief Obtains the ApplicationInfo based on a given bundle name.
261      * @param appName Indicates the application bundle name to be queried.
262      * @param flags Indicates the flag used to specify information contained
263      *             in the ApplicationInfo object that will be returned.
264      * @param userId Indicates the user ID.
265      * @param appInfo Indicates the obtained ApplicationInfo object.
266      * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise.
267      */
268     ErrCode GetApplicationInfoWithResponseId(
269         const std::string &appName, int32_t flags, int32_t &userId, ApplicationInfo &appInfo) const;
270     /**
271      * @brief Obtains information about all installed applications of a specified user.
272      * @param flags Indicates the flag used to specify information contained
273      *             in the ApplicationInfo objects that will be returned.
274      * @param userId Indicates the user ID.
275      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
276      * @return Returns true if the application is successfully obtained; returns false otherwise.
277      */
278     bool GetApplicationInfos(
279         int32_t flags, const int userId, std::vector<ApplicationInfo> &appInfos) const;
280     /**
281      * @brief Obtains information about all installed applications of a specified user.
282      * @param flags Indicates the flag used to specify information contained
283      *             in the ApplicationInfo objects that will be returned.
284      * @param userId Indicates the user ID.
285      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
286      * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise.
287      */
288     ErrCode GetApplicationInfosV9(
289         int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) const;
290     /**
291      * @brief Obtains BundleInfo of all bundles available in the system.
292      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
293      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
294      * @param userId Indicates the user ID.
295      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
296      */
297     bool GetBundleInfos(int32_t flags,
298         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) const;
299     /**
300      * @brief Obtains BundleInfo of all bundles available in the system.
301      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
302      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
303      * @param userId Indicates the user ID.
304      * @return Returns ERR_OK if the BundleInfos is successfully obtained; returns error code otherwise.
305      */
306     ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) const;
307     /**
308      * @brief Obtains the BundleInfo based on a given bundle name.
309      * @param bundleName Indicates the application bundle name to be queried.
310      * @param flags Indicates the information contained in the BundleInfo object to be returned.
311      * @param bundleInfo Indicates the obtained BundleInfo object.
312      * @param userId Indicates the user ID.
313      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
314      */
315     bool GetBundleInfo(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo,
316         int32_t userId = Constants::UNSPECIFIED_USERID) const;
317     /**
318      * @brief Obtains the BundleInfo based on a given bundle name.
319      * @param bundleName Indicates the application bundle name to be queried.
320      * @param flags Indicates the information contained in the BundleInfo object to be returned.
321      * @param bundleInfo Indicates the obtained BundleInfo object.
322      * @param userId Indicates the user ID.
323      * @param appIndex Indicates the app index.
324      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
325      */
326     ErrCode GetBundleInfoV9(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo,
327         int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const;
328     /**
329      * @brief Batch obtains the BundleInfos based on a given bundle name list.
330      * @param bundleNames Indicates the application bundle name list to be queried.
331      * @param flags Indicates the information contained in the BundleInfo object to be returned.
332      * @param bundleInfos Indicates the obtained BundleInfo list object.
333      * @param userId Indicates the user ID.
334      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
335      */
336     void BatchGetBundleInfo(const std::vector<std::string> &bundleNames, int32_t flags,
337         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) const;
338     /**
339      * @brief Obtains the BundlePackInfo based on a given bundle name.
340      * @param bundleName Indicates the application bundle name to be queried.
341      * @param flags Indicates the information contained in the BundleInfo object to be returned.
342      * @param BundlePackInfo Indicates the obtained BundlePackInfo object.
343      * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise.
344      */
345     ErrCode GetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundleInfo,
346         int32_t userId = Constants::UNSPECIFIED_USERID) const;
347     /**
348      * @brief Obtains the BundleInfo of application bundles based on the specified metaData.
349      * @param metaData Indicates the metadata to get in the bundle.
350      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
351      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
352      */
353     bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) const;
354     /**
355      * @brief Obtains the bundle name of a specified application based on the given UID.
356      * @param uid Indicates the uid.
357      * @param bundleName Indicates the obtained bundle name.
358      * @return Returns true if the bundle name is successfully obtained; returns false otherwise.
359      */
360     bool GetBundleNameForUid(const int32_t uid, std::string &bundleName) const;
361     /**
362      * @brief Obtains all bundle names of a specified application based on the given application UID.
363      * @param uid Indicates the uid.
364      * @param bundleNames Indicates the obtained bundle names.
365      * @return Returns true if the bundle names is successfully obtained; returns false otherwise.
366      */
367     bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) const;
368     /**
369      * @brief Obtains the formal name associated with the given UID.
370      * @param uid Indicates the uid.
371      * @param name Indicates the obtained formal name.
372      * @return Returns ERR_OK if called successfully; returns error code otherwise.
373      */
374     ErrCode GetNameForUid(const int uid, std::string &name) const;
375     /**
376      * @brief Obtains an array of all group IDs associated with a specified bundle.
377      * @param bundleName Indicates the bundle name.
378      * @param gids Indicates the group IDs associated with the specified bundle.
379      * @return Returns true if the gids is successfully obtained; returns false otherwise.
380      */
381     bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) const;
382     /**
383      * @brief Obtains an array of all group IDs associated with the given bundle name and UID.
384      * @param bundleName Indicates the bundle name.
385      * @param uid Indicates the uid.
386      * @param gids Indicates the group IDs associated with the specified bundle.
387      * @return Returns true if the gids is successfully obtained; returns false otherwise.
388      */
389     virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) const;
390     /**
391      * @brief Obtains the BundleInfo of all keep-alive applications in the system.
392      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
393      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
394      */
395     bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) const;
396     /**
397      * @brief Obtains the label of a specified ability.
398      * @param bundleName Indicates the bundle name.
399      * @param moduleName Indicates the module name.
400      * @param abilityName Indicates the ability name.
401      * @param label Indicates the obtained label.
402      * @return Returns ERR_OK if the ability label is successfully obtained; returns errCode otherwise.
403      */
404     ErrCode GetAbilityLabel(const std::string &bundleName, const std::string &moduleName,
405         const std::string &abilityName, std::string &label) const;
406     /**
407      * @brief Obtains the Want for starting the main ability of an application based on the given bundle name.
408      * @param bundleName Indicates the bundle name.
409      * @param want Indicates the obtained launch Want object.
410      * @param userId Indicates the user ID.
411      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
412      */
413     ErrCode GetLaunchWantForBundle(
414         const std::string &bundleName, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) const;
415     /**
416      * @brief Obtain the HAP module info of a specific ability.
417      * @param abilityInfo Indicates the ability.
418      * @param userId Indicates the user ID.
419      * @param hapModuleInfo Indicates the obtained HapModuleInfo object.
420      * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
421      */
422     bool GetHapModuleInfo(const AbilityInfo &abilityInfo,
423         HapModuleInfo &hapModuleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) const;
424     /**
425      * @brief Check whether the app is system app by it's UID.
426      * @param uid Indicates the uid.
427      * @return Returns true if the bundle is a system application; returns false otherwise.
428      */
429     bool CheckIsSystemAppByUid(const int uid) const;
430     /**
431      * @brief Obtains all bundle names installed.
432      * @param bundleNames Indicates the bundle Names.
433      * @param userId Indicates the user ID.
434      * @return Returns true if have bundle installed; returns false otherwise.
435      */
436     bool GetBundleList(
437         std::vector<std::string> &bundleNames, int32_t userId = Constants::UNSPECIFIED_USERID) const;
438     /**
439      * @brief Obtains debug bundle names installed.
440      * @param bundleNames Indicates the debug bundle Names.
441      * @param userId Indicates the user ID.
442      * @return Returns true if have debug bundle installed; returns false otherwise.
443      */
444     bool GetDebugBundleList(
445         std::vector<std::string> &bundleNames, int32_t userId) const;
446     /**
447      * @brief Set the bundle status disable.
448      * @param bundleName Indicates the bundle name.
449      * @return Returns true if the bundle status successfully set; returns false otherwise.
450      */
451     bool DisableBundle(const std::string &bundleName);
452     /**
453      * @brief Set the bundle status enable.
454      * @param bundleName Indicates the bundle name.
455      * @return Returns true if the bundle status successfully set; returns false otherwise.
456      */
457     bool EnableBundle(const std::string &bundleName);
458     /**
459      * @brief Get whether the application status is enabled.
460      * @param bundleName Indicates the bundle name.
461      * @param isEnable Indicates the application status is enabled.
462      * @return Returns result of the operation.
463      */
464     ErrCode IsApplicationEnabled(const std::string &bundleName,
465         int32_t appIndex, bool &isEnable, int32_t userId = Constants::UNSPECIFIED_USERID) const;
466     /**
467      * @brief Set the application status.
468      * @param bundleName Indicates the bundle name.
469      * @param isEnable Indicates the status to set.
470      * @param userId Indicates the user id.
471      * @return Returns result of the operation.
472      */
473     ErrCode SetApplicationEnabled(const std::string &bundleName, int32_t appIndex, bool isEnable,
474         const std::string &caller, int32_t userId = Constants::UNSPECIFIED_USERID);
475     /**
476      * @brief Sets whether to enable a specified ability through the proxy object.
477      * @param abilityInfo Indicates information about the ability to check.
478      * @param isEnable Indicates the ability status is enabled.
479      * @return Returns result of the operation.
480      */
481     ErrCode IsAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool &isEnable) const;
482     /**
483      * @brief Sets whether to enable a specified ability through the proxy object.
484      * @param abilityInfo Indicates information about the ability.
485      * @param isEnabled Specifies whether to enable the ability.
486      *                 The value true means to enable it, and the value false means to disable it.
487      * @param userId Indicates the user id.
488      * @return Returns result of the operation.
489      */
490     ErrCode SetAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool isEnabled,
491         int32_t userId = Constants::UNSPECIFIED_USERID);
492     /**
493      * @brief Register the bundle status callback function.
494      * @param bundleStatusCallback Indicates the callback object that using for notifing the bundle status.
495      * @return Returns true if this function is successfully called; returns false otherwise.
496      */
497     bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback);
498 
499     bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback);
500 
501     bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback);
502     /**
503      * @brief Clear the specific bundle status callback.
504      * @param bundleStatusCallback Indicates the callback to be cleared.
505      * @return Returns true if this function is successfully called; returns false otherwise.
506      */
507     bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback);
508     /**
509      * @brief Unregister all the callbacks of status changed.
510      * @return Returns true if this function is successfully called; returns false otherwise.
511      */
512     bool UnregisterBundleStatusCallback();
513     /**
514      * @brief Get a mutex for locking by bundle name.
515      * @param bundleName Indicates the bundle name.
516      * @return Returns a reference of mutex that for locing by bundle name.
517      */
518     std::mutex &GetBundleMutex(const std::string &bundleName);
519     /**
520      * @brief Obtains the provision Id based on a given bundle name.
521      * @param bundleName Indicates the application bundle name to be queried.
522      * @param provisionId Indicates the provision Id to be returned.
523      * @return Returns true if the provision Id is successfully obtained; returns false otherwise.
524      */
525     bool GetProvisionId(const std::string &bundleName, std::string &provisionId) const;
526     /**
527      * @brief Obtains the app feature based on a given bundle name.
528      * @param bundleName Indicates the application bundle name to be queried.
529      * @param provisionId Indicates the app feature to be returned.
530      * @return Returns true if the app feature is successfully obtained; returns false otherwise.
531      */
532     bool GetAppFeature(const std::string &bundleName, std::string &appFeature) const;
533     /**
534      * @brief Set the flag that indicates whether initial user create successfully.
535      * @param flag Indicates the flag to be set.
536      * @return
537      */
538     void SetInitialUserFlag(bool flag);
539     /**
540      * @brief Get a shared pointer to the IBundleDataStorage object.
541      * @return Returns the pointer of IBundleDataStorage object.
542      */
543     std::shared_ptr<IBundleDataStorage> GetDataStorage() const;
544     /**
545      * @brief Obtains the FormInfo objects provided by all applications on the device.
546      * @param formInfos List of FormInfo objects if obtained;
547      * @return Returns true if this function is successfully called; returns false otherwise.
548      */
549     bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) const;
550     /**
551      * @brief Obtains the FormInfo objects provided by a specified application on the device.
552      * @param bundleName Indicates the bundle name of the  application.
553      * @param formInfos List of FormInfo objects if obtained;
554      * @return Returns true if this function is successfully called; returns false otherwise.
555      */
556     bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) const;
557     /**
558      * @brief Obtains the FormInfo objects provided by a specified module name.
559      * @param formInfos List of FormInfo objects if obtained;
560      * @param moduleName Indicates the module name of the application.
561      * @param bundleName Indicates the bundle name of the application.
562      * @return Returns true if this function is successfully called; returns false otherwise.
563      */
564     bool GetFormsInfoByModule(
565         const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) const;
566     /**
567      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
568      * @param bundleName Indicates the bundle name of the application.
569      * @param userId Indicates the user ID.
570      * @param shortcutInfos List of ShortcutInfo objects if obtained.
571      * @return Returns true if this function is successfully called; returns false otherwise.
572      */
573     bool GetShortcutInfos(
574         const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos) const;
575     /**
576      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
577      * @param bundleName Indicates the bundle name of the application.
578      * @param userId Indicates the user ID.
579      * @param shortcutInfos List of ShortcutInfo objects if obtained.
580      * @return Returns errcode of the result.
581      */
582     ErrCode GetShortcutInfoV9(
583         const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos) const;
584     /**
585      * @brief Obtains the CommonEventInfo objects provided by an event key on the device.
586      * @param eventKey Indicates the event of the subscribe.
587      * @param commonEventInfos List of CommonEventInfo objects if obtained.
588      * @return Returns true if this function is successfully called; returns false otherwise.
589      */
590     bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) const;
591     /**
592      * @brief Obtains the PreInstallBundleInfo objects provided by bundleName.
593      * @param bundleName Indicates the bundle name of the application.
594      * @param preInstallBundleInfo Indicates information about the PreInstallBundleInfo.
595      * @return Returns true if this function is successfully called; returns false otherwise.
596      */
597     bool GetPreInstallBundleInfo(const std::string &bundleName, PreInstallBundleInfo &preInstallBundleInfo);
598     /**
599      * @brief Save new PreInstallBundleInfo.
600      * @param bundleName Indicates the bundle name.
601      * @param preInstallBundleInfo Indicates the PreInstallBundleInfo object to be save.
602      * @return Returns true if this function is successfully called; returns false otherwise.
603      */
604     bool SavePreInstallBundleInfo(const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo);
605     /**
606      * @brief Obtains the PreInstallBundleInfo objects provided by bundleName.
607      * @param preInstallBundleInfo Indicates information about the PreInstallBundleInfo.
608      * @return Returns true if this function is successfully called; returns false otherwise.
609      */
610     bool LoadAllPreInstallBundleInfos(std::vector<PreInstallBundleInfo> &preInstallBundleInfos);
611     /**
612      * @brief Save new PreInstallBundleInfo.
613      * @param bundleName Indicates the bundle name.
614      * @param preInstallBundleInfo Indicates the PreInstallBundleInfo object to be save.
615      * @return Returns true if this function is successfully called; returns false otherwise.
616      */
617     bool DeletePreInstallBundleInfo(
618         const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo);
619     /**
620      * @brief Save installation mark to datebase storage.
621      * @param info Indicates the innerBundleInfo of the bundle which needs to save installation mark.
622      * @return Returns true if this function is successfully called; returns false otherwise.
623      */
624     bool SaveInnerBundleInfo(const InnerBundleInfo &info) const;
625     /**
626      * @brief GetInnerBundleUserInfoByUserId.
627      * @param bundleName Indicates the application bundle name to be queried.
628      * @param userId Indicates the user ID.
629      * @param innerBundleUserInfo Indicates the obtained InnerBundleUserInfo object.
630      * @return Returns true if the application is successfully obtained; returns false otherwise.
631      */
632     bool GetInnerBundleUserInfoByUserId(
633         const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo) const;
634     /**
635      * @brief save all created users.
636      * @param userId Indicates the user ID.
637      */
638     void AddUserId(int32_t userId);
639     /**
640      * @brief remove userId.
641      * @param userId Indicates the user ID.
642      */
643     void RemoveUserId(int32_t userId);
644     /**
645      * @brief query users.
646      * @param userId Indicates the user ID.
647      * @return Returns true when query user success; returns false otherwise.
648      */
649     bool HasUserId(int32_t userId) const;
650     /**
651      * @brief Get userId by calling uid.
652      * @return Returns userId.
653      */
654     int32_t GetUserIdByCallingUid() const;
655     /**
656      * @brief Get all user.
657      * @return Returns all userId.
658      */
659     std::set<int32_t> GetAllUser() const;
660     /**
661      * @brief Has initial user created.
662      * @return Returns initial user flag.
663      */
HasInitialUserCreated()664     bool HasInitialUserCreated() const
665     {
666         return initialUserFlag_;
667     }
668     /**
669      * @brief Set bundlePromise.
670      * @param bundlePromise Indicates the bundlePromise.
671      */
SetBundlePromise(const std::shared_ptr<BundlePromise> & bundlePromise)672     void SetBundlePromise(const std::shared_ptr<BundlePromise>& bundlePromise)
673     {
674         bundlePromise_ = bundlePromise;
675     }
676     /**
677      * @brief Get bundleUserInfos by bundleName.
678      * @param bundleName Indicates the application bundle name to be queried.
679      * @param innerBundleUserInfo Indicates the obtained InnerBundleUserInfo object.
680      * @return Returns true if the application is successfully obtained; returns false otherwise.
681      */
682     bool GetInnerBundleUserInfos(
683         const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos) const;
684     /**
685      * @brief Get app privilege level.
686      * @param bundleName Indicates the bundle name of the app privilege level.
687      * @param userId Indicates the user id.
688      * @return Returns app privilege level.
689      */
690     std::string GetAppPrivilegeLevel(
691         const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID);
692     /**
693      * @brief Query a ExtensionAbilityInfo of list by the given Want.
694      * @param want Indicates the information of the ability.
695      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
696      * @param userId Indicates the user ID.
697      * @param extensionInfos Indicates the obtained ExtensionAbilityInfo of list.
698      * @return Returns true if the ExtensionAbilityInfo is successfully obtained; returns false otherwise.
699      */
700     bool QueryExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId,
701         std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const;
702     /**
703      * @brief Query a ExtensionAbilityInfo of list by the given Want.
704      * @param want Indicates the information of the ability.
705      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
706      * @param userId Indicates the user ID.
707      * @param extensionInfos Indicates the obtained ExtensionAbilityInfo of list.
708      * @return Returns ERR_OK if the ExtensionAbilityInfo is successfully obtained; returns errCode otherwise.
709      */
710     ErrCode QueryExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
711         std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const;
712 
713     /**
714      * @brief Query a ExtensionAbilityInfo without want.
715      * @param want Indicates the information of the ability.
716      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
717      * @param userId Indicates the user ID.
718      * @param extensionInfos Indicates the obtained ExtensionAbilityInfo of list.
719      * @return Returns ERR_OK if the ExtensionAbilityInfo is successfully obtained; returns errCode otherwise.
720      */
721     ErrCode QueryExtensionAbilityInfos(uint32_t flags, int32_t userId,
722         std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const;
723 
724     ErrCode QueryExtensionAbilityInfosByExtensionTypeName(const std::string &typeName, uint32_t flags,
725         int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const;
726     /**
727      * @brief Obtains the PreInstallBundleInfo objects in Cache.
728      * @return Returns PreInstallBundleInfos.
729      */
730     const std::vector<PreInstallBundleInfo> GetAllPreInstallBundleInfos();
731     /**
732      * @brief Restore uid and gid .
733      * @return Returns true if this function is successfully called; returns false otherwise.
734      */
735     bool RestoreUidAndGid();
736     /**
737      * @brief Load all bundle state data from jsonDb .
738      * @return
739      */
740     void LoadAllBundleStateDataFromJsonDb();
741 
742     bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId,
743         std::vector<ExtensionAbilityInfo> &extensionInfos) const;
744 
745     bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId,
746         ExtensionAbilityInfo &extensionAbilityInfo) const;
747 
748     bool AddInnerBundleUserInfo(const std::string &bundleName, const InnerBundleUserInfo& newUserInfo);
749 
750     bool RemoveInnerBundleUserInfo(const std::string &bundleName, int32_t userId);
751 
752     bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId,
753         AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) const;
754 
755     bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault,
756         std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos,
757         bool &findDefaultApp);
758     bool UpateExtResources(const std::string &bundleName,
759         const std::vector<ExtendResourceInfo> &extendResourceInfos);
760     bool RemoveExtResources(const std::string &bundleName,
761         const std::vector<std::string> &moduleNames);
762     bool UpateCurDynamicIconModule(
763         const std::string &bundleName, const std::string &moduleName);
764     void CreateAppInstallDir(int32_t userId);
765     void RemoveAppInstallDir(int32_t userId);
766     bool IsObtainAbilityInfo(const Want &want, int32_t userId, AbilityInfo &abilityInfo);
767 
768     /**
769      * @brief Sets whether to enable isRemovable based on given bundle name, module name and isEnable.
770      * @param bundleName Indicates the bundleName.
771      * @param moduleName Indicates the moduleName.
772      * @param isEnable Set module isRemovable is enable.
773      * @return Returns true if the module isRemovable is set success; returns false otherwise.
774      */
775     bool SetModuleRemovable(const std::string &bundleName, const std::string &moduleName, bool isEnable);
776     /**
777      * @brief Get Module isRemovable by bundleName and moduleName.
778      * @param bundleName Indicates the application bundle name to be queried.
779      * @param moduleName Indicates the moduleName.
780      * @param isRemovable Indicates the module whether is removable.
781      * @return Returns ERR_OK if the module isRemovable is successfully obtained; returns other ErrCode otherwise.
782      */
783     ErrCode IsModuleRemovable(const std::string &bundleName, const std::string &moduleName, bool &isRemovable) const;
784 
785 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
786     int64_t GetBundleSpaceSize(const std::string &bundleName) const;
787     int64_t GetBundleSpaceSize(const std::string &bundleName, int32_t userId) const;
788     int64_t GetAllFreeInstallBundleSpaceSize() const;
789     bool GetFreeInstallModules(
790         std::map<std::string, std::vector<std::string>> &freeInstallModules) const;
791 #endif
792 
793 #ifdef ABILITY_RUNTIME_ENABLE
794     std::vector<int32_t> GetNoRunningBundleCloneIndexes(const sptr<IAppMgr> appMgrProxy, const std::string &bundleName,
795         const std::vector<int32_t> &cloneAppIndexes) const;
796 #endif
797     void GetBundleCacheInfos(
798         const int32_t userId, std::vector<std::tuple<std::string, std::vector<std::string>,
799         std::vector<int32_t>>> &validBundles, bool isClean = false) const;
800     void GetBundleCacheInfo(
801         std::function<std::vector<int32_t>(std::string&, std::vector<int32_t>&)> idxFilter,
802         const InnerBundleInfo &info,
803         std::vector<std::tuple<std::string, std::vector<std::string>, std::vector<int32_t>>> &validBundles,
804         const int32_t userId, bool isClean) const;
805     bool GetBundleStats(const std::string &bundleName,
806         const int32_t userId, std::vector<int64_t> &bundleStats,
807         const int32_t appIndex = 0, const uint32_t statFlag = 0) const;
808     void GetBundleModuleNames(const std::string &bundleName, std::vector<std::string> &moduleNameList) const;
809     bool GetAllBundleStats(const int32_t userId, std::vector<int64_t> &bundleStats) const;
810     bool HasUserInstallInBundle(const std::string &bundleName, const int32_t userId) const;
811     bool GetAllDependentModuleNames(const std::string &bundleName, const std::string &moduleName,
812         std::vector<std::string> &dependentModuleNames);
813     ErrCode SetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName, int32_t upgradeFlag);
814     int32_t GetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName) const;
815     /**
816      * @brief Get the Inner Bundle Info With Flags object
817      * @param bundleName Indicates the application bundle name to be queried.
818      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
819      * @param info Indicates the innerBundleInfo of the bundle.
820      * @param userId Indicates the user ID.
821      * @return Returns true if get inner bundle info is successfully obtained; returns false otherwise.
822      */
823     bool GetInnerBundleInfoWithFlags(const std::string &bundleName, const int32_t flags,
824         InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const;
825     bool GetInnerBundleInfoWithFlags(const std::string &bundleName, const int32_t flags,
826         int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const;
827     bool GetInnerBundleInfoWithBundleFlagsAndLock(const std::string &bundleName, int32_t flags,
828         InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID) const;
829     ErrCode GetInnerBundleInfoWithFlagsV9(const std::string &bundleName, int32_t flags,
830         InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const;
831     ErrCode GetInnerBundleInfoWithBundleFlagsV9(const std::string &bundleName, int32_t flags,
832         InnerBundleInfo &info, int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) const;
833     std::shared_ptr<BundleSandboxAppHelper> GetSandboxAppHelper() const;
834     ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo);
835 
836 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
837     bool QueryInfoAndSkillsByElement(int32_t userId, const Element& element,
838         AbilityInfo& abilityInfo, ExtensionAbilityInfo& extensionInfo, std::vector<Skill>& skills) const;
839 
840     bool GetElement(int32_t userId, const ElementName& elementName, Element& element) const;
841 #endif
842 
843     int32_t GetUserId(int32_t userId = Constants::UNSPECIFIED_USERID) const;
844 
845     ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName, const std::string &abilityName,
846         std::unique_ptr<uint8_t[]> &mediaDataPtr, size_t &len, int32_t userId) const;
847 
848     std::shared_mutex &GetStatusCallbackMutex();
849 
850     std::vector<sptr<IBundleStatusCallback>> GetCallBackList() const;
851 
852     std::string GetStringById(const std::string &bundleName, const std::string &moduleName,
853         uint32_t resId, int32_t userId, const std::string &localeInfo);
854 
855     std::string GetIconById(
856         const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId);
857     void UpdateRemovable(const std::string &bundleName, bool removable);
858     void UpdatePrivilegeCapability(
859         const std::string &bundleName, const ApplicationInfo &appInfo);
860     bool FetchInnerBundleInfo(
861         const std::string &bundleName, InnerBundleInfo &innerBundleInfo);
862     bool GetInnerBundleInfoUsers(const std::string &bundleName, std::set<int32_t> &userIds);
863     bool IsSystemHsp(const std::string &bundleName);
864 
865     bool UpdateUninstallBundleInfo(const std::string &bundleName, const UninstallBundleInfo &uninstallBundleInfo);
866     bool GetUninstallBundleInfo(const std::string &bundleName, UninstallBundleInfo &uninstallBundleInfo);
867     bool DeleteUninstallBundleInfo(const std::string &bundleName, int32_t userId);
868     bool GetAllUninstallBundleInfo(std::map<std::string, UninstallBundleInfo> &uninstallBundleInfos);
869 
870     bool AddFirstInstallBundleInfo(const std::string &bundleName, const int32_t userId,
871         const FirstInstallBundleInfo &firstInstallBundleInfo);
872     bool GetFirstInstallBundleInfo(const std::string &bundleName, const int32_t userId,
873         FirstInstallBundleInfo &firstInstallBundleInfo);
874     bool DeleteFirstInstallBundleInfo(int32_t userId);
875 
876     bool UpdateQuickFixInnerBundleInfo(const std::string &bundleName, const InnerBundleInfo &innerBundleInfo);
877 
878     void NotifyBundleEventCallback(const EventFwk::CommonEventData &eventData) const;
879 
GetAllInnerBundleInfos()880     const std::map<std::string, InnerBundleInfo> GetAllInnerBundleInfos() const
881     {
882         std::shared_lock<std::shared_mutex> lock(bundleInfoMutex_);
883         return bundleInfos_;
884     }
885 
886     bool QueryOverlayInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info);
887 
888     void SaveOverlayInfo(const std::string &bundleName, InnerBundleInfo &innerBundleInfo);
889 
890     ErrCode GetAppProvisionInfo(const std::string &bundleName, int32_t userId,
891         AppProvisionInfo &appProvisionInfo);
892 
893     virtual ErrCode GetProvisionMetadata(const std::string &bundleName, int32_t userId,
894         std::vector<Metadata> &provisionMetadatas) const;
895 
896     ErrCode GetBaseSharedBundleInfos(const std::string &bundleName,
897         std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos,
898         GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO) const;
899 
900     bool GetBaseSharedBundleInfo(const Dependency &dependency, BaseSharedBundleInfo &baseSharedBundleInfo) const;
901 
902     ErrCode GetAllSharedBundleInfo(std::vector<SharedBundleInfo> &sharedBundles) const;
903 
904     ErrCode GetSharedBundleInfo(const std::string &bundleName, const std::string &moduleName,
905         std::vector<SharedBundleInfo> &sharedBundles);
906 
907     bool DeleteSharedBundleInfo(const std::string &bundleName);
908 
909     ErrCode GetSharedBundleInfoBySelf(const std::string &bundleName, SharedBundleInfo &sharedBundleInfo);
910 
911     ErrCode GetSharedDependencies(const std::string &bundleName, const std::string &moduleName,
912         std::vector<Dependency> &dependencies);
913 
914     bool CheckHspVersionIsRelied(int32_t versionCode, const InnerBundleInfo &info) const;
915     bool CheckHspBundleIsRelied(const std::string &hspBundleName) const;
916     bool IsPreInstallApp(const std::string &bundleName);
917     bool GetBundleType(const std::string &bundleName, BundleType &bundleType)const;
918 
919     ErrCode GetSharedBundleInfo(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo);
920     ErrCode GetSpecifiedDistributionType(const std::string &bundleName, std::string &specifiedDistributionType);
921     ErrCode GetAdditionalInfo(const std::string &bundleName, std::string &additionalInfo);
922     ErrCode GetAdditionalInfoForAllUser(const std::string &bundleName, std::string &additionalInfo);
923 
924     ErrCode GetProxyDataInfos(const std::string &bundleName, const std::string &moduleName, int32_t userId,
925         std::vector<ProxyData> &proxyDatas) const;
926 
927     ErrCode GetAllProxyDataInfos(int32_t userId, std::vector<ProxyData> &proxyDatas) const;
928 
929     std::string GetBundleNameByAppId(const std::string &appId) const;
930 
931     void SetAOTCompileStatus(const std::string &bundleName, const std::string &moduleName,
932         AOTCompileStatus aotCompileStatus, uint32_t versionCode);
933     void ResetAOTFlags();
934     void ResetAOTFlagsCommand(const std::string &bundleName);
935     ErrCode ResetAOTCompileStatus(const std::string &bundleName, const std::string &moduleName,
936         int32_t triggerMode);
937     std::vector<std::string> GetAllBundleName() const;
938     /**
939      * @brief Get lite bundleInfo of all bundles under the specified user
940      * @param userId Indicates the user ID
941      * @return Returns lite bundleInfo list, tuple format : {bundleName, uid, gid}
942      */
943     std::vector<std::tuple<std::string, int32_t, int32_t>> GetAllLiteBundleInfo(const int32_t userId) const;
944     std::vector<std::string> GetBundleNamesForNewUser() const;
945     bool IsBundleExist(const std::string &bundleName) const;
946     bool QueryInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info) const;
947     std::vector<int32_t> GetUserIds(const std::string &bundleName) const;
948     ErrCode SetExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName,
949         const std::string &abilityName, const std::string &extName, const std::string &mimeType);
950     ErrCode DelExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName,
951         const std::string &abilityName, const std::string &extName, const std::string &mimeType);
952     bool QueryAppGalleryAbilityName(std::string &bundleName, std::string &abilityName);
953     void ScanAllBundleGroupInfo();
954     void HandleGroupIdAndIndex(const std::set<std::string> errorGroupIds,
955         std::map<int32_t, std::string> &indexMap, std::map<std::string, int32_t> &groupIdMap);
956     bool HandleErrorDataGroupInfos(
957         const std::map<std::string, int32_t> &groupIdMap,
958         const std::map<std::string, std::set<std::string>> &needProcessGroupInfoBundleNames);
959     bool QueryDataGroupInfos(const std::string &bundleName, int32_t userId, std::vector<DataGroupInfo> &infos) const;
960     bool GetGroupDir(const std::string &dataGroupId, std::string &dir,
961         int32_t userId = Constants::UNSPECIFIED_USERID) const;
962     void GenerateDataGroupUuidAndUid(DataGroupInfo &dataGroupInfo, int32_t userId,
963         std::unordered_set<int32_t> &uniqueIdSet) const;
964     void GenerateDataGroupInfos(const std::string &bundleName,
965         const std::unordered_set<std::string> &dataGroupIdList, int32_t userId,
966         bool needSaveStorage = false);
967     bool CreateAppGroupDir(const std::string &bundleName, int32_t userId);
968     void CreateAppEl5GroupDir(const std::string &bundleName, int32_t userId);
969     void GetDataGroupIndexMap(std::map<std::string, std::pair<int32_t, std::string>> &dataGroupIndexMap,
970         std::unordered_set<int32_t> &uniqueIdSet) const;
971     bool IsShareDataGroupIdNoLock(const std::string &dataGroupId, int32_t userId) const;
972     void GenerateNewUserDataGroupInfos(const std::string &bundleName, int32_t userId);
973     void DeleteUserDataGroupInfos(const std::string &bundleName, int32_t userId, bool keepData);
974     bool IsDataGroupIdExistNoLock(const std::string &dataGroupId, int32_t userId) const;
975     void ProcessAllUserDataGroupInfosWhenBundleUpdate(InnerBundleInfo &innerBundleInfo);
976     void DeleteGroupDirsForException(const InnerBundleInfo &oldInfo, int32_t userId) const;
977     ErrCode GetJsonProfile(ProfileType profileType, const std::string &bundleName, const std::string &moduleName,
978         std::string &profile, int32_t userId) const;
979     ErrCode GetJsonProfileByExtractor(const std::string &hapPath, const std::string &profilePath,
980         std::string &profile) const;
981     bool GetOldAppIds(const std::string &bundleName, std::vector<std::string> &appIds) const;
982     ErrCode GetInnerBundleInfoByUid(const int32_t uid, InnerBundleInfo &innerBundleInfo) const;
983     ErrCode GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerBundleInfo &innerBundleInfo,
984         int32_t &appIndex) const;
985     std::string GetModuleNameByBundleAndAbility(const std::string& bundleName, const std::string& abilityName);
986     const std::vector<PreInstallBundleInfo> GetRecoverablePreInstallBundleInfos();
987     ErrCode SetAdditionalInfo(const std::string& bundleName, const std::string& additionalInfo) const;
988     ErrCode GetAppServiceHspBundleInfo(const std::string &bundleName, BundleInfo &bundleInfo);
989     ErrCode CreateBundleDataDir(int32_t userId);
990     ErrCode CreateBundleDataDirWithEl(int32_t userId, DataDirEl dirEl);
991     void GenerateOdid(const std::string &developerId, std::string &odid) const;
992     ErrCode GetOdid(std::string &odid) const;
993     ErrCode GetOdidByBundleName(const std::string &bundleName, std::string &odid) const;
994     void UpdateRouterInfo(const std::string &bundleName);
995     void UpdateRouterInfo(InnerBundleInfo &innerBundleInfo);
996     void FindRouterHapPath(const InnerBundleInfo &innerBundleInfo,
997         std::map<std::string, std::pair<std::string, std::string>> &hapPathMap);
998     void UpdateRouterInfo(const std::string &bundleName,
999         std::map<std::string, std::pair<std::string, std::string>> &hapPathMap);
1000 
1001     bool DeleteRouterInfo(const std::string &bundleName);
1002     bool DeleteRouterInfo(const std::string &bundleName, const std::string &moduleName);
1003     void GetAllBundleNames(std::set<std::string> &bundleNames);
1004 
1005     void UpdateIsPreInstallApp(const std::string &bundleName, bool isPreInstallApp);
1006 
1007     /**
1008      * @brief Check whether the link can be opened.
1009      * @param link Indicates the link to be opened.
1010      * @param canOpen Indicates whether the link can be opened.
1011      * @return  Returns result of the operation.
1012      */
1013     ErrCode CanOpenLink(
1014         const std::string &link, bool &canOpen) const;
1015     ErrCode GetAllBundleInfoByDeveloperId(const std::string &developerId,
1016         std::vector<BundleInfo> &bundleInfos, int32_t userId);
1017     ErrCode GetDeveloperIds(const std::string &appDistributionType,
1018         std::vector<std::string> &developerIdList, int32_t userId);
1019     ErrCode SwitchUninstallState(const std::string &bundleName, const bool &state,
1020         const bool isNeedSendNotify, bool &stateChange);
1021 
1022     ErrCode AddCloneBundle(const std::string &bundleName, const InnerBundleCloneInfo &attr);
1023     ErrCode RemoveCloneBundle(const std::string &bundleName, const int32_t userId, int32_t appIndex);
1024     ErrCode QueryAbilityInfoByContinueType(const std::string &bundleName, const std::string &continueType,
1025         AbilityInfo &abilityInfo, int32_t userId, int32_t appIndex = 0) const;
1026     ErrCode GetBundleNameAndIndex(const int32_t uid, std::string &bundleName, int32_t &appIndex) const;
1027     ErrCode GetBundleNameAndIndexForUid(const int32_t uid, std::string &bundleName, int32_t &appIndex) const;
1028 
1029     ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t userId,
1030         int32_t appIndex, AbilityInfo &abilityInfo) const;
1031     ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appIndex,
1032         BundleInfo &bundleInfo, int32_t userId) const;
1033     std::vector<int32_t> GetCloneAppIndexes(const std::string &bundleName, int32_t userId) const;
1034 
1035     ErrCode ExplicitQueryExtensionInfoV9(const Want &want, int32_t flags, int32_t userId,
1036         ExtensionAbilityInfo &extensionInfo, int32_t appIndex = 0) const;
1037 
1038     void QueryAllCloneExtensionInfos(const Want &want, int32_t flags, int32_t userId,
1039         std::vector<ExtensionAbilityInfo> &infos) const;
1040     void QueryAllCloneExtensionInfosV9(const Want &want, int32_t flags, int32_t userId,
1041         std::vector<ExtensionAbilityInfo> &infos) const;
1042 
1043     ErrCode GetAppIdByBundleName(const std::string &bundleName, std::string &appId) const;
1044 
1045     ErrCode GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) const;
1046 
1047     ErrCode GetSignatureInfoByUid(const int32_t uid, SignatureInfo &signatureInfo) const;
1048 
1049     ErrCode GetInnerBundleInfoWithSandboxByUid(const int uid, InnerBundleInfo &innerBundleInfo) const;
1050 
1051     ErrCode UpdateAppEncryptedStatus(const std::string &bundleName, bool isExisted,
1052         int32_t appIndex = 0, bool needSaveStorage = true);
1053 
1054     ErrCode AddDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId);
1055     ErrCode DeleteDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId);
1056     ErrCode GetAllDesktopShortcutInfo(int32_t userId, std::vector<ShortcutInfo> &shortcutInfos);
1057     ErrCode DeleteDesktopShortcutInfo(const std::string &bundleName);
1058     ErrCode DeleteDesktopShortcutInfo(const std::string &bundleName, int32_t userId, int32_t appIndex);
1059 
1060     void GetBundleInfosForContinuation(std::vector<BundleInfo> &bundleInfos) const;
1061 
1062     /**
1063      * @brief Get a list of application package names that continue the specified package name.
1064      * @param continueBundleName The package name that is being continued.
1065      * @param bundleNames Continue the list of specified package names.
1066      * @param userId Indicates the user ID.
1067      * @return Returns ERR_OK if successfully obtained; returns error code otherwise.
1068      */
1069     ErrCode GetContinueBundleNames(
1070         const std::string &continueBundleName, std::vector<std::string> &bundleNames, int32_t userId);
1071     void HandleOTACodeEncryption();
1072 
1073     ErrCode IsBundleInstalled(const std::string &bundleName, int32_t userId, int32_t appIndex, bool &isInstalled);
1074     void CreateEl5Dir(const std::vector<CreateDirParam> &el5Params, bool needSaveStorage = false);
1075     void CreateEl5DirNoCache(const std::vector<CreateDirParam> &el5Params, InnerBundleInfo &info);
1076     int32_t GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t appIndex) const;
1077     ErrCode GetBundleNameByAppId(const std::string &appId, std::string &bundleName);
1078     ErrCode GetDirForAtomicService(const std::string &bundleName, std::string &dataDir) const;
1079     ErrCode GetDirForAtomicServiceByUserId(const std::string &bundleName, int32_t userId,
1080         AccountSA::OhosAccountInfo &accountInfo, std::string &dataDir) const;
1081     std::string GetDirForApp(const std::string &bundleName, const int32_t appIndex) const;
1082     ErrCode GetDirByBundleNameAndAppIndex(const std::string &bundleName, const int32_t appIndex,
1083         std::string &dataDir) const;
1084     std::vector<int32_t> GetCloneAppIndexesByInnerBundleInfo(const InnerBundleInfo &innerBundleInfo,
1085         int32_t userId) const;
1086     ErrCode GetBundleDir(int32_t userId, BundleType type, AccountSA::OhosAccountInfo &accountInfo,
1087         BundleDir &bundleDir) const;
1088     ErrCode GetAllBundleDirs(int32_t userId, std::vector<BundleDir> &bundleDirs) const;
1089     ErrCode GetAssetAccessGroups(const std::string &bundleName, std::vector<std::string> &assetAccessGroups) const;
1090     ErrCode GetDeveloperId(const std::string &bundleName, std::string &developerId) const;
1091     ErrCode AddPluginInfo(const InnerBundleInfo &innerBundleInfo, const PluginBundleInfo &pluginBundleInfo,
1092         const int32_t userId);
1093     ErrCode RemovePluginInfo(const InnerBundleInfo &innerBundleInfo, const std::string &pluginBundleName,
1094         const int32_t userId);
1095     bool GetPluginBundleInfo(const std::string &hostBundleName, const std::string &pluginBundleName,
1096         PluginBundleInfo &pluginBundleInfo, const int32_t userId = Constants::ALL_USERID);
1097 
1098 private:
1099     /**
1100      * @brief Init transferStates.
1101      * @return
1102      */
1103     void InitStateTransferMap();
1104     /**
1105      * @brief Determine whether to delete the data status.
1106      * @param state Indicates the InstallState object.
1107      * @return Returns true if state is INSTALL_FAIL,UNINSTALL_FAIL,UNINSTALL_SUCCESS,or UPDATING_FAIL; returns false
1108      * otherwise.
1109      */
1110     bool IsDeleteDataState(const InstallState state) const;
1111     /**
1112      * @brief Determine whether it is disable.
1113      * @param state Indicates the InstallState object.
1114      * @return Returns true if install state is UPDATING_START or UNINSTALL_START; returns false otherwise.
1115      */
1116     bool IsDisableState(const InstallState state) const;
1117     /**
1118      * @brief Delete bundle info if InstallState is not INSTALL_FAIL.
1119      * @param bundleName Indicates the bundle Names.
1120      * @param state Indicates the InstallState object.
1121      * @return Returns true if install state is UPDATING_START or UNINSTALL_START; returns false otherwise.
1122      */
1123     void DeleteBundleInfo(const std::string &bundleName, const InstallState state, const bool isKeepData = false);
1124     /**
1125      * @brief Implicit query abilityInfos by the given Want.
1126      * @param want Indicates the information of the ability.
1127      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
1128      * @param userId Indicates the user ID.
1129      * @param abilityInfos Indicates the obtained AbilityInfo of list.
1130      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
1131      */
1132     bool ImplicitQueryAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1133         std::vector<AbilityInfo> &abilityInfos, int32_t appIndex = 0) const;
1134     ErrCode ImplicitQueryAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1135         std::vector<AbilityInfo> &abilityInfos, int32_t appIndex = 0) const;
1136     bool CheckAbilityInfoFlagExist(int32_t flags, AbilityInfoFlag abilityInfoFlag) const;
1137     void GetMatchAbilityInfos(const Want &want, int32_t flags, const InnerBundleInfo &info,
1138         int32_t userId, std::vector<AbilityInfo> &abilityInfos,
1139         const std::vector<std::string> &paramMimeTypes, int32_t appIndex = 0) const;
1140     void AddSkillUrisInfo(const std::vector<Skill> &skills, std::vector<SkillUriForAbilityAndExtension> &skillUris,
1141         std::optional<size_t> matchSkillIndex, std::optional<size_t> matchUriIndex) const;
1142     void GetMatchAbilityInfosV9(const Want &want, int32_t flags, const InnerBundleInfo &info,
1143         int32_t userId, std::vector<AbilityInfo> &abilityInfos,
1144         const std::vector<std::string> &paramMimeTypes, int32_t appIndex = 0) const;
1145     bool ExplicitQueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo,
1146         int32_t appIndex = 0) const;
1147     ErrCode ExplicitQueryAbilityInfoV9(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo,
1148         int32_t appIndex = 0) const;
1149     bool GenerateBundleId(const std::string &bundleName, int32_t &bundleId);
1150     int32_t GetUserIdByUid(int32_t uid) const;
1151     bool GetAllBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos) const;
1152     ErrCode GetAllBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos) const;
1153     bool ExplicitQueryExtensionInfo(const Want &want, int32_t flags, int32_t userId,
1154         ExtensionAbilityInfo &extensionInfo, int32_t appIndex = 0) const;
1155     bool ImplicitQueryExtensionInfos(const Want &want, int32_t flags, int32_t userId,
1156         std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const;
1157     ErrCode ImplicitQueryExtensionInfosV9(const Want &want, int32_t flags, int32_t userId,
1158         std::vector<ExtensionAbilityInfo> &extensionInfos, int32_t appIndex = 0) const;
1159     void GetMatchExtensionInfos(const Want &want, int32_t flags, const int32_t &userId, const InnerBundleInfo &info,
1160         std::vector<ExtensionAbilityInfo> &einfos, int32_t appIndex = 0) const;
1161     void GetMatchExtensionInfosV9(const Want &want, int32_t flags, int32_t userId, const InnerBundleInfo &info,
1162         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const;
1163     void GetAllExtensionInfos(uint32_t flags, int32_t userId, const InnerBundleInfo &info,
1164         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const;
1165     void GetOneExtensionInfosByExtensionTypeName(const std::string &typeName, uint32_t flags, int32_t userId,
1166         const InnerBundleInfo &info, std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex = 0) const;
1167     bool MatchUtd(Skill &skill, const std::string &utd, int32_t count) const;
1168     bool MatchUtd(const std::string &skillUtd, const std::string &wantUtd) const;
1169     bool MatchTypeWithUtd(const std::string &mimeType, const std::string &wantUtd) const;
1170     std::vector<int32_t> GetCloneAppIndexesNoLock(const std::string &bundleName, int32_t userId) const;
1171     void GetCloneAppInfo(const InnerBundleInfo &info, int32_t userId, int32_t flags,
1172         std::vector<ApplicationInfo> &appInfos) const;
1173     void GetCloneAppInfoV9(const InnerBundleInfo &info, int32_t userId, int32_t flags,
1174         std::vector<ApplicationInfo> &appInfos) const;
1175 #ifdef GLOBAL_RESMGR_ENABLE
1176     std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(const std::string &bundleName,
1177         const std::string &moduleName, int32_t userId, const std::string &localeInfo = Constants::EMPTY_STRING) const;
1178     std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(const std::string &hapPath) const;
1179 #endif
1180 
1181     void FilterAbilityInfosByModuleName(const std::string &moduleName, std::vector<AbilityInfo> &abilityInfos) const;
1182     void InnerCreateEl5Dir(const CreateDirParam &el5Param);
1183     void SetEl5DirPolicy(const CreateDirParam &el5Param, bool needSaveStorage);
1184     void SetEl5DirPolicy(const CreateDirParam &el5Param, InnerBundleInfo &info);
1185 
1186     void FilterExtensionAbilityInfosByModuleName(const std::string &moduleName,
1187         std::vector<ExtensionAbilityInfo> &extensionInfos) const;
1188     void CompatibleOldBundleStateInKvDb();
1189     void ResetBundleStateData();
1190     bool QueryAbilityInfoWithFlags(const std::optional<AbilityInfo> &option, int32_t flags, int32_t userId,
1191         const InnerBundleInfo &innerBundleInfo, AbilityInfo &info, int32_t appIndex = 0) const;
1192     ErrCode QueryAbilityInfoWithFlagsV9(const std::optional<AbilityInfo> &option, int32_t flags, int32_t userId,
1193         const InnerBundleInfo &innerBundleInfo, AbilityInfo &info,
1194         int32_t appIndex = 0) const;
1195     bool ImplicitQueryCurAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1196         std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const;
1197     ErrCode ImplicitQueryCurAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1198         std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const;
1199     void ImplicitQueryAllAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1200         std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const;
1201     void ImplicitQueryAllAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1202         std::vector<AbilityInfo> &abilityInfos, int32_t appIndex) const;
1203     bool ImplicitQueryCurExtensionInfos(const Want &want, int32_t flags, int32_t userId,
1204         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const;
1205     ErrCode ImplicitQueryCurExtensionInfosV9(const Want &want, int32_t flags, int32_t userId,
1206         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const;
1207     void ImplicitQueryAllExtensionInfos(const Want &want, int32_t flags, int32_t userId,
1208         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const;
1209     void ImplicitQueryAllExtensionInfosV9(const Want &want, int32_t flags, int32_t userId,
1210         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex) const;
1211     ErrCode ImplicitQueryAllExtensionInfos(uint32_t flags, int32_t userId,
1212         std::vector<ExtensionAbilityInfo> &infos, int32_t appIndex, const std::string &typeName = "") const;
1213     void GetMatchLauncherAbilityInfosForCloneInfos(const InnerBundleInfo& info, const AbilityInfo &abilityInfo,
1214         const InnerBundleUserInfo &bundleUserInfo, std::vector<AbilityInfo>& abilityInfos) const;
1215     void ModifyApplicationInfoByCloneInfo(const InnerBundleCloneInfo &cloneInfo,
1216         ApplicationInfo &applicationInfo) const;
1217     void ModifyBundleInfoByCloneInfo(const InnerBundleCloneInfo &cloneInfo, BundleInfo &bundleInfo) const;
1218     void GetCloneBundleInfos(const InnerBundleInfo& info, int32_t flags, int32_t userId,
1219         BundleInfo &bundleInfo, std::vector<BundleInfo> &bundleInfos) const;
1220     void GetBundleNameAndIndexByName(const std::string &keyName, std::string &bundleName, int32_t &appIndex) const;
1221     void GetCloneAbilityInfos(std::vector<AbilityInfo> &abilityInfos,
1222         const ElementName &element, int32_t flags, int32_t userId) const;
1223     void GetCloneAbilityInfosV9(std::vector<AbilityInfo> &abilityInfos,
1224         const ElementName &element, int32_t flags, int32_t userId) const;
1225     ErrCode ExplicitQueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t userId,
1226         int32_t appIndex, AbilityInfo &abilityInfo) const;
1227     ErrCode ExplicitQueryCloneAbilityInfoV9(const ElementName &element, int32_t flags, int32_t userId,
1228         int32_t appIndex, AbilityInfo &abilityInfo) const;
1229     void ImplicitQueryCloneAbilityInfos(
1230         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
1231     bool ImplicitQueryCurCloneAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1232         std::vector<AbilityInfo> &abilityInfos) const;
1233     void ImplicitQueryAllCloneAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1234         std::vector<AbilityInfo> &abilityInfos) const;
1235     void ImplicitQueryCloneAbilityInfosV9(
1236         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) const;
1237     bool ImplicitQueryCurCloneAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1238         std::vector<AbilityInfo> &abilityInfos) const;
1239     void ImplicitQueryAllCloneAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1240         std::vector<AbilityInfo> &abilityInfos) const;
1241     bool ImplicitQueryCurCloneExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1242         std::vector<ExtensionAbilityInfo> &abilityInfos) const;
1243     ErrCode ImplicitQueryCurCloneExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1244         std::vector<ExtensionAbilityInfo> &abilityInfos) const;
1245     bool ImplicitQueryAllCloneExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId,
1246         std::vector<ExtensionAbilityInfo> &infos) const;
1247     ErrCode ImplicitQueryAllCloneExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
1248         std::vector<ExtensionAbilityInfo> &abilityInfos) const;
1249     ErrCode CheckInnerBundleInfoWithFlags(
1250         const InnerBundleInfo &innerBundleInfo, const int32_t flags, int32_t userId, int32_t appIndex = 0) const;
1251     ErrCode CheckInnerBundleInfoWithFlagsV9(
1252         const InnerBundleInfo &innerBundleInfo, const int32_t flags, int32_t userId, int32_t appIndex = 0) const;
1253     ErrCode CheckBundleAndAbilityDisabled(const InnerBundleInfo &info, int32_t flags, int32_t userId) const;
1254     void AddAppDetailAbilityInfo(InnerBundleInfo &info) const;
1255     void GetAllLauncherAbility(const Want &want, std::vector<AbilityInfo> &abilityInfos,
1256         const int32_t userId, const int32_t requestUserId) const;
1257     ErrCode GetLauncherAbilityByBundleName(const Want &want, std::vector<AbilityInfo> &abilityInfos,
1258         const int32_t userId, const int32_t requestUserId) const;
1259     void ModifyLauncherAbilityInfo(bool isStage, AbilityInfo &abilityInfo) const;
1260     bool MatchPrivateType(const Want &want, const std::vector<std::string> &supportExtNames,
1261         const std::vector<std::string> &supportMimeTypes, const std::vector<std::string> &paramMimeTypes) const;
1262     bool UpdateOverlayInfo(const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
1263     void ResetExternalOverlayModuleState(const std::string &bundleName, const std::string &modulePackage);
1264     void BuildExternalOverlayConnection(const std::string &moduleName, InnerBundleInfo &oldInfo, int32_t userId);
1265     void RemoveOverlayInfoAndConnection(const InnerBundleInfo &innerBundleInfo, const std::string &bundleName);
1266     ErrCode FindAbilityInfoInBundleInfo(const InnerBundleInfo &innerBundleInfo, const std::string &moduleName,
1267         const std::string &abilityName, AbilityInfo &abilityInfo) const;
1268     void RestoreSandboxUidAndGid(std::map<int32_t, std::string> &bundleIdMap);
1269     bool IsUpdateInnerBundleInfoSatisified(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
1270     ErrCode ProcessBundleMenu(BundleInfo& bundleInfo, int32_t flag, bool clearData) const;
1271     bool MatchShare(const Want &want, const std::vector<Skill> &skills) const;
1272     std::vector<Skill> FindSkillsContainShareAction(const std::vector<Skill> &skills) const;
1273     void EmplaceExtensionInfo(const InnerBundleInfo &info, const std::vector<Skill> &skills,
1274         ExtensionAbilityInfo &extensionInfo, int32_t flags, int32_t userId, std::vector<ExtensionAbilityInfo> &infos,
1275         std::optional<size_t> matchSkillIndex, std::optional<size_t> matchUriIndex, int32_t appIndex = 0) const;
1276     void EmplaceAbilityInfo(const InnerBundleInfo &info, const std::vector<Skill> &skills, AbilityInfo &abilityInfo,
1277         int32_t flags, int32_t userId, std::vector<AbilityInfo> &infos,
1278         std::optional<size_t> matchSkillIndex, std::optional<size_t> matchUriIndex, int32_t appIndex = 0) const;
1279     void AddAppHspBundleName(const BundleType type, const std::string &bundleName);
1280     void ConvertServiceHspToSharedBundleInfo(const InnerBundleInfo &innerBundleInfo,
1281         std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos) const;
1282     void ProcessBundleRouterMap(BundleInfo& bundleInfo, int32_t flag) const;
1283     void ProcessAllowedAcls(const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo) const;
1284     void FilterAbilityInfosByAppLinking(const Want &want, int32_t flags,
1285         std::vector<AbilityInfo> &abilityInfos) const;
1286     void GetMultiLauncherAbilityInfo(const Want& want,
1287         const InnerBundleInfo& info, const InnerBundleUserInfo &bundleUserInfo,
1288         int64_t installTime, std::vector<AbilityInfo>& abilityInfos) const;
1289     void CreateNewDataGroupInfo(const std::string &groupId, const int32_t userId,
1290         const DataGroupInfo &oldDataGroupInfo, DataGroupInfo &newDataGroupInfo);
1291     ErrCode CreateEl5GroupDirs(const std::vector<DataGroupInfo> &dataGroupInfos, int32_t userId);
1292     ErrCode CreateGroupDirs(const std::vector<DataGroupInfo> &dataGroupInfos, int32_t userId,
1293         bool needCreateEl5Dir);
1294     bool CreateAppGroupDir(const InnerBundleInfo &info, int32_t userId);
1295 
1296     void PreProcessAnyUserFlag(const std::string &bundleName, int32_t& flags, int32_t &userId) const;
1297     void PostProcessAnyUserFlags(int32_t flags, int32_t userId,
1298         int32_t originalUserId, BundleInfo &bundleInfo, const InnerBundleInfo &innerBundleInfo) const;
1299     void GetExtensionAbilityInfoByTypeName(uint32_t flags, int32_t userId,
1300         std::vector<ExtensionAbilityInfo> &infos, const std::string &typeName) const;
1301     bool GetShortcutInfosByInnerBundleInfo(
1302         const InnerBundleInfo &info, std::vector<ShortcutInfo> &shortcutInfos) const;
1303     std::string TryGetRawDataByExtractor(const std::string &hapPath, const std::string &profileName,
1304         const AbilityInfo &abilityInfo) const;
1305     void RestoreUidAndGidFromUninstallInfo();
1306     ErrCode IsSystemApp(const std::string &bundleName, bool &isSystemApp);
1307     bool InnerProcessShortcutId(const std::string &hapPath, std::vector<ShortcutInfo> &shortcutInfos) const;
1308 
1309 private:
1310     bool initialUserFlag_ = false;
1311     int32_t baseAppUid_ = Constants::BASE_APP_UID;
1312     mutable std::mutex stateMutex_;
1313     mutable std::mutex multiUserIdSetMutex_;
1314     mutable std::mutex hspBundleNameMutex_;
1315     mutable ffrt::mutex eventCallbackMutex_;
1316     mutable std::shared_mutex bundleInfoMutex_;
1317     mutable std::shared_mutex bundleIdMapMutex_;
1318     mutable std::shared_mutex callbackMutex_;
1319     mutable std::shared_mutex bundleMutex_;
1320     std::shared_ptr<IBundleDataStorage> dataStorage_;
1321     std::shared_ptr<IPreInstallDataStorage> preInstallDataStorage_;
1322     std::shared_ptr<BundleStateStorage> bundleStateStorage_;
1323     std::shared_ptr<BundlePromise> bundlePromise_ = nullptr;
1324     std::shared_ptr<BundleSandboxAppHelper> sandboxAppHelper_;
1325     std::shared_ptr<IShortcutDataStorage> shortcutStorage_;
1326     std::shared_ptr<IRouterDataStorage> routerStorage_;
1327     std::shared_ptr<UninstallDataMgrStorageRdb> uninstallDataMgr_;
1328     std::shared_ptr<FirstInstallDataMgrStorageRdb> firstInstallDataMgr_;
1329     // use vector because these functions using for IPC, the bundleName may duplicate
1330     std::vector<sptr<IBundleStatusCallback>> callbackList_;
1331     // common event callback
1332     std::vector<sptr<IBundleEventCallback>> eventCallbackList_;
1333     // using for locking by bundleName
1334     std::unordered_map<std::string, std::mutex> bundleMutexMap_;
1335     // using for generating bundleId
1336     // key:bundleId
1337     // value:bundleName
1338     std::map<int32_t, std::string> bundleIdMap_;
1339     // all installed bundles
1340     // key:bundleName
1341     // value:innerbundleInfo
1342     std::map<std::string, InnerBundleInfo> bundleInfos_;
1343     // key:bundle name
1344     std::map<std::string, InstallState> installStates_;
1345     // current-status:previous-statue pair
1346     std::multimap<InstallState, InstallState> transferStates_;
1347     // save all created users.
1348     std::set<int32_t> multiUserIdsSet_;
1349     std::set<std::string> appServiceHspBundleName_;
1350 
1351     static bool HasAppLinkingFlag(uint32_t flags);
1352 };
1353 }  // namespace AppExecFwk
1354 }  // namespace OHOS
1355 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_DATA_MGR_H
1356