• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 OHOS_STORAGE_DAEMON_USER_MANAGER_H
17 #define OHOS_STORAGE_DAEMON_USER_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 #include <mutex>
22 #include <sys/types.h>
23 #include <nocopyable.h>
24 #include "user/mount_manager.h"
25 #include "utils/file_utils.h"
26 
27 namespace OHOS {
28 namespace StorageDaemon {
29 class UserManager final {
30 public:
31     UserManager();
32     virtual ~UserManager() = default;
33     static std::shared_ptr<UserManager> GetInstance();
34     int32_t PrepareUserDirs(int32_t userId, uint32_t flags);
35     int32_t DestroyUserDirs(int32_t userId, uint32_t flags);
36     int32_t StartUser(int32_t userId);
37     int32_t StopUser(int32_t userId);
38 
39 private:
40     int32_t PrepareDirsFromIdAndLevel(int32_t userId, const std::string &level);
41     int32_t DestroyDirsFromIdAndLevel(int32_t userId, const std::string &level);
42     int32_t PrepareEl1BundleDir(int32_t userId);
43     int32_t DestroyEl1BundleDir(int32_t userId);
44     int32_t PrepareEl2BackupDir(int32_t userId);
45     int32_t DestroyEl2BackupDir(int32_t userId);
46     int32_t SetElDirFscryptPolicy(int32_t userId, const std::string &level,
47         const std::vector<FileList> &list);
48 
49     DISALLOW_COPY_AND_MOVE(UserManager);
50 
51     static std::shared_ptr<UserManager> instance_;
52     const std::vector<DirInfo> rootDirVec_;
53     const std::vector<DirInfo> subDirVec_;
54     const std::vector<DirInfo> backupDirVec_;
55     const std::string bundle_ = "/data/app/el1/bundle/%d";
56     std::mutex mutex_;
57 };
58 } // STORAGE_DAEMON
59 } // OHOS
60 
61 #endif // OHOS_STORAGE_DAEMON_USER_MANAGER_H