1 /*
2  * Copyright (c) 2021-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_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 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 ActiveUserKey(uint32_t userId,
71                           const std::vector<uint8_t> &token,
72                           const std::vector<uint8_t> &secret) override;
73     int32_t InactiveUserKey(uint32_t userId) override;
74     int32_t LockUserScreen(uint32_t userId) override;
75     int32_t UnlockUserScreen(uint32_t userId,
76                              const std::vector<uint8_t> &token,
77                              const std::vector<uint8_t> &secret) override;
78     int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) override;
79     int32_t UpdateKeyContext(uint32_t userId) override;
80     int32_t GenerateAppkey(uint32_t hashId, uint32_t userId, std::string &keyId) override;
81     int32_t DeleteAppkey(const std::string keyId) override;
82     int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override;
83 
84     // app file share api
85     std::vector<int32_t> CreateShareFile(const std::vector<std::string> &uriList,
86                                         uint32_t tokenId, uint32_t flag) override;
87     int32_t DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList) override;
88 
89     int32_t SetBundleQuota(const std::string &bundleName, int32_t uid, const std::string &bundleDataDirPath,
90         int32_t limitSizeMb) override;
91     int32_t UpdateMemoryPara(int32_t size, int32_t &oldSize) override;
92 
93     int32_t GetBundleStatsForIncrease(uint32_t userId, const std::vector<std::string> &bundleNames,
94         const std::vector<int64_t> &incrementalBackTimes, std::vector<int64_t> &pkgFileSizes,
95         std::vector<int64_t> &incPkgFileSizes) override;
96 
97     // dfs service
98     int32_t MountDfsDocs(int32_t userId, const std::string &relativePath,
99         const std::string &networkId, const std::string &deviceId) override;
100 
101     int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
102         const std::string &networkId, const std::string &deviceId) override;
103 private:
104     static inline BrokerDelegator<StorageManagerProxy> delegator_;
105     int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
106 };
107 } // StorageManager
108 } // OHOS
109 
110 #endif // OHOS_STORAGE_MANAGER_STORAGE_MANAGER_PROXY_H
111