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_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 class IStorageManager : public IRemoteBroker { 29 public: 30 virtual int32_t PrepareAddUser(int32_t userId, uint32_t flags) = 0; 31 virtual int32_t RemoveUser(int32_t userId, uint32_t flags) = 0; 32 virtual int32_t PrepareStartUser(int32_t userId) = 0; 33 virtual int32_t StopUser(int32_t userId) = 0; 34 virtual int32_t GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize) = 0; 35 virtual int32_t GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize) = 0; 36 virtual int32_t GetBundleStats(std::string pkgName, BundleStats &bundleStats) = 0; 37 virtual int32_t GetSystemSize(int64_t &systemSize) = 0; 38 virtual int32_t GetTotalSize(int64_t &totalSize) = 0; 39 virtual int32_t GetFreeSize(int64_t &freeSize) = 0; 40 virtual int32_t GetUserStorageStats(StorageStats &storageStats) = 0; 41 virtual int32_t GetUserStorageStats(int32_t userId, StorageStats &storageStats) = 0; 42 virtual int32_t GetCurrentBundleStats(BundleStats &bundleStats) = 0; 43 virtual int32_t NotifyVolumeCreated(VolumeCore vc) = 0; 44 virtual int32_t NotifyVolumeMounted(std::string volumeId, int fsType, std::string fsUuid, 45 std::string path, std::string description) = 0; 46 virtual int32_t NotifyVolumeDestroyed(std::string volumeId) = 0; 47 virtual int32_t Mount(std::string volumeId) = 0; 48 virtual int32_t Unmount(std::string volumeId) = 0; 49 virtual int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) = 0; 50 virtual int32_t NotifyDiskCreated(Disk disk) = 0; 51 virtual int32_t NotifyDiskDestroyed(std::string diskId) = 0; 52 virtual int32_t Partition(std::string diskId, int32_t type) = 0; 53 virtual int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) = 0; 54 virtual int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc) = 0; 55 virtual int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc) = 0; 56 virtual int32_t SetVolumeDescription(std::string fsUuid, std::string description) = 0; 57 virtual int32_t Format(std::string volumeId, std::string fsType) = 0; 58 virtual int32_t GetDiskById(std::string diskId, Disk &disk) = 0; 59 60 // fscrypt api 61 virtual int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) = 0; 62 virtual int32_t DeleteUserKeys(uint32_t userId) = 0; 63 virtual int32_t UpdateUserAuth(uint32_t userId, 64 const std::vector<uint8_t> &token, 65 const std::vector<uint8_t> &oldSecret, 66 const std::vector<uint8_t> &newSecret) = 0; 67 virtual int32_t ActiveUserKey(uint32_t userId, 68 const std::vector<uint8_t> &token, 69 const std::vector<uint8_t> &secret) = 0; 70 virtual int32_t InactiveUserKey(uint32_t userId) = 0; 71 virtual int32_t UpdateKeyContext(uint32_t userId) = 0; 72 73 // app file share api 74 virtual int32_t CreateShareFile(std::string uri, int32_t tokenID, int32_t flag) = 0; 75 virtual int32_t DeleteShareFile(int32_t tokenId, std::vector<std::string>sharePathList) = 0; 76 77 enum { 78 PREPARE_ADD_USER = 1, 79 REMOVE_USER, 80 PREPARE_START_USER, 81 STOP_USER, 82 GET_TOTAL, 83 GET_FREE, 84 GET_BUNDLE_STATUS, 85 GET_SYSTEM_SIZE, 86 GET_TOTAL_SIZE, 87 GET_FREE_SIZE, 88 GET_CURR_USER_STATS, 89 GET_USER_STATS, 90 GET_CURR_BUNDLE_STATS, 91 NOTIFY_VOLUME_CREATED, 92 NOTIFY_VOLUME_MOUNTED, 93 NOTIFY_VOLUME_DESTROYED, 94 MOUNT, 95 UNMOUNT, 96 GET_ALL_VOLUMES, 97 NOTIFY_DISK_CREATED, 98 NOTIFY_DISK_DESTROYED, 99 PARTITION, 100 GET_ALL_DISKS, 101 CREATE_USER_KEYS, 102 DELETE_USER_KEYS, 103 UPDATE_USER_AUTH, 104 ACTIVE_USER_KEY, 105 INACTIVE_USER_KEY, 106 UPDATE_KEY_CONTEXT, 107 GET_VOL_BY_UUID, 108 GET_VOL_BY_ID, 109 SET_VOL_DESC, 110 FORMAT, 111 GET_DISK_BY_ID, 112 CREATE_SHARE_FILE, 113 DELETE_SHARE_FILE, 114 }; 115 116 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.StorageManager.IStorageManager"); 117 }; 118 } // StorageManager 119 } // OHOS 120 121 #endif // OHOS_STORAGE_MANAGER_ISTORAGER_MANAGER_H