• 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 STORAGE_DAEMON_CILENT_H
17 #define STORAGE_DAEMON_CILENT_H
18 
19 #include <mutex>
20 #include <iostream>
21 #include <vector>
22 #include <sys/types.h>
23 
24 #include "iremote_proxy.h"
25 #include "ipc/istorage_daemon.h"
26 #include "ipc/storage_daemon.h"
27 #include "ipc/storage_daemon_proxy.h"
28 
29 namespace OHOS {
30 namespace StorageDaemon {
31 class StorageDaemonClient {
32 public:
33     static int32_t PrepareUserDirs(int32_t userId, uint32_t flags);
34     static int32_t DestroyUserDirs(int32_t userId, uint32_t flags);
35     static int32_t StartUser(int32_t userId);
36     static int32_t StopUser(int32_t userId);
37     static int32_t PrepareUserSpace(uint32_t userId, const std::string &volumId, uint32_t flags);
38     static int32_t DestroyUserSpace(uint32_t userId, const std::string &volumId, uint32_t flags);
39     static int32_t InitGlobalKey(void);
40     static int32_t InitGlobalUserKeys(void);
41     static int32_t GenerateUserKeys(uint32_t userId, uint32_t flags);
42     static int32_t DeleteUserKeys(uint32_t userId);
43     static int32_t UpdateUserAuth(uint32_t userId, uint64_t secureUid,
44                                   const std::vector<uint8_t> &token,
45                                   const std::vector<uint8_t> &oldSecret,
46                                   const std::vector<uint8_t> &newSecret);
47     static int32_t ActiveUserKey(uint32_t userId,
48                                  const std::vector<uint8_t> &token,
49                                  const std::vector<uint8_t> &secret);
50     static int32_t InactiveUserKey(uint32_t userId);
51     static int32_t FscryptEnable(const std::string &fscryptOptions);
52     static int32_t UpdateKeyContext(uint32_t userId);
53 
54 private:
55     static sptr<IStorageDaemon> GetStorageDaemonProxy(void);
56     static bool CheckServiceStatus(uint32_t serviceFlags);
57 };
58 } // StorageDaemon
59 } // OHOS
60 
61 #endif