1 /* 2 * Copyright (c) 2022-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_BUNDLE_USER_MGR_HOST_IMPL_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_USER_MGR_HOST_IMPL_H 18 19 #include "bundle_data_mgr.h" 20 #include "bundle_installer_host.h" 21 #include "bundle_user_mgr_host.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 class BundleUserMgrHostImpl : public BundleUserMgrHost { 26 public: 27 static bool SkipThirdPreloadAppInstallation(const int32_t userId, const PreInstallBundleInfo &preInfo); 28 /** 29 * @brief Create new user. 30 * @param userId Indicates the userId. 31 * @param bundleUserStatus Indicates the bundleUserStatus. 32 * @param disallowList Pass in the provisioned disallowList. 33 */ 34 ErrCode CreateNewUser(int32_t userId, const std::vector<std::string> &disallowList = {}, 35 const std::optional<std::vector<std::string>> &allowList = std::nullopt) override; 36 /** 37 * @brief Remove user. 38 * @param userId Indicates the userId. 39 * @param bundleUserStatus Indicates the bundleUserStatus. 40 */ 41 virtual ErrCode RemoveUser(int32_t userId) override; 42 43 void AddNotifyBundleEvents(const NotifyBundleEvents ¬ifyBundleEvents); 44 45 void SavePreInstallException(const std::string &bundleName); 46 47 private: 48 void CheckSystemHspInstallPath(); 49 void BootFailError(const char *exceptionInfo); 50 const std::shared_ptr<BundleDataMgr> GetDataMgrFromService(); 51 const sptr<IBundleInstaller> GetBundleInstaller(); 52 void InnerUninstallBundle(int32_t userId, const std::vector<BundleInfo> &bundleInfos); 53 ErrCode CheckInitialUser(); 54 void BeforeCreateNewUser(int32_t userId); 55 void OnCreateNewUser(int32_t userId, bool needToSkipPreBundleInstall, 56 const std::vector<std::string> &disallowList = {}, 57 const std::optional<std::vector<std::string>> &allowList = std::nullopt); 58 void AfterCreateNewUser(int32_t userId); 59 void RemoveArkProfile(int32_t userId); 60 void RemoveAsanLogDirectory(int32_t userId); 61 void HandleSceneBoard(int32_t userId) const; 62 void HandleNotifyBundleEventsAsync(); 63 void HandleNotifyBundleEvents(); 64 void ClearBundleEvents(); 65 bool GetAllPreInstallBundleInfos( 66 const std::vector<std::string> &disallowList, 67 int32_t userId, bool needToSkipPreBundleInstall, 68 std::set<PreInstallBundleInfo> &preInstallBundleInfos, 69 const std::optional<std::vector<std::string>> &allowList = std::nullopt); 70 void UninstallBackupUninstallList(int32_t userId, bool needToSkipPreBundleInstall); 71 void GetAdditionalBundleInfos(std::set<PreInstallBundleInfo> &preInstallBundleInfos); 72 73 bool InnerProcessSkipPreInstallBundles( 74 const std::set<std::string> &uninstallList, bool needToSkipPreBundleInstall); 75 76 ErrCode InnerRemoveUser(int32_t userId, bool needLock); 77 78 ErrCode ProcessRemoveUser(int32_t userId); 79 80 ErrCode CreateArkStartupCacheDir(int32_t userId); 81 82 ErrCode RemoveSystemOptimizeDir(int32_t userId); 83 84 std::mutex bundleUserMgrMutex_; 85 86 std::mutex bundleEventMutex_; 87 std::vector<NotifyBundleEvents> bundleEvents_; 88 }; 89 } // namespace AppExecFwk 90 } // namespace OHOS 91 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_USER_MGR_HOST_IMPL_H 92