• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_USER_LOCKED_EVENT_SUBSCRIBER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_USER_LOCKED_EVENT_SUBSCRIBER_H
18 
19 #include <mutex>
20 
21 #include "bundle_info.h"
22 #include "common_event_data.h"
23 #include "common_event_subscriber.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class UserUnlockedEventSubscriber final : public EventFwk::CommonEventSubscriber {
28 public:
29     explicit UserUnlockedEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo);
30     virtual ~UserUnlockedEventSubscriber();
31     void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
32 
33 private:
34     std::mutex mutex_;
35     int32_t userId_ = 0;
36 };
37 
38 class UpdateAppDataMgr {
39 public:
40     static void UpdateAppDataDirSelinuxLabel(int32_t userId);
41     static void ProcessUpdateAppDataDir(
42         int32_t userId, const std::vector<BundleInfo> &bundleInfos, const std::string &elDir);
43     static void ProcessUpdateAppLogDir(const std::vector<BundleInfo> &bundleInfos, int32_t userId);
44     static void ProcessFileManagerDir(const std::vector<BundleInfo> &bundleInfos, int32_t userId);
45     static void ProcessExtensionDir(const BundleInfo &bundleInfo, std::vector<std::string> &dirs);
46     static void ProcessNewBackupDir(const std::vector<BundleInfo> &bundleInfos, int32_t userId);
47 private:
48     static void CheckPathAttribute(const std::string &path, const BundleInfo &bundleInfo, bool &isExist);
49     static void CreateNewBackupDir(const BundleInfo &bundleInfo, int32_t userId);
50     static bool CreateBundleDataDir(const BundleInfo &bundleInfo, int32_t userId, const std::string &elDir);
51     static bool CreateBundleLogDir(const BundleInfo &bundleInfo, int32_t userId);
52     static bool CreateBundleCloudDir(const BundleInfo &bundleInfo, int32_t userId);
53     static void CreateDataGroupDir(const BundleInfo &bundleInfo, int32_t userId);
54 };
55 }  // namespace AppExecFwk
56 }  // namespace OHOS
57 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_USER_LOCKED_EVENT_SUBSCRIBER_H
58