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_INTERFACE_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H 18 19 #include "ability_info.h" 20 #include "application_info.h" 21 #include "bundle_constants.h" 22 #include "bundle_event_callback_interface.h" 23 #include "bundle_info.h" 24 #include "bundle_installer_interface.h" 25 #include "bundle_status_callback_interface.h" 26 #include "bundle_user_mgr_interface.h" 27 #include "clean_cache_callback_interface.h" 28 #include "common_event_info.h" 29 #include "distributed_bundle_info.h" 30 #include "form_info.h" 31 #include "foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include/permission_def.h" 32 #include "hap_module_info.h" 33 #include "module_usage_record.h" 34 #include "on_permission_changed_callback_interface.h" 35 #include "ohos/aafwk/content/want.h" 36 #ifdef SUPPORT_GRAPHICS 37 #include "pixel_map.h" 38 #endif 39 #include "shortcut_info.h" 40 41 namespace OHOS { 42 namespace AppExecFwk { 43 enum class DumpFlag { 44 DUMP_BUNDLE_LIST = 1, // corresponse to option "-bundle-list" 45 DUMP_ALL_BUNDLE_INFO, // corresponse to option "-bundle" 46 DUMP_BUNDLE_INFO, // corresponse to option "-bundle [name]" 47 DUMP_SHORTCUT_INFO, // corresponse to option "-bundle [name] -shortcut-info" 48 }; 49 50 class IBundleMgr : public IRemoteBroker { 51 public: 52 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleMgr"); 53 54 using Want = OHOS::AAFwk::Want; 55 /** 56 * @brief Obtains the ApplicationInfo based on a given bundle name. 57 * @param appName Indicates the application bundle name to be queried. 58 * @param flag Indicates the flag used to specify information contained 59 * in the ApplicationInfo object that will be returned. 60 * @param userId Indicates the user ID. 61 * @param appInfo Indicates the obtained ApplicationInfo object. 62 * @return Returns true if the application is successfully obtained; returns false otherwise. 63 */ 64 virtual bool GetApplicationInfo( 65 const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) = 0; 66 /** 67 * @brief Obtains the ApplicationInfo based on a given bundle name. 68 * @param appName Indicates the application bundle name to be queried. 69 * @param flags Indicates the flag used to specify information contained 70 * in the ApplicationInfo object that will be returned. 71 * @param userId Indicates the user ID. 72 * @param appInfo Indicates the obtained ApplicationInfo object. 73 * @return Returns true if the application is successfully obtained; returns false otherwise. 74 */ GetApplicationInfo(const std::string & appName,int32_t flags,int32_t userId,ApplicationInfo & appInfo)75 virtual bool GetApplicationInfo( 76 const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo) 77 { 78 return false; 79 } 80 /** 81 * @brief Obtains information about all installed applications of a specified user. 82 * @param flag Indicates the flag used to specify information contained 83 * in the ApplicationInfo objects that will be returned. 84 * @param userId Indicates the user ID. 85 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 86 * @return Returns true if the application is successfully obtained; returns false otherwise. 87 */ 88 virtual bool GetApplicationInfos( 89 const ApplicationFlag flag, int userId, std::vector<ApplicationInfo> &appInfos) = 0; 90 /** 91 * @brief Obtains information about all installed applications of a specified user. 92 * @param flags Indicates the flag used to specify information contained 93 * in the ApplicationInfo objects that will be returned. 94 * @param userId Indicates the user ID. 95 * @param appInfos Indicates all of the obtained ApplicationInfo objects. 96 * @return Returns true if the application is successfully obtained; returns false otherwise. 97 */ GetApplicationInfos(int32_t flags,int32_t userId,std::vector<ApplicationInfo> & appInfos)98 virtual bool GetApplicationInfos( 99 int32_t flags, int32_t userId, std::vector<ApplicationInfo> &appInfos) 100 { 101 return false; 102 } 103 /** 104 * @brief Obtains the BundleInfo based on a given bundle name. 105 * @param bundleName Indicates the application bundle name to be queried. 106 * @param flag Indicates the information contained in the BundleInfo object to be returned. 107 * @param bundleInfo Indicates the obtained BundleInfo object. 108 * @param userId Indicates the user ID. 109 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 110 */ 111 virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, 112 BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) = 0; 113 /** 114 * @brief Obtains the BundleInfo based on a given bundle name. 115 * @param bundleName Indicates the application bundle name to be queried. 116 * @param flags Indicates the information contained in the BundleInfo object to be returned. 117 * @param bundleInfo Indicates the obtained BundleInfo object. 118 * @param userId Indicates the user ID. 119 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 120 */ 121 virtual bool GetBundleInfo(const std::string &bundleName, int32_t flags, 122 BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) 123 { 124 return false; 125 } 126 /** 127 * @brief Obtains BundleInfo of all bundles available in the system. 128 * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned. 129 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 130 * @param userId Indicates the user ID. 131 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 132 */ 133 virtual bool GetBundleInfos(const BundleFlag flag, 134 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) = 0; 135 /** 136 * @brief Obtains BundleInfo of all bundles available in the system. 137 * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be returned. 138 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 139 * @param userId Indicates the user ID. 140 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 141 */ 142 virtual bool GetBundleInfos(int32_t flags, 143 std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID) 144 { 145 return false; 146 } 147 /** 148 * @brief Obtains the application UID based on the given bundle name and user ID. 149 * @param bundleName Indicates the bundle name of the application. 150 * @param userId Indicates the user ID. 151 * @return Returns the uid if successfully obtained; returns -1 otherwise. 152 */ 153 virtual int GetUidByBundleName(const std::string &bundleName, const int userId) = 0; 154 /** 155 * @brief Obtains the application ID based on the given bundle name and user ID. 156 * @param bundleName Indicates the bundle name of the application. 157 * @param userId Indicates the user ID. 158 * @return Returns the application ID if successfully obtained; returns empty string otherwise. 159 */ 160 virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) = 0; 161 /** 162 * @brief Obtains the bundle name of a specified application based on the given UID. 163 * @param uid Indicates the uid. 164 * @param bundleName Indicates the obtained bundle name. 165 * @return Returns true if the bundle name is successfully obtained; returns false otherwise. 166 */ 167 virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) = 0; 168 /** 169 * @brief Obtains all bundle names of a specified application based on the given application UID. 170 * @param uid Indicates the uid. 171 * @param bundleNames Indicates the obtained bundle names. 172 * @return Returns true if the bundle names is successfully obtained; returns false otherwise. 173 */ 174 virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) = 0; 175 /** 176 * @brief Obtains the formal name associated with the given UID. 177 * @param uid Indicates the uid. 178 * @param name Indicates the obtained formal name. 179 * @return Returns true if the formal name is successfully obtained; returns false otherwise. 180 */ 181 virtual bool GetNameForUid(const int uid, std::string &name) = 0; 182 /** 183 * @brief Obtains an array of all group IDs associated with a specified bundle. 184 * @param bundleName Indicates the bundle name. 185 * @param gids Indicates the group IDs associated with the specified bundle. 186 * @return Returns true if the gids is successfully obtained; returns false otherwise. 187 */ 188 virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) = 0; 189 /** 190 * @brief Obtains an array of all group IDs associated with the given bundle name and UID. 191 * @param bundleName Indicates the bundle name. 192 * @param uid Indicates the uid. 193 * @param gids Indicates the group IDs associated with the specified bundle. 194 * @return Returns true if the gids is successfully obtained; returns false otherwise. 195 */ 196 virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) = 0; 197 /** 198 * @brief Obtains the type of a specified application based on the given bundle name. 199 * @param bundleName Indicates the bundle name. 200 * @return Returns "system" if the bundle is a system application; returns "third-party" otherwise. 201 */ 202 virtual std::string GetAppType(const std::string &bundleName) = 0; 203 /** 204 * @brief Check whether the app is system app by it's UID. 205 * @param uid Indicates the uid. 206 * @return Returns true if the bundle is a system application; returns false otherwise. 207 */ 208 virtual bool CheckIsSystemAppByUid(const int uid) = 0; 209 /** 210 * @brief Obtains the BundleInfo of application bundles based on the specified metaData. 211 * @param metaData Indicates the metadata to get in the bundle. 212 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 213 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 214 */ 215 virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) = 0; 216 /** 217 * @brief Query the AbilityInfo by the given Want. 218 * @param want Indicates the information of the ability. 219 * @param abilityInfo Indicates the obtained AbilityInfo object. 220 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 221 */ 222 virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) = 0; 223 /** 224 * @brief Query the AbilityInfo by the given Want. 225 * @param want Indicates the information of the ability. 226 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 227 * @param userId Indicates the user ID. 228 * @param abilityInfo Indicates the obtained AbilityInfo object. 229 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 230 */ QueryAbilityInfo(const Want & want,int32_t flags,int32_t userId,AbilityInfo & abilityInfo)231 virtual bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) 232 { 233 return false; 234 } 235 /** 236 * @brief Query the AbilityInfo of list by the given Want. 237 * @param want Indicates the information of the ability. 238 * @param abilityInfos Indicates the obtained AbilityInfos object. 239 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 240 */ 241 virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) = 0; 242 /** 243 * @brief Query the AbilityInfo of list by the given Want. 244 * @param want Indicates the information of the ability. 245 * @param flags Indicates the information contained in the AbilityInfo object to be returned. 246 * @param userId Indicates the user ID. 247 * @param abilityInfos Indicates the obtained AbilityInfos object. 248 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 249 */ QueryAbilityInfos(const Want & want,int32_t flags,int32_t userId,std::vector<AbilityInfo> & abilityInfos)250 virtual bool QueryAbilityInfos( 251 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos) 252 { 253 return false; 254 } 255 /** 256 * @brief Query the AbilityInfo of list for clone by the given Want. 257 * @param want Indicates the information of the ability. 258 * @param abilityInfos Indicates the obtained AbilityInfos object. 259 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 260 */ 261 virtual bool QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos) = 0; 262 /** 263 * @brief Query the AllAbilityInfos of list by the given userId. 264 * @param userId Indicates the information of the user. 265 * @param abilityInfos Indicates the obtained AbilityInfos object. 266 * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. 267 */ QueryAllAbilityInfos(const Want & want,int32_t userId,std::vector<AbilityInfo> & abilityInfos)268 virtual bool QueryAllAbilityInfos(const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos) 269 { 270 return false; 271 } 272 /** 273 * @brief Query the AbilityInfo by ability.uri in config.json. 274 * @param abilityUri Indicates the uri of the ability. 275 * @param abilityInfo Indicates the obtained AbilityInfo object. 276 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 277 */ 278 virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) = 0; 279 /** 280 * @brief Query the AbilityInfo by ability.uri in config.json. 281 * @param abilityUri Indicates the uri of the ability. 282 * @param userId Indicates the user ID. 283 * @param abilityInfo Indicates the obtained AbilityInfo object. 284 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 285 */ QueryAbilityInfoByUri(const std::string & abilityUri,int32_t userId,AbilityInfo & abilityInfo)286 virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) 287 { 288 return true; 289 }; 290 /** 291 * @brief Query the AbilityInfo by ability.uri in config.json. 292 * @param abilityUri Indicates the uri of the ability. 293 * @param abilityInfos Indicates the obtained AbilityInfos object. 294 * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. 295 */ 296 virtual bool QueryAbilityInfosByUri(const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) = 0; 297 /** 298 * @brief Obtains the BundleInfo of all keep-alive applications in the system. 299 * @param bundleInfos Indicates all of the obtained BundleInfo objects. 300 * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. 301 */ 302 virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) = 0; 303 /** 304 * @brief Obtains the label of a specified ability. 305 * @param bundleName Indicates the bundle name. 306 * @param className Indicates the ability class name. 307 * @return Returns the label of the ability if exist; returns empty string otherwise. 308 */ 309 virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) = 0; 310 /** 311 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 312 * @param hapFilePath Indicates the absolute file path of the HAP. 313 * @param flag Indicates the information contained in the BundleInfo object to be returned. 314 * @param bundleInfo Indicates the obtained BundleInfo object. 315 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 316 */ 317 virtual bool GetBundleArchiveInfo( 318 const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) = 0; 319 /** 320 * @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP). 321 * @param hapFilePath Indicates the absolute file path of the HAP. 322 * @param flags Indicates the information contained in the BundleInfo object to be returned. 323 * @param bundleInfo Indicates the obtained BundleInfo object. 324 * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. 325 */ GetBundleArchiveInfo(const std::string & hapFilePath,int32_t flags,BundleInfo & bundleInfo)326 virtual bool GetBundleArchiveInfo( 327 const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo) 328 { 329 return false; 330 } 331 /** 332 * @brief Obtain the HAP module info of a specific ability. 333 * @param abilityInfo Indicates the ability. 334 * @param hapModuleInfo Indicates the obtained HapModuleInfo object. 335 * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. 336 */ 337 virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) = 0; 338 /** 339 * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. 340 * @param bundleName Indicates the bundle name. 341 * @param want Indicates the obtained launch Want object. 342 * @return Returns true if the launch Want object is successfully obtained; returns false otherwise. 343 */ 344 virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) = 0; 345 /** 346 * @brief Checks whether the publickeys of two bundles are the same. 347 * @param firstBundleName Indicates the first bundle name. 348 * @param secondBundleName Indicates the second bundle name. 349 * @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found; 350 * returns SIGNATURE_NOT_MATCHED if their publickeys are different; 351 * returns SIGNATURE_MATCHED if their publickeys are the same. 352 */ 353 virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) = 0; 354 /** 355 * @brief Checks whether a specified bundle has been granted a specific permission. 356 * @param bundleName Indicates the name of the bundle to check. 357 * @param permission Indicates the permission to check. 358 * @return Returns 0 if the bundle has the permission; returns -1 otherwise. 359 */ 360 virtual int CheckPermission(const std::string &bundleName, const std::string &permission) = 0; 361 /** 362 * @brief Checks whether a specified bundle has been granted a specific permission. 363 * @param bundleName Indicates the name of the bundle to check. 364 * @param permission Indicates the permission to check. 365 * @param userId Indicates the user id. 366 * @return Returns 0 if the bundle has the permission; returns -1 otherwise. 367 */ 368 virtual int CheckPermissionByUid( 369 const std::string &bundleName, const std::string &permission, const int userId) = 0; 370 /** 371 * @brief Obtains detailed information about a specified permission. 372 * @param permissionName Indicates the name of the ohos permission. 373 * @param permissionDef Indicates the object containing detailed information about the given ohos permission. 374 * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise. 375 */ 376 virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) = 0; 377 /** 378 * @brief Obtains all known permission groups in the system. 379 * @param permissionDefs Indicates the list of objects containing the permission group information. 380 * @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise. 381 */ 382 virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) = 0; 383 /** 384 * @brief Obtains all known permission groups in the system. 385 * @param permissions Indicates the permission array. 386 * @param appNames Indicates the list of application names that have the specified permissions. 387 * @return Returns true if the application names is successfully obtained; returns false otherwise. 388 */ 389 virtual bool GetAppsGrantedPermissions( 390 const std::vector<std::string> &permissions, std::vector<std::string> &appNames) = 0; 391 /** 392 * @brief Checks whether the system has a specified capability. 393 * @param capName Indicates the name of the system feature to check. 394 * @return Returns true if the given feature specified by name is available in the system; returns false otherwise. 395 */ 396 virtual bool HasSystemCapability(const std::string &capName) = 0; 397 /** 398 * @brief Obtains the capabilities that are available in the system. 399 * @param systemCaps Indicates the list of capabilities available in the system. 400 * @return Returns true if capabilities in the system are successfully obtained; returns false otherwise. 401 */ 402 virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) = 0; 403 /** 404 * @brief Checks whether the current device has been started in safe mode. 405 * @return Returns true if the device is in safe mode; returns false otherwise. 406 */ 407 virtual bool IsSafeMode() = 0; 408 /** 409 * @brief Clears cache data of a specified application. 410 * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared. 411 * @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result. 412 * @param userId description the user id. 413 * @return Returns true if this function is successfully called; returns false otherwise. 414 */ 415 virtual bool CleanBundleCacheFiles( 416 const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback, 417 int32_t userId = Constants::UNSPECIFIED_USERID) 418 { 419 return true; 420 } 421 /** 422 * @brief Clears application running data of a specified application. 423 * @param bundleName Indicates the bundle name of the application whose data is to be cleared. 424 * @param userId Indicates the user id. 425 * @return Returns true if the data cleared successfully; returns false otherwise. 426 */ 427 virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) = 0; 428 /** 429 * @brief Register the specific bundle status callback. 430 * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result. 431 * @return Returns true if this function is successfully called; returns false otherwise. 432 */ 433 virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0; 434 RegisterBundleEventCallback(const sptr<IBundleEventCallback> & bundleEventCallback)435 virtual bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) 436 { 437 return false; 438 } 439 UnregisterBundleEventCallback(const sptr<IBundleEventCallback> & bundleEventCallback)440 virtual bool UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback) 441 { 442 return false; 443 } 444 /** 445 * @brief Clear the specific bundle status callback. 446 * @param bundleStatusCallback Indicates the callback to be cleared. 447 * @return Returns true if this function is successfully called; returns false otherwise. 448 */ 449 virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0; 450 /** 451 * @brief Unregister all the callbacks of status changed. 452 * @return Returns true if this function is successfully called; returns false otherwise. 453 */ 454 virtual bool UnregisterBundleStatusCallback() = 0; 455 /** 456 * @brief Dump the bundle informations with specific flags. 457 * @param flag Indicates the information contained in the dump result. 458 * @param bundleName Indicates the bundle name if needed. 459 * @param userId Indicates the user ID. 460 * @param result Indicates the dump information result. 461 * @return Returns true if the dump result is successfully obtained; returns false otherwise. 462 */ 463 virtual bool DumpInfos( 464 const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) = 0; 465 /** 466 * @brief Checks whether a specified application is enabled. 467 * @param bundleName Indicates the bundle name of the application. 468 * @return Returns true if the application is enabled; returns false otherwise. 469 */ 470 virtual bool IsApplicationEnabled(const std::string &bundleName) = 0; 471 /** 472 * @brief Sets whether to enable a specified application. 473 * @param bundleName Indicates the bundle name of the application. 474 * @param isEnable Specifies whether to enable the application. 475 * The value true means to enable it, and the value false means to disable it. 476 * @param userId description the user id. 477 * @return Returns true if the application is enabled; returns false otherwise. 478 */ 479 virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable, 480 int32_t userId = Constants::UNSPECIFIED_USERID) 481 { 482 return true; 483 } 484 /** 485 * @brief Sets whether to enable a specified ability. 486 * @param abilityInfo Indicates information about the ability to check. 487 * @return Returns true if the ability is enabled; returns false otherwise. 488 */ 489 virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) = 0; 490 /** 491 * @brief Sets whether to enable a specified ability. 492 * @param abilityInfo Indicates information about the ability. 493 * @param isEnabled Specifies whether to enable the ability. 494 * The value true means to enable it, and the value false means to disable it. 495 * @param userId description the user id. 496 * @return Returns true if the ability is enabled; returns false otherwise. 497 */ 498 virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled, 499 int32_t userId = Constants::UNSPECIFIED_USERID) 500 { 501 return true; 502 } 503 /** 504 * @brief Obtains the icon of a specified ability. 505 * @param bundleName Indicates the bundle name. 506 * @param className Indicates the ability class name. 507 * @return Returns the icon resource string of the ability if exist; returns empty string otherwise. 508 */ 509 virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) = 0; 510 /** 511 * @brief Confirms with the permission management module to check whether a request prompt is required for granting 512 * a certain permission. 513 * @param bundleName Indicates the name of the bundle to check. 514 * @param permission Indicates the permission to check. 515 * @param userId Indicates the user id. 516 * @return Returns true if the current application does not have the permission and the user does not turn off 517 * further requests; returns false if the current application already has the permission, the permission is rejected 518 * by the system, or the permission is denied by the user and the user has turned off further requests. 519 */ 520 virtual bool CanRequestPermission( 521 const std::string &bundleName, const std::string &permissionName, const int userId) = 0; 522 /** 523 * @brief Requests a certain permission from user. 524 * @param bundleName Indicates the name of the bundle to request permission. 525 * @param permission Indicates the permission to request permission. 526 * @param userId Indicates the user id. 527 * @return Returns true if the permission request successfully; returns false otherwise. 528 */ 529 virtual bool RequestPermissionFromUser( 530 const std::string &bundleName, const std::string &permission, const int userId) = 0; 531 /** 532 * @brief Registers a callback for listening for permission changes of all UIDs. 533 * @param callback Indicates the callback method to register. 534 * @return Returns true if this function is successfully called; returns false otherwise. 535 */ 536 virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) = 0; 537 /** 538 * @brief Registers a callback for listening for permission changes of specified UIDs. 539 * @param uids Indicates the list of UIDs whose permission changes will be monitored. 540 * @param callback Indicates the callback method to register. 541 * @return Returns true if this function is successfully called; returns false otherwise. 542 */ 543 virtual bool RegisterPermissionsChanged( 544 const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) = 0; 545 /** 546 * @brief Unregisters a specified callback for listening for permission changes. 547 * @param callback Indicates the callback method to register. 548 * @return Returns true if this function is successfully called; returns false otherwise. 549 */ 550 virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) = 0; 551 /** 552 * @brief Obtains the FormInfo objects provided by all applications on the device. 553 * @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 554 * device. 555 * @return Returns true if this function is successfully called; returns false otherwise. 556 */ 557 virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) = 0; 558 /** 559 * @brief Obtains the FormInfo objects provided by a specified application on the device. 560 * @param bundleName Indicates the bundle name of the application. 561 * @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 562 * device. 563 * @return Returns true if this function is successfully called; returns false otherwise. 564 */ 565 virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) = 0; 566 /** 567 * @brief Obtains the FormInfo objects provided by a specified. 568 * @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the 569 * device. 570 * @param moduleName Indicates the module name of the application. 571 * @param bundleName Indicates the bundle name of the application. 572 * @return Returns true if this function is successfully called; returns false otherwise. 573 */ 574 virtual bool GetFormsInfoByModule( 575 const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) = 0; 576 /** 577 * @brief Obtains the ShortcutInfo objects provided by a specified application on the device. 578 * @param bundleName Indicates the bundle name of the application. 579 * @param shortcutInfos List of ShortcutInfo objects if obtained. 580 * @return Returns true if this function is successfully called; returns false otherwise. 581 */ 582 virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) = 0; 583 /** 584 * @brief Obtains the CommonEventInfo objects provided by an event key on the device. 585 * @param eventKey Indicates the event of the subscribe. 586 * @param commonEventInfos List of CommonEventInfo objects if obtained. 587 * @return Returns true if this function is successfully called; returns false otherwise. 588 */ 589 virtual bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) = 0; 590 /** 591 * @brief Get module usage record list in descending order of lastLaunchTime. 592 * @param maxNum the return size of the records, must be in range of 1 to 1000. 593 * @param moduleUsageRecords List of ModuleUsageRecord objects if obtained. 594 * @return Returns true if this function is successfully called; returns false otherwise. 595 */ 596 virtual bool GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) = 0; 597 /** 598 * @brief Obtains the interface used to install and uninstall bundles. 599 * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise. 600 */ 601 virtual sptr<IBundleInstaller> GetBundleInstaller() = 0; 602 /** 603 * @brief Notify a specified ability for ability. 604 * @param bundleName Indicates the bundle name of the ability to ability. 605 * @param abilityName Indicates the name of the ability to ability. 606 * @param launchTime Indicates the ability launchTime. 607 * @param uid Indicates the uid. 608 * @return Returns true if this function is successfully called; returns false otherwise. 609 */ 610 virtual bool NotifyAbilityLifeStatus( 611 const std::string &bundleName, const std::string &abilityName, const int64_t launchTime, const int uid = 0) = 0; 612 /** 613 * @brief Remove cloned bundle. 614 * @param bundleName Indicates the bundle name of remove cloned bundle. 615 * @param uid Indicates the uid of remove cloned bundle. 616 * @return Returns true if this function is successfully called; returns false otherwise. 617 */ 618 virtual bool RemoveClonedBundle(const std::string &bundleName, const int32_t uid) = 0; 619 /** 620 * @brief create bundle clone. 621 * @param bundleName Indicates the bundle name of create bundle clone. 622 * @return Returns true if this function is successfully called; returns false otherwise. 623 */ 624 virtual bool BundleClone(const std::string &bundleName) = 0; 625 /** 626 * @brief Determine whether the application is in the allow list. 627 * @param bundleName Indicates the bundle Names. 628 * @return Returns true if bundle name in the allow list successfully; returns false otherwise. 629 */ 630 virtual bool CheckBundleNameInAllowList(const std::string &bundleName) = 0; 631 /** 632 * @brief Obtains the interface used to create or delete user. 633 * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise. 634 */ 635 virtual sptr<IBundleUserMgr> GetBundleUserMgr() = 0; 636 /** 637 * @brief Obtains the DistributedBundleInfo based on a given bundle name and networkId. 638 * @param networkId Indicates the networkId of remote device. 639 * @param userId Indicates the user id. 640 * @param bundleName Indicates the application bundle name to be queried. 641 * @param distributedBundleInfo Indicates the obtained DistributedBundleInfo object. 642 * @return Returns true if the DistributedBundleInfo is successfully obtained; returns false otherwise. 643 */ 644 virtual bool GetDistributedBundleInfo( 645 const std::string &networkId, int32_t userId, const std::string &bundleName, 646 DistributedBundleInfo &distributedBundleInfo) = 0; 647 /** 648 * @brief Get app privilege level. 649 * @param bundleName Indicates the bundle name of the app privilege level. 650 * @param userId Indicates the user id. 651 * @return Returns app privilege level. 652 */ 653 virtual std::string GetAppPrivilegeLevel( 654 const std::string &bundleName, int32_t userId = Constants::UNSPECIFIED_USERID) 655 { 656 return Constants::EMPTY_STRING; 657 } 658 /** 659 * @brief Query extension info. 660 * @param Want Indicates the information of extension info. 661 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 662 * @param userId Indicates the userId in the system. 663 * @param extensionInfos Indicates the obtained extensions. 664 * @return Returns true if this function is successfully called; returns false otherwise. 665 */ QueryExtensionAbilityInfos(const Want & want,const int32_t & flag,const int32_t & userId,std::vector<ExtensionAbilityInfo> & extensionInfos)666 virtual bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId, 667 std::vector<ExtensionAbilityInfo> &extensionInfos) 668 { 669 return true; 670 } 671 /** 672 * @brief Query extension info. 673 * @param Want Indicates the information of extension info. 674 * @param extensionType Indicates the type of the extension. 675 * @param flag Indicates the query flag which will fliter any specified stuff in the extension info. 676 * @param userId Indicates the userId in the system. 677 * @param extensionInfos Indicates the obtained extensions. 678 * @return Returns true if this function is successfully called; returns false otherwise. 679 */ QueryExtensionAbilityInfos(const Want & want,const ExtensionAbilityType & extensionType,const int32_t & flag,const int32_t & userId,std::vector<ExtensionAbilityInfo> & extensionInfos)680 virtual bool QueryExtensionAbilityInfos(const Want &want, const ExtensionAbilityType &extensionType, 681 const int32_t &flag, const int32_t &userId, std::vector<ExtensionAbilityInfo> &extensionInfos) 682 { 683 return true; 684 } 685 QueryExtensionAbilityInfos(const ExtensionAbilityType & extensionType,const int32_t & userId,std::vector<ExtensionAbilityInfo> & extensionInfos)686 virtual bool QueryExtensionAbilityInfos(const ExtensionAbilityType &extensionType, const int32_t &userId, 687 std::vector<ExtensionAbilityInfo> &extensionInfos) 688 { 689 return true; 690 } 691 VerifyCallingPermission(const std::string & permission)692 virtual bool VerifyCallingPermission(const std::string &permission) 693 { 694 return true; 695 } 696 GetAccessibleAppCodePaths(int32_t userId)697 virtual std::vector<std::string> GetAccessibleAppCodePaths(int32_t userId) 698 { 699 std::vector<std::string> vec; 700 return vec; 701 } 702 QueryExtensionAbilityInfoByUri(const std::string & uri,int32_t userId,ExtensionAbilityInfo & extensionAbilityInfo)703 virtual bool QueryExtensionAbilityInfoByUri(const std::string &uri, int32_t userId, 704 ExtensionAbilityInfo &extensionAbilityInfo) 705 { 706 return false; 707 } 708 ImplicitQueryInfoByPriority(const Want & want,int32_t flags,int32_t userId,AbilityInfo & abilityInfo,ExtensionAbilityInfo & extensionInfo)709 virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId, 710 AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo) 711 { 712 return false; 713 } 714 715 #ifdef SUPPORT_GRAPHICS GetAbilityPixelMapIcon(const std::string & bundleName,const std::string & abilityName)716 virtual std::shared_ptr<Media::PixelMap> GetAbilityPixelMapIcon(const std::string &bundleName, 717 const std::string &abilityName) 718 { 719 return nullptr; 720 } 721 #endif 722 723 /** 724 * @brief Obtains the AbilityInfo based on a given bundle name. 725 * @param bundleName Indicates the bundle name to be queried. 726 * @param abilityName Indicates the ability name to be queried. 727 * @param abilityInfo Indicates the obtained AbilityInfo object. 728 * @return Returns true if the abilityInfo is successfully obtained; returns false otherwise. 729 730 */ GetAbilityInfo(const std::string & bundleName,const std::string & abilityName,AbilityInfo & abilityInfo)731 virtual bool GetAbilityInfo( 732 const std::string &bundleName, const std::string &abilityName, AbilityInfo &abilityInfo) 733 { 734 return false; 735 } 736 737 enum class Message { 738 GET_APPLICATION_INFO = 0, 739 GET_APPLICATION_INFOS, 740 GET_BUNDLE_INFO, 741 GET_BUNDLE_INFOS, 742 GET_UID_BY_BUNDLE_NAME, 743 GET_APPID_BY_BUNDLE_NAME, 744 GET_BUNDLE_NAME_FOR_UID, 745 GET_BUNDLES_FOR_UID, 746 GET_NAME_FOR_UID, 747 GET_BUNDLE_GIDS, 748 GET_BUNDLE_GIDS_BY_UID, 749 GET_APP_TYPE, 750 CHECK_IS_SYSTEM_APP_BY_UID, 751 GET_BUNDLE_INFOS_BY_METADATA, 752 QUERY_ABILITY_INFO, 753 QUERY_ABILITY_INFOS, 754 QUERY_ABILITY_INFOS_FOR_CLONE, 755 QUERY_ABILITY_INFO_BY_URI, 756 QUERY_ABILITY_INFOS_BY_URI, 757 QUERY_KEEPALIVE_BUNDLE_INFOS, 758 GET_ABILITY_LABEL, 759 GET_BUNDLE_ARCHIVE_INFO, 760 GET_HAP_MODULE_INFO, 761 GET_LAUNCH_WANT_FOR_BUNDLE, 762 CHECK_PUBLICKEYS, 763 CHECK_PERMISSION, 764 CHECK_PERMISSION_BY_UID, 765 GET_PERMISSION_DEF, 766 GET_ALL_PERMISSION_GROUP_DEFS, 767 GET_APPS_GRANTED_PERMISSIONS, 768 HAS_SYSTEM_CAPABILITY, 769 GET_SYSTEM_AVAILABLE_CAPABILITIES, 770 IS_SAFE_MODE, 771 CLEAN_BUNDLE_CACHE_FILES, 772 CLEAN_BUNDLE_DATA_FILES, 773 REGISTER_BUNDLE_STATUS_CALLBACK, 774 CLEAR_BUNDLE_STATUS_CALLBACK, 775 UNREGISTER_BUNDLE_STATUS_CALLBACK, 776 DUMP_INFOS, 777 IS_APPLICATION_ENABLED, 778 SET_APPLICATION_ENABLED, 779 IS_ABILITY_ENABLED, 780 SET_ABILITY_ENABLED, 781 GET_ABILITY_INFO, 782 GET_ABILITY_ICON, 783 GET_ABILITY_PIXELMAP_ICON, 784 CAN_REQUEST_PERMISSION, 785 REQUEST_PERMISSION_FROM_USER, 786 REGISTER_ALL_PERMISSIONS_CHANGED, 787 REGISTER_PERMISSIONS_CHANGED, 788 UNREGISTER_PERMISSIONS_CHANGED, 789 GET_ALL_FORMS_INFO, 790 GET_FORMS_INFO_BY_APP, 791 GET_FORMS_INFO_BY_MODULE, 792 GET_MODULE_USAGE_RECORD, 793 GET_SHORTCUT_INFO, 794 GET_ALL_COMMON_EVENT_INFO, 795 GET_BUNDLE_INSTALLER, 796 NOTIFY_ABILITY_LIFE_STATUS, 797 REMOVE_CLONED_BUNDLE, 798 BUNDLE_CLONE, 799 CHECK_BUNDLE_NAME_IN_ALLOWLIST, 800 QUERY_ABILITY_INFO_MUTI_PARAM, 801 QUERY_ABILITY_INFOS_MUTI_PARAM, 802 QUERY_ALL_ABILITY_INFOS, 803 GET_APPLICATION_INFO_WITH_INT_FLAGS, 804 GET_APPLICATION_INFOS_WITH_INT_FLAGS, 805 GET_BUNDLE_INFO_WITH_INT_FLAGS, 806 GET_BUNDLE_INFOS_WITH_INT_FLAGS, 807 GET_BUNDLE_ARCHIVE_INFO_WITH_INT_FLAGS, 808 GET_BUNDLE_USER_MGR, 809 GET_DISTRIBUTE_BUNDLE_INFO, 810 QUERY_ABILITY_INFO_BY_URI_FOR_USERID, 811 GET_APPLICATION_PRIVILEGE_LEVEL, 812 QUERY_EXTENSION_INFO_WITHOUT_TYPE, 813 QUERY_EXTENSION_INFO, 814 QUERY_EXTENSION_INFO_BY_TYPE, 815 VERIFY_CALLING_PERMISSION, 816 GET_ACCESSIBLE_APP_CODE_PATH, 817 QUERY_EXTENSION_ABILITY_INFO_BY_URI, 818 IMPLICIT_QUERY_INFO_BY_PRIORITY, 819 REGISTER_BUNDLE_EVENT_CALLBACK, 820 UNREGISTER_BUNDLE_EVENT_CALLBACK, 821 }; 822 }; 823 } // namespace AppExecFwk 824 } // namespace OHOS 825 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H 826