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_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H 18 #include <mutex> 19 #include <string> 20 21 #include "ability_info.h" 22 #include "appexecfwk_errors.h" 23 #include "bms_extension.h" 24 #include "bundle_info.h" 25 #include "bundle_resource_info.h" 26 #include "launcher_ability_resource_info.h" 27 #include "interfaces/hap_verify.h" 28 #include "want.h" 29 #include "abs_rdb_predicates.h" 30 31 namespace OHOS { 32 namespace AppExecFwk { 33 class BmsExtensionDataMgr { 34 public: 35 using Want = OHOS::AAFwk::Want; 36 37 BmsExtensionDataMgr(); 38 ErrCode Init(); 39 bool CheckApiInfo(const BundleInfo &bundleInfo, uint32_t sdkVersion); 40 bool CheckApiInfo(uint32_t compatibleVersion, uint32_t sdkVersion); 41 ErrCode HapVerify(const std::string &filePath, Security::Verify::HapVerifyResult &hapVerifyResult); 42 bool IsRdDevice(); 43 ErrCode QueryAbilityInfos(const Want &want, int32_t userId, std::vector<AbilityInfo> &abilityInfos); 44 ErrCode QueryAbilityInfosWithFlag(const Want &want, int32_t flags, int32_t userId, 45 std::vector<AbilityInfo> &abilityInfos, bool isNewVersion = false); 46 ErrCode GetBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId, 47 bool isNewVersion = false); 48 ErrCode GetBundleInfo(const std::string &bundleName, int32_t flags, int32_t userId, 49 BundleInfo &bundleInfo, bool isNewVersion = false); 50 ErrCode Uninstall(const std::string &bundleName); 51 ErrCode GetBundleStats(const std::string &bundleName, int32_t userId, std::vector<int64_t> &bundleStats); 52 ErrCode ClearData(const std::string &bundleName, int32_t userId); 53 ErrCode ClearCache(const std::string &bundleName, sptr<IRemoteObject> callback, int32_t userId); 54 ErrCode GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t &uid); 55 ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName); 56 ErrCode VerifyActivationLock(bool &res); 57 ErrCode GetBackupUninstallList(int32_t userId, std::set<std::string> &uninstallBundles); 58 ErrCode ClearBackupUninstallFile(int32_t userId); 59 ErrCode AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId); 60 ErrCode AddResourceInfoByAbility(const std::string &bundleName, const std::string &moduleName, 61 const std::string &abilityName, const int32_t userId); 62 ErrCode DeleteResourceInfo(const std::string &key); 63 ErrCode OptimizeDisposedPredicates(const std::string &callingName, const std::string &appId, 64 int32_t userId, int32_t appIndex, NativeRdb::AbsRdbPredicates &absRdbPredicates); 65 bool IsAppInBlocklist(const std::string &bundleName, const int32_t userId); 66 bool CheckWhetherCanBeUninstalled(const std::string &bundleName); 67 68 ErrCode GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags, 69 BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0); 70 ErrCode GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags, 71 std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0); 72 ErrCode GetAllBundleResourceInfo(const uint32_t flags, std::vector<BundleResourceInfo> &bundleResourceInfos); 73 ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags, 74 std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos); 75 void CheckBundleNameAndStratAbility(const std::string &bundleName, const std::string &appIdentifier); 76 bool DetermineCloneNum(const std::string &bundleName, const std::string &appIdentifier, int32_t &cloneNum); 77 std::string GetCompatibleDeviceType(const std::string &bundleName); 78 private: 79 bool OpenHandler(); 80 static BmsExtension bmsExtension_; 81 static void *handler_; 82 }; 83 } // namespace AppExecFwk 84 } // namespace OHOS 85 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_DATA_MGR_H