1 /* 2 * Copyright (c) 2025 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_PATCH_DATA_MGR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PATCH_DATA_MGR_H 18 19 #include "patch_data_storage_rdb.h" 20 #include "inner_patch_info.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 class PatchDataMgr final { 25 public: 26 static PatchDataMgr& GetInstance(); 27 /** 28 * @brief Add new InnerPatchInfo. 29 * @param bundleName Indicates the bundle name. 30 * @param info Indicates the InnerBundleInfo object to be save. 31 * @return Returns true if this function is successfully called; returns false otherwise. 32 */ 33 bool AddInnerPatchInfo(const std::string &bundleName, const InnerPatchInfo &info); 34 35 /** 36 * @brief Get target InnerPatchInfo. 37 * @param bundleName Indicates the bundle name. 38 * @param info Indicates the InnerBundleInfo object to be save. 39 * @return Returns true if this function is successfully called; returns false otherwise. 40 */ 41 bool GetInnerPatchInfo(const std::string &bundleName, InnerPatchInfo &info) const; 42 43 /** 44 * @brief delete InnerPatchInfo. 45 * @param bundleName Indicates the bundle name. 46 * @return Returns true if this function is successfully called; returns false otherwise. 47 */ 48 bool DeleteInnerPatchInfo(const std::string &bundleName); 49 50 /** 51 * @brief Process InnerPatchInfo. 52 * @param bundleName Indicates the bundle name. 53 * @param installSources Indicates the app install sources. 54 * @param versionCode Indicates the app version. 55 * @param type Indicates app patch type. 56 * @param isPatch Indicates whether the app is an emergency patch module. 57 * @return no return 58 */ 59 void ProcessPatchInfo(const std::string &bundleName, const std::vector<std::string> &installSources, 60 uint32_t versionCode, AppPatchType type, bool isPatch = false); 61 62 private: 63 PatchDataMgr(); 64 ~PatchDataMgr(); 65 DISALLOW_COPY_AND_MOVE(PatchDataMgr); 66 67 std::shared_ptr<PatchDataStorageRdb> patchDataStorage_; 68 }; 69 70 } // namespace AppExecFwk 71 } // namespace OHOS 72 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PATCH_DATA_MGR_H 73