1 /* 2 * Copyright (c) 2024 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_MANAGER_STORAGE_MANAGER_PROXY_MOCK_H 17 #define OHOS_STORAGE_MANAGER_STORAGE_MANAGER_PROXY_MOCK_H 18 19 #include "iremote_proxy.h" 20 #include "istorage_manager.h" 21 22 namespace OHOS { 23 namespace StorageManager { 24 class StorageManagerProxy : public IRemoteProxy<IStorageManager> { 25 public: StorageManagerProxy(const sptr<IRemoteObject> & impl)26 explicit StorageManagerProxy(const sptr<IRemoteObject>& impl) 27 : IRemoteProxy<IStorageManager>(impl) {} ~StorageManagerProxy()28 ~StorageManagerProxy() override {} 29 30 int32_t PrepareAddUser(int32_t userId, uint32_t flags) override; 31 int32_t RemoveUser(int32_t userId, uint32_t flags) override; 32 int32_t PrepareStartUser(int32_t userId) override; 33 int32_t StopUser(int32_t userId) override; 34 int32_t CompleteAddUser(int32_t userId) override; 35 int32_t GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize) override; 36 int32_t GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize) override; 37 int32_t GetBundleStats(std::string pkgName, BundleStats &bundleStats, int32_t appIndex, 38 uint32_t statFlag) override; 39 int32_t GetSystemSize(int64_t &systemSize) override; 40 int32_t GetTotalSize(int64_t &totalSize) override; 41 int32_t GetFreeSize(int64_t &freeSize) override; 42 int32_t GetUserStorageStats(StorageStats &storageStats) override; 43 int32_t GetUserStorageStats(int32_t userId, StorageStats &storageStats) override; 44 int32_t GetUserStorageStatsByType(int32_t userId, StorageStats &storageStats, std::string type) override; 45 int32_t GetCurrentBundleStats(BundleStats &bundleStats, uint32_t statFlag) override; 46 int32_t NotifyVolumeCreated(VolumeCore vc) override; 47 int32_t NotifyVolumeMounted(std::string volumeId, int32_t fsType, std::string fsUuid, 48 std::string path, std::string description) override; 49 int32_t NotifyVolumeStateChanged(std::string volumeId, VolumeState state) override; 50 int32_t Mount(std::string volumeId) override; 51 int32_t Unmount(std::string volumeId) override; 52 int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) override; 53 int32_t NotifyDiskCreated(Disk disk) override; 54 int32_t NotifyDiskDestroyed(std::string diskId) override; 55 int32_t Partition(std::string diskId, int32_t type) override; 56 int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) override; 57 int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc) override; 58 int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc) override; 59 int32_t SetVolumeDescription(std::string fsUuid, std::string description) override; 60 int32_t Format(std::string volumeId, std::string fsType) override; 61 int32_t GetDiskById(std::string diskId, Disk &disk) override; 62 63 // fscrypt api 64 int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) override; 65 int32_t DeleteUserKeys(uint32_t userId) override; 66 int32_t UpdateUserAuth(uint32_t userId, uint64_t secureUid, 67 const std::vector<uint8_t> &token, 68 const std::vector<uint8_t> &oldSecret, 69 const std::vector<uint8_t> &newSecret) override; 70 int32_t UpdateUseAuthWithRecoveryKey(const std::vector<uint8_t> &authToken, 71 const std::vector<uint8_t> &newSecret, 72 uint64_t secureUid, 73 uint32_t userId, 74 std::vector<std::vector<uint8_t>> &plainText) override; 75 int32_t ActiveUserKey(uint32_t userId, 76 const std::vector<uint8_t> &token, 77 const std::vector<uint8_t> &secret) override; 78 int32_t InactiveUserKey(uint32_t userId) override; 79 int32_t LockUserScreen(uint32_t userId) override; 80 int32_t UnlockUserScreen(uint32_t userId, 81 const std::vector<uint8_t> &token, 82 const std::vector<uint8_t> &secret) override; 83 int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) override; 84 int32_t UpdateKeyContext(uint32_t userId, bool needRemoveTmpKey = false) override; 85 int32_t GenerateAppkey(uint32_t hashId, uint32_t userId, std::string &keyId) override; 86 int32_t DeleteAppkey(const std::string keyId) override; 87 int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override; 88 int32_t GetUserNeedActiveStatus(uint32_t userId, bool &needActive) override; 89 int32_t CreateRecoverKey(uint32_t userId, 90 uint32_t userType, 91 const std::vector<uint8_t> &token, 92 const std::vector<uint8_t> &secret) override; 93 int32_t SetRecoverKey(const std::vector<uint8_t> &key) override; 94 int32_t NotifyMtpMounted(const std::string &id, const std::string &path, const std::string &desc, 95 const std::string &uuid) override; 96 int32_t NotifyMtpUnmounted(const std::string &id, const std::string &path, const bool isBadRemove) override; 97 98 // app file share api 99 std::vector<int32_t> CreateShareFile(const std::vector<std::string> &uriList, 100 uint32_t tokenId, uint32_t flag) override; 101 int32_t DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList) override; 102 103 int32_t SetBundleQuota(const std::string &bundleName, int32_t uid, const std::string &bundleDataDirPath, 104 int32_t limitSizeMb) override; 105 int32_t UpdateMemoryPara(int32_t size, int32_t &oldSize) override; 106 107 int32_t GetBundleStatsForIncrease(uint32_t userId, const std::vector<std::string> &bundleNames, 108 const std::vector<int64_t> &incrementalBackTimes, std::vector<int64_t> &pkgFileSizes, 109 std::vector<int64_t> &incPkgFileSizes) override; 110 111 // dfs service 112 int32_t MountDfsDocs(int32_t userId, const std::string &relativePath, 113 const std::string &networkId, const std::string &deviceId) override; 114 115 int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath, 116 const std::string &networkId, const std::string &deviceId) override; 117 int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override; 118 int32_t UMountMediaFuse(int32_t userId) override; 119 // file mgr fuse 120 int32_t MountFileMgrFuse(int32_t userId, const std::string &path, int32_t &fuseFd) override; 121 int32_t UMountFileMgrFuse(int32_t userId, const std::string &path) override; 122 private: 123 static inline BrokerDelegator<StorageManagerProxy> delegator_; 124 int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 125 }; 126 } // StorageManager 127 } // OHOS 128 129 #endif // OHOS_STORAGE_MANAGER_STORAGE_MANAGER_PROXY_MOCK_H 130