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_ISTORAGE_MANAGER_H 17 #define OHOS_STORAGE_MANAGER_ISTORAGE_MANAGER_H 18 19 #include "iremote_broker.h" 20 #include "volume_core.h" 21 #include "volume_external.h" 22 #include "disk.h" 23 #include "bundle_stats.h" 24 #include "storage_stats.h" 25 26 namespace OHOS { 27 namespace StorageManager { 28 // PrepareAddUser flags 29 enum { 30 CRYPTO_FLAG_EL1 = 1, 31 CRYPTO_FLAG_EL2 = 2, 32 CRYPTO_FLAG_EL3 = 4, 33 CRYPTO_FLAG_EL4 = 8, 34 CRYPTO_FLAG_EL5 = 16, 35 }; 36 class IStorageManager : public IRemoteBroker { 37 public: 38 virtual int32_t PrepareAddUser(int32_t userId, uint32_t flags) = 0; 39 virtual int32_t RemoveUser(int32_t userId, uint32_t flags) = 0; 40 virtual int32_t PrepareStartUser(int32_t userId) = 0; 41 virtual int32_t StopUser(int32_t userId) = 0; 42 virtual int32_t CompleteAddUser(int32_t userId) = 0; 43 virtual int32_t GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize) = 0; 44 virtual int32_t GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize) = 0; 45 virtual int32_t GetBundleStats(std::string pkgName, BundleStats &bundleStats, 46 int32_t appIndex = 0, uint32_t statFlag = 0) = 0; 47 virtual int32_t GetSystemSize(int64_t &systemSize) = 0; 48 virtual int32_t GetTotalSize(int64_t &totalSize) = 0; 49 virtual int32_t GetFreeSize(int64_t &freeSize) = 0; 50 virtual int32_t GetUserStorageStats(StorageStats &storageStats) = 0; 51 virtual int32_t GetUserStorageStats(int32_t userId, StorageStats &storageStats) = 0; 52 virtual int32_t GetUserStorageStatsByType(int32_t userId, StorageStats &storageStats, std::string type) = 0; 53 virtual int32_t GetCurrentBundleStats(BundleStats &bundleStats, uint32_t statFlag = 0) = 0; 54 virtual int32_t NotifyVolumeCreated(VolumeCore vc) = 0; 55 virtual int32_t NotifyVolumeMounted(std::string volumeId, int fsType, std::string fsUuid, 56 std::string path, std::string description) = 0; 57 virtual int32_t NotifyVolumeStateChanged(std::string volumeId, VolumeState state) = 0; 58 virtual int32_t Mount(std::string volumeId) = 0; 59 virtual int32_t Unmount(std::string volumeId) = 0; 60 virtual int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) = 0; 61 virtual int32_t NotifyDiskCreated(Disk disk) = 0; 62 virtual int32_t NotifyDiskDestroyed(std::string diskId) = 0; 63 virtual int32_t Partition(std::string diskId, int32_t type) = 0; 64 virtual int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) = 0; 65 virtual int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc) = 0; 66 virtual int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc) = 0; 67 virtual int32_t SetVolumeDescription(std::string fsUuid, std::string description) = 0; 68 virtual int32_t Format(std::string volumeId, std::string fsType) = 0; 69 virtual int32_t GetDiskById(std::string diskId, Disk &disk) = 0; 70 71 // fscrypt api 72 virtual int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) = 0; 73 virtual int32_t DeleteUserKeys(uint32_t userId) = 0; 74 virtual int32_t UpdateUserAuth(uint32_t userId, uint64_t secureUid, 75 const std::vector<uint8_t> &token, 76 const std::vector<uint8_t> &oldSecret, 77 const std::vector<uint8_t> &newSecret) = 0; 78 virtual int32_t ActiveUserKey(uint32_t userId, 79 const std::vector<uint8_t> &token, 80 const std::vector<uint8_t> &secret) = 0; 81 virtual int32_t InactiveUserKey(uint32_t userId) = 0; 82 virtual int32_t UpdateKeyContext(uint32_t userId) = 0; 83 virtual int32_t LockUserScreen(uint32_t userId) = 0; 84 virtual int32_t UnlockUserScreen(uint32_t userId, 85 const std::vector<uint8_t> &token, 86 const std::vector<uint8_t> &secret) = 0; 87 virtual int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) = 0; 88 virtual int32_t GenerateAppkey(uint32_t hashId, uint32_t userId, std::string &keyId) = 0; 89 virtual int32_t DeleteAppkey(const std::string keyId) = 0; 90 virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) = 0; 91 92 // app file share api 93 virtual std::vector<int32_t> CreateShareFile(const std::vector<std::string> &uriList, 94 uint32_t tokenId, uint32_t flag) = 0; 95 virtual int32_t DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList) = 0; 96 SetBundleQuota(const std::string & bundleName,int32_t uid,const std::string & bundleDataDirPath,int32_t limitSizeMb)97 virtual int32_t SetBundleQuota(const std::string &bundleName, int32_t uid, const std::string &bundleDataDirPath, 98 int32_t limitSizeMb) 99 { 100 return 0; 101 } 102 103 virtual int32_t UpdateMemoryPara(int32_t size, int32_t &oldSize) = 0; 104 virtual int32_t GetBundleStatsForIncrease(uint32_t userId, const std::vector<std::string> &bundleNames, 105 const std::vector<int64_t> &incrementalBackTimes, std::vector<int64_t> &pkgFileSizes, 106 std::vector<int64_t> &incPkgFileSizes) = 0; 107 108 // dfs service 109 virtual int32_t MountDfsDocs(int32_t userId, const std::string &relativePath, 110 const std::string &networkId, const std::string &deviceId) = 0; 111 virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath, 112 const std::string &networkId, const std::string &deviceId) = 0; 113 114 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.StorageManager.IStorageManager"); 115 }; 116 } // StorageManager 117 } // OHOS 118 119 #endif // OHOS_STORAGE_MANAGER_ISTORAGER_MANAGER_H