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_CLIENT_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_CLIENT_H 18 19 #include "bms_extension_data_mgr.h" 20 #include "bundle_data_mgr.h" 21 #include "bundle_resource_info.h" 22 #include "launcher_ability_resource_info.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 class BmsExtensionClient { 27 public: 28 using Want = OHOS::AAFwk::Want; 29 30 BmsExtensionClient(); 31 virtual ~BmsExtensionClient() = default; 32 33 ErrCode QueryLauncherAbility(const Want &want, int32_t userId, 34 std::vector<AbilityInfo> &abilityInfos) const; 35 36 ErrCode QueryAbilityInfos(const Want &want, int32_t flags, int32_t userId, 37 std::vector<AbilityInfo> &abilityInfos, bool isNewVersion = false) const; 38 39 ErrCode BatchQueryAbilityInfos(const std::vector<Want> &wants, int32_t flags, int32_t userId, 40 std::vector<AbilityInfo> &abilityInfos, bool isNewVersion = false) const; 41 42 ErrCode QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, 43 AbilityInfo &abilityInfo, bool isNewVersion = false) const; 44 45 ErrCode GetBundleInfos( 46 int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId, bool isNewVersion = false) const; 47 48 ErrCode GetBundleInfo(const std::string &bundleName, int32_t flags, 49 BundleInfo &bundleInfo, int32_t userId, bool isNewVersion = false) const; 50 51 ErrCode BatchGetBundleInfo(const std::vector<std::string> &bundleNames, int32_t flags, 52 std::vector<BundleInfo> &bundleInfo, int32_t userId, bool isNewVersion = false) const; 53 54 ErrCode ImplicitQueryAbilityInfos( 55 const Want &want, int32_t flags, int32_t userId, std::vector<AbilityInfo> &abilityInfos, 56 bool isNewVersion) const; 57 ErrCode GetBundleStats(const std::string &bundleName, int32_t userId, std::vector<int64_t> &bundleStats); 58 ErrCode ClearData(const std::string &bundleName, int32_t userId); 59 ErrCode ClearCache(const std::string &bundleName, sptr<IRemoteObject> callback, int32_t userId); 60 ErrCode GetUidByBundleName(const std::string &bundleName, int32_t userId, int32_t &uid); 61 ErrCode GetBundleNameByUid(int32_t uid, std::string &bundleName); 62 ErrCode AddResourceInfoByBundleName(const std::string &bundleName, const int32_t userId); 63 ErrCode AddResourceInfoByAbility(const std::string &bundleName, const std::string &moduleName, 64 const std::string &abilityName, const int32_t userId); 65 ErrCode DeleteResourceInfo(const std::string &key); 66 ErrCode OptimizeDisposedPredicates(const std::string &callingName, const std::string &appId, 67 int32_t userId, int32_t appIndex, NativeRdb::AbsRdbPredicates &absRdbPredicates); 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 76 private: 77 void ModifyLauncherAbilityInfo(AbilityInfo &abilityInfo) const; 78 const std::shared_ptr<BundleDataMgr> GetDataMgr() const; 79 80 std::shared_ptr<BmsExtensionDataMgr> bmsExtensionImpl_; 81 }; 82 } // AppExecFwk 83 } // OHOS 84 85 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BMS_EXTENSION_CLIENT_H