1 /* 2 * Copyright (c) 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_HMP_BUNDLE_INSTALLER_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_HMP_BUNDLE_INSTALLER_H 18 19 #include "base_bundle_installer.h" 20 21 namespace OHOS { 22 namespace AppExecFwk { 23 class HmpBundleInstaller : public BaseBundleInstaller { 24 public: 25 HmpBundleInstaller(); 26 virtual ~HmpBundleInstaller() override; 27 28 ErrCode InstallSystemHspInHmp(const std::string &bundleDir) const; 29 30 ErrCode InstallNormalAppInHmp(const std::string &bundleDir, bool removable = true); 31 32 bool GetRequiredUserIds(std::string bundleName, std::set<int32_t> &userIds); 33 34 void RollbackHmpBundle(const std::set<std::string> &systemHspList, 35 const std::set<std::string> &hapList); 36 37 void UpdateBundleInfo(const std::string &bundleName, const std::string &bundleDir, const std::string &hspDir); 38 39 private: 40 bool CheckAppIsUpdatedByUser(const std::string &bundleName); 41 42 std::set<std::string> GetHmpBundleList(const std::string &path) const; 43 44 void UpdateInnerBundleInfo(const std::string &bundleName, 45 const std::unordered_map<std::string, InnerBundleInfo> &infos); 46 47 void ParseInfos(const std::string &bundleDir, const std::string &hspDir, 48 std::unordered_map<std::string, InnerBundleInfo> &infos); 49 50 bool ParseHapFiles(const std::string &hapFilePath, std::unordered_map<std::string, InnerBundleInfo> &infos); 51 52 bool UninstallSystemBundle(const std::string &bundleName, const std::string &modulePackage); 53 54 void CheckUninstallSystemHsp(const std::string &bundleName); 55 56 void UpdatePreInfoInDb( 57 const std::string &bundleName, const std::unordered_map<std::string, InnerBundleInfo> &infos); 58 59 void UpdateBundleInfoForHmp(const std::string &filePath, std::set<std::string> hapList, 60 std::set<std::string> systemHspList); 61 62 bool GetIsRemovable(const std::string &bundleName); 63 64 bool InitDataMgr(); 65 66 std::shared_ptr<BundleDataMgr> dataMgr_ = nullptr; 67 68 DISALLOW_COPY_AND_MOVE(HmpBundleInstaller); 69 }; 70 } // namespace AppExecFwk 71 } // namespace OHOS 72 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_HMP_BUNDLE_INSTALLER_H 73