1/* 2* Copyright (C) 2022 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 16import {AsyncCallback, Callback} from "./basic"; 17 18/** 19 * Provides filesystem statistics APIs 20 * 21 * @since 8 22 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 23 */ 24declare namespace storageStatistics { 25 /** 26 * Get the totalSize of volume. 27 * 28 * @since 8 29 * @param volumeUuid the uuid of the volume 30 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 31 * @permission ohos.permission.STORAGE_MANAGER 32 * @throws { BusinessError } 201 - Permission verification failed. 33 * @throws { BusinessError } 202 - The caller is not a system application. 34 * @throws { BusinessError } 401 - The input parameter is invalid. 35 * @throws { BusinessError } 13600001 - IPC error. 36 * @throws { BusinessError } 13600008 - No such object. 37 * @throws { BusinessError } 13900032 - Unknown error. 38 * @systemapi 39 */ 40 function getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): void; 41 function getTotalSizeOfVolume(volumeUuid: string): Promise<number>; 42 /** 43 * Get the free size Of volume. 44 * 45 * @since 8 46 * @param volumeUuid the uuid of the volume 47 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 48 * @permission ohos.permission.STORAGE_MANAGER 49 * @throws { BusinessError } 201 - Permission verification failed. 50 * @throws { BusinessError } 202 - The caller is not a system application. 51 * @throws { BusinessError } 401 - The input parameter is invalid. 52 * @throws { BusinessError } 13600001 - IPC error. 53 * @throws { BusinessError } 13600008 - No such object. 54 * @throws { BusinessError } 13900032 - Unknown error. 55 * @systemapi 56 */ 57 function getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): void; 58 function getFreeSizeOfVolume(volumeUuid: string): Promise<number>; 59 60 /** 61 * Get the bundlestat 62 * 63 * @since 9 64 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 65 */ 66 67 export interface BundleStats { 68 /** 69 * The size of application installation data. 70 * @since 9 71 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 72 */ 73 appSize: number; 74 75 /** 76 * The size of application cache data. 77 * @since 9 78 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 79 */ 80 cacheSize: number; 81 82 /** 83 * The size of application local data, distributed data and database data. 84 * @since 9 85 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 86 */ 87 dataSize: number; 88 } 89 /** 90 * Get the bundlestat 91 * 92 * @since 9 93 * @param packageName the name of the application 94 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 95 * @permission ohos.permission.STORAGE_MANAGER 96 * @throws { BusinessError } 201 - Permission verification failed. 97 * @throws { BusinessError } 202 - The caller is not a system application. 98 * @throws { BusinessError } 401 - The input parameter is invalid. 99 * @throws { BusinessError } 13600001 - IPC error. 100 * @throws { BusinessError } 13600008 - No such object. 101 * @throws { BusinessError } 13900032 - Unknown error. 102 * @systemapi 103 */ 104 function getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void; 105 function getBundleStats(packageName: string): Promise<BundleStats>; 106 107 /** 108 * Get the Current BundleStats 109 * 110 * @since 9 111 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 112 * @throws { BusinessError } 401 - The input parameter is invalid. 113 * @throws { BusinessError } 13600001 - IPC error. 114 * @throws { BusinessError } 13900032 - Unknown error. 115 */ 116 function getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void; 117 function getCurrentBundleStats(): Promise<BundleStats>; 118 119 /** 120 * Get the systemsize 121 * 122 * @since 9 123 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 124 * @permission ohos.permission.STORAGE_MANAGER 125 * @throws { BusinessError } 201 - Permission verification failed. 126 * @throws { BusinessError } 202 - The caller is not a system application. 127 * @throws { BusinessError } 401 - The input parameter is invalid. 128 * @throws { BusinessError } 13600001 - IPC error. 129 * @throws { BusinessError } 13900032 - Unknown error. 130 * @systemapi 131 */ 132 function getSystemSize(callback: AsyncCallback<number>): void; 133 function getSystemSize(): Promise<number>; 134 135 /** 136 * Get the UserStorageStats 137 * 138 * @since 9 139 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 140 * @systemapi 141 */ 142 export interface StorageStats { 143 /** 144 * The total size of device. 145 * @since 9 146 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 147 * @systemapi 148 */ 149 total: number; 150 151 /** 152 * The size of audio file. 153 * @since 9 154 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 155 * @systemapi 156 */ 157 audio: number; 158 159 /** 160 * The size of video file. 161 * @since 9 162 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 163 * @systemapi 164 */ 165 video: number; 166 167 /** 168 * The size of image file. 169 * @since 9 170 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 171 * @systemapi 172 */ 173 image: number; 174 175 /** 176 * The size of other file. 177 * @since 9 178 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 179 * @systemapi 180 */ 181 file: number; 182 183 /** 184 * The size of application. 185 * @since 9 186 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 187 * @systemapi 188 */ 189 app: number; 190 } 191 192 /** 193 * Get the UserStorageStats 194 * 195 * @since 9 196 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 197 * @permission ohos.permission.STORAGE_MANAGER 198 * @throws { BusinessError } 201 - Permission verification failed. 199 * @throws { BusinessError } 202 - The caller is not a system application. 200 * @throws { BusinessError } 401 - The input parameter is invalid. 201 * @throws { BusinessError } 13600001 - IPC error. 202 * @throws { BusinessError } 13900032 - Unknown error. 203 * @systemapi 204 */ 205 function getUserStorageStats(): Promise<StorageStats>; 206 function getUserStorageStats(callback: AsyncCallback<StorageStats>): void; 207 208 /** 209 * Get the UserStorageStats 210 * 211 * @since 9 212 * @param userId the id of the user 213 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 214 * @permission ohos.permission.STORAGE_MANAGER 215 * @throws { BusinessError } 201 - Permission verification failed. 216 * @throws { BusinessError } 202 - The caller is not a system application. 217 * @throws { BusinessError } 401 - The input parameter is invalid. 218 * @throws { BusinessError } 13600001 - IPC error. 219 * @throws { BusinessError } 13600009 - User if out of range. 220 * @throws { BusinessError } 13900032 - Unknown error. 221 * @systemapi 222 */ 223 function getUserStorageStats(userId: number): Promise<StorageStats>; 224 function getUserStorageStats(userId: number, callback: AsyncCallback<StorageStats>): void; 225 226 /** 227 * Get the totalsize 228 * 229 * @since 9 230 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 231 * @permission ohos.permission.STORAGE_MANAGER 232 * @throws { BusinessError } 201 - Permission verification failed. 233 * @throws { BusinessError } 202 - The caller is not a system application. 234 * @throws { BusinessError } 401 - The input parameter is invalid. 235 * @throws { BusinessError } 13600001 - IPC error. 236 * @throws { BusinessError } 13900032 - Unknown error. 237 * @systemapi 238 */ 239 function getTotalSize(callback: AsyncCallback<number>): void; 240 function getTotalSize(): Promise<number>; 241 242 /** 243 * Get the freesize 244 * 245 * @since 9 246 * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics 247 * @permission ohos.permission.STORAGE_MANAGER 248 * @throws { BusinessError } 201 - Permission verification failed. 249 * @throws { BusinessError } 202 - The caller is not a system application. 250 * @throws { BusinessError } 401 - The input parameter is invalid. 251 * @throws { BusinessError } 13600001 - IPC error. 252 * @throws { BusinessError } 13900032 - Unknown error. 253 * @systemapi 254 */ 255 function getFreeSize(callback: AsyncCallback<number>): void; 256 function getFreeSize(): Promise<number>; 257} 258 259export default storageStatistics; 260