IStorageManager.aidl revision 35e46d297255363a20ccde62af3c58c4ce3c13c5
1/**
2 * Copyright (c) 2016, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.os.storage;
18
19import android.content.pm.IPackageMoveObserver;
20import android.os.ParcelFileDescriptor;
21import android.os.storage.DiskInfo;
22import android.os.storage.IStorageEventListener;
23import android.os.storage.IStorageShutdownObserver;
24import android.os.storage.IObbActionListener;
25import android.os.storage.StorageVolume;
26import android.os.storage.VolumeInfo;
27import android.os.storage.VolumeRecord;
28import com.android.internal.os.AppFuseMount;
29
30/**
31 * WARNING! Update IMountService.h and IMountService.cpp if you change this
32 * file. In particular, the transaction ids below must match the
33 * _TRANSACTION enum in IMountService.cpp
34 *
35 * @hide - Applications should use android.os.storage.StorageManager to access
36 *       storage functions.
37 */
38interface IStorageManager {
39    /**
40     * Registers an IStorageEventListener for receiving async notifications.
41     */
42    void registerListener(IStorageEventListener listener) = 0;
43    /**
44     * Unregisters an IStorageEventListener
45     */
46    void unregisterListener(IStorageEventListener listener) = 1;
47    /**
48     * Returns true if a USB mass storage host is connected
49     */
50    boolean isUsbMassStorageConnected() = 2;
51    /**
52     * Enables / disables USB mass storage. The caller should check actual
53     * status of enabling/disabling USB mass storage via StorageEventListener.
54     */
55    void setUsbMassStorageEnabled(boolean enable) = 3;
56    /**
57     * Returns true if a USB mass storage host is enabled (media is shared)
58     */
59    boolean isUsbMassStorageEnabled() = 4;
60    /**
61     * Mount external storage at given mount point. Returns an int consistent
62     * with StorageResultCode
63     */
64    int mountVolume(in String mountPoint) = 5;
65    /**
66     * Safely unmount external storage at given mount point. The unmount is an
67     * asynchronous operation. Applications should register StorageEventListener
68     * for storage related status changes.
69     * @param mountPoint the mount point
70     * @param force whether or not to forcefully unmount it (e.g. even if programs are using this
71     *     data currently)
72     * @param removeEncryption whether or not encryption mapping should be removed from the volume.
73     *     This value implies {@code force}.
74     */
75    void unmountVolume(in String mountPoint, boolean force, boolean removeEncryption) = 6;
76    /**
77     * Format external storage given a mount point. Returns an int consistent
78     * with StorageResultCode
79     */
80    int formatVolume(in String mountPoint) = 7;
81    /**
82     * Returns an array of pids with open files on the specified path.
83     */
84    int[] getStorageUsers(in String path) = 8;
85    /**
86     * Gets the state of a volume via its mountpoint.
87     */
88    String getVolumeState(in String mountPoint) = 9;
89    /*
90     * Creates a secure container with the specified parameters. Returns an int
91     * consistent with StorageResultCode
92     */
93    int createSecureContainer(in String id, int sizeMb, in String fstype, in String key,
94            int ownerUid, boolean external) = 10;
95    /*
96     * Finalize a container which has just been created and populated. After
97     * finalization, the container is immutable. Returns an int consistent with
98     * StorageResultCode
99     */
100    int finalizeSecureContainer(in String id) = 11;
101    /*
102     * Destroy a secure container, and free up all resources associated with it.
103     * NOTE: Ensure all references are released prior to deleting. Returns an
104     * int consistent with StorageResultCode
105     */
106    int destroySecureContainer(in String id, boolean force) = 12;
107    /*
108     * Mount a secure container with the specified key and owner UID. Returns an
109     * int consistent with StorageResultCode
110     */
111    int mountSecureContainer(in String id, in String key, int ownerUid, boolean readOnly) = 13;
112    /*
113     * Unount a secure container. Returns an int consistent with
114     * StorageResultCode
115     */
116    int unmountSecureContainer(in String id, boolean force) = 14;
117    /*
118     * Returns true if the specified container is mounted
119     */
120    boolean isSecureContainerMounted(in String id) = 15;
121    /*
122     * Rename an unmounted secure container. Returns an int consistent with
123     * StorageResultCode
124     */
125    int renameSecureContainer(in String oldId, in String newId) = 16;
126    /*
127     * Returns the filesystem path of a mounted secure container.
128     */
129    String getSecureContainerPath(in String id) = 17;
130    /**
131     * Gets an Array of currently known secure container IDs
132     */
133    String[] getSecureContainerList() = 18;
134    /**
135     * Shuts down the StorageManagerService and gracefully unmounts all external media.
136     * Invokes call back once the shutdown is complete.
137     */
138    void shutdown(IStorageShutdownObserver observer) = 19;
139    /**
140     * Call into StorageManagerService by PackageManager to notify that its done
141     * processing the media status update request.
142     */
143    void finishMediaUpdate() = 20;
144    /**
145     * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
146     * only allows the calling process's UID access to the contents.
147     * StorageManagerService will call back to the supplied IObbActionListener to inform
148     * it of the terminal state of the call.
149     */
150    void mountObb(in String rawPath, in String canonicalPath, in String key,
151            IObbActionListener token, int nonce) = 21;
152    /**
153     * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
154     * any program using it will be forcibly killed to unmount the image.
155     * StorageManagerService will call back to the supplied IObbActionListener to inform
156     * it of the terminal state of the call.
157     */
158    void unmountObb(in String rawPath, boolean force, IObbActionListener token, int nonce) = 22;
159    /**
160     * Checks whether the specified Opaque Binary Blob (OBB) is mounted
161     * somewhere.
162     */
163    boolean isObbMounted(in String rawPath) = 23;
164    /**
165     * Gets the path to the mounted Opaque Binary Blob (OBB).
166     */
167    String getMountedObbPath(in String rawPath) = 24;
168    /**
169     * Returns whether or not the external storage is emulated.
170     */
171    boolean isExternalStorageEmulated() = 25;
172    /**
173     * Decrypts any encrypted volumes.
174     */
175    int decryptStorage(in String password) = 26;
176    /**
177     * Encrypts storage.
178     */
179    int encryptStorage(int type, in String password) = 27;
180    /**
181     * Changes the encryption password.
182     */
183    int changeEncryptionPassword(int type, in String password) = 28;
184    /**
185     * Returns list of all mountable volumes.
186     */
187    StorageVolume[] getVolumeList(int uid, in String packageName, int flags) = 29;
188    /**
189     * Gets the path on the filesystem for the ASEC container itself.
190     *
191     * @param cid ASEC container ID
192     * @return path to filesystem or {@code null} if it's not found
193     * @throws RemoteException
194     */
195    String getSecureContainerFilesystemPath(in String cid) = 30;
196    /**
197     * Determines the encryption state of the volume.
198     * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible
199     * values.
200     * Note that this has been replaced in most cases by the APIs in
201     * StorageManager (see isEncryptable and below)
202     * This is still useful to get the error state when encryption has failed
203     * and CryptKeeper needs to throw up a screen advising the user what to do
204     */
205    int getEncryptionState() = 31;
206    /**
207     * Verify the encryption password against the stored volume.  This method
208     * may only be called by the system process.
209     */
210    int verifyEncryptionPassword(in String password) = 32;
211    /*
212     * Fix permissions in a container which has just been created and populated.
213     * Returns an int consistent with StorageResultCode
214     */
215    int fixPermissionsSecureContainer(in String id, int gid, in String filename) = 33;
216    /**
217     * Ensure that all directories along given path exist, creating parent
218     * directories as needed. Validates that given path is absolute and that it
219     * contains no relative "." or ".." paths or symlinks. Also ensures that
220     * path belongs to a volume managed by vold, and that path is either
221     * external storage data or OBB directory belonging to calling app.
222     */
223    int mkdirs(in String callingPkg, in String path) = 34;
224    /**
225     * Determines the type of the encryption password
226     * @return PasswordType
227     */
228    int getPasswordType() = 35;
229    /**
230     * Get password from vold
231     * @return password or empty string
232     */
233    String getPassword() = 36;
234    /**
235     * Securely clear password from vold
236     */
237    oneway void clearPassword() = 37;
238    /**
239     * Set a field in the crypto header.
240     * @param field field to set
241     * @param contents contents to set in field
242     */
243    oneway void setField(in String field, in String contents) = 38;
244    /**
245     * Gets a field from the crypto header.
246     * @param field field to get
247     * @return contents of field
248     */
249    String getField(in String field) = 39;
250    int resizeSecureContainer(in String id, int sizeMb, in String key) = 40;
251    /**
252     * Report the time of the last maintenance operation such as fstrim.
253     * @return Timestamp of the last maintenance operation, in the
254     *     System.currentTimeMillis() time base
255     * @throws RemoteException
256     */
257    long lastMaintenance() = 41;
258    /**
259     * Kick off an immediate maintenance operation
260     * @throws RemoteException
261     */
262    void runMaintenance() = 42;
263    void waitForAsecScan() = 43;
264    DiskInfo[] getDisks() = 44;
265    VolumeInfo[] getVolumes(int flags) = 45;
266    VolumeRecord[] getVolumeRecords(int flags) = 46;
267    void mount(in String volId) = 47;
268    void unmount(in String volId) = 48;
269    void format(in String volId) = 49;
270    void partitionPublic(in String diskId) = 50;
271    void partitionPrivate(in String diskId) = 51;
272    void partitionMixed(in String diskId, int ratio) = 52;
273    void setVolumeNickname(in String fsUuid, in String nickname) = 53;
274    void setVolumeUserFlags(in String fsUuid, int flags, int mask) = 54;
275    void forgetVolume(in String fsUuid) = 55;
276    void forgetAllVolumes() = 56;
277    String getPrimaryStorageUuid() = 57;
278    void setPrimaryStorageUuid(in String volumeUuid, IPackageMoveObserver callback) = 58;
279    long benchmark(in String volId) = 59;
280    void setDebugFlags(int flags, int mask) = 60;
281    void createUserKey(int userId, int serialNumber, boolean ephemeral) = 61;
282    void destroyUserKey(int userId) = 62;
283    void unlockUserKey(int userId, int serialNumber, in byte[] token, in byte[] secret) = 63;
284    void lockUserKey(int userId) = 64;
285    boolean isUserKeyUnlocked(int userId) = 65;
286    void prepareUserStorage(in String volumeUuid, int userId, int serialNumber, int flags) = 66;
287    void destroyUserStorage(in String volumeUuid, int userId, int flags) = 67;
288    boolean isConvertibleToFBE() = 68;
289    void addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 70;
290    void fixateNewestUserKeyAuth(int userId) = 71;
291    void fstrim(int flags) = 72;
292    AppFuseMount mountProxyFileDescriptorBridge() = 73;
293    ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74;
294    long getCacheQuotaBytes(String volumeUuid, int uid) = 75;
295    long getCacheSizeBytes(String volumeUuid, int uid) = 76;
296    long getAllocatableBytes(String volumeUuid, int flags, String callingPackage) = 77;
297    void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78;
298    void secdiscard(in String path) = 79;
299}
300