1/* 2 * Copyright (C) 2022-2023 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/** 17 * @file 18 * @kit CoreFileKit 19 */ 20 21import { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * Provides volumemanager statistics APIs 25 * 26 * @namespace volumeManager 27 * @syscap SystemCapability.FileManagement.StorageService.Volume 28 * @systemapi 29 * @since 9 30 */ 31declare namespace volumeManager { 32 /** 33 * Get All Volumes 34 * 35 * @interface Volume 36 * @syscap SystemCapability.FileManagement.StorageService.Volume 37 * @systemapi 38 * @since 9 39 */ 40 export interface Volume { 41 /** 42 * Volume ID. 43 * 44 * @type { string } 45 * @syscap SystemCapability.FileManagement.StorageService.Volume 46 * @systemapi 47 * @since 9 48 */ 49 id: string; 50 51 /** 52 * Universally unique identifier of volume. 53 * 54 * @type { string } 55 * @syscap SystemCapability.FileManagement.StorageService.Volume 56 * @systemapi 57 * @since 9 58 */ 59 uuid: string; 60 61 /** 62 * The ID of disk that volume belongs to. 63 * 64 * @type { string } 65 * @syscap SystemCapability.FileManagement.StorageService.Volume 66 * @systemapi 67 * @since 9 68 */ 69 diskId: string; 70 71 /** 72 * The label of the volume. 73 * 74 * @type { string } 75 * @syscap SystemCapability.FileManagement.StorageService.Volume 76 * @systemapi 77 * @since 9 78 */ 79 description: string; 80 81 /** 82 * The volume is removable or not. 83 * 84 * @type { boolean } 85 * @syscap SystemCapability.FileManagement.StorageService.Volume 86 * @systemapi 87 * @since 9 88 */ 89 removable: boolean; 90 91 /** 92 * The mount state of the volume. 93 * 94 * @type { number } 95 * @syscap SystemCapability.FileManagement.StorageService.Volume 96 * @systemapi 97 * @since 9 98 */ 99 state: number; 100 101 /** 102 * The mount path of the volume. 103 * 104 * @type { string } 105 * @syscap SystemCapability.FileManagement.StorageService.Volume 106 * @systemapi 107 * @since 9 108 */ 109 path: string; 110 111 /** 112 * The file system type of the volume. 113 * 114 * @type { string } 115 * @syscap SystemCapability.FileManagement.StorageService.Volume 116 * @systemapi 117 * @since 12 118 */ 119 fsType: string; 120 } 121 /** 122 * Get All Volumes 123 * 124 * @permission ohos.permission.STORAGE_MANAGER 125 * @param { AsyncCallback<Array<Volume>> } callback - callback 126 * @throws { BusinessError } 201 - Permission verification failed. 127 * @throws { BusinessError } 202 - The caller is not a system application. 128 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Mandatory 129parameters are left unspecified; 130 * @throws { BusinessError } 13600001 - IPC error. 131 * @throws { BusinessError } 13900042 - Unknown error. 132 * @syscap SystemCapability.FileManagement.StorageService.Volume 133 * @systemapi 134 * @since 9 135 */ 136 function getAllVolumes(callback: AsyncCallback<Array<Volume>>): void; 137 138 /** 139 * Get All Volumes 140 * 141 * @permission ohos.permission.STORAGE_MANAGER 142 * @returns { Promise<Array<Volume>> } return Promise 143 * @throws { BusinessError } 201 - Permission verification failed. 144 * @throws { BusinessError } 202 - The caller is not a system application. 145 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Mandatory 146parameters are left unspecified; 147 * @throws { BusinessError } 13600001 - IPC error. 148 * @throws { BusinessError } 13900042 - Unknown error. 149 * @syscap SystemCapability.FileManagement.StorageService.Volume 150 * @systemapi 151 * @since 9 152 */ 153 function getAllVolumes(): Promise<Array<Volume>>; 154 155 /** 156 * Mount 157 * 158 * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER 159 * @param { string } volumeId - The id of the volume 160 * @param { AsyncCallback<void> } callback - callback 161 * @throws { BusinessError } 201 - Permission verification failed. 162 * @throws { BusinessError } 202 - The caller is not a system application. 163 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 164parameters are left unspecified; 165 * <br>2.Incorrect parameter types. 166 * @throws { BusinessError } 13600001 - IPC error. 167 * @throws { BusinessError } 13600002 - Not supported filesystem. 168 * @throws { BusinessError } 13600003 - Failed to mount. 169 * @throws { BusinessError } 13600005 - Incorrect volume state. 170 * @throws { BusinessError } 13600008 - No such object. 171 * @throws { BusinessError } 13900042 - Unknown error. 172 * @syscap SystemCapability.FileManagement.StorageService.Volume 173 * @systemapi 174 * @since 9 175 */ 176 function mount(volumeId: string, callback: AsyncCallback<void>): void; 177 178 /** 179 * Mount 180 * 181 * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER 182 * @param { string } volumeId - The id of the volume 183 * @returns { Promise<void> } return Promise 184 * @throws { BusinessError } 201 - Permission verification failed. 185 * @throws { BusinessError } 202 - The caller is not a system application. 186 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 187parameters are left unspecified; 188 * <br>2.Incorrect parameter types. 189 * @throws { BusinessError } 13600001 - IPC error. 190 * @throws { BusinessError } 13600002 - Not supported filesystem. 191 * @throws { BusinessError } 13600003 - Failed to mount. 192 * @throws { BusinessError } 13600005 - Incorrect volume state. 193 * @throws { BusinessError } 13600008 - No such object. 194 * @throws { BusinessError } 13900042 - Unknown error. 195 * @syscap SystemCapability.FileManagement.StorageService.Volume 196 * @systemapi 197 * @since 9 198 */ 199 function mount(volumeId: string): Promise<void>; 200 201 /** 202 * UnMount 203 * 204 * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER 205 * @param { string } volumeId - The id of the volume 206 * @param { AsyncCallback<void> } callback - callback 207 * @throws { BusinessError } 201 - Permission verification failed. 208 * @throws { BusinessError } 202 - The caller is not a system application. 209 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 210parameters are left unspecified; 211 * <br>2.Incorrect parameter types. 212 * @throws { BusinessError } 13600001 - IPC error. 213 * @throws { BusinessError } 13600002 - Not supported filesystem. 214 * @throws { BusinessError } 13600004 - Failed to unmount. 215 * @throws { BusinessError } 13600005 - Incorrect volume state. 216 * @throws { BusinessError } 13600008 - No such object. 217 * @throws { BusinessError } 13900042 - Unknown error. 218 * @syscap SystemCapability.FileManagement.StorageService.Volume 219 * @systemapi 220 * @since 9 221 */ 222 function unmount(volumeId: string, callback: AsyncCallback<void>): void; 223 224 /** 225 * UnMount 226 * 227 * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER 228 * @param { string } volumeId - The id of the volume 229 * @returns { Promise<void> } return Promise 230 * @throws { BusinessError } 201 - Permission verification failed. 231 * @throws { BusinessError } 202 - The caller is not a system application. 232 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 233parameters are left unspecified; 234 * <br>2.Incorrect parameter types. 235 * @throws { BusinessError } 13600001 - IPC error. 236 * @throws { BusinessError } 13600002 - Not supported filesystem. 237 * @throws { BusinessError } 13600004 - Failed to unmount. 238 * @throws { BusinessError } 13600005 - Incorrect volume state. 239 * @throws { BusinessError } 13600008 - No such object. 240 * @throws { BusinessError } 13900042 - Unknown error. 241 * @syscap SystemCapability.FileManagement.StorageService.Volume 242 * @systemapi 243 * @since 9 244 */ 245 function unmount(volumeId: string): Promise<void>; 246 247 /** 248 * Get the volume by uuid. 249 * 250 * @permission ohos.permission.STORAGE_MANAGER 251 * @param { string } uuid - The uuid of volume 252 * @param { AsyncCallback<Volume> } callback - callback 253 * @throws { BusinessError } 201 - Permission verification failed. 254 * @throws { BusinessError } 202 - The caller is not a system application. 255 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 256parameters are left unspecified; 257 * <br>2.Incorrect parameter types. 258 * @throws { BusinessError } 13600001 - IPC error. 259 * @throws { BusinessError } 13600008 - No such object. 260 * @throws { BusinessError } 13900042 - Unknown error. 261 * @syscap SystemCapability.FileManagement.StorageService.Volume 262 * @systemapi 263 * @since 9 264 */ 265 function getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void; 266 267 /** 268 * Get the volume by uuid. 269 * 270 * @permission ohos.permission.STORAGE_MANAGER 271 * @param { string } uuid - The uuid of volume 272 * @returns { Promise<Volume> } return Promise 273 * @throws { BusinessError } 201 - Permission verification failed. 274 * @throws { BusinessError } 202 - The caller is not a system application. 275 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 276parameters are left unspecified; 277 * <br>2.Incorrect parameter types. 278 * @throws { BusinessError } 13600001 - IPC error. 279 * @throws { BusinessError } 13600008 - No such object. 280 * @throws { BusinessError } 13900042 - Unknown error. 281 * @syscap SystemCapability.FileManagement.StorageService.Volume 282 * @systemapi 283 * @since 9 284 */ 285 function getVolumeByUuid(uuid: string): Promise<Volume>; 286 287 /** 288 * Get the volume by id. 289 * 290 * @permission ohos.permission.STORAGE_MANAGER 291 * @param { string } volumeId - The id of volume 292 * @param { AsyncCallback<Volume> } callback - callback 293 * @throws { BusinessError } 201 - Permission verification failed. 294 * @throws { BusinessError } 202 - The caller is not a system application. 295 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 296parameters are left unspecified; 297 * <br>2.Incorrect parameter types. 298 * @throws { BusinessError } 13600001 - IPC error. 299 * @throws { BusinessError } 13600008 - No such object. 300 * @throws { BusinessError } 13900042 - Unknown error. 301 * @syscap SystemCapability.FileManagement.StorageService.Volume 302 * @systemapi 303 * @since 9 304 */ 305 function getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void; 306 307 /** 308 * Get the volume by id. 309 * 310 * @permission ohos.permission.STORAGE_MANAGER 311 * @param { string } volumeId - The id of volume 312 * @returns { Promise<Volume> } return Promise 313 * @throws { BusinessError } 201 - Permission verification failed. 314 * @throws { BusinessError } 202 - The caller is not a system application. 315 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 316parameters are left unspecified; 317 * <br>2.Incorrect parameter types. 318 * @throws { BusinessError } 13600001 - IPC error. 319 * @throws { BusinessError } 13600008 - No such object. 320 * @throws { BusinessError } 13900042 - Unknown error. 321 * @syscap SystemCapability.FileManagement.StorageService.Volume 322 * @systemapi 323 * @since 9 324 */ 325 function getVolumeById(volumeId: string): Promise<Volume>; 326 327 /** 328 * Set the description of volume. 329 * 330 * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER 331 * @param { string } uuid - The uuid of volume 332 * @param { string } description - New description of volume 333 * @param { AsyncCallback<void> } callback - callback 334 * @throws { BusinessError } 201 - Permission verification failed. 335 * @throws { BusinessError } 202 - The caller is not a system application. 336 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 337parameters are left unspecified; 338 * <br>2.Incorrect parameter types. 339 * @throws { BusinessError } 13600001 - IPC error. 340 * @throws { BusinessError } 13600002 - Not supported filesystem. 341 * @throws { BusinessError } 13600005 - Incorrect volume state. 342 * @throws { BusinessError } 13600008 - No such object. 343 * @throws { BusinessError } 13900042 - Unknown error. 344 * @syscap SystemCapability.FileManagement.StorageService.Volume 345 * @systemapi 346 * @since 9 347 */ 348 function setVolumeDescription(uuid: string, description: string, callback: AsyncCallback<void>): void; 349 350 /** 351 * Set the description of volume. 352 * 353 * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER 354 * @param { string } uuid - The uuid of volume 355 * @param { string } description - New description of volume 356 * @returns { Promise<void> } return Promise 357 * @throws { BusinessError } 201 - Permission verification failed. 358 * @throws { BusinessError } 202 - The caller is not a system application. 359 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 360parameters are left unspecified; 361 * <br>2.Incorrect parameter types. 362 * @throws { BusinessError } 13600001 - IPC error. 363 * @throws { BusinessError } 13600002 - Not supported filesystem. 364 * @throws { BusinessError } 13600005 - Incorrect volume state. 365 * @throws { BusinessError } 13600008 - No such object. 366 * @throws { BusinessError } 13900042 - Unknown error. 367 * @syscap SystemCapability.FileManagement.StorageService.Volume 368 * @systemapi 369 * @since 9 370 */ 371 function setVolumeDescription(uuid: string, description: string): Promise<void>; 372 373 /** 374 * Format. 375 * 376 * @permission ohos.permission.MOUNT_FORMAT_MANAGER 377 * @param { string } volumeId - The id of the volume 378 * @param { string } fsType - The file system type after formatting 379 * @param { AsyncCallback<void> } callback - callback 380 * @throws { BusinessError } 201 - Permission verification failed. 381 * @throws { BusinessError } 202 - The caller is not a system application. 382 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 383parameters are left unspecified; 384 * <br>2.Incorrect parameter types. 385 * @throws { BusinessError } 13600001 - IPC error. 386 * @throws { BusinessError } 13600002 - Not supported filesystem. 387 * @throws { BusinessError } 13600005 - Incorrect volume state. 388 * @throws { BusinessError } 13600008 - No such object. 389 * @throws { BusinessError } 13900042 - Unknown error. 390 * @syscap SystemCapability.FileManagement.StorageService.Volume 391 * @systemapi 392 * @since 9 393 */ 394 function format(volumeId: string, fsType: string, callback: AsyncCallback<void>): void; 395 396 /** 397 * Format. 398 * 399 * @permission ohos.permission.MOUNT_FORMAT_MANAGER 400 * @param { string } volumeId - The id of the volume 401 * @param { string } fsType - The file system type after formatting 402 * @returns { Promise<void> } return Promise 403 * @throws { BusinessError } 201 - Permission verification failed. 404 * @throws { BusinessError } 202 - The caller is not a system application. 405 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 406parameters are left unspecified; 407 * <br>2.Incorrect parameter types. 408 * @throws { BusinessError } 13600001 - IPC error. 409 * @throws { BusinessError } 13600002 - Not supported filesystem. 410 * @throws { BusinessError } 13600005 - Incorrect volume state. 411 * @throws { BusinessError } 13600008 - No such object. 412 * @throws { BusinessError } 13900042 - Unknown error. 413 * @syscap SystemCapability.FileManagement.StorageService.Volume 414 * @systemapi 415 * @since 9 416 */ 417 function format(volumeId: string, fsType: string): Promise<void>; 418 419 /** 420 * Partition. 421 * 422 * @permission ohos.permission.MOUNT_FORMAT_MANAGER 423 * @param { string } diskId - The id of the disk 424 * @param { number } type - Type of partition such as private partition or public partition 425 * @param { AsyncCallback<void> } callback - callback 426 * @throws { BusinessError } 201 - Permission verification failed. 427 * @throws { BusinessError } 202 - The caller is not a system application. 428 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 429parameters are left unspecified; 430 * <br>2.Incorrect parameter types. 431 * @throws { BusinessError } 13600001 - IPC error. 432 * @throws { BusinessError } 13600008 - No such object. 433 * @throws { BusinessError } 13900042 - Unknown error. 434 * @syscap SystemCapability.FileManagement.StorageService.Volume 435 * @systemapi 436 * @since 9 437 */ 438 function partition(diskId: string, type: number, callback: AsyncCallback<void>): void; 439 440 /** 441 * Partition. 442 * 443 * @permission ohos.permission.MOUNT_FORMAT_MANAGER 444 * @param { string } diskId - The id of the disk 445 * @param { number } type - Type of partition such as private partition or public partition 446 * @returns { Promise<void> } return Promise 447 * @throws { BusinessError } 201 - Permission verification failed. 448 * @throws { BusinessError } 202 - The caller is not a system application. 449 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory 450parameters are left unspecified; 451 * <br>2.Incorrect parameter types. 452 * @throws { BusinessError } 13600001 - IPC error. 453 * @throws { BusinessError } 13600008 - No such object. 454 * @throws { BusinessError } 13900042 - Unknown error. 455 * @syscap SystemCapability.FileManagement.StorageService.Volume 456 * @systemapi 457 * @since 9 458 */ 459 function partition(diskId: string, type: number): Promise<void>; 460} 461 462export default volumeManager; 463