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_CLIENT_H 17 #define STORAGE_DAEMON_CLIENT_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 static int32_t LockUserScreen(uint32_t userId); 54 static int32_t UnlockUserScreen(uint32_t userId, 55 const std::vector<uint8_t> &token, 56 const std::vector<uint8_t> &secret); 57 static int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus); 58 static int32_t GenerateAppkey(uint32_t userId, uint32_t hashId, std::string &keyId); 59 static int32_t DeleteAppkey(uint32_t userId, const std::string keyId); 60 static int32_t MountDfsDocs(int32_t userId, const std::string &relativePath, 61 const std::string &networkId, const std::string &deviceId); 62 static int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath, 63 const std::string &networkId, const std::string &deviceId); 64 static int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false); 65 66 private: 67 static sptr<IStorageDaemon> GetStorageDaemonProxy(void); 68 static bool CheckServiceStatus(uint32_t serviceFlags); 69 }; 70 } // StorageDaemon 71 } // OHOS 72 73 #endif