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