• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = {}) override;
35     /**
36      * @brief Remove user.
37      * @param userId Indicates the userId.
38      * @param bundleUserStatus Indicates the bundleUserStatus.
39      */
40     virtual ErrCode RemoveUser(int32_t userId) override;
41 
42     void AddNotifyBundleEvents(const NotifyBundleEvents &notifyBundleEvents);
43 
44     void SavePreInstallException(const std::string &bundleName);
45 
46 private:
47     void CheckBackUpFirstBootLog();
48     const std::shared_ptr<BundleDataMgr> GetDataMgrFromService();
49     const sptr<IBundleInstaller> GetBundleInstaller();
50     void InnerUninstallBundle(int32_t userId, const std::vector<BundleInfo> &bundleInfos);
51     ErrCode CheckInitialUser();
52     void BeforeCreateNewUser(int32_t userId);
53     void OnCreateNewUser(int32_t userId, bool needToSkipPreBundleInstall,
54         const std::vector<std::string> &disallowList = {});
55     void AfterCreateNewUser(int32_t userId);
56     void RemoveArkProfile(int32_t userId);
57     void RemoveAsanLogDirectory(int32_t userId);
58     void HandleSceneBoard(int32_t userId) const;
59     void HandleNotifyBundleEventsAsync();
60     void HandleNotifyBundleEvents();
61     void ClearBundleEvents();
62     bool GetAllPreInstallBundleInfos(
63         const std::vector<std::string> &disallowList,
64         int32_t userId,
65         bool needToSkipPreBundleInstall,
66         std::set<PreInstallBundleInfo> &preInstallBundleInfos);
67     void UninstallBackupUninstallList(int32_t userId, bool needToSkipPreBundleInstall);
68     void GetAdditionalBundleInfos(std::set<PreInstallBundleInfo> &preInstallBundleInfos);
69 
70     bool InnerProcessSkipPreInstallBundles(
71         const std::set<std::string> &uninstallList, bool needToSkipPreBundleInstall);
72 
73     ErrCode InnerRemoveUser(int32_t userId, bool needLock);
74 
75     ErrCode ProcessRemoveUser(int32_t userId);
76 
77     std::mutex bundleUserMgrMutex_;
78 
79     std::mutex bundleEventMutex_;
80     std::vector<NotifyBundleEvents> bundleEvents_;
81 };
82 }  // namespace AppExecFwk
83 }  // namespace OHOS
84 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_USER_MGR_HOST_IMPL_H
85