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_ON_DEMAND_INSTALL_DATA_MGR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_ON_DEMAND_INSTALL_DATA_MGR_H 18 19 #include <cstdint> 20 #include <mutex> 21 #include <shared_mutex> 22 #include <string> 23 #include <vector> 24 25 #include "install_param.h" 26 #include "on_demand_install_data_storage_rdb.h" 27 #include "pre_install_bundle_info.h" 28 29 namespace OHOS { 30 namespace AppExecFwk { 31 32 class OnDemandInstallDataMgr { 33 public: 34 virtual ~OnDemandInstallDataMgr(); 35 36 static OnDemandInstallDataMgr& GetInstance(); 37 38 /** 39 * @brief Save new OnDemandInstallBundleInfo. 40 * @param bundleName Indicates the bundle name. 41 * @param preInstallBundleInfo Indicates the PreInstallBundleInfo object to be save. 42 * @return Returns true if this function is successfully called; returns false otherwise. 43 */ 44 bool SaveOnDemandInstallBundleInfo( 45 const std::string &bundleName, const PreInstallBundleInfo &preInstallBundleInfo); 46 /** 47 * @brief Delete OnDemandInstallBundleInfo. 48 * @param bundleName Indicates the bundle name of the application. 49 * @return Returns true if this function is successfully called; returns false otherwise. 50 */ 51 bool DeleteOnDemandInstallBundleInfo(const std::string &bundleName); 52 /** 53 * @brief Obtains the OnDemandInstallBundleInfo objects provided by bundleName. 54 * @param bundleName Indicates the bundle name of the application. 55 * @param preInstallBundleInfo Indicates information about the PreInstallBundleInfo. 56 * @return Returns true if this function is successfully called; returns false otherwise. 57 */ 58 bool GetOnDemandInstallBundleInfo(const std::string &bundleName, PreInstallBundleInfo &preInstallBundleInfo); 59 /** 60 * @brief Obtains the all OnDemandInstallBundleInfo. 61 * @param preInstallBundleInfos Indicates information about the PreInstallBundleInfos. 62 * @return Returns true if this function is successfully called; returns false otherwise. 63 */ 64 bool GetAllOnDemandInstallBundleInfos(std::vector<PreInstallBundleInfo> &preInstallBundleInfos); 65 66 void DeleteNoDataPreloadBundleInfos(); 67 68 bool IsOnDemandInstall(const InstallParam &installParam); 69 70 std::string GetAppidentifier(const std::string &bundlePath); 71 72 private: 73 OnDemandInstallDataMgr(); 74 std::shared_ptr<OnDemandInstallDataStorageRdb> onDemandDataStorage_; 75 }; 76 } // namespace AppExecFwk 77 } // namespace OHOS 78 #endif // FOUNDATION_APPEXECFWK_SERVICES_ON_DEMAND_INSTALL_DATA_MGR_H