1 /* 2 * Copyright (c) 2023-2024 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 OHOS_FILEMGMT_BACKUP_BUNDLE_MGR_ADAPTER_H 17 #define OHOS_FILEMGMT_BACKUP_BUNDLE_MGR_ADAPTER_H 18 19 #include <string> 20 #include <vector> 21 22 #include "b_json/b_json_entity_caps.h" 23 #include "bundlemgr/bundle_mgr_interface.h" 24 #include "b_incremental_data.h" 25 #include "istorage_manager.h" 26 27 namespace OHOS::FileManagement::Backup { 28 class InnerReceiverImpl; 29 30 class BundleMgrAdapter { 31 public: 32 33 /** 34 * @brief Get the bundle infos object 35 * 36 * @param bundleNames bundle names 37 * @param userId User ID 38 * @return std::vector<BJsonEntityCaps::BundleInfo> 39 */ 40 static std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfos(const std::vector<std::string> &bundleNames, 41 int32_t userId); 42 43 /** 44 * @brief Get app gallery bundle name 45 */ 46 static std::string GetAppGalleryBundleName(); 47 48 /** 49 * @brief Get the bundle infos object for incremental backup 50 * 51 * @param incrementalDataList bundle Name and time list 52 * @param userId User ID 53 * @return std::vector<BJsonEntityCaps::BundleInfo> 54 */ 55 static std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForIncremental( 56 const std::vector<BIncrementalData> &incrementalDataList, int32_t userId); 57 58 static std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForIncremental(int32_t userId, 59 const std::vector<BIncrementalData> &extraIncreData = {}); 60 61 static std::vector<BJsonEntityCaps::BundleInfo> GetFullBundleInfos(int32_t userId); 62 63 static std::string GetExtName(string bundleName, int32_t userId); 64 65 static std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForSA(); 66 67 static void GetBundleInfoForSA(std::string bundleName, std::vector<BJsonEntityCaps::BundleInfo> &bundleInfos); 68 69 static bool IsUser0BundleName(std::string bundleName, int32_t userId); 70 71 static std::vector<BJsonEntityCaps::BundleInfo> GetBundleInfosForAppend( 72 const std::vector<BIncrementalData> &incrementalDataList, int32_t userId); 73 private: 74 static bool GetCurBundleExtenionInfo(AppExecFwk::BundleInfo &installedBundle, const std::string &bundleName, 75 std::vector<AppExecFwk::ExtensionAbilityInfo> &extensionInfos, sptr<AppExecFwk::IBundleMgr> bms, 76 int32_t userId); 77 }; 78 } // namespace OHOS::FileManagement::Backup 79 #endif // OHOS_FILEMGMT_BACKUP_BUNDLE_MGR_ADAPTER_H 80