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