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_MANAGER_STORAGE_MANAGER_PROXY_H 17 #define OHOS_STORAGE_MANAGER_STORAGE_MANAGER_PROXY_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 GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize) override; 35 int32_t GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize) override; 36 int32_t GetBundleStats(std::string pkgName, BundleStats &bundleStats) override; 37 int32_t GetSystemSize(int64_t &systemSize) override; 38 int32_t GetTotalSize(int64_t &totalSize) override; 39 int32_t GetFreeSize(int64_t &freeSize) override; 40 int32_t GetUserStorageStats(StorageStats &storageStats) override; 41 int32_t GetUserStorageStats(int32_t userId, StorageStats &storageStats) override; 42 int32_t GetCurrentBundleStats(BundleStats &bundleStats) override; 43 int32_t NotifyVolumeCreated(VolumeCore vc) override; 44 int32_t NotifyVolumeMounted(std::string volumeId, int32_t fsType, std::string fsUuid, 45 std::string path, std::string description) override; 46 int32_t NotifyVolumeStateChanged(std::string volumeId, VolumeState state) override; 47 int32_t Mount(std::string volumeId) override; 48 int32_t Unmount(std::string volumeId) override; 49 int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) override; 50 int32_t NotifyDiskCreated(Disk disk) override; 51 int32_t NotifyDiskDestroyed(std::string diskId) override; 52 int32_t Partition(std::string diskId, int32_t type) override; 53 int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) override; 54 int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc) override; 55 int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc) override; 56 int32_t SetVolumeDescription(std::string fsUuid, std::string description) override; 57 int32_t Format(std::string volumeId, std::string fsType) override; 58 int32_t GetDiskById(std::string diskId, Disk &disk) override; 59 60 // fscrypt api 61 int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) override; 62 int32_t DeleteUserKeys(uint32_t userId) override; 63 int32_t UpdateUserAuth(uint32_t userId, uint64_t secureUid, 64 const std::vector<uint8_t> &token, 65 const std::vector<uint8_t> &oldSecret, 66 const std::vector<uint8_t> &newSecret) override; 67 int32_t ActiveUserKey(uint32_t userId, 68 const std::vector<uint8_t> &token, 69 const std::vector<uint8_t> &secret) override; 70 int32_t InactiveUserKey(uint32_t userId) override; 71 int32_t UpdateKeyContext(uint32_t userId) override; 72 73 // app file share api 74 int32_t CreateShareFile(std::string uri, uint32_t tokenId, uint32_t flag) override; 75 int32_t DeleteShareFile(uint32_t tokenId, std::vector<std::string>sharePathList) override; 76 77 int32_t SetBundleQuota(const std::string &bundleName, int32_t uid, const std::string &bundleDataDirPath, 78 int32_t limitSizeMb) override; 79 80 private: 81 static inline BrokerDelegator<StorageManagerProxy> delegator_; 82 int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 83 }; 84 } // StorageManager 85 } // OHOS 86 87 #endif // OHOS_STORAGE_MANAGER_STORAGE_MANAGER_PROXY_H 88