1 /*
2  * Copyright (c) 2021-2024 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 <atomic>
20 
21 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
22 #include "bundle_connect_ability_mgr.h"
23 #endif
24 #include "bundle_common_event_mgr.h"
25 #include "bundle_data_mgr.h"
26 #include "bundle_mgr_host.h"
27 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK
28 #include "distributed_bms_interface.h"
29 #endif
30 #include "inner_bundle_user_info.h"
31 
32 namespace OHOS {
33 namespace AppExecFwk {
34 class BundleMgrHostImpl : public BundleMgrHost {
35 public:
36     BundleMgrHostImpl() = default;
37     virtual ~BundleMgrHostImpl() = default;
38     /**
39      * @brief Obtains the ApplicationInfo based on a given bundle name.
40      * @param appName Indicates the application bundle name to be queried.
41      * @param flag Indicates the flag used to specify information contained
42      *             in the ApplicationInfo object that will be returned.
43      * @param userId Indicates the user ID.
44      * @param appInfo Indicates the obtained ApplicationInfo object.
45      * @return Returns true if the application is successfully obtained; returns false otherwise.
46      */
47     virtual bool GetApplicationInfo(
48         const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
49     /**
50      * @brief Obtains the ApplicationInfo based on a given bundle name.
51      * @param appName Indicates the application bundle name to be queried.
52      * @param flags Indicates the flag used to specify information contained
53      *             in the ApplicationInfo object that will be returned.
54      * @param userId Indicates the user ID.
55      * @param appInfo Indicates the obtained ApplicationInfo object.
56      * @return Returns true if the application is successfully obtained; returns false otherwise.
57      */
58     virtual bool GetApplicationInfo(
59         const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override;
60     /**
61      * @brief Obtains the ApplicationInfo based on a given bundle name.
62      * @param appName Indicates the application bundle name to be queried.
63      * @param flags Indicates the flag used to specify information contained
64      *             in the ApplicationInfo object that will be returned.
65      * @param userId Indicates the user ID.
66      * @param appInfo Indicates the obtained ApplicationInfo object.
67      * @return Returns ERR_OK if the application is successfully obtained; returns error code otherwise.
68      */
69     virtual ErrCode GetApplicationInfoV9(
70         const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) override;
71     /**
72      * @brief Obtains information about all installed applications of a specified user.
73      * @param flag Indicates the flag used to specify information contained
74      *             in the ApplicationInfo objects that will be returned.
75      * @param userId Indicates the user ID.
76      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
77      * @return Returns true if the applications is successfully obtained; returns false otherwise.
78      */
79     virtual bool GetApplicationInfos(
80         const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override;
81     /**
82      * @brief Obtains information about all installed applications of a specified user.
83      * @param flags Indicates the flag used to specify information contained
84      *             in the ApplicationInfo objects that will be returned.
85      * @param userId Indicates the user ID.
86      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
87      * @return Returns true if the applications is successfully obtained; returns false otherwise.
88      */
89     virtual bool GetApplicationInfos(
90         int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override;
91     /**
92      * @brief Obtains information about all installed applications of a specified user.
93      * @param flags Indicates the flag used to specify information contained
94      *             in the ApplicationInfo objects that will be returned.
95      * @param userId Indicates the user ID.
96      * @param appInfos Indicates all of the obtained ApplicationInfo objects.
97      * @return Returns ERR_OK if the applications is successfully obtained; returns error code otherwise.
98      */
99     virtual ErrCode GetApplicationInfosV9(
100         int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) override;
101     /**
102      * @brief Obtains the BundleInfo based on a given bundle name.
103      * @param bundleName Indicates the application bundle name to be queried.
104      * @param flag Indicates the information contained in the BundleInfo object to be returned.
105      * @param bundleInfo Indicates the obtained BundleInfo object.
106      * @param userId Indicates the user ID.
107      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
108      */
109     virtual bool GetBundleInfo(const std::string &bundleName,
110         const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
111     /**
112      * @brief Obtains the BundleInfo based on a given bundle name.
113      * @param bundleName Indicates the application bundle name to be queried.
114      * @param flags Indicates the information contained in the BundleInfo object to be returned.
115      * @param bundleInfo Indicates the obtained BundleInfo object.
116      * @param userId Indicates the user ID.
117      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
118      */
119     virtual bool GetBundleInfo(const std::string &bundleName,
120         int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
121     /**
122      * @brief Obtains the BundleInfo based on a given bundle name.
123      * @param bundleName Indicates the application bundle name to be queried.
124      * @param flags Indicates the information contained in the BundleInfo object to be returned.
125      * @param bundleInfo Indicates the obtained BundleInfo object.
126      * @param userId Indicates the user ID.
127      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
128      */
129     virtual ErrCode GetBundleInfoV9(const std::string &bundleName,
130         int32_t flags, BundleInfo &bundleInfo, int32_t userId) override;
131     /**
132      * @brief Batch obtains the BundleInfos based on a given bundle name list.
133      * @param bundleNames Indicates the application bundle name list to be queried.
134      * @param flags Indicates the information contained in the BundleInfo object to be returned.
135      * @param bundleInfos Indicates the obtained BundleInfos object.
136      * @param userId Indicates the user ID.
137      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
138      */
139     virtual ErrCode BatchGetBundleInfo(const std::vector<std::string> &bundleNames,
140         int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) override;
141     /**
142      * @brief Obtains the BundleInfo based on a given bundle name.
143      * @param flags Indicates the information contained in the BundleInfo object to be returned.
144      * @param bundleInfo Indicates the obtained BundleInfo object.
145      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
146      */
147     virtual ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo) override;
148     /**
149      * @brief Obtains the BundleInfo based on a given bundle name, which the calling app depends on.
150      * @param sharedBundleName Indicates the bundle name to be queried.
151      * @param sharedBundleInfo Indicates the obtained BundleInfo object.
152      * @param flag Indicates the flag, GetDependentBundleInfoFlag.
153      * @return Returns ERR_OK if the BundleInfo is successfully obtained; returns error code otherwise.
154      */
155     virtual ErrCode GetDependentBundleInfo(const std::string &sharedBundleName, BundleInfo &sharedBundleInfo,
156         GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO) override;
157     /**
158      * @brief Obtains the BundlePackInfo based on a given bundle name.
159      * @param bundleName Indicates the application bundle name to be queried.
160      * @param flags Indicates the information contained in the BundleInfo object to be returned.
161      * @param BundlePackInfo Indicates the obtained BundlePackInfo object.
162      * @param userId Indicates the user ID.
163      * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise.
164      */
165     virtual ErrCode GetBundlePackInfo(const std::string &bundleName, const BundlePackFlag flag,
166         BundlePackInfo &bundlePackInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
167 
168     /**
169      * @brief Obtains the BundlePackInfo based on a given bundle name.
170      * @param bundleName Indicates the application bundle name to be queried.
171      * @param flags Indicates the information contained in the BundleInfo object to be returned.
172      * @param BundlePackInfo Indicates the obtained BundlePackInfo object.
173      * @param userId Indicates the user ID.
174      * @return Returns ERR_OK if the BundlePackInfo is successfully obtained; returns other ErrCode otherwise.
175      */
176     virtual ErrCode GetBundlePackInfo(const std::string &bundleName, int32_t flags, BundlePackInfo &bundlePackInfo,
177         int32_t userId = Constants::UNSPECIFIED_USERID) override;
178 
179     /**
180      * @brief Obtains BundleInfo of all bundles available in the system.
181      * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned.
182      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
183      * @param userId Indicates the user ID.
184      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
185      */
186     virtual bool GetBundleInfos(const BundleFlag flag,
187         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
188     /**
189      * @brief Obtains BundleInfo of all bundles available in the system.
190      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
191      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
192      * @param userId Indicates the user ID.
193      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
194      */
195     virtual bool GetBundleInfos(int32_t flags,
196         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
197     /**
198      * @brief Obtains BundleInfo of all bundles available in the system.
199      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
200      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
201      * @param userId Indicates the user ID.
202      * @return Returns ERR_OK if the BundleInfos is successfully obtained; returns error code otherwise.
203      */
204     virtual ErrCode GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId) override;
205     /**
206      * @brief Obtains the application UID based on the given bundle name and user ID.
207      * @param bundleName Indicates the bundle name of the application.
208      * @param userId Indicates the user ID.
209      * @return Returns the uid if successfully obtained; returns -1 otherwise.
210      */
211     virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override;
212     /**
213      * @brief Obtains all bundle names of a specified application based on the given application UID.
214      * @param uid Indicates the uid.
215      * @param bundleNames Indicates the obtained bundle names.
216      * @return Returns true if the bundle names is successfully obtained; returns false otherwise.
217      */
218     virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override;
219     /**
220      * @brief Obtains the formal name associated with the given UID.
221      * @param uid Indicates the uid.
222      * @param name Indicates the obtained formal name.
223      * @return Returns ERR_OK if execute success; returns errCode otherwise.
224      */
225     virtual ErrCode GetNameForUid(const int uid, std::string &name) override;
226     /**
227      * @brief Obtains the formal name associated with the given UID.
228      * @param uid Indicates the uid.
229      * @param name Indicates the obtained formal bundleName.
230      * @param appIndex Indicates the obtained appIndex.
231      * @return Returns ERR_OK if execute success; returns errCode otherwise.
232      */
233     virtual ErrCode GetNameAndIndexForUid(const int uid, std::string &bundleName, int32_t &appIndex) override;
234     /**
235      * @brief Obtains an array of all group IDs associated with a specified bundle.
236      * @param bundleName Indicates the bundle name.
237      * @param gids Indicates the group IDs associated with the specified bundle.
238      * @return Returns true if the gids is successfully obtained; returns false otherwise.
239      */
240     virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override;
241     /**
242      * @brief Obtains an array of all group IDs associated with the given bundle name and UID.
243      * @param bundleName Indicates the bundle name.
244      * @param uid Indicates the uid.
245      * @param gids Indicates the group IDs associated with the specified bundle.
246      * @return Returns true if the gids is successfully obtained; returns false otherwise.
247      */
248     virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) override;
249     /**
250      * @brief Check whether the app is system app by it's UID.
251      * @param uid Indicates the uid.
252      * @return Returns true if the bundle is a system application; returns false otherwise.
253      */
254     virtual bool CheckIsSystemAppByUid(const int uid) override;
255     /**
256      * @brief Obtains the BundleInfo of application bundles based on the specified metaData.
257      * @param metaData Indicates the metadata to get in the bundle.
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 GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override;
262     /**
263      * @brief Query the AbilityInfo by the given Want.
264      * @param want Indicates the information of the ability.
265      * @param abilityInfo Indicates the obtained AbilityInfo object.
266      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
267      */
268     virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
269 
270 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
271     /**
272      * @brief Query the AbilityInfo by the given Want.
273      * @param want Indicates the information of the ability.
274      * @param abilityInfo Indicates the obtained AbilityInfo object.
275      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
276      */
277     virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId,
278         AbilityInfo &abilityInfo, const sptr<IRemoteObject> &callBack) override;
279 
280     /**
281      * @brief Silent install by the given Want.
282      * @param want Indicates the information of the want.
283      * @param userId Indicates the user ID.
284      * @param callBack Indicates the callback to be invoked for return the operation result.
285      * @return Returns true if silent install successfully; returns false otherwise.
286      */
287     virtual bool SilentInstall(const Want &want, int32_t userId, const sptr<IRemoteObject> &callBack) override;
288 
289     virtual bool CheckAbilityEnableInstall(
290         const Want &want, int32_t missionId, int32_t userId, const sptr<IRemoteObject> &callback) override;
291 #endif
292     /**
293      * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object.
294      * @param bundleName Indicates the application bundle name to be queried.
295      * @param abilityName Indicates the application ability name to be queried.
296      * @param abilityInfo Indicates the obtained AbilityInfo object.
297      * @return Returns true if the application is successfully obtained; returns false otherwise.
298      */
299     virtual bool GetAbilityInfo(
300         const std::string &bundleName, const std::string &abilityName, AbilityInfo &abilityInfo) override;
301     /**
302      * @brief Obtains the AbilityInfo based on a given bundle name through the proxy object.
303      * @param bundleName Indicates the application bundle name to be queried.
304      * @param moduleName Indicates the module name to be queried.
305      * @param abilityName Indicates the application ability name to be queried.
306      * @param abilityInfo Indicates the obtained AbilityInfo object.
307      * @return Returns true if the application is successfully obtained; returns false otherwise.
308      */
309     virtual bool GetAbilityInfo(
310         const std::string &bundleName, const std::string &moduleName,
311         const std::string &abilityName, AbilityInfo &abilityInfo) override;
312     /**
313      * @brief Query the AbilityInfo by the given Want.
314      * @param want Indicates the information of the ability.
315      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
316      * @param userId Indicates the user ID.
317      * @param abilityInfo Indicates the obtained AbilityInfo object.
318      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
319      */
320     virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) override;
321 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
322     /**
323      * @brief Upgrade atomic service
324      * @param want Indicates the information of the ability.
325      * @param userId Indicates the user ID.
326      */
327     virtual void UpgradeAtomicService(const Want &want, int32_t userId) override;
328 
329     virtual bool ProcessPreload(const Want &want) override;
330 #endif
331     /**
332      * @brief Query the AbilityInfo of list by the given Want.
333      * @param want Indicates the information of the ability.
334      * @param abilityInfos Indicates the obtained AbilityInfos object.
335      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
336      */
337     virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
338     /**
339      * @brief Query the AbilityInfo of list by the given Want.
340      * @param want Indicates the information of the ability.
341      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
342      * @param userId Indicates the user ID.
343      * @param abilityInfos Indicates the obtained AbilityInfos object.
344      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
345      */
346     virtual bool QueryAbilityInfos(
347         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
348     /**
349      * @brief Query the AbilityInfo of list by the given Want.
350      * @param want Indicates the information of the ability.
351      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
352      * @param userId Indicates the user ID.
353      * @param abilityInfos Indicates the obtained AbilityInfos object.
354      * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise.
355      */
356     virtual ErrCode QueryAbilityInfosV9(
357         const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
358     /**
359      * @brief Batch query the AbilityInfo of list by the given Wants.
360      * @param wants Indicates the information of the abilities.
361      * @param flags Indicates the information contained in the AbilityInfo object to be returned.
362      * @param userId Indicates the user ID.
363      * @param abilityInfos Indicates the obtained AbilityInfos object.
364      * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise.
365      */
366     virtual ErrCode BatchQueryAbilityInfos(
367         const std::vector<Want> &wants, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
368     /**
369      * @brief Query the launcher AbilityInfo of list by the given Want.
370      * @param want Indicates the information of the ability.
371      * @param userId Indicates the user ID.
372      * @param abilityInfos Indicates the obtained AbilityInfos object.
373      * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise.
374      */
375     virtual ErrCode QueryLauncherAbilityInfos(const Want &want,
376         int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
377     /**
378      * @brief Query the AbilityInfo of list of all service on launcher.
379      * @param userId Indicates the information of the user.
380      * @param abilityInfos Indicates the obtained AbilityInfos object.
381      * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
382      */
383     virtual bool QueryAllAbilityInfos(
384         const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) override;
385     /**
386      * @brief Query the AbilityInfo by ability.uri in config.json.
387      * @param abilityUri Indicates the uri of the ability.
388      * @param abilityInfo Indicates the obtained AbilityInfo object.
389      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
390      */
391     virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override;
392     /**
393      * @brief Query the AbilityInfo by ability.uri in config.json.
394      * @param abilityUri Indicates the uri of the ability.
395      * @param abilityInfos Indicates the obtained AbilityInfos object.
396      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
397      */
398     virtual bool QueryAbilityInfosByUri(
399         const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) override;
400     /**
401      * @brief Query the AbilityInfo by ability.uri in config.json through the proxy object.
402      * @param abilityUri Indicates the uri of the ability.
403      * @param userId Indicates the user ID.
404      * @param abilityInfo Indicates the obtained AbilityInfo object.
405      * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
406      */
407     virtual bool QueryAbilityInfoByUri(
408         const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) override;
409     /**
410      * @brief Obtains the BundleInfo of all keep-alive applications in the system.
411      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
412      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
413      */
414     virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override;
415     /**
416      * @brief Obtains the label of a specified ability.
417      * @param bundleName Indicates the bundle name.
418      * @param abilityName Indicates the ability name.
419      * @return Returns the label of the ability if exist; returns empty string otherwise.
420      */
421     virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &abilityName) override;
422     /**
423      * @brief Obtains the label of a specified ability.
424      * @param bundleName Indicates the bundle name.
425      * @param moduleName Indicates the module name.
426      * @param abilityName Indicates the ability name.
427      * @param label Indicates the obtained label.
428      * @return Returns ERR_OK if called successfully; returns error code otherwise.
429      */
430     virtual ErrCode GetAbilityLabel(const std::string &bundleName, const std::string &moduleName,
431         const std::string &abilityName, std::string &label) override;
432     /**
433      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
434      * @param hapFilePath Indicates the absolute file path of the HAP.
435      * @param flag Indicates the information contained in the BundleInfo object to be returned.
436      * @param bundleInfo Indicates the obtained BundleInfo object.
437      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
438      */
439     virtual bool GetBundleArchiveInfo(
440         const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override;
441     /**
442      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
443      * @param hapFilePath Indicates the absolute file path of the HAP.
444      * @param flags Indicates the information contained in the BundleInfo object to be returned.
445      * @param bundleInfo Indicates the obtained BundleInfo object.
446      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
447      */
448     virtual bool GetBundleArchiveInfo(
449         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override;
450     /**
451      * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
452      * @param hapFilePath Indicates the absolute file path of the HAP.
453      * @param flags Indicates the information contained in the BundleInfo object to be returned.
454      * @param bundleInfo Indicates the obtained BundleInfo object.
455      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
456      */
457     virtual ErrCode GetBundleArchiveInfoV9(
458         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) override;
459     /**
460      * @brief Obtain the HAP module info of a specific ability.
461      * @param abilityInfo Indicates the ability.
462      * @param hapModuleInfo Indicates the obtained HapModuleInfo object.
463      * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
464      */
465     virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override;
466     /**
467      * @brief Obtain the HAP module info of a specific ability through the proxy object.
468      * @param abilityInfo Indicates the ability.
469      * @param userId Indicates the userId.
470      * @param hapModuleInfo Indicates the obtained HapModuleInfo object.
471      * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
472      */
473     virtual bool GetHapModuleInfo(
474         const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo) override;
475     /**
476      * @brief Obtains the Want for starting the main ability of an application based on the given bundle name.
477      * @param bundleName Indicates the bundle name.
478      * @param want Indicates the obtained launch Want object.
479      * @param userId Indicates the userId.
480      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
481      */
482     virtual ErrCode GetLaunchWantForBundle(
483         const std::string &bundleName, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) override;
484     /**
485      * @brief Obtains detailed information about a specified permission.
486      * @param permissionName Indicates the name of the ohos permission.
487      * @param permissionDef Indicates the object containing detailed information about the given ohos permission.
488      * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise.
489      */
490     virtual ErrCode GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override;
491     /**
492      * @brief Clears cache data of a specified size.
493      * @param cacheSize Indicates the size of the cache data is to be cleared.
494      * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
495      */
496     virtual ErrCode CleanBundleCacheFilesAutomatic(uint64_t cacheSize) override;
497     /**
498      * @brief Clears cache data of a specified application.
499      * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
500      * @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
501      * @param userId description the user id.
502      * @param appIndex Indicates the app index.
503      * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
504      */
505     virtual ErrCode CleanBundleCacheFiles(
506         const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
507         int32_t userId = Constants::UNSPECIFIED_USERID, int32_t appIndex = 0) override;
508     /**
509      * @brief Clears application running data of a specified application.
510      * @param bundleName Indicates the bundle name of the application whose data is to be cleared.
511      * @param userId Indicates the user id.
512      * @param appIndex Indicates the app index.
513      * @return Returns true if the data cleared successfully; returns false otherwise.
514      */
515     virtual bool CleanBundleDataFiles(const std::string &bundleName,
516         const int userId = Constants::UNSPECIFIED_USERID, const int appIndex = 0) override;
517     /**
518      * @brief Register the specific bundle status callback.
519      * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
520      * @return Returns true if this function is successfully called; returns false otherwise.
521      */
522     virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
523 
524     virtual bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override;
525 
526     virtual bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) override;
527     /**
528      * @brief Clear the specific bundle status callback.
529      * @param bundleStatusCallback Indicates the callback to be cleared.
530      * @return Returns true if this function is successfully called; returns false otherwise.
531      */
532     virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
533     /**
534      * @brief Unregister all the callbacks of status changed.
535      * @return Returns true if this function is successfully called; returns false otherwise.
536      */
537     virtual bool UnregisterBundleStatusCallback() override;
538     /**
539      * @brief Dump the bundle informations with specific flags.
540      * @param flag Indicates the information contained in the dump result.
541      * @param bundleName Indicates the bundle name if needed.
542      * @param userId Indicates the user ID.
543      * @param result Indicates the dump information result.
544      * @return Returns true if the dump result is successfully obtained; returns false otherwise.
545      */
546     virtual bool DumpInfos(
547         const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) override;
548     /**
549      * @brief Compile the bundle informations with specific flags.
550      * @param bundleName Indicates the bundle name if needed.
551      * @param compileMode Indicates the mode name.
552      * @param isAllBundle Does it represent all bundlenames.
553      * @return Returns true if the compile result is successfully obtained; returns false otherwise.
554      */
555     virtual ErrCode CompileProcessAOT(const std::string &bundleName, const std::string &compileMode,
556         bool isAllBundle, std::vector<std::string> &compileResults) override;
557     /**
558      * @brief Compile the bundle informations with specific flags.
559      * @param bundleName Indicates the bundle name if needed.
560      * @param isAllBundle Does it represent all bundlenames.
561      * @return Returns true if the compile result is successfully obtained; returns false otherwise.
562      */
563     virtual ErrCode CompileReset(const std::string &bundleName, bool isAllBundle) override;
564     /**
565      * @brief copy ap file to /data/local/pgo.
566      * @param bundleName Indicates the bundle name if needed.
567      * @param isAllBundle Does it represent all bundlenames.
568      * @param result Indicates the copy ap information result.
569      * @return Returns ERR_OK if called successfully; returns error code otherwise.
570      */
571     virtual ErrCode CopyAp(const std::string &bundleName, bool isAllBundle, std::vector<std::string> &results) override;
572     /**
573      * @brief Checks whether a specified application is enabled.
574      * @param bundleName Indicates the bundle name of the application.
575      * @param isEnable Indicates the application status is enabled.
576      * @return Returns result of the operation.
577      */
578     virtual ErrCode IsApplicationEnabled(const std::string &bundleName, bool &isEnable) override;
579     /**
580      * @brief Checks whether a specified clone application is enabled.
581      * @param bundleName Indicates the bundle name of the application.
582      * @param appIndex Indicates the app index of clone applications.
583      * @param isEnable Indicates the application status is enabled.
584      * @return Returns result of the operation.
585      */
586     virtual ErrCode IsCloneApplicationEnabled(
587         const std::string &bundleName, int32_t appIndex, bool &isEnable) override;
588     /**
589      * @brief Sets whether to enable a specified application.
590      * @param bundleName Indicates the bundle name of the application.
591      * @param isEnable Specifies whether to enable the application.
592      *                 The value true means to enable it, and the value false means to disable it.
593      * @param userId description the user id.
594      * @return Returns result of the operation.
595      */
596     virtual ErrCode SetApplicationEnabled(const std::string &bundleName, bool isEnable,
597         int32_t userId = Constants::UNSPECIFIED_USERID) override;
598     /**
599      * @brief Sets whether to enable a specified clone application.
600      * @param bundleName Indicates the bundle name of the application.
601      * @param appIndex Indicates the app index of clone applications.
602      * @param isEnable Specifies whether to enable the application.
603      *                 The value true means to enable it, and the value false means to disable it.
604      * @param userId description the user id.
605      * @return Returns result of the operation.
606      */
607     virtual ErrCode SetCloneApplicationEnabled(const std::string &bundleName, int32_t appIndex, bool isEnable,
608         int32_t userId = Constants::UNSPECIFIED_USERID) override;
609     /**
610      * @brief Sets whether to enable a specified ability through the proxy object.
611      * @param abilityInfo Indicates information about the ability to check.
612      * @param isEnable Indicates the ability status is enabled.
613      * @return Returns result of the operation.
614      */
615     virtual ErrCode IsAbilityEnabled(const AbilityInfo &abilityInfo, bool &isEnable) override;
616     /**
617      * @brief Sets whether to enable a specified ability.
618      * @param abilityInfo Indicates information about the ability to check.
619      * @param appIndex Indicates the app index of clone applications.
620      * @param isEnable Indicates the ability status is enabled.
621      * @return Returns result of the operation.
622      */
623     virtual ErrCode IsCloneAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool &isEnable) override;
624     /**
625      * @brief Sets whether to enable a specified ability through the proxy object.
626      * @param abilityInfo Indicates information about the ability.
627      * @param isEnabled Specifies whether to enable the ability.
628      *                 The value true means to enable it, and the value false means to disable it.
629      * @param userId description the user id.
630      * @return Returns result of the operation.
631      */
632     virtual ErrCode SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled,
633         int32_t userId = Constants::UNSPECIFIED_USERID) override;
634     /**
635      * @brief Sets whether to enable a specified ability through the proxy object.
636      * @param abilityInfo Indicates information about the ability.
637      * @param appIndex Indicates the app index of clone applications.
638      * @param isEnabled Specifies whether to enable the ability.
639      *                 The value true means to enable it, and the value false means to disable it.
640      * @param userId description the user id.
641      * @return Returns result of the operation.
642      */
643     virtual ErrCode SetCloneAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool isEnabled,
644         int32_t userId = Constants::UNSPECIFIED_USERID) override;
645     /**
646      * @brief Obtains the interface used to install and uninstall bundles.
647      * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise.
648      */
649     virtual sptr<IBundleInstaller> GetBundleInstaller() override;
650     /**
651      * @brief Obtains the interface used to create or delete user.
652      * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise.
653      */
654     virtual sptr<IBundleUserMgr> GetBundleUserMgr() override;
655     /**
656      * @brief Obtains the IVerifyManager.
657      * @return Returns a pointer to IVerifyManager class if exist; returns nullptr otherwise.
658      */
659     virtual sptr<IVerifyManager> GetVerifyManager() override;
660     /**
661      * @brief Obtains the FormInfo objects provided by all applications on the device.
662      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
663      * device.
664      * @return Returns true if this function is successfully called; returns false otherwise.
665      */
666     virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override;
667     /**
668      * @brief Obtains the FormInfo objects provided by a specified application on the device.
669      * @param bundleName Indicates the bundle name of the application.
670      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
671      * device.
672      * @return Returns true if this function is successfully called; returns false otherwise.
673      */
674     virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override;
675     /**
676      * @brief Obtains the FormInfo objects provided by a specified module name.
677      * @param bundleName Indicates the bundle name of the application.
678      * @param moduleName Indicates the module name of the application.
679      * @param formInfos List of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
680      * device.
681      * @return Returns true if this function is successfully called; returns false otherwise.
682      */
683     virtual bool GetFormsInfoByModule(
684         const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override;
685     /**
686      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
687      * @param bundleName Indicates the bundle name of the application.
688      * @param shortcutInfos List of ShortcutInfo objects if obtained.
689      * @return Returns true if GetShortcutInfos successfully; returns false otherwise.
690      */
691     virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
692 
693     /**
694      * @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
695      * @param bundleName Indicates the bundle name of the application.
696      * @param shortcutInfos List of ShortcutInfo objects if obtained.
697      * @return Returns errCode of result.
698      */
699     virtual ErrCode GetShortcutInfoV9(const std::string &bundleName,
700         std::vector<ShortcutInfo> &shortcutInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
701     /**
702      * @brief Obtains the CommonEventInfo objects provided by an event key on the device.
703      * @param eventKey Indicates the event of the subscribe.
704      * @param commonEventInfos List of CommonEventInfo objects if obtained.
705      * @return Returns true if this function is successfully called; returns false otherwise.
706      */
707     virtual bool GetAllCommonEventInfo(const std::string &eventKey,
708         std::vector<CommonEventInfo> &commonEventInfos) override;
709     /**
710      * @brief Obtains the DistributedBundleInfo based on a given bundle name and networkId.
711      * @param networkId Indicates the networkId of remote device.
712      * @param bundleName Indicates the application bundle name to be queried.
713      * @param distributedBundleInfo Indicates the obtained DistributedBundleInfo object.
714      * @return Returns true if the DistributedBundleInfo is successfully obtained; returns false otherwise.
715      */
716     virtual bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName,
717         DistributedBundleInfo &distributedBundleInfo) override;
718     /**
719      * @brief Get app privilege level.
720      * @param bundleName Indicates the bundle name of the app privilege level.
721      * @param userId Indicates the user id.
722      * @return Returns app privilege level.
723      */
724     virtual std::string GetAppPrivilegeLevel(
725         const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID) override;
726     /**
727      * @brief Query extension info.
728      * @param Want Indicates the information of extension info.
729      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
730      * @param userId Indicates the userId in the system.
731      * @param extensionInfos Indicates the obtained extensions.
732      * @return Returns true if this function is successfully called; returns false otherwise.
733      */
734     virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId,
735         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
736     /**
737      * @brief Query extension info.
738      * @param Want Indicates the information of extension info.
739      * @param flag Indicates the query flag which will filter any specified stuff in the extension info.
740      * @param userId Indicates the userId in the system.
741      * @param extensionInfos Indicates the obtained extensions.
742      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
743      */
744     virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId,
745         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
746     /**
747      * @brief Query extension info.
748      * @param Want Indicates the information of extension info.
749      * @param extensionType Indicates the type of the extension.
750      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
751      * @param userId Indicates the userId in the system.
752      * @param extensionInfos Indicates the obtained extensions.
753      * @return Returns true if this function is successfully called; returns false otherwise.
754      */
755     virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType,
756         const int32_t &flag, const int32_t &userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
757     /**
758      * @brief Query extension info.
759      * @param Want Indicates the information of extension info.
760      * @param extensionType Indicates the type of the extension.
761      * @param flag Indicates the query flag which will filter any specified stuff in the extension info.
762      * @param userId Indicates the userId in the system.
763      * @param extensionInfos Indicates the obtained extensions.
764      * @return Returns ERR_OK if this function is successfully called; returns errCode otherwise.
765      */
766     virtual ErrCode QueryExtensionAbilityInfosV9(const Want &want, const ExtensionAbilityType &extensionType,
767         int32_t flags, int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
768     /**
769      * @brief Process hidump.
770      * @param fd Indicates the fd.
771      * @param args Indicates the params.
772      * @return Returns the dump result.
773      */
774     int Dump(int fd, const std::vector<std::u16string> &args) override;
775 
776     virtual bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId,
777         std::vector<ExtensionAbilityInfo> &extensionInfos) override;
778 
779     virtual bool VerifyCallingPermission(const std::string &permission) override;
780 
781     virtual sptr<IExtendResourceManager> GetExtendResourceManager() override;
782 
783     virtual bool VerifySystemApi(int32_t beginApiVersion = Constants::INVALID_API_VERSION) override;
784 
785     virtual bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId,
786         ExtensionAbilityInfo &extensionAbilityInfo) override;
787 
788     virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override;
789 
790     virtual std::string GetAppType(const std::string &bundleName) override;
791 
792     virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId) override;
793 
794     virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId,
795         int32_t appIndex) override;
796 
797     virtual int GetUidByDebugBundleName(const std::string &bundleName, const int userId) override;
798 
799     virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId,
800         AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) override;
801 
802     virtual bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault,
803         std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos,
804         bool &findDefaultApp) override;
805 
806     /**
807      * @brief Obtains the value of isRemovable based on a given bundle name and module name.
808      * @param bundleName Indicates the bundle name to be queried.
809      * @param moduleName Indicates the module name to be queried.
810      * @param isRemovable Indicates the module whether is removable.
811      * @return Returns ERR_OK if the isRemovable is successfully obtained; returns other ErrCode otherwise.
812      */
813     virtual ErrCode IsModuleRemovable(const std::string &bundleName, const std::string &moduleName,
814         bool &isRemovable) override;
815     /**
816      * @brief Sets whether to enable isRemovable based on a given bundle name and module name.
817      * @param bundleName Indicates the bundle name to be queried.
818      * @param moduleName Indicates the module name to be queried.
819      * @param isEnable Specifies whether to enable the isRemovable of InnerModuleInfo.
820      *                 The value true means to enable it, and the value false means to disable it
821      * @return Returns true if the isRemovable is successfully obtained; returns false otherwise.
822      */
823     virtual bool SetModuleRemovable(
824         const std::string &bundleName, const std::string &moduleName, bool isEnable) override;
825     /**
826      * @brief Obtains the dependent module names.
827      *
828      * @param bundleName Indicates the bundle name to be queried.
829      * @param moduleName Indicates the module name to be queried.
830      * @param dependentModuleNames Indicates the obtained dependent module names.
831      * @return Returns true if this function is successfully called; returns false otherwise.
832      */
833     virtual bool GetAllDependentModuleNames(const std::string &bundleName, const std::string &moduleName,
834         std::vector<std::string> &dependentModuleNames) override;
835     /**
836      * @brief Obtains the value of upgradeFlag based on a given bundle name and module name.
837      * @param bundleName Indicates the bundle name to be queried.
838      * @param moduleName Indicates the module name to be queried.
839      * @return Returns true if the upgradeFlag is successfully obtained; returns false otherwise.
840      */
841     virtual bool GetModuleUpgradeFlag(const std::string &bundleName, const std::string &moduleName) override;
842     /**
843      * @brief Sets whether to enable upgradeFlag based on a given bundle name and module name.
844      * @param bundleName Indicates the bundle name to be queried.
845      * @param moduleName Indicates the module name to be queried.
846      * @param isEnable Specifies whether to enable the upgradeFlag of InnerModuleInfo.
847      *                 The value true means to enable it, and the value false means to disable it
848      * @return Returns ERR_OK if the UpgradeFlag is successfully obtained; returns other ErrCode otherwise.
849      */
850     virtual ErrCode SetModuleUpgradeFlag(
851         const std::string &bundleName, const std::string &moduleName, int32_t upgradeFlag) override;
852     virtual ErrCode GetSandboxBundleInfo(
853         const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info) override;
854 
855     virtual bool ObtainCallingBundleName(std::string &bundleName) override;
856 
857     virtual bool GetBundleStats(const std::string &bundleName, int32_t userId,
858         std::vector<int64_t> &bundleStats, int32_t appIndex = 0, uint32_t statFlag = 0) override;
859 
860     virtual bool GetAllBundleStats(int32_t userId, std::vector<int64_t> &bundleStats) override;
861 
862 #ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
863     virtual sptr<IDefaultApp> GetDefaultAppProxy() override;
864 #endif
865 
866 #ifdef BUNDLE_FRAMEWORK_APP_CONTROL
867     virtual sptr<IAppControlMgr> GetAppControlProxy() override;
868 #endif
869 
870     virtual ErrCode GetSandboxAbilityInfo(const Want &want, int32_t appIndex, int32_t flags, int32_t userId,
871         AbilityInfo &info) override;
872     virtual ErrCode GetSandboxExtAbilityInfos(const Want &want, int32_t appIndex, int32_t flags, int32_t userId,
873         std::vector<ExtensionAbilityInfo> &infos) override;
874     virtual ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId,
875         HapModuleInfo &info) override;
876 
877     virtual ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName,
878         const std::string &abilityName, std::unique_ptr<uint8_t[]> &mediaDataPtr, size_t &len, int32_t userId) override;
879 
880     virtual sptr<IQuickFixManager> GetQuickFixManagerProxy() override;
881     virtual std::string GetStringById(const std::string &bundleName, const std::string &moduleName,
882         uint32_t resId, int32_t userId, const std::string &localeInfo) override;
883     virtual std::string GetIconById(const std::string &bundleName, const std::string &moduleName,
884         uint32_t resId, uint32_t density, int32_t userId) override;
885     virtual ErrCode SetDebugMode(bool isDebug) override;
886     virtual sptr<IOverlayManager> GetOverlayManagerProxy() override;
887     virtual ErrCode GetAppProvisionInfo(const std::string &bundleName, int32_t userId,
888         AppProvisionInfo &appProvisionInfo) override;
889     virtual ErrCode GetProvisionMetadata(const std::string &bundleName, int32_t userId,
890         std::vector<Metadata> &provisionMetadatas) override;
891     virtual ErrCode GetBaseSharedBundleInfos(const std::string &bundleName,
892         std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos,
893         GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO) override;
894     virtual ErrCode GetAllSharedBundleInfo(std::vector<SharedBundleInfo> &sharedBundles) override;
895     virtual ErrCode GetSharedBundleInfo(const std::string &bundleName, const std::string &moduleName,
896         std::vector<SharedBundleInfo> &sharedBundles) override;
897     virtual ErrCode GetSharedBundleInfoBySelf(const std::string &bundleName,
898         SharedBundleInfo &sharedBundleInfo) override;
899     virtual ErrCode GetSharedDependencies(const std::string &bundleName, const std::string &moduleName,
900         std::vector<Dependency> &dependencies) override;
901     virtual ErrCode GetProxyDataInfos(const std::string &bundleName, const std::string &moduleName,
902         std::vector<ProxyData> &proxyDatas, int32_t userId = Constants::UNSPECIFIED_USERID) override;
903     virtual ErrCode GetAllProxyDataInfos(
904         std::vector<ProxyData> &proxyDatas, int32_t userId = Constants::UNSPECIFIED_USERID) override;
905     virtual ErrCode GetSpecifiedDistributionType(const std::string &bundleName,
906         std::string &specifiedDistributionType) override;
907     virtual ErrCode GetAdditionalInfo(const std::string &bundleName,
908         std::string &additionalInfo) override;
909     virtual ErrCode SetExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName,
910         const std::string &abilityName, const std::string &extName, const std::string &mimeType) override;
911     virtual ErrCode DelExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName,
912         const std::string &abilityName, const std::string &extName, const std::string &mimeType) override;
913     virtual bool QueryDataGroupInfos(const std::string &bundleName, int32_t userId,
914         std::vector<DataGroupInfo> &infos) override;
915     virtual bool GetGroupDir(const std::string &dataGroupId, std::string &dir) override;
916     virtual bool QueryAppGalleryBundleName(std::string &bundleName) override;
917     virtual ErrCode ResetAOTCompileStatus(const std::string &bundleName, const std::string &moduleName,
918         int32_t triggerMode) override;
919     void SetBrokerServiceStatus(bool isServiceExisted);
920 
921     /**
922      * @brief Query extension info with type name.
923      * @param Want Indicates the information of extension info.
924      * @param extensionTypeName Indicates the type of the extension.
925      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
926      * @param userId Indicates the userId in the system.
927      * @param extensionInfos Indicates the obtained extensions.
928      * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
929      */
930     virtual ErrCode QueryExtensionAbilityInfosWithTypeName(const Want &want, const std::string &extensionTypeName,
931         const int32_t flag, const int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
932 
933     /**
934      * @brief Query extension info only with type name.
935      * @param extensionTypeName Indicates the type of the extension.
936      * @param flag Indicates the query flag which will fliter any specified stuff in the extension info.
937      * @param userId Indicates the userId in the system.
938      * @param extensionInfos Indicates the obtained extensions.
939      * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
940      */
941     virtual ErrCode QueryExtensionAbilityInfosOnlyWithTypeName(const std::string &extensionTypeName,
942         const uint32_t flag, const int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos) override;
943 
944     virtual ErrCode GetJsonProfile(ProfileType profileType, const std::string &bundleName,
945         const std::string &moduleName, std::string &profile, int32_t userId = Constants::UNSPECIFIED_USERID) override;
946 
947     virtual sptr<IBundleResource> GetBundleResourceProxy() override;
948 
949     virtual ErrCode GetRecoverableApplicationInfo(
950         std::vector<RecoverableApplicationInfo> &recoverableApplicaitons) override;
951 
952     virtual ErrCode GetUninstalledBundleInfo(const std::string bundleName, BundleInfo &bundleInfo) override;
953 
954     virtual ErrCode SetAdditionalInfo(const std::string &bundleName, const std::string &additionalInfo) override;
955 
956     virtual ErrCode CreateBundleDataDir(int32_t userId) override;
957 
958     /**
959      * @brief Check whether the link can be opened.
960      * @param link Indicates the link to be opened.
961      * @param canOpen Indicates whether the link can be opened.
962      * @return  Returns result of the operation.
963      */
964     virtual ErrCode CanOpenLink(
965         const std::string &link, bool &canOpen) override;
966 
967     virtual ErrCode GetOdid(std::string &odid) override;
968 
969     /**
970      * @brief Get preinstalled application infos.
971      * @param preinstalledApplicationInfos Indicates all of the obtained PreinstalledApplicationInfo objects.
972      * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise.
973      */
974     virtual ErrCode GetAllPreinstalledApplicationInfos(
975         std::vector<PreinstalledApplicationInfo> &preinstalledApplicationInfos) override;
976     virtual ErrCode GetAllBundleInfoByDeveloperId(const std::string &developerId,
977         std::vector<BundleInfo> &bundleInfos, int32_t userId) override;
978 
979     virtual ErrCode GetDeveloperIds(const std::string &appDistributionType,
980         std::vector<std::string> &developerIdList, int32_t userId) override;
981 
982     virtual ErrCode SwitchUninstallState(const std::string &bundleName, const bool &state,
983         bool isNeedSendNotify) override;
984 
985     virtual ErrCode QueryAbilityInfoByContinueType(const std::string &bundleName, const std::string &continueType,
986         AbilityInfo &abilityInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
987 
988     virtual ErrCode QueryCloneAbilityInfo(const ElementName &element,
989         int32_t flags, int32_t appIndex, AbilityInfo &abilityInfo, int32_t userId) override;
990 
991     virtual ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appIndex,
992         BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) override;
993 
994     virtual ErrCode GetCloneAppIndexes(const std::string &bundleName, std::vector<int32_t> &appIndexes,
995         int32_t userId = Constants::UNSPECIFIED_USERID) override;
996 
997     virtual ErrCode GetLaunchWant(Want &want) override;
998 
999     virtual ErrCode QueryCloneExtensionAbilityInfoWithAppIndex(const ElementName &elementName, int32_t flags,
1000         int32_t appIndex, ExtensionAbilityInfo &extensionAbilityInfo,
1001         int32_t userId = Constants::UNSPECIFIED_USERID) override;
1002 
1003     virtual ErrCode GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) override;
1004 
1005     virtual ErrCode AddDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId) override;
1006 
1007     virtual ErrCode DeleteDesktopShortcutInfo(const ShortcutInfo &shortcutInfo, int32_t userId) override;
1008 
1009     virtual ErrCode GetAllDesktopShortcutInfo(int32_t userId, std::vector<ShortcutInfo> &shortcutInfos) override;
1010 
1011     virtual ErrCode GetCompatibleDeviceTypeNative(std::string &deviceType) override;
1012     virtual ErrCode GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) override;
1013 
1014     virtual ErrCode GetOdidByBundleName(const std::string &bundleName, std::string &odid) override;
1015 
1016     /**
1017      * @brief Obtains continuable BundleInfo of all bundles available in the system.
1018      * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned.
1019      * @param bundleInfos Indicates all of the obtained BundleInfo objects.
1020      * @param userId Indicates the user ID.
1021      * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
1022      */
1023     virtual bool GetBundleInfosForContinuation(int32_t flags,
1024         std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) override;
1025 
1026     /**
1027      * @brief Get a list of application package names that continue the specified package name.
1028      * @param continueBundleName The package name that is being continued.
1029      * @param bundleNames Continue the list of specified package names.
1030      * @param userId Indicates the user ID.
1031      * @return Returns ERR_OK if successfully obtained; returns error code otherwise.
1032      */
1033     virtual ErrCode GetContinueBundleNames(const std::string &continueBundleName, std::vector<std::string> &bundleNames,
1034         int32_t userId = Constants::UNSPECIFIED_USERID) override;
1035 
1036     virtual ErrCode IsBundleInstalled(const std::string &bundleName, int32_t userId,
1037         int32_t appIndex, bool &isInstalled) override;
1038     virtual ErrCode GetBundleNameByAppId(const std::string &appId, std::string &bundleName) override;
1039     virtual ErrCode GetDirByBundleNameAndAppIndex(const std::string &bundleName, const int32_t appIndex,
1040         std::string &dataDir) override;
1041     virtual ErrCode GetAllBundleDirs(int32_t userId, std::vector<BundleDir> &bundleDirs) override;
1042 
1043 private:
1044     const std::shared_ptr<BundleDataMgr> GetDataMgrFromService();
1045 #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK
1046     const OHOS::sptr<IDistributedBms> GetDistributedBundleMgrService();
1047 #endif
1048 #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL
1049     const std::shared_ptr<BundleConnectAbilityMgr> GetConnectAbilityMgrFromService();
1050 #endif
1051     bool GetBundleUserInfo(
1052         const std::string &bundleName, int32_t userId, InnerBundleUserInfo &innerBundleUserInfo);
1053     bool GetBundleUserInfos(
1054         const std::string &bundleName, std::vector<InnerBundleUserInfo> &innerBundleUserInfos);
1055     bool GetShortcutInfos(
1056         const std::string &bundleName, int32_t userId, std::vector<ShortcutInfo> &shortcutInfos);
1057     bool DumpAllBundleInfoNames(int32_t userId, std::string &result);
1058     bool DumpAllBundleInfoNamesByUserId(int32_t userId, std::string &result);
1059     bool DumpBundleInfo(const std::string &bundleName, int32_t userId, std::string &result);
1060     bool DumpShortcutInfo(const std::string &bundleName, int32_t userId, std::string &result);
1061     std::set<int32_t> GetExistsCommonUserIs();
1062     bool VerifyDependency(const std::string &sharedBundleName);
1063     void CleanBundleCacheTask(const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
1064         const std::shared_ptr<BundleDataMgr> &dataMgr, int32_t userId, int32_t appIndex = 0);
1065     void GetAppCachePaths(const std::string &suffixName,
1066         const int32_t userId, const std::vector<std::string> &moduleNameList, std::vector<std::string> &cachePaths);
1067     ErrCode CleanBundleCacheFilesGetCleanSize(const std::string &bundleName,
1068         int32_t userId, uint64_t &cleanCacheSize);
1069     void CleanBundleCacheTaskGetCleanSize(const std::string &bundleName,
1070         int32_t userId, uint64_t &cleanCacheSize);
1071     void NotifyBundleStatus(const NotifyBundleEvents &installRes);
1072     ErrCode GetBundleArchiveInfoBySandBoxPath(
1073         const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo, bool fromV9 = false);
1074     bool IsPreInstallApp(const std::string &bundleName);
1075     bool GetPreferableBundleInfoFromHapPaths(const std::vector<std::string> &hapPaths,
1076         BundleInfo &bundleInfo);
1077     bool IsBundleExist(const std::string &bundleName);
1078     ErrCode ClearCache(const std::string &bundleName, const sptr<ICleanCacheCallback> cleanCacheCallback,
1079         int32_t userId);
1080     void FilterAbilityInfos(std::vector<AbilityInfo> &abilityInfos);
1081     void SetProvisionInfoToInnerBundleInfo(const std::string &hapPath, InnerBundleInfo &info);
1082     bool CheckAppIndex(const std::string &bundleName, int32_t userId, int32_t appIndex);
1083     bool CheckCanSetEnable(const std::string &bundleName);
1084     bool IsAppLinking(int32_t flags) const;
1085     std::string GetCallerName();
1086 
1087     std::atomic<bool> isBrokerServiceExisted_ = false;
1088 };
1089 }  // namespace AppExecFwk
1090 }  // namespace OHOS
1091 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_MGR_HOST_IMPL_H
1092