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