• 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 {AsyncCallback, Callback} from "./basic";
17
18/**
19 * Provides volumemanager statistics APIs
20 *
21 * @since 9
22 * @syscap SystemCapability.FileManagement.StorageService.Volume
23 * @systemapi
24 */
25declare namespace volumeManager {
26
27/**
28   * Get All Volumes
29   *
30   * @since 9
31   * @syscap SystemCapability.FileManagement.StorageService.Volume
32   * @systemapi
33   */
34 export interface Volume {
35   /**
36     * Volume ID.
37     * @since 9
38     * @syscap SystemCapability.FileManagement.StorageService.Volume
39     * @systemapi
40     */
41   id: string;
42
43   /**
44     * Universally unique identifier of volume.
45     * @since 9
46     * @syscap SystemCapability.FileManagement.StorageService.Volume
47     * @systemapi
48     */
49   uuid: string;
50
51   /**
52     * The ID of disk that volume belongs to.
53     * @since 9
54     * @syscap SystemCapability.FileManagement.StorageService.Volume
55     * @systemapi
56     */
57   diskId: string;
58
59   /**
60     * The label of the volume.
61     * @since 9
62     * @syscap SystemCapability.FileManagement.StorageService.Volume
63     * @systemapi
64     */
65   description: string;
66
67   /**
68     * The volume is removable or not.
69     * @since 9
70     * @syscap SystemCapability.FileManagement.StorageService.Volume
71     * @systemapi
72     */
73   removable: boolean;
74
75   /**
76     * The mount state of the volume.
77     * @since 9
78     * @syscap SystemCapability.FileManagement.StorageService.Volume
79     * @systemapi
80     */
81   state: number;
82
83   /**
84     * The mount path of the volume.
85     * @since 9
86     * @syscap SystemCapability.FileManagement.StorageService.Volume
87     */
88   path: string;
89}
90/**
91   * Get All Volumes
92   *
93   * @since 9
94   * @returns Returns the information of all volumes
95   * @syscap SystemCapability.FileManagement.StorageService.Volume
96   * @permission ohos.permission.STORAGE_MANAGER
97   * @throws { BusinessError } 201 - Permission verification failed.
98   * @throws { BusinessError } 202 - The caller is not a system application.
99   * @throws { BusinessError } 401 - The input parameter is invalid.
100   * @throws { BusinessError } 13600001 - IPC error.
101   * @throws { BusinessError } 13900032 - Unknown error.
102   * @systemapi
103   */
104function getAllVolumes(callback: AsyncCallback<Array<Volume>>): void;
105function getAllVolumes(): Promise<Array<Volume>>;
106
107
108 /**
109   * Mount
110   *
111   * @since 9
112   * @param volumeId the id of the volume
113   * @syscap SystemCapability.FileManagement.StorageService.Volume
114   * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER
115   * @throws { BusinessError } 201 - Permission verification failed.
116   * @throws { BusinessError } 202 - The caller is not a system application.
117   * @throws { BusinessError } 401 - The input parameter is invalid.
118   * @throws { BusinessError } 13600001 - IPC error.
119   * @throws { BusinessError } 13600002 - Not supported filesystem.
120   * @throws { BusinessError } 13600003 - Failed to mount.
121   * @throws { BusinessError } 13600005 - Incorrect volume state.
122   * @throws { BusinessError } 13600008 - No such object.
123   * @throws { BusinessError } 13900032 - Unknown error.
124   * @systemapi
125   */
126function mount(volumeId: string, callback: AsyncCallback<void>): void;
127function mount(volumeId: string): Promise<void>;
128
129/**
130   * UnMount
131   *
132   * @since 9
133   * @param volumeId the id of the volume
134   * @syscap SystemCapability.FileManagement.StorageService.Volume
135   * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER
136   * @throws { BusinessError } 201 - Permission verification failed.
137   * @throws { BusinessError } 202 - The caller is not a system application.
138   * @throws { BusinessError } 401 - The input parameter is invalid.
139   * @throws { BusinessError } 13600001 - IPC error.
140   * @throws { BusinessError } 13600002 - Not supported filesystem.
141   * @throws { BusinessError } 13600004 - Failed to unmount.
142   * @throws { BusinessError } 13600005 - Incorrect volume state.
143   * @throws { BusinessError } 13600008 - No such object.
144   * @throws { BusinessError } 13900032 - Unknown error.
145   * @systemapi
146   */
147function unmount(volumeId: string, callback: AsyncCallback<void>): void;
148function unmount(volumeId: string): Promise<void>;
149
150/**
151   * Get the volume by uuid.
152   *
153   * @since 9
154   * @param uuid the uuid of volume
155   * @syscap SystemCapability.FileManagement.StorageService.Volume
156   * @permission ohos.permission.STORAGE_MANAGER
157   * @throws { BusinessError } 201 - Permission verification failed.
158   * @throws { BusinessError } 202 - The caller is not a system application.
159   * @throws { BusinessError } 401 - The input parameter is invalid.
160   * @throws { BusinessError } 13600001 - IPC error.
161   * @throws { BusinessError } 13600008 - No such object.
162   * @throws { BusinessError } 13900032 - Unknown error.
163   * @systemapi
164   */
165function getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void;
166function getVolumeByUuid(uuid: string): Promise<Volume>;
167
168/**
169   * Get the volume by id.
170   *
171   * @since 9
172   * @param volumeId the id of volume
173   * @syscap SystemCapability.FileManagement.StorageService.Volume
174   * @permission ohos.permission.STORAGE_MANAGER
175   * @throws { BusinessError } 201 - Permission verification failed.
176   * @throws { BusinessError } 202 - The caller is not a system application.
177   * @throws { BusinessError } 401 - The input parameter is invalid.
178   * @throws { BusinessError } 13600001 - IPC error.
179   * @throws { BusinessError } 13600008 - No such object.
180   * @throws { BusinessError } 13900032 - Unknown error.
181   * @systemapi
182   */
183function getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void;
184function getVolumeById(volumeId: string): Promise<Volume>;
185
186/**
187   * Set the description of volume.
188   *
189   * @since 9
190   * @param uuid the uuid of volume
191   * @param description new description of volume
192   * @syscap SystemCapability.FileManagement.StorageService.Volume
193   * @permission ohos.permission.MOUNT_UNMOUNT_MANAGER
194   * @throws { BusinessError } 201 - Permission verification failed.
195   * @throws { BusinessError } 202 - The caller is not a system application.
196   * @throws { BusinessError } 401 - The input parameter is invalid.
197   * @throws { BusinessError } 13600001 - IPC error.
198   * @throws { BusinessError } 13600002 - Not supported filesystem.
199   * @throws { BusinessError } 13600005 - Incorrect volume state.
200   * @throws { BusinessError } 13600008 - No such object.
201   * @throws { BusinessError } 13900032 - Unknown error.
202   * @systemapi
203   */
204function setVolumeDescription(uuid: string, description: string, callback: AsyncCallback<void>): void;
205function setVolumeDescription(uuid: string, description: string): Promise<void>;
206
207/**
208   * Format.
209   *
210   * @since 9
211   * @param volumeId the id of the volume
212   * @param fsType the file system type after formatting
213   * @syscap SystemCapability.FileManagement.StorageService.Volume
214   * @permission ohos.permission.MOUNT_FORMAT_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 } 13600002 - Not supported filesystem.
220   * @throws { BusinessError } 13600005 - Incorrect volume state.
221   * @throws { BusinessError } 13600008 - No such object.
222   * @throws { BusinessError } 13900032 - Unknown error.
223   * @systemapi
224   */
225function format(volumeId: string, fsType: string, callback: AsyncCallback<void>): void;
226function format(volumeId: string, fsType: string): Promise<void>;
227
228
229/**
230   * Partition.
231   *
232   * @since 9
233   * @param diskId the id of the disk
234   * @param type of partition such as private partition or public partition
235   * @syscap SystemCapability.FileManagement.StorageService.Volume
236   * @permission ohos.permission.MOUNT_FORMAT_MANAGER
237   * @throws { BusinessError } 201 - Permission verification failed.
238   * @throws { BusinessError } 202 - The caller is not a system application.
239   * @throws { BusinessError } 401 - The input parameter is invalid.
240   * @throws { BusinessError } 13600001 - IPC error.
241   * @throws { BusinessError } 13600008 - No such object.
242   * @throws { BusinessError } 13900032 - Unknown error.
243   * @systemapi
244   */
245function partition(diskId: string, type: number, callback: AsyncCallback<void>): void;
246function partition(diskId: string, type: number): Promise<void>;
247}
248
249export default volumeManager;
250