• 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 "user/mount_manager.h"
20 
21 namespace OHOS {
22 namespace StorageDaemon {
23 class UserManager final {
24 public:
25     UserManager();
26     virtual ~UserManager() = default;
27     static UserManager &GetInstance();
28     int32_t CheckCrypto(int32_t userId, uint32_t flags);
29     int32_t PrepareUserDirs(int32_t userId, uint32_t flags);
30     int32_t DestroyUserDirs(int32_t userId, uint32_t flags);
31     int32_t StartUser(int32_t userId);
32     int32_t StopUser(int32_t userId);
33     void CreateElxBundleDataDir(uint32_t userId, uint8_t elx);
34     void CheckDirsFromVec(int32_t userId);
35 
36 private:
37     int32_t PrepareDirsFromIdAndLevel(int32_t userId, const std::string &level);
38     int32_t DestroyDirsFromIdAndLevel(int32_t userId, const std::string &level);
39     int32_t PrepareEl1BundleDir(int32_t userId);
40     int32_t DestroyEl1BundleDir(int32_t userId);
41     int32_t PrepareEl2BackupDir(int32_t userId);
42     int32_t DestroyEl2BackupDir(int32_t userId);
43     int32_t PrepareEl1Dir(int32_t userId);
44     int32_t DestroyEl1Dir(int32_t userId);
45     int32_t SetElDirFscryptPolicy(int32_t userId, const std::string &level,
46         const std::vector<FileList> &list);
47     int32_t CheckUserIdRange(int32_t userId);
48 
49     DISALLOW_COPY_AND_MOVE(UserManager);
50 
51     const std::vector<DirInfo> rootDirVec_;
52     const std::vector<DirInfo> el3DirEl4DirEl5DirVec_;
53     const std::vector<DirInfo> subDirVec_;
54     const std::vector<DirInfo> el2DirVec_;
55     const std::vector<DirInfo> el1DirVec_;
56     const std::string bundle_ = "/data/app/el1/bundle/%d";
57     std::mutex mutex_;
58 };
59 } // STORAGE_DAEMON
60 } // OHOS
61 
62 #endif // OHOS_STORAGE_DAEMON_USER_MANAGER_H