1 /* 2 * Copyright (c) 2024-2025 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(const std::string& volumeUuid, int64_t &freeSize) override; 36 int32_t GetTotalSizeOfVolume(const std::string& volumeUuid, int64_t &totalSize) override; 37 int32_t GetBundleStats(const 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, const std::string& type) override; 45 int32_t GetCurrentBundleStats(BundleStats &bundleStats, uint32_t statFlag) override; 46 int32_t NotifyVolumeCreated(const VolumeCore& vc) override; 47 int32_t NotifyVolumeMounted(const std::string &volumeId, 48 const std::string &fsTypeStr, 49 const std::string &fsUuid, 50 const std::string &path, 51 const std::string &description) override; 52 int32_t NotifyVolumeStateChanged(const std::string& volumeId, uint32_t state) override; 53 int32_t NotifyVolumeDamaged(const std::string &volumeId, 54 const std::string &fsTypeStr, 55 const std::string &fsUuid, 56 const std::string &path, 57 const std::string &description) override; 58 int32_t Mount(const std::string& volumeId) override; 59 int32_t Unmount(const std::string& volumeId) override; 60 int32_t TryToFix(const std::string& volumeId) override; 61 int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) override; 62 int32_t NotifyDiskCreated(const Disk& disk) override; 63 int32_t NotifyDiskDestroyed(const std::string& diskId) override; 64 int32_t Partition(const std::string& diskId, int32_t type) override; 65 int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) override; 66 int32_t GetVolumeByUuid(const std::string& fsUuid, VolumeExternal &vc) override; 67 int32_t GetVolumeById(const std::string& volumeId, VolumeExternal &vc) override; 68 int32_t SetVolumeDescription(const std::string& fsUuid, const std::string& description) override; 69 int32_t Format(const std::string& volumeId, const std::string& fsType) override; 70 int32_t GetDiskById(const std::string& diskId, Disk &disk) override; 71 int32_t QueryUsbIsInUse(const std::string &diskPath, bool &isInUse) override; 72 73 // fscrypt api 74 int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) override; 75 int32_t DeleteUserKeys(uint32_t userId) override; 76 int32_t UpdateUserAuth(uint32_t userId, uint64_t secureUid, 77 const std::vector<uint8_t> &token, 78 const std::vector<uint8_t> &oldSecret, 79 const std::vector<uint8_t> &newSecret) override; 80 int32_t UpdateUseAuthWithRecoveryKey(const std::vector<uint8_t> &authToken, 81 const std::vector<uint8_t> &newSecret, 82 uint64_t secureUid, 83 uint32_t userId, 84 const std::vector<std::vector<uint8_t>> &plainText) override; 85 int32_t ActiveUserKey(uint32_t userId, 86 const std::vector<uint8_t> &token, 87 const std::vector<uint8_t> &secret) override; 88 int32_t InactiveUserKey(uint32_t userId) override; 89 int32_t LockUserScreen(uint32_t userId) override; 90 int32_t UnlockUserScreen(uint32_t userId, 91 const std::vector<uint8_t> &token, 92 const std::vector<uint8_t> &secret) override; 93 int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) override; 94 int32_t UpdateKeyContext(uint32_t userId, bool needRemoveTmpKey = false) override; 95 int32_t GenerateAppkey(uint32_t hashId, uint32_t userId, std::string &keyId, bool needReSet = false) override; 96 int32_t DeleteAppkey(const std::string& keyId) override; 97 int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override; 98 int32_t GetUserNeedActiveStatus(uint32_t userId, bool &needActive) override; 99 int32_t CreateRecoverKey(uint32_t userId, 100 uint32_t userType, 101 const std::vector<uint8_t> &token, 102 const std::vector<uint8_t> &secret) override; 103 int32_t SetRecoverKey(const std::vector<uint8_t> &key) override; 104 int32_t ResetSecretWithRecoveryKey(uint32_t userId, uint32_t rkType, const std::vector<uint8_t> &key) override; 105 int32_t NotifyMtpMounted(const std::string &id, const std::string &path, const std::string &desc, 106 const std::string &uuid) override; 107 int32_t NotifyMtpUnmounted(const std::string &id, const std::string &path, bool isBadRemove) override; 108 int32_t RegisterUeceActivationCallback(const sptr<IUeceActivationCallback>& callback) override; 109 int32_t UnregisterUeceActivationCallback() override; 110 111 // app file share api 112 int32_t CreateShareFile(const StorageFileRawData &rawData, 113 uint32_t tokenId, 114 uint32_t flag, 115 std::vector<int32_t> &funcResult) override; 116 int32_t DeleteShareFile(uint32_t tokenId, const StorageFileRawData &rawData) override; 117 118 int32_t SetBundleQuota(const std::string &bundleName, int32_t uid, const std::string &bundleDataDirPath, 119 int32_t limitSizeMb) override; 120 int32_t UpdateMemoryPara(int32_t size, int32_t &oldSize) override; 121 122 // dfs service 123 int32_t MountDfsDocs(int32_t userId, const std::string &relativePath, 124 const std::string &networkId, const std::string &deviceId) override; 125 126 int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath, 127 const std::string &networkId, const std::string &deviceId) override; 128 int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override; 129 int32_t UMountMediaFuse(int32_t userId) override; 130 // file mgr fuse 131 int32_t MountFileMgrFuse(int32_t userId, const std::string &path, int32_t &fuseFd) override; 132 int32_t UMountFileMgrFuse(int32_t userId, const std::string &path) override; 133 // file lock 134 int32_t IsFileOccupied(const std::string &path, const std::vector<std::string> &inputList, 135 std::vector<std::string> &outputList, bool &isOccupy) override; 136 int32_t MountDisShareFile(int32_t userId, const std::map<std::string, std::string> &shareFiles) override; 137 int32_t UMountDisShareFile(int32_t userId, const std::string &networkId) override; 138 int32_t InactiveUserPublicDirKey(uint32_t userId) override; 139 private: 140 static inline BrokerDelegator<StorageManagerProxy> delegator_; 141 int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 142 }; 143 } // StorageManager 144 } // OHOS 145 146 #endif // OHOS_STORAGE_MANAGER_STORAGE_MANAGER_PROXY_MOCK_H 147