1 /* 2 * Copyright (c) 2023 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_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_CORE_EXT_INCLUDE_BUNDLE_MGR_EX_H 17 #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_CORE_EXT_INCLUDE_BUNDLE_MGR_EX_H 18 19 #include "appexecfwk_errors.h" 20 #include "ability_info.h" 21 #include "bundle_info.h" 22 #include "bundle_resource_info.h" 23 #include "launcher_ability_resource_info.h" 24 #include "interfaces/hap_verify.h" 25 #include "want.h" 26 #include "abs_rdb_predicates.h" 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 class BundleMgrExt { 31 public: 32 using Want = OHOS::AAFwk::Want; 33 34 virtual ~BundleMgrExt() = default; 35 36 virtual bool CheckApiInfo(const BundleInfo& bundleInfo) = 0; HapVerify(const std::string & filePath,Security::Verify::HapVerifyResult & hapVerifyResult)37 virtual ErrCode HapVerify(const std::string &filePath, Security::Verify::HapVerifyResult &hapVerifyResult) 38 { 39 return ERR_BUNDLEMANAGER_INSTALL_FAILED_SIGNATURE_EXTENSION_NOT_EXISTED; 40 } IsRdDevice()41 virtual bool IsRdDevice() 42 { 43 return false; 44 } QueryAbilityInfos(const Want & want,int32_t userId,std::vector<AbilityInfo> & abilityInfos)45 virtual ErrCode QueryAbilityInfos(const Want &want, int32_t userId, 46 std::vector<AbilityInfo> &abilityInfos) 47 { 48 return ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED; 49 } 50 virtual ErrCode QueryAbilityInfosWithFlag(const Want &want, int32_t flags, int32_t userId, 51 std::vector<AbilityInfo> &abilityInfos, bool isNewVersion = false) 52 { 53 return ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED; 54 } 55 virtual ErrCode GetBundleInfo(const std::string &bundleName, int32_t flags, int32_t userId, 56 BundleInfo &bundleInfo, bool isNewVersion = false) 57 { 58 return ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED; 59 } 60 virtual ErrCode GetBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId, 61 bool isNewVersion = false) 62 { 63 return ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED; 64 } Uninstall(const std::string & bundleName)65 virtual ErrCode Uninstall(const std::string &bundleName) 66 { 67 return ERR_BUNDLE_MANAGER_INSTALL_FAILED_BUNDLE_EXTENSION_NOT_EXISTED; 68 } GetBundleStats(const std::string & bundleName,int32_t userId,std::vector<int64_t> & bundleStats)69 virtual ErrCode GetBundleStats(const std::string &bundleName, int32_t userId, std::vector<int64_t> &bundleStats) 70 { 71 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 72 } ClearData(const std::string & bundleName,int32_t userId)73 virtual ErrCode ClearData(const std::string &bundleName, int32_t userId) 74 { 75 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 76 } ClearCache(const std::string & bundleName,sptr<IRemoteObject> callback,int32_t userId)77 virtual ErrCode ClearCache(const std::string &bundleName, sptr<IRemoteObject> callback, int32_t userId) 78 { 79 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 80 } GetUidByBundleName(const std::string & bundleName,int32_t userId,int32_t & uid)81 virtual ErrCode GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t &uid) 82 { 83 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 84 } GetBundleNameByUid(int32_t uid,std::string & bundleName)85 virtual ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName) 86 { 87 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 88 } VerifyActivationLock(bool & res)89 virtual ErrCode VerifyActivationLock(bool &res) 90 { 91 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 92 } GetBackupUninstallList(int32_t userId,std::set<std::string> & uninstallBundles)93 virtual ErrCode GetBackupUninstallList(int32_t userId, std::set<std::string> &uninstallBundles) 94 { 95 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 96 } ClearBackupUninstallFile(int32_t userId)97 virtual ErrCode ClearBackupUninstallFile(int32_t userId) 98 { 99 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 100 } AddResourceInfoByBundleName(const std::string & bundleName,const int32_t userId)101 virtual ErrCode AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId) 102 { 103 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 104 } AddResourceInfoByAbility(const std::string & bundleName,const std::string & moduleName,const std::string & abilityName,const int32_t userId)105 virtual ErrCode AddResourceInfoByAbility(const std::string &bundleName, const std::string &moduleName, 106 const std::string &abilityName, const int32_t userId) 107 { 108 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 109 } DeleteResourceInfo(const std::string & key)110 virtual ErrCode DeleteResourceInfo(const std::string &key) 111 { 112 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 113 } OptimizeDisposedPredicates(const std::string & callingName,const std::string & appId,int32_t userId,int32_t appIndex,NativeRdb::AbsRdbPredicates & absRdbPredicates)114 virtual ErrCode OptimizeDisposedPredicates(const std::string &callingName, const std::string &appId, 115 int32_t userId, int32_t appIndex, NativeRdb::AbsRdbPredicates &absRdbPredicates) 116 { 117 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 118 } IsAppInBlocklist(const std::string & bundleName,const int32_t userId)119 virtual bool IsAppInBlocklist(const std::string &bundleName, const int32_t userId) 120 { 121 return false; 122 } CheckWhetherCanBeUninstalled(const std::string & bundleName)123 virtual bool CheckWhetherCanBeUninstalled(const std::string &bundleName) 124 { 125 return true; 126 } DetermineCloneNum(const std::string & bundleName,const std::string & appIdentifier,int32_t & cloneNum)127 virtual bool DetermineCloneNum(const std::string &bundleName, const std::string &appIdentifier, int32_t &cloneNum) 128 { 129 return false; 130 } 131 virtual ErrCode GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags, 132 BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0) 133 { 134 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 135 } 136 virtual ErrCode GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags, 137 std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0) 138 { 139 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 140 } GetAllBundleResourceInfo(const uint32_t flags,std::vector<BundleResourceInfo> & bundleResourceInfos)141 virtual ErrCode GetAllBundleResourceInfo(const uint32_t flags, std::vector<BundleResourceInfo> &bundleResourceInfos) 142 { 143 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 144 } GetAllLauncherAbilityResourceInfo(const uint32_t flags,std::vector<LauncherAbilityResourceInfo> & launcherAbilityResourceInfos)145 virtual ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags, 146 std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos) 147 { 148 return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; 149 } CheckBundleNameAndStratAbility(const std::string & bundleName,const std::string & appIdentifier)150 virtual void CheckBundleNameAndStratAbility(const std::string &bundleName, const std::string &appIdentifier) 151 { 152 return; 153 } 154 }; 155 156 } // AppExecFwk 157 } // OHOS 158 159 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_CORE_EXT_INCLUDE_BUNDLE_MGR_EX_H