• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_MGR_HOST_IMPL_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H
18 
19 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
20 #include "bundle_connect_ability_mgr.h"
21 #endif
22 #include "bundle_common_event_mgr.h"
23 #include "bundle_data_mgr.h"
24 #include "bundle_mgr_host.h"
25 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK
26 #include "distributed_bms_interface.h"
27 #endif
28 #include "inner_bundle_user_info.h"
29 
30 namespace OHOS {
31 namespace AppExecFwk {
32 class BundleMgrHostImpl : public BundleMgrHost {
33 public:
34     BundleMgrHostImpl() = default;
35     virtual ~BundleMgrHostImpl() = default;
36     /**
37      * @brief Obtains the ApplicationInfo based on a given bundle name.
38      * @param appName Indicates the application bundle name to be queried.
39      * @param flag Indicates the flag used to specify information contained
40      *             in the ApplicationInfo object that will be returned.
41      * @param userId Indicates the user ID.
42      * @param appInfo Indicates the obtained ApplicationInfo object.
43      * @return Returns true if the application is successfully obtained; returns false otherwise.
44      */
45     virtual bool GetApplicationInfo(
46         const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
47     /**
48      * @brief Obtains the ApplicationInfo based on a given bundle name.
49      * @param appName Indicates the application bundle name to be queried.
50      * @param flags Indicates the flag used to specify information contained
51      *             in the ApplicationInfo object that will be returned.
52      * @param userId Indicates the user ID.
53      * @param appInfo Indicates the obtained ApplicationInfo object.
54      * @return Returns true if the application is successfully obtained; returns false otherwise.
55      */
56     virtual bool GetApplicationInfo(
57         const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override;
58     /**
59      * @brief Obtains the ApplicationInfo based on a given bundle name.
60      * @param appName Indicates the application bundle name to be queried.
61      * @param flags Indicates the flag used to specify information contained
62      *             in the ApplicationInfo object that will be returned.
63      * @param userId Indicates the user ID.
64      * @param appInfo Indicates the obtained ApplicationInfo object.
65      * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise.
66      */
67     virtual ErrCode GetApplicationInfoV9(
68         const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override;
69     /**
70      * @brief Obtains information about all installed applications of a specified user.
71      * @param flag Indicates the flag used to specify information contained
72      *             in the ApplicationInfo objects that will be returned.
73      * @param userId Indicates the user ID.
74      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
75      * @return Returns true if the applications is successfully obtained; returns false otherwise.
76      */
77     virtual bool GetApplicationInfos(
78         const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override;
79     /**
80      * @brief Obtains information about all installed applications of a specified user.
81      * @param flags Indicates the flag used to specify information contained
82      *             in the ApplicationInfo objects that will be returned.
83      * @param userId Indicates the user ID.
84      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
85      * @return Returns true if the applications is successfully obtained; returns false otherwise.
86      */
87     virtual bool GetApplicationInfos(
88         int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override;
89     /**
90      * @brief Obtains information about all installed applications of a specified user.
91      * @param flags Indicates the flag used to specify information contained
92      *             in the ApplicationInfo objects that will be returned.
93      * @param userId Indicates the user ID.
94      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
95      * @return Returns ERR_OK if the applications is successfully obtained; returns error code otherwise.
96      */
97     virtual ErrCode GetApplicationInfosV9(
98         int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override;
99     /**
100      * @brief Obtains the BundleInfo based on a given bundle name.
101      * @param bundleName Indicates the application bundle name to be queried.
102      * @param flag Indicates the information contained in the BundleInfo object to be returned.
103      * @param bundleInfo Indicates the obtained BundleInfo object.
104      * @param userId Indicates the user ID.
105      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
106      */
107     virtual bool GetBundleInfo(const std::string &bundleName,
108         const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
109     /**
110      * @brief Obtains the BundleInfo based on a given bundle name.
111      * @param bundleName Indicates the application bundle name to be queried.
112      * @param flags Indicates the information contained in the BundleInfo object to be returned.
113      * @param bundleInfo Indicates the obtained BundleInfo object.
114      * @param userId Indicates the user ID.
115      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
116      */
117     virtual bool GetBundleInfo(const std::string &bundleName,
118         int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
119     /**
120      * @brief Obtains the BundleInfo based on a given bundle name.
121      * @param bundleName Indicates the application bundle name to be queried.
122      * @param flags Indicates the information contained in the BundleInfo object to be returned.
123      * @param bundleInfo Indicates the obtained BundleInfo object.
124      * @param userId Indicates the user ID.
125      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
126      */
127     virtual ErrCode GetBundleInfoV9(const std::string &bundleName,
128         int32_t flags, BundleInfo &bundleInfo, int32_t userId) override;
129     /**
130      * @brief Obtains the BundleInfo based on a given bundle name.
131      * @param flags Indicates the information contained in the BundleInfo object to be returned.
132      * @param bundleInfo Indicates the obtained BundleInfo object.
133      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
134      */
135     virtual ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo) override;
136     /**
137      * @brief Obtains the BundleInfo based on a given bundle name, which the calling app depends on.
138      * @param sharedBundleName Indicates the bundle name to be queried.
139      * @param sharedBundleInfo Indicates the obtained BundleInfo object.
140      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
141      */
142     virtual ErrCode GetDependentBundleInfo(const std::string &sharedBundleName, BundleInfo &sharedBundleInfo) override;
143     /**
144      * @brief Obtains the BundlePackInfo based on a given bundle name.
145      * @param bundleName Indicates the application bundle name to be queried.
146      * @param flags Indicates the information contained in the BundleInfo object to be returned.
147      * @param BundlePackInfo Indicates the obtained BundlePackInfo object.
148      * @param userId Indicates the user ID.
149      * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise.
150      */
151     virtual ErrCode GetBundlePackInfo(const std::string &bundleName, const BundlePackFlag flag,
152         BundlePackInfo &bundlePackInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
153 
154     /**
155      * @brief Obtains the BundlePackInfo based on a given bundle name.
156      * @param bundleName Indicates the application bundle name to be queried.
157      * @param flags Indicates the information contained in the BundleInfo object to be returned.
158      * @param BundlePackInfo Indicates the obtained BundlePackInfo object.
159      * @param userId Indicates the user ID.
160      * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise.
161      */
162     virtual ErrCode GetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundlePackInfo,
163         int32_t userId = Constants::UNSPECIFIED_USERID) override;
164 
165     /**
166      * @brief Obtains BundleInfo of all bundles available in the system.
167      * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned.
168      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
169      * @param userId Indicates the user ID.
170      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
171      */
172     virtual bool GetBundleInfos(const BundleFlag flag,
173         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
174     /**
175      * @brief Obtains BundleInfo of all bundles available in the system.
176      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
177      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
178      * @param userId Indicates the user ID.
179      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
180      */
181     virtual bool GetBundleInfos(int32_t flags,
182         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
183     /**
184      * @brief Obtains BundleInfo of all bundles available in the system.
185      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
186      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
187      * @param userId Indicates the user ID.
188      * @return Returns ERR_OK if the BundleInfos is successfully obtained; returns error code otherwise.
189      */
190     virtual ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) override;
191     /**
192      * @brief Obtains the application UID based on the given bundle name and user ID.
193      * @param bundleName Indicates the bundle name of the application.
194      * @param userId Indicates the user ID.
195      * @return Returns the uid if successfully obtained; returns -1 otherwise.
196      */
197     virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override;
198     /**
199      * @brief Obtains all bundle names of a specified application based on the given application UID.
200      * @param uid Indicates the uid.
201      * @param bundleNames Indicates the obtained bundle names.
202      * @return Returns true if the bundle names is successfully obtained; returns false otherwise.
203      */
204     virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override;
205     /**
206      * @brief Obtains the formal name associated with the given UID.
207      * @param uid Indicates the uid.
208      * @param name Indicates the obtained formal name.
209      * @return Returns ERR_OK if execute success; returns errCode otherwise.
210      */
211     virtual ErrCode GetNameForUid(const int uid, std::string &name) override;
212     /**
213      * @brief Obtains an array of all group IDs associated with a specified bundle.
214      * @param bundleName Indicates the bundle name.
215      * @param gids Indicates the group IDs associated with the specified bundle.
216      * @return Returns true if the gids is successfully obtained; returns false otherwise.
217      */
218     virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override;
219     /**
220      * @brief Obtains an array of all group IDs associated with the given bundle name and UID.
221      * @param bundleName Indicates the bundle name.
222      * @param uid Indicates the uid.
223      * @param gids Indicates the group IDs associated with the specified bundle.
224      * @return Returns true if the gids is successfully obtained; returns false otherwise.
225      */
226     virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) override;
227     /**
228      * @brief Check whether the app is system app by it's UID.
229      * @param uid Indicates the uid.
230      * @return Returns true if the bundle is a system application; returns false otherwise.
231      */
232     virtual bool CheckIsSystemAppByUid(const int uid) override;
233     /**
234      * @brief Obtains the BundleInfo of application bundles based on the specified metaData.
235      * @param metaData Indicates the metadata to get in the bundle.
236      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
237      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
238      */
239     virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override;
240     /**
241      * @brief Query the AbilityInfo by the given Want.
242      * @param want Indicates the information of the ability.
243      * @param abilityInfo Indicates the obtained AbilityInfo object.
244      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
245      */
246     virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
247 
248 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
249     /**
250      * @brief Query the AbilityInfo by the given Want.
251      * @param want Indicates the information of the ability.
252      * @param abilityInfo Indicates the obtained AbilityInfo object.
253      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
254      */
255     virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId,
256         AbilityInfo &abilityInfo, const sptr<IRemoteObject> &callBack) override;
257 
258     /**
259      * @brief Silent install by the given Want.
260      * @param want Indicates the information of the want.
261      * @param userId Indicates the user ID.
262      * @param callBack Indicates the callback to be invoked for return the operation result.
263      * @return Returns true if silent install successfully; returns false otherwise.
264      */
265     virtual bool SilentInstall(const Want &want, int32_t userId, const sptr<IRemoteObject> &callBack) override;
266 
267     virtual bool CheckAbilityEnableInstall(
268         const Want &want, int32_t missionId, int32_t userId, const sptr<IRemoteObject> &callback) override;
269 #endif
270     /**
271      * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object.
272      * @param bundleName Indicates the application bundle name to be queried.
273      * @param abilityName Indicates the application ability name to be queried.
274      * @param abilityInfo Indicates the obtained AbilityInfo object.
275      * @return Returns true if the application is successfully obtained; returns false otherwise.
276      */
277     virtual bool GetAbilityInfo(
278         const std::string &bundleName, const std::string &abilityName, AbilityInfo &abilityInfo) override;
279     /**
280      * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object.
281      * @param bundleName Indicates the application bundle name to be queried.
282      * @param moduleName Indicates the module name to be queried.
283      * @param abilityName Indicates the application ability name to be queried.
284      * @param abilityInfo Indicates the obtained AbilityInfo object.
285      * @return Returns true if the application is successfully obtained; returns false otherwise.
286      */
287     virtual bool GetAbilityInfo(
288         const std::string &bundleName, const std::string &moduleName,
289         const std::string &abilityName, AbilityInfo &abilityInfo) override;
290     /**
291      * @brief Query the AbilityInfo by the given Want.
292      * @param want Indicates the information of the ability.
293      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
294      * @param userId Indicates the user ID.
295      * @param abilityInfo Indicates the obtained AbilityInfo object.
296      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
297      */
298     virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) override;
299 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
300     /**
301      * @brief Upgrade atomic service
302      * @param want Indicates the information of the ability.
303      * @param userId Indicates the user ID.
304      */
305     virtual void UpgradeAtomicService(const Want &want, int32_t userId) override;
306 
307     virtual bool ProcessPreload(const Want &want) override;
308 #endif
309     /**
310      * @brief Query the AbilityInfo of list by the given Want.
311      * @param want Indicates the information of the ability.
312      * @param abilityInfos Indicates the obtained AbilityInfos object.
313      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
314      */
315     virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
316     /**
317      * @brief Query the AbilityInfo of list by the given Want.
318      * @param want Indicates the information of the ability.
319      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
320      * @param userId Indicates the user ID.
321      * @param abilityInfos Indicates the obtained AbilityInfos object.
322      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
323      */
324     virtual bool QueryAbilityInfos(
325         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
326     /**
327      * @brief Query the AbilityInfo of list by the given Want.
328      * @param want Indicates the information of the ability.
329      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
330      * @param userId Indicates the user ID.
331      * @param abilityInfos Indicates the obtained AbilityInfos object.
332      * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise.
333      */
334     virtual ErrCode QueryAbilityInfosV9(
335         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
336     /**
337      * @brief Query the launcher AbilityInfo of list by the given Want.
338      * @param want Indicates the information of the ability.
339      * @param userId Indicates the user ID.
340      * @param abilityInfos Indicates the obtained AbilityInfos object.
341      * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise.
342      */
343     virtual ErrCode QueryLauncherAbilityInfos(const Want &want,
344         int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
345     /**
346      * @brief Query the AbilityInfo of list of all service on launcher.
347      * @param userId Indicates the information of the user.
348      * @param abilityInfos Indicates the obtained AbilityInfos object.
349      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
350      */
351     virtual bool QueryAllAbilityInfos(
352         const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
353     /**
354      * @brief Query the AbilityInfo by ability.uri in config.json.
355      * @param abilityUri Indicates the uri of the ability.
356      * @param abilityInfo Indicates the obtained AbilityInfo object.
357      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
358      */
359     virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override;
360     /**
361      * @brief Query the AbilityInfo by ability.uri in config.json.
362      * @param abilityUri Indicates the uri of the ability.
363      * @param abilityInfos Indicates the obtained AbilityInfos object.
364      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
365      */
366     virtual bool QueryAbilityInfosByUri(
367         const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) override;
368     /**
369      * @brief Query the AbilityInfo by ability.uri in config.json through the proxy object.
370      * @param abilityUri Indicates the uri of the ability.
371      * @param userId Indicates the user ID.
372      * @param abilityInfo Indicates the obtained AbilityInfo object.
373      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
374      */
375     virtual bool QueryAbilityInfoByUri(
376         const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) override;
377     /**
378      * @brief Obtains the BundleInfo of all keep-alive applications in the system.
379      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
380      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
381      */
382     virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override;
383     /**
384      * @brief Obtains the label of a specified ability.
385      * @param bundleName Indicates the bundle name.
386      * @param abilityName Indicates the ability name.
387      * @return Returns the label of the ability if exist; returns empty string otherwise.
388      */
389     virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &abilityName) override;
390     /**
391      * @brief Obtains the label of a specified ability.
392      * @param bundleName Indicates the bundle name.
393      * @param moduleName Indicates the module name.
394      * @param abilityName Indicates the ability name.
395      * @param label Indicates the obtained label.
396      * @return Returns ERR_OK if called successfully; returns error code otherwise.
397      */
398     virtual ErrCode GetAbilityLabel(const std::string &bundleName, const std::string &moduleName,
399         const std::string &abilityName, std::string &label) override;
400     /**
401      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
402      * @param hapFilePath Indicates the absolute file path of the HAP.
403      * @param flag Indicates the information contained in the BundleInfo object to be returned.
404      * @param bundleInfo Indicates the obtained BundleInfo object.
405      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
406      */
407     virtual bool GetBundleArchiveInfo(
408         const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override;
409     /**
410      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
411      * @param hapFilePath Indicates the absolute file path of the HAP.
412      * @param flags Indicates the information contained in the BundleInfo object to be returned.
413      * @param bundleInfo Indicates the obtained BundleInfo object.
414      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
415      */
416     virtual bool GetBundleArchiveInfo(
417         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override;
418     /**
419      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
420      * @param hapFilePath Indicates the absolute file path of the HAP.
421      * @param flags Indicates the information contained in the BundleInfo object to be returned.
422      * @param bundleInfo Indicates the obtained BundleInfo object.
423      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
424      */
425     virtual ErrCode GetBundleArchiveInfoV9(
426         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override;
427     /**
428      * @brief Obtain the HAP module info of a specific ability.
429      * @param abilityInfo Indicates the ability.
430      * @param hapModuleInfo Indicates the obtained HapModuleInfo object.
431      * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
432      */
433     virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override;
434     /**
435      * @brief Obtain the HAP module info of a specific ability through the proxy object.
436      * @param abilityInfo Indicates the ability.
437      * @param userId Indicates the userId.
438      * @param hapModuleInfo Indicates the obtained HapModuleInfo object.
439      * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
440      */
441     virtual bool GetHapModuleInfo(
442         const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo) override;
443     /**
444      * @brief Obtains the Want for starting the main ability of an application based on the given bundle name.
445      * @param bundleName Indicates the bundle name.
446      * @param want Indicates the obtained launch Want object.
447      * @param userId Indicates the userId.
448      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
449      */
450     virtual ErrCode GetLaunchWantForBundle(
451         const std::string &bundleName, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) override;
452     /**
453      * @brief Obtains detailed information about a specified permission.
454      * @param permissionName Indicates the name of the ohos permission.
455      * @param permissionDef Indicates the object containing detailed information about the given ohos permission.
456      * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise.
457      */
458     virtual ErrCode GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override;
459     /**
460      * @brief Clears cache data of a specified application.
461      * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
462      * @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
463      * @param userId description the user id.
464      * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
465      */
466     virtual ErrCode CleanBundleCacheFiles(
467         const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback,
468         int32_t userId = Constants::UNSPECIFIED_USERID) override;
469     /**
470      * @brief Clears application running data of a specified application.
471      * @param bundleName Indicates the bundle name of the application whose data is to be cleared.
472      * @param userId Indicates the user id.
473      * @return Returns true if the data cleared successfully; returns false otherwise.
474      */
475     virtual bool CleanBundleDataFiles(const std::string &bundleName,
476         const int userId = Constants::UNSPECIFIED_USERID) override;
477     /**
478      * @brief Register the specific bundle status callback.
479      * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
480      * @return Returns true if this function is successfully called; returns false otherwise.
481      */
482     virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
483 
484     virtual bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override;
485 
486     virtual bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override;
487     /**
488      * @brief Clear the specific bundle status callback.
489      * @param bundleStatusCallback Indicates the callback to be cleared.
490      * @return Returns true if this function is successfully called; returns false otherwise.
491      */
492     virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
493     /**
494      * @brief Unregister all the callbacks of status changed.
495      * @return Returns true if this function is successfully called; returns false otherwise.
496      */
497     virtual bool UnregisterBundleStatusCallback() override;
498     /**
499      * @brief Dump the bundle informations with specific flags.
500      * @param flag Indicates the information contained in the dump result.
501      * @param bundleName Indicates the bundle name if needed.
502      * @param userId Indicates the user ID.
503      * @param result Indicates the dump information result.
504      * @return Returns true if the dump result is successfully obtained; returns false otherwise.
505      */
506     virtual bool DumpInfos(
507         const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override;
508     /**
509      * @brief Checks whether a specified application is enabled.
510      * @param bundleName Indicates the bundle name of the application.
511      * @param isEnable Indicates the application status is enabled.
512      * @return Returns result of the operation.
513      */
514     virtual ErrCode IsApplicationEnabled(const std::string &bundleName, bool &isEnable) override;
515     /**
516      * @brief Sets whether to enable a specified application.
517      * @param bundleName Indicates the bundle name of the application.
518      * @param isEnable Specifies whether to enable the application.
519      *                 The value true means to enable it, and the value false means to disable it.
520      * @param userId description the user id.
521      * @return Returns result of the operation.
522      */
523     virtual ErrCode SetApplicationEnabled(const std::string &bundleName, bool isEnable,
524         int32_t userId = Constants::UNSPECIFIED_USERID) override;
525     /**
526      * @brief Sets whether to enable a specified ability through the proxy object.
527      * @param abilityInfo Indicates information about the ability to check.
528      * @param isEnable Indicates the ability status is enabled.
529      * @return Returns result of the operation.
530      */
531     virtual ErrCode IsAbilityEnabled(const AbilityInfo &abilityInfo, bool &isEnable) override;
532     /**
533      * @brief Sets whether to enable a specified ability through the proxy object.
534      * @param abilityInfo Indicates information about the ability.
535      * @param isEnabled Specifies whether to enable the ability.
536      *                 The value true means to enable it, and the value false means to disable it.
537      * @param userId description the user id.
538      * @return Returns result of the operation.
539      */
540     virtual ErrCode SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled,
541         int32_t userId = Constants::UNSPECIFIED_USERID) override;
542     /**
543      * @brief Obtains the interface used to install and uninstall bundles.
544      * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise.
545      */
546     virtual sptr<IBundleInstaller> GetBundleInstaller() override;
547     /**
548      * @brief Obtains the interface used to create or delete user.
549      * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise.
550      */
551     virtual sptr<IBundleUserMgr> GetBundleUserMgr() override;
552     /**
553      * @brief Obtains the FormInfo objects provided by all applications on the device.
554      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
555      * device.
556      * @return Returns true if this function is successfully called; returns false otherwise.
557      */
558     virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override;
559     /**
560      * @brief Obtains the FormInfo objects provided by a specified application on the device.
561      * @param bundleName Indicates the bundle name of the application.
562      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
563      * device.
564      * @return Returns true if this function is successfully called; returns false otherwise.
565      */
566     virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override;
567     /**
568      * @brief Obtains the FormInfo objects provided by a specified module name.
569      * @param bundleName Indicates the bundle name of the application.
570      * @param moduleName Indicates the module name of the application.
571      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
572      * device.
573      * @return Returns true if this function is successfully called; returns false otherwise.
574      */
575     virtual bool GetFormsInfoByModule(
576         const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override;
577     /**
578      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
579      * @param bundleName Indicates the bundle name of the application.
580      * @param shortcutInfos List of ShortcutInfo objects if obtained.
581      * @return Returns true if GetShortcutInfos successfully; returns false otherwise.
582      */
583     virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
584 
585     /**
586      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
587      * @param bundleName Indicates the bundle name of the application.
588      * @param shortcutInfos List of ShortcutInfo objects if obtained.
589      * @return Returns errCode of result.
590      */
591     virtual ErrCode GetShortcutInfoV9(const std::string &bundleName,
592         std::vector<ShortcutInfo> &shortcutInfos) override;
593     /**
594      * @brief Obtains the CommonEventInfo objects provided by an event key on the device.
595      * @param eventKey Indicates the event of the subscribe.
596      * @param commonEventInfos List of CommonEventInfo objects if obtained.
597      * @return Returns true if this function is successfully called; returns false otherwise.
598      */
599     virtual bool GetAllCommonEventInfo(const std::string &eventKey,
600         std::vector<CommonEventInfo> &commonEventInfos) override;
601     /**
602      * @brief Obtains the DistributedBundleInfo based on a given bundle name and networkId.
603      * @param networkId Indicates the networkId of remote device.
604      * @param bundleName Indicates the application bundle name to be queried.
605      * @param distributedBundleInfo Indicates the obtained DistributedBundleInfo object.
606      * @return Returns true if the DistributedBundleInfo is successfully obtained; returns false otherwise.
607      */
608     virtual bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName,
609         DistributedBundleInfo &distributedBundleInfo) override;
610     /**
611      * @brief Get app privilege level.
612      * @param bundleName Indicates the bundle name of the app privilege level.
613      * @param userId Indicates the user id.
614      * @return Returns app privilege level.
615      */
616     virtual std::string GetAppPrivilegeLevel(
617         const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID) override;
618     /**
619      * @brief Query extension info.
620      * @param Want Indicates the information of extension info.
621      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
622      * @param userId Indicates the userId in the system.
623      * @param extensionInfos Indicates the obtained extensions.
624      * @return Returns true if this function is successfully called; returns false otherwise.
625      */
626     virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId,
627         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
628     /**
629      * @brief Query extension info.
630      * @param Want Indicates the information of extension info.
631      * @param flag Indicates the query flag which will filter any specified stuff in the extension info.
632      * @param userId Indicates the userId in the system.
633      * @param extensionInfos Indicates the obtained extensions.
634      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
635      */
636     virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
637         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
638     /**
639      * @brief Query extension info.
640      * @param Want Indicates the information of extension info.
641      * @param extensionType Indicates the type of the extension.
642      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
643      * @param userId Indicates the userId in the system.
644      * @param extensionInfos Indicates the obtained extensions.
645      * @return Returns true if this function is successfully called; returns false otherwise.
646      */
647     virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType,
648         const int32_t &flag, const int32_t &userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
649     /**
650      * @brief Query extension info.
651      * @param Want Indicates the information of extension info.
652      * @param extensionType Indicates the type of the extension.
653      * @param flag Indicates the query flag which will filter any specified stuff in the extension info.
654      * @param userId Indicates the userId in the system.
655      * @param extensionInfos Indicates the obtained extensions.
656      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
657      */
658     virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, const ExtensionAbilityType &extensionType,
659         int32_t flags, int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
660     /**
661      * @brief Process hidump.
662      * @param fd Indicates the fd.
663      * @param args Indicates the params.
664      * @return Returns the dump result.
665      */
666     int Dump(int fd, const std::vector<std::u16string> &args) override;
667 
668     virtual bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId,
669         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
670 
671     virtual bool VerifyCallingPermission(const std::string &permission) override;
672 
673     virtual bool VerifySystemApi(int32_t beginApiVersion = Constants::INVALID_API_VERSION) override;
674 
675     virtual bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId,
676         ExtensionAbilityInfo &extensionAbilityInfo) override;
677 
678     virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override;
679 
680     virtual std::string GetAppType(const std::string &bundleName) override;
681 
682     virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
683 
684     virtual int GetUidByDebugBundleName(const std::string &bundleName, const int userId) override;
685 
686     virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId,
687         AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) override;
688 
689     virtual bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault,
690         std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
691 
692     /**
693      * @brief Obtains the value of isRemovable based on a given bundle name and module name.
694      * @param bundleName Indicates the bundle name to be queried.
695      * @param moduleName Indicates the module name to be queried.
696      * @param isRemovable Indicates the module whether is removable.
697      * @return Returns ERR_OK if the isRemovable is successfully obtained; returns other ErrCode otherwise.
698      */
699     virtual ErrCode IsModuleRemovable(const std::string &bundleName, const std::string &moduleName,
700         bool &isRemovable) override;
701     /**
702      * @brief Sets whether to enable isRemovable based on a given bundle name and module name.
703      * @param bundleName Indicates the bundle name to be queried.
704      * @param moduleName Indicates the module name to be queried.
705      * @param isEnable Specifies whether to enable the isRemovable of InnerModuleInfo.
706      *                 The value true means to enable it, and the value false means to disable it
707      * @return Returns true if the isRemovable is successfully obtained; returns false otherwise.
708      */
709     virtual bool SetModuleRemovable(
710         const std::string &bundleName, const std::string &moduleName, bool isEnable) override;
711     /**
712      * @brief Obtains the dependent module names.
713      *
714      * @param bundleName Indicates the bundle name to be queried.
715      * @param moduleName Indicates the module name to be queried.
716      * @param dependentModuleNames Indicates the obtained dependent module names.
717      * @return Returns true if this function is successfully called; returns false otherwise.
718      */
719     virtual bool GetAllDependentModuleNames(const std::string &bundleName, const std::string &moduleName,
720         std::vector<std::string> &dependentModuleNames) override;
721     /**
722      * @brief Obtains the value of upgradeFlag based on a given bundle name and module name.
723      * @param bundleName Indicates the bundle name to be queried.
724      * @param moduleName Indicates the module name to be queried.
725      * @return Returns true if the upgradeFlag is successfully obtained; returns false otherwise.
726      */
727     virtual bool GetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName) override;
728     /**
729      * @brief Sets whether to enable upgradeFlag based on a given bundle name and module name.
730      * @param bundleName Indicates the bundle name to be queried.
731      * @param moduleName Indicates the module name to be queried.
732      * @param isEnable Specifies whether to enable the upgradeFlag of InnerModuleInfo.
733      *                 The value true means to enable it, and the value false means to disable it
734      * @return Returns ERR_OK if the UpgradeFlag is successfully obtained; returns other ErrCode otherwise.
735      */
736     virtual ErrCode SetModuleUpgradeFlag(
737         const std::string &bundleName, const std::string &moduleName, int32_t upgradeFlag) override;
738     virtual ErrCode GetSandboxBundleInfo(
739         const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info) override;
740 
741     virtual bool ObtainCallingBundleName(std::string &bundleName) override;
742 
743     virtual bool GetBundleStats(const std::string &bundleName, int32_t userId,
744         std::vector<int64_t> &bundleStats) override;
745 
746 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
747     virtual sptr<IDefaultApp> GetDefaultAppProxy() override;
748 #endif
749 
750 #ifdef BUNDLE_FRAMEWORK_APP_CONTROL
751     virtual sptr<IAppControlMgr> GetAppControlProxy() override;
752 #endif
753 
754     virtual ErrCode GetSandboxAbilityInfo(const Want &want, int32_t appIndex, int32_t flags, int32_t userId,
755         AbilityInfo &info) override;
756     virtual ErrCode GetSandboxExtAbilityInfos(const Want &want, int32_t appIndex, int32_t flags, int32_t userId,
757         std::vector<ExtensionAbilityInfo> &infos) override;
758     virtual ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId,
759         HapModuleInfo &info) override;
760 
761     virtual ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName,
762         const std::string &abilityName, std::unique_ptr<uint8_t[]> &mediaDataPtr, size_t &len, int32_t userId) override;
763 
764     virtual sptr<IQuickFixManager> GetQuickFixManagerProxy() override;
765     virtual std::string GetStringById(const std::string &bundleName, const std::string &moduleName,
766         uint32_t resId, int32_t userId, const std::string &localeInfo) override;
767     virtual std::string GetIconById(const std::string &bundleName, const std::string &moduleName,
768         uint32_t resId, uint32_t density, int32_t userId) override;
769     virtual ErrCode SetDebugMode(bool isDebug) override;
770     virtual sptr<IOverlayManager> GetOverlayManagerProxy() override;
771     virtual ErrCode GetAppProvisionInfo(const std::string &bundleName, int32_t userId,
772         AppProvisionInfo &appProvisionInfo) override;
773     virtual ErrCode GetProvisionMetadata(const std::string &bundleName, int32_t userId,
774         std::vector<Metadata> &provisionMetadatas) override;
775     virtual ErrCode GetBaseSharedBundleInfos(const std::string &bundleName,
776         std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos) override;
777     virtual ErrCode GetAllSharedBundleInfo(std::vector<SharedBundleInfo> &sharedBundles) override;
778     virtual ErrCode GetSharedBundleInfo(const std::string &bundleName, const std::string &moduleName,
779         std::vector<SharedBundleInfo> &sharedBundles) override;
780     virtual ErrCode GetSharedBundleInfoBySelf(const std::string &bundleName,
781         SharedBundleInfo &sharedBundleInfo) override;
782     virtual ErrCode GetSharedDependencies(const std::string &bundleName, const std::string &moduleName,
783         std::vector<Dependency> &dependencies) override;
784     virtual ErrCode GetProxyDataInfos(const std::string &bundleName, const std::string &moduleName,
785         std::vector<ProxyData> &proxyDatas, int32_t userId = Constants::UNSPECIFIED_USERID) override;
786     virtual ErrCode GetAllProxyDataInfos(
787         std::vector<ProxyData> &proxyDatas, int32_t userId = Constants::UNSPECIFIED_USERID) override;
788     virtual ErrCode GetSpecifiedDistributionType(const std::string &bundleName,
789         std::string &specifiedDistributionType) override;
790     virtual ErrCode GetAdditionalInfo(const std::string &bundleName,
791         std::string &additionalInfo) override;
792     virtual ErrCode SetExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName,
793         const std::string &abilityName, const std::string &extName, const std::string &mimeType) override;
794     virtual ErrCode DelExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName,
795         const std::string &abilityName, const std::string &extName, const std::string &mimeType) override;
796     virtual bool QueryDataGroupInfos(const std::string &bundleName, int32_t userId,
797         std::vector<DataGroupInfo> &infos) override;
798     virtual bool GetGroupDir(const std::string &dataGroupId, std::string &dir) override;
799     virtual bool QueryAppGalleryBundleName(std::string &bundleName) override;
800     void SetBrokerServiceStatus(bool isServiceExisted);
801 
802 private:
803     const std::shared_ptr<BundleDataMgr> GetDataMgrFromService();
804 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK
805     const OHOS::sptr<IDistributedBms> GetDistributedBundleMgrService();
806 #endif
807 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
808     const std::shared_ptr<BundleConnectAbilityMgr> GetConnectAbilityMgrFromService();
809 #endif
810     bool GetBundleUserInfo(
811         const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo);
812     bool GetBundleUserInfos(
813         const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos);
814     bool GetShortcutInfos(
815         const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos);
816     bool DumpAllBundleInfoNames(int32_t userId, std::string &result);
817     bool DumpAllBundleInfoNamesByUserId(int32_t userId, std::string &result);
818     bool DumpBundleInfo(const std::string &bundleName, int32_t userId, std::string &result);
819     bool DumpShortcutInfo(const std::string &bundleName, int32_t userId, std::string &result);
820     std::set<int32_t> GetExistsCommonUserIs();
821     bool VerifyQueryPermission(const std::string &queryBundleName);
822     bool VerifyPrivilegedPermission(const std::string &queryBundleName);
823     bool VerifyDependency(const std::string &sharedBundleName);
824     void CleanBundleCacheTask(const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback,
825         const std::shared_ptr<BundleDataMgr> &dataMgr, int32_t userId);
826     void NotifyBundleStatus(const NotifyBundleEvents &installRes);
827     ErrCode GetBundleArchiveInfoBySandBoxPath(
828         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo, bool fromV9 = false);
829     bool IsPreInstallApp(const std::string &bundleName);
830 
831     bool isBrokerServiceExisted_ = false;
832 };
833 }  // namespace AppExecFwk
834 }  // namespace OHOS
835 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H
836