• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #include "bundle_clone_mgr.h"
20 #include "bundle_data_mgr.h"
21 #include "bundle_mgr_host.h"
22 #include "bundle_mgr_service_event_handler.h"
23 #include "inner_bundle_user_info.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class BundleMgrHostImpl : public BundleMgrHost {
28 public:
BundleMgrHostImpl()29     BundleMgrHostImpl()
30     {
31         auto myRunner = EventRunner::Create(true);
32         handler_ = std::make_shared<BMSEventHandler>(myRunner);
33     }
~BundleMgrHostImpl()34     virtual ~BundleMgrHostImpl() {}
35     /**
36      * @brief Obtains the ApplicationInfo based on a given bundle name.
37      * @param appName Indicates the application bundle name to be queried.
38      * @param flag Indicates the flag used to specify information contained
39      *             in the ApplicationInfo object that will be returned.
40      * @param userId Indicates the user ID.
41      * @param appInfo Indicates the obtained ApplicationInfo object.
42      * @return Returns true if the application is successfully obtained; returns false otherwise.
43      */
44     virtual bool GetApplicationInfo(
45         const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
46     /**
47      * @brief Obtains the ApplicationInfo based on a given bundle name.
48      * @param appName Indicates the application bundle name to be queried.
49      * @param flags Indicates the flag used to specify information contained
50      *             in the ApplicationInfo object that will be returned.
51      * @param userId Indicates the user ID.
52      * @param appInfo Indicates the obtained ApplicationInfo object.
53      * @return Returns true if the application is successfully obtained; returns false otherwise.
54      */
55     virtual bool GetApplicationInfo(
56         const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override;
57     /**
58      * @brief Obtains information about all installed applications of a specified user.
59      * @param flag Indicates the flag used to specify information contained
60      *             in the ApplicationInfo objects that will be returned.
61      * @param userId Indicates the user ID.
62      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
63      * @return Returns true if the applications is successfully obtained; returns false otherwise.
64      */
65     virtual bool GetApplicationInfos(
66         const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override;
67     /**
68      * @brief Obtains information about all installed applications of a specified user.
69      * @param flags Indicates the flag used to specify information contained
70      *             in the ApplicationInfo objects that will be returned.
71      * @param userId Indicates the user ID.
72      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
73      * @return Returns true if the applications is successfully obtained; returns false otherwise.
74      */
75     virtual bool GetApplicationInfos(
76         int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override;
77     /**
78      * @brief Obtains the BundleInfo based on a given bundle name.
79      * @param bundleName Indicates the application bundle name to be queried.
80      * @param flag Indicates the information contained in the BundleInfo object to be returned.
81      * @param bundleInfo Indicates the obtained BundleInfo object.
82      * @param userId Indicates the user ID.
83      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
84      */
85     virtual bool GetBundleInfo(const std::string &bundleName,
86         const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
87     /**
88      * @brief Obtains the BundleInfo based on a given bundle name.
89      * @param bundleName Indicates the application bundle name to be queried.
90      * @param flags Indicates the information contained in the BundleInfo object to be returned.
91      * @param bundleInfo Indicates the obtained BundleInfo object.
92      * @param userId Indicates the user ID.
93      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
94      */
95     virtual bool GetBundleInfo(const std::string &bundleName,
96         int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
97     /**
98      * @brief Obtains BundleInfo of all bundles available in the system.
99      * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned.
100      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
101      * @param userId Indicates the user ID.
102      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
103      */
104     virtual bool GetBundleInfos(const BundleFlag flag,
105         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
106     /**
107      * @brief Obtains BundleInfo of all bundles available in the system.
108      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
109      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
110      * @param userId Indicates the user ID.
111      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
112      */
113     virtual bool GetBundleInfos(int32_t flags,
114         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
115     /**
116      * @brief Obtains the application UID based on the given bundle name and user ID.
117      * @param bundleName Indicates the bundle name of the application.
118      * @param userId Indicates the user ID.
119      * @return Returns the uid if successfully obtained; returns -1 otherwise.
120      */
121     virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override;
122     /**
123      * @brief Obtains all bundle names of a specified application based on the given application UID.
124      * @param uid Indicates the uid.
125      * @param bundleNames Indicates the obtained bundle names.
126      * @return Returns true if the bundle names is successfully obtained; returns false otherwise.
127      */
128     virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override;
129     /**
130      * @brief Obtains the formal name associated with the given UID.
131      * @param uid Indicates the uid.
132      * @param name Indicates the obtained formal name.
133      * @return Returns true if the formal name is successfully obtained; returns false otherwise.
134      */
135     virtual bool GetNameForUid(const int uid, std::string &name) override;
136     /**
137      * @brief Obtains an array of all group IDs associated with a specified bundle.
138      * @param bundleName Indicates the bundle name.
139      * @param gids Indicates the group IDs associated with the specified bundle.
140      * @return Returns true if the gids is successfully obtained; returns false otherwise.
141      */
142     virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override;
143     /**
144      * @brief Obtains an array of all group IDs associated with the given bundle name and UID.
145      * @param bundleName Indicates the bundle name.
146      * @param uid Indicates the uid.
147      * @param gids Indicates the group IDs associated with the specified bundle.
148      * @return Returns true if the gids is successfully obtained; returns false otherwise.
149      */
150     virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) override;
151     /**
152      * @brief Check whether the app is system app by it's UID.
153      * @param uid Indicates the uid.
154      * @return Returns true if the bundle is a system application; returns false otherwise.
155      */
156     virtual bool CheckIsSystemAppByUid(const int uid) override;
157     /**
158      * @brief Obtains the BundleInfo of application bundles based on the specified metaData.
159      * @param metaData Indicates the metadata to get in the bundle.
160      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
161      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
162      */
163     virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override;
164     /**
165      * @brief Query the AbilityInfo by the given Want.
166      * @param want Indicates the information of the ability.
167      * @param abilityInfo Indicates the obtained AbilityInfo object.
168      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
169      */
170     virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
171     /**
172      * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object.
173      * @param bundleName Indicates the application bundle name to be queried.
174      * @param abilityName Indicates the application ability name to be queried.
175      * @param abilityInfo Indicates the obtained AbilityInfo object.
176      * @return Returns true if the application is successfully obtained; returns false otherwise.
177      */
178     virtual bool GetAbilityInfo(
179         const std::string &bundleName, const std::string &abilityName, AbilityInfo &abilityInfo) override;
180     /**
181      * @brief Query the AbilityInfo 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 abilityInfo Indicates the obtained AbilityInfo object.
186      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
187      */
188     virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) override;
189     /**
190      * @brief Query the AbilityInfo of list by the given Want.
191      * @param want Indicates the information of the ability.
192      * @param abilityInfos Indicates the obtained AbilityInfos object.
193      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
194      */
195     virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
196     /**
197      * @brief Query the AbilityInfo of list by the given Want.
198      * @param want Indicates the information of the ability.
199      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
200      * @param userId Indicates the user ID.
201      * @param abilityInfos Indicates the obtained AbilityInfos object.
202      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
203      */
204     virtual bool QueryAbilityInfos(
205         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
206     /**
207      * @brief Query the AbilityInfo of list for clone by the given Want.
208      * @param want Indicates the information of the ability.
209      * @param abilityInfos Indicates the obtained AbilityInfos object.
210      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
211      */
212     virtual bool QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
213     /**
214      * @brief Query the AbilityInfo of list of all service on launcher.
215      * @param userId Indicates the information of the user.
216      * @param abilityInfos Indicates the obtained AbilityInfos object.
217      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
218      */
219     virtual bool QueryAllAbilityInfos(
220         const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
221     /**
222      * @brief Query the AbilityInfo by ability.uri in config.json.
223      * @param abilityUri Indicates the uri of the ability.
224      * @param abilityInfo Indicates the obtained AbilityInfo object.
225      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
226      */
227     virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override;
228     /**
229      * @brief Query the AbilityInfo by ability.uri in config.json.
230      * @param abilityUri Indicates the uri of the ability.
231      * @param abilityInfos Indicates the obtained AbilityInfos object.
232      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
233      */
234     virtual bool QueryAbilityInfosByUri(
235         const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) override;
236     /**
237      * @brief Query the AbilityInfo by ability.uri in config.json through the proxy object.
238      * @param abilityUri Indicates the uri of the ability.
239      * @param userId Indicates the user ID.
240      * @param abilityInfo Indicates the obtained AbilityInfo object.
241      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
242      */
243     virtual bool QueryAbilityInfoByUri(
244         const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) override;
245     /**
246      * @brief Obtains the BundleInfo of all keep-alive applications in the system.
247      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
248      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
249      */
250     virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override;
251     /**
252      * @brief Obtains the label of a specified ability.
253      * @param bundleName Indicates the bundle name.
254      * @param className Indicates the ability class name.
255      * @return Returns the label of the ability if exist; returns empty string otherwise.
256      */
257     virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) override;
258     /**
259      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
260      * @param hapFilePath Indicates the absolute file path of the HAP.
261      * @param flag Indicates the information contained in the BundleInfo object to be returned.
262      * @param bundleInfo Indicates the obtained BundleInfo object.
263      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
264      */
265     virtual bool GetBundleArchiveInfo(
266         const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override;
267     /**
268      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
269      * @param hapFilePath Indicates the absolute file path of the HAP.
270      * @param flags Indicates the information contained in the BundleInfo object to be returned.
271      * @param bundleInfo Indicates the obtained BundleInfo object.
272      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
273      */
274     virtual bool GetBundleArchiveInfo(
275         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override;
276     /**
277      * @brief Obtain the HAP module info of a specific ability.
278      * @param abilityInfo Indicates the ability.
279      * @param hapModuleInfo Indicates the obtained HapModuleInfo object.
280      * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
281      */
282     virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override;
283     /**
284      * @brief Obtains the Want for starting the main ability of an application based on the given bundle name.
285      * @param bundleName Indicates the bundle name.
286      * @param want Indicates the obtained launch Want object.
287      * @return Returns true if the launch Want object is successfully obtained; returns false otherwise.
288      */
289     virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) override;
290     /**
291      * @brief Checks whether the publickeys of two bundles are the same.
292      * @param firstBundleName Indicates the first bundle name.
293      * @param secondBundleName Indicates the second bundle name.
294      * @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found;
295      *         returns SIGNATURE_NOT_MATCHED if their publickeys are different;
296      *         returns SIGNATURE_MATCHED if their publickeys are the same.
297      */
298     virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override;
299     /**
300      * @brief Checks whether a specified bundle has been granted a specific permission.
301      * @param bundleName Indicates the name of the bundle to check.
302      * @param permission Indicates the permission to check.
303      * @return Returns 0 if the bundle has the permission; returns -1 otherwise.
304      */
305     virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override;
306     /**
307      * @brief Checks whether a specified bundle has been granted a specific permission.
308      * @param bundleName Indicates the name of the bundle to check.
309      * @param permission Indicates the permission to check.
310      * @param userId Indicates the user id.
311      * @return Returns 0 if the bundle has the permission; returns -1 otherwise.
312      */
313     virtual int CheckPermissionByUid(const std::string &bundleName,
314         const std::string &permission, const int userId) override;
315     /**
316      * @brief Obtains detailed information about a specified permission.
317      * @param permissionName Indicates the name of the ohos permission.
318      * @param permissionDef Indicates the object containing detailed information about the given ohos permission.
319      * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise.
320      */
321     virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override;
322     /**
323      * @brief Obtains all known permission groups in the system.
324      * @param permissionDefs Indicates the list of objects containing the permission group information.
325      * @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise.
326      */
327     virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) override;
328     /**
329      * @brief Obtains all known permission groups in the system.
330      * @param permissions Indicates the permission array.
331      * @param appNames Indicates the list of application names that have the specified permissions.
332      * @return Returns true if the application names is successfully obtained; returns false otherwise.
333      */
334     virtual bool GetAppsGrantedPermissions(
335         const std::vector<std::string> &permissions, std::vector<std::string> &appNames) override;
336     /**
337      * @brief Checks whether the system has a specified capability.
338      * @param capName Indicates the name of the system feature to check.
339      * @return Returns true if the given feature specified by name is available in the system; returns false otherwise.
340      */
341     virtual bool HasSystemCapability(const std::string &capName) override;
342     /**
343      * @brief Obtains the capabilities that are available in the system.
344      * @param systemCaps Indicates the list of capabilities available in the system.
345      * @return Returns true if capabilities in the system are successfully obtained; returns false otherwise.
346      */
347     virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override;
348     /**
349      * @brief Checks whether the current device has been started in safe mode.
350      * @return Returns true if the device is in safe mode; returns false otherwise.
351      */
352     virtual bool IsSafeMode() override;
353     /**
354      * @brief Clears cache data of a specified application.
355      * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
356      * @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
357      * @param userId description the user id.
358      * @return Returns true if this function is successfully called; returns false otherwise.
359      */
360     virtual bool CleanBundleCacheFiles(
361         const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback,
362         int32_t userId = Constants::UNSPECIFIED_USERID) override;
363     /**
364      * @brief Clears application running data of a specified application.
365      * @param bundleName Indicates the bundle name of the application whose data is to be cleared.
366      * @param userId Indicates the user id.
367      * @return Returns true if the data cleared successfully; returns false otherwise.
368      */
369     virtual bool CleanBundleDataFiles(const std::string &bundleName,
370         const int userId = Constants::UNSPECIFIED_USERID) override;
371     /**
372      * @brief Register the specific bundle status callback.
373      * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
374      * @return Returns true if this function is successfully called; returns false otherwise.
375      */
376     virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
377 
378     virtual bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override;
379 
380     virtual bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override;
381     /**
382      * @brief Clear the specific bundle status callback.
383      * @param bundleStatusCallback Indicates the callback to be cleared.
384      * @return Returns true if this function is successfully called; returns false otherwise.
385      */
386     virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
387     /**
388      * @brief Unregister all the callbacks of status changed.
389      * @return Returns true if this function is successfully called; returns false otherwise.
390      */
391     virtual bool UnregisterBundleStatusCallback() override;
392     /**
393      * @brief Dump the bundle informations with specific flags.
394      * @param flag Indicates the information contained in the dump result.
395      * @param bundleName Indicates the bundle name if needed.
396      * @param userId Indicates the user ID.
397      * @param result Indicates the dump information result.
398      * @return Returns true if the dump result is successfully obtained; returns false otherwise.
399      */
400     virtual bool DumpInfos(
401         const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override;
402     /**
403      * @brief Checks whether a specified application is enabled.
404      * @param bundleName Indicates the bundle name of the application.
405      * @return Returns true if the application is enabled; returns false otherwise.
406      */
407     virtual bool IsApplicationEnabled(const std::string &bundleName) override;
408     /**
409      * @brief Sets whether to enable a specified application.
410      * @param bundleName Indicates the bundle name of the application.
411      * @param isEnable Specifies whether to enable the application.
412      *                 The value true means to enable it, and the value false means to disable it.
413      * @param userId description the user id.
414      * @return Returns true if the application is enabled; returns false otherwise.
415      */
416     virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable,
417         int32_t userId = Constants::UNSPECIFIED_USERID) override;
418     /**
419      * @brief Sets whether to enable a specified ability through the proxy object.
420      * @param abilityInfo Indicates information about the ability to check.
421      * @return Returns true if the ability is enabled; returns false otherwise.
422      */
423     virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override;
424     /**
425      * @brief Sets whether to enable a specified ability through the proxy object.
426      * @param abilityInfo Indicates information about the ability.
427      * @param isEnabled Specifies whether to enable the ability.
428      *                 The value true means to enable it, and the value false means to disable it.
429      * @param userId description the user id.
430      * @return Returns true if the ability is enabled; returns false otherwise.
431      */
432     virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled,
433         int32_t userId = Constants::UNSPECIFIED_USERID) override;
434     /**
435      * @brief Obtains the icon of a specified ability through the proxy object.
436      * @param bundleName Indicates the bundle name.
437      * @param className Indicates the ability class name.
438      * @return Returns the icon resource string of the ability if exist; returns empty string otherwise.
439      */
440     virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override;
441     /**
442      * @brief Obtains the interface used to install and uninstall bundles.
443      * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise.
444      */
445     virtual sptr<IBundleInstaller> GetBundleInstaller() override;
446     /**
447      * @brief Obtains the interface used to create or delete user.
448      * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise.
449      */
450     virtual sptr<IBundleUserMgr> GetBundleUserMgr() override;
451     /**
452      * @brief Confirms with the permission management module to check whether a request prompt is required for granting
453      * a certain permission.
454      * @param bundleName Indicates the name of the bundle to check.
455      * @param permission Indicates the permission to check.
456      * @param userId Indicates the user id.
457      * @return Returns true if the current application does not have the permission and the user does not turn off
458      * further requests; returns false if the current application already has the permission, the permission is rejected
459      * by the system, or the permission is denied by the user and the user has turned off further requests.
460      */
461     virtual bool CanRequestPermission(
462         const std::string &bundleName, const std::string &permissionName, const int userId) override;
463     /**
464      * @brief Requests a certain permission from user.
465      * @param bundleName Indicates the name of the bundle to request permission.
466      * @param permission Indicates the permission to request permission.
467      * @param userId Indicates the user id.
468      * @return Returns true if the permission request successfully; returns false otherwise.
469      */
470     virtual bool RequestPermissionFromUser(
471         const std::string &bundleName, const std::string &permissionName, const int userId) override;
472     /**
473      * @brief Registers a callback for listening for permission changes of all UIDs.
474      * @param callback Indicates the callback method to register.
475      * @return Returns true if this function is successfully called; returns false otherwise.
476      */
477     virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override;
478     /**
479      * @brief Registers a callback for listening for permission changes of specified UIDs.
480      * @param uids Indicates the list of UIDs whose permission changes will be monitored.
481      * @param callback Indicates the callback method to register.
482      * @return Returns true if this function is successfully called; returns false otherwise.
483      */
484     virtual bool RegisterPermissionsChanged(
485         const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) override;
486     /**
487      * @brief Unregisters a specified callback for listening for permission changes.
488      * @param callback Indicates the callback method to register.
489      * @return Returns true if this function is successfully called; returns false otherwise.
490      */
491     virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override;
492     /**
493      * @brief Obtains the FormInfo objects provided by all applications on the device.
494      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
495      * device.
496      * @return Returns true if this function is successfully called; returns false otherwise.
497      */
498     virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override;
499     /**
500      * @brief Obtains the FormInfo objects provided by a specified application on the device.
501      * @param bundleName Indicates the bundle name of the application.
502      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
503      * device.
504      * @return Returns true if this function is successfully called; returns false otherwise.
505      */
506     virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override;
507     /**
508      * @brief Obtains the FormInfo objects provided by a specified module name.
509      * @param bundleName Indicates the bundle name of the application.
510      * @param moduleName Indicates the module name of the application.
511      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
512      * device.
513      * @return Returns true if this function is successfully called; returns false otherwise.
514      */
515     virtual bool GetFormsInfoByModule(
516         const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override;
517     /**
518      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
519      * @param bundleName Indicates the bundle name of the application.
520      * @param shortcutInfos List of ShortcutInfo objects if obtained.
521      * @return Returns true if GetShortcutInfos successfully; returns false otherwise.
522      */
523     virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
524     /**
525      * @brief Obtains the CommonEventInfo objects provided by an event key on the device.
526      * @param eventKey Indicates the event of the subscribe.
527      * @param commonEventInfos List of CommonEventInfo objects if obtained.
528      * @return Returns true if this function is successfully called; returns false otherwise.
529      */
530     virtual bool GetAllCommonEventInfo(const std::string &eventKey,
531         std::vector<CommonEventInfo> &commonEventInfos) override;
532     /**
533      * @brief Get module usage record list in descending order of lastLaunchTime.
534      * @param maxNum the return size of the records, must be in range of 1 to 1000.
535      * @param moduleUsageRecords List of ModuleUsageRecord objects if obtained.
536      * @return Returns true if this function is successfully called; returns false otherwise.
537      */
538     virtual bool GetModuleUsageRecords(const int32_t number,
539         std::vector<ModuleUsageRecord> &moduleUsageRecords) override;
540     /**
541      * @brief Notify a specified ability for ability.
542      * @param bundleName Indicates the bundle name of the ability to ability.
543      * @param abilityName Indicates the name of the ability to ability.
544      * @param launchTime Indicates the ability launchTime.
545      * @param uid Indicates the uid.
546      * @return Returns true if this function is successfully called; returns false otherwise.
547      */
548     virtual bool NotifyAbilityLifeStatus(const std::string &bundleName,
549         const std::string &abilityName, const int64_t launchTime, const int uid) override;
550     /**
551      * @brief Remove cloned bundle.
552      * @param bundleName Indicates the bundle name of remove cloned bundle.
553      * @param uid Indicates the uid of remove cloned bundle.
554      * @return Returns true if this function is successfully called; returns false otherwise.
555      */
556     virtual bool RemoveClonedBundle(const std::string &bundleName, const int32_t uid) override;
557     /**
558      * @brief create bundle clone.
559      * @param bundleName Indicates the bundle name of create bundle clone.
560      * @return Returns true if this function is successfully called; returns false otherwise.
561      */
562     virtual bool BundleClone(const std::string &bundleName) override;
563     /**
564      * @brief Determine whether the application is in the allow list.
565      * @param bundleName Indicates the bundle Names.
566      * @return Returns true if bundle name in the allow list successfully; returns false otherwise.
567      */
568     virtual bool CheckBundleNameInAllowList(const std::string &bundleName) override;
569     /**
570      * @brief Obtains the DistributedBundleInfo based on a given bundle name and networkId.
571      * @param networkId Indicates the networkId of remote device.
572      * @param userId Indicates the user id.
573      * @param bundleName Indicates the application bundle name to be queried.
574      * @param distributedBundleInfo Indicates the obtained DistributedBundleInfo object.
575      * @return Returns true if the DistributedBundleInfo is successfully obtained; returns false otherwise.
576      */
577     virtual bool GetDistributedBundleInfo(
578         const std::string &networkId, int32_t userId, const std::string &bundleName,
579         DistributedBundleInfo &distributedBundleInfo) override;
580     /**
581      * @brief Get app privilege level.
582      * @param bundleName Indicates the bundle name of the app privilege level.
583      * @param userId Indicates the user id.
584      * @return Returns app privilege level.
585      */
586     virtual std::string GetAppPrivilegeLevel(
587         const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID) override;
588     /**
589      * @brief Query extension info.
590      * @param Want Indicates the information of extension info.
591      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
592      * @param userId Indicates the userId in the system.
593      * @param extensionInfos Indicates the obtained extensions.
594      * @return Returns true if this function is successfully called; returns false otherwise.
595      */
596     virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId,
597         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
598     /**
599      * @brief Query extension info.
600      * @param Want Indicates the information of extension info.
601      * @param extensionType Indicates the type of the extension.
602      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
603      * @param userId Indicates the userId in the system.
604      * @param extensionInfos Indicates the obtained extensions.
605      * @return Returns true if this function is successfully called; returns false otherwise.
606      */
607     virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType,
608         const int32_t &flag, const int32_t &userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
609 
610     virtual bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId,
611         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
612 
613     virtual bool VerifyCallingPermission(const std::string &permission) override;
614 
615     virtual std::vector<std::string> GetAccessibleAppCodePaths(int32_t userId) override;
616 
617     virtual bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId,
618         ExtensionAbilityInfo &extensionAbilityInfo) override;
619 
620     virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override;
621 
622     virtual std::string GetAppType(const std::string &bundleName) override;
623 
624     virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
625 
626     virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId,
627         AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) override;
628 #ifdef SUPPORT_GRAPHICS
629     virtual std::shared_ptr<Media::PixelMap> GetAbilityPixelMapIcon(const std::string &bundleName,
630         const std::string &abilityName) override;
631 #endif
632 private:
633     const std::shared_ptr<BundleCloneMgr> GetCloneMgrFromService();
634     const std::shared_ptr<BundleDataMgr> GetDataMgrFromService();
635     bool GetBundleUserInfo(
636         const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo);
637     bool GetBundleUserInfos(
638         const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos);
639     bool GetShortcutInfos(
640         const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos);
641     bool DumpAllBundleInfoNames(int32_t userId, std::string &result);
642     bool DumpAllBundleInfoNamesByUserId(int32_t userId, std::string &result);
643     bool DumpAllBundleInfos(int32_t userId, std::string &result);
644     bool DumpBundleInfo(const std::string &bundleName, int32_t userId, std::string &result);
645     bool DumpShortcutInfo(const std::string &bundleName, int32_t userId, std::string &result);
646     std::set<int32_t> GetExistsCommonUserIs();
647     bool VerifyQueryPermission(const std::string &queryBundleName);
648     void CleanBundleCacheTask(const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback,
649         const std::string &applicationDataDir, int32_t userId);
650 
651     std::shared_ptr<BMSEventHandler> handler_;
652 };
653 }  // namespace AppExecFwk
654 }  // namespace OHOS
655 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H
656