blob: 98cbce6c175d5afeb728223f6673ae89bd41cc84 [file] [log] [blame]
Sudheer Shankaf7341142016-10-18 17:15:18 -07001/**
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;
Sudheer Shanka2250d562016-11-07 15:41:02 -080022import android.os.storage.IStorageEventListener;
23import android.os.storage.IStorageShutdownObserver;
Sudheer Shankaf7341142016-10-18 17:15:18 -070024import android.os.storage.IObbActionListener;
25import android.os.storage.StorageVolume;
26import android.os.storage.VolumeInfo;
27import android.os.storage.VolumeRecord;
28
29/**
30 * WARNING! Update IMountService.h and IMountService.cpp if you change this
31 * file. In particular, the transaction ids below must match the
32 * _TRANSACTION enum in IMountService.cpp
33 *
34 * @hide - Applications should use android.os.storage.StorageManager to access
35 * storage functions.
36 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080037interface IStorageManager {
Sudheer Shankaf7341142016-10-18 17:15:18 -070038 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -080039 * Registers an IStorageEventListener for receiving async notifications.
Sudheer Shankaf7341142016-10-18 17:15:18 -070040 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080041 void registerListener(IStorageEventListener listener) = 0;
Sudheer Shankaf7341142016-10-18 17:15:18 -070042 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -080043 * Unregisters an IStorageEventListener
Sudheer Shankaf7341142016-10-18 17:15:18 -070044 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080045 void unregisterListener(IStorageEventListener listener) = 1;
Sudheer Shankaf7341142016-10-18 17:15:18 -070046 /**
47 * Returns true if a USB mass storage host is connected
48 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070049 boolean isUsbMassStorageConnected() = 2;
Sudheer Shankaf7341142016-10-18 17:15:18 -070050 /**
51 * Enables / disables USB mass storage. The caller should check actual
52 * status of enabling/disabling USB mass storage via StorageEventListener.
53 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070054 void setUsbMassStorageEnabled(boolean enable) = 3;
Sudheer Shankaf7341142016-10-18 17:15:18 -070055 /**
56 * Returns true if a USB mass storage host is enabled (media is shared)
57 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070058 boolean isUsbMassStorageEnabled() = 4;
Sudheer Shankaf7341142016-10-18 17:15:18 -070059 /**
60 * Mount external storage at given mount point. Returns an int consistent
Sudheer Shanka2250d562016-11-07 15:41:02 -080061 * with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070062 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070063 int mountVolume(in String mountPoint) = 5;
Sudheer Shankaf7341142016-10-18 17:15:18 -070064 /**
65 * Safely unmount external storage at given mount point. The unmount is an
66 * asynchronous operation. Applications should register StorageEventListener
67 * for storage related status changes.
68 * @param mountPoint the mount point
69 * @param force whether or not to forcefully unmount it (e.g. even if programs are using this
70 * data currently)
71 * @param removeEncryption whether or not encryption mapping should be removed from the volume.
72 * This value implies {@code force}.
73 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070074 void unmountVolume(in String mountPoint, boolean force, boolean removeEncryption) = 6;
Sudheer Shankaf7341142016-10-18 17:15:18 -070075 /**
76 * Format external storage given a mount point. Returns an int consistent
Sudheer Shanka2250d562016-11-07 15:41:02 -080077 * with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070078 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070079 int formatVolume(in String mountPoint) = 7;
Sudheer Shankaf7341142016-10-18 17:15:18 -070080 /**
81 * Returns an array of pids with open files on the specified path.
82 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070083 int[] getStorageUsers(in String path) = 8;
Sudheer Shankaf7341142016-10-18 17:15:18 -070084 /**
85 * Gets the state of a volume via its mountpoint.
86 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070087 String getVolumeState(in String mountPoint) = 9;
Sudheer Shankaf7341142016-10-18 17:15:18 -070088 /*
89 * Creates a secure container with the specified parameters. Returns an int
Sudheer Shanka2250d562016-11-07 15:41:02 -080090 * consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070091 */
92 int createSecureContainer(in String id, int sizeMb, in String fstype, in String key,
Sudheer Shanka34b33882016-11-01 00:13:51 -070093 int ownerUid, boolean external) = 10;
Sudheer Shankaf7341142016-10-18 17:15:18 -070094 /*
95 * Finalize a container which has just been created and populated. After
96 * finalization, the container is immutable. Returns an int consistent with
Sudheer Shanka2250d562016-11-07 15:41:02 -080097 * StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070098 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070099 int finalizeSecureContainer(in String id) = 11;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700100 /*
101 * Destroy a secure container, and free up all resources associated with it.
102 * NOTE: Ensure all references are released prior to deleting. Returns an
Sudheer Shanka2250d562016-11-07 15:41:02 -0800103 * int consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700104 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700105 int destroySecureContainer(in String id, boolean force) = 12;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700106 /*
107 * Mount a secure container with the specified key and owner UID. Returns an
Sudheer Shanka2250d562016-11-07 15:41:02 -0800108 * int consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700109 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700110 int mountSecureContainer(in String id, in String key, int ownerUid, boolean readOnly) = 13;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700111 /*
112 * Unount a secure container. Returns an int consistent with
Sudheer Shanka2250d562016-11-07 15:41:02 -0800113 * StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700114 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700115 int unmountSecureContainer(in String id, boolean force) = 14;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700116 /*
117 * Returns true if the specified container is mounted
118 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700119 boolean isSecureContainerMounted(in String id) = 15;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700120 /*
121 * Rename an unmounted secure container. Returns an int consistent with
Sudheer Shanka2250d562016-11-07 15:41:02 -0800122 * StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700123 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700124 int renameSecureContainer(in String oldId, in String newId) = 16;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700125 /*
126 * Returns the filesystem path of a mounted secure container.
127 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700128 String getSecureContainerPath(in String id) = 17;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700129 /**
130 * Gets an Array of currently known secure container IDs
131 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700132 String[] getSecureContainerList() = 18;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700133 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -0800134 * Shuts down the StorageManagerService and gracefully unmounts all external media.
Sudheer Shankaf7341142016-10-18 17:15:18 -0700135 * Invokes call back once the shutdown is complete.
136 */
Sudheer Shanka2250d562016-11-07 15:41:02 -0800137 void shutdown(IStorageShutdownObserver observer) = 19;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700138 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -0800139 * Call into StorageManagerService by PackageManager to notify that its done
Sudheer Shankaf7341142016-10-18 17:15:18 -0700140 * processing the media status update request.
141 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700142 void finishMediaUpdate() = 20;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700143 /**
144 * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
145 * only allows the calling process's UID access to the contents.
Sudheer Shanka2250d562016-11-07 15:41:02 -0800146 * StorageManagerService will call back to the supplied IObbActionListener to inform
Sudheer Shankaf7341142016-10-18 17:15:18 -0700147 * it of the terminal state of the call.
148 */
149 void mountObb(in String rawPath, in String canonicalPath, in String key,
Sudheer Shanka34b33882016-11-01 00:13:51 -0700150 IObbActionListener token, int nonce) = 21;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700151 /**
152 * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
153 * any program using it will be forcibly killed to unmount the image.
Sudheer Shanka2250d562016-11-07 15:41:02 -0800154 * StorageManagerService will call back to the supplied IObbActionListener to inform
Sudheer Shankaf7341142016-10-18 17:15:18 -0700155 * it of the terminal state of the call.
156 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700157 void unmountObb(in String rawPath, boolean force, IObbActionListener token, int nonce) = 22;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700158 /**
159 * Checks whether the specified Opaque Binary Blob (OBB) is mounted
160 * somewhere.
161 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700162 boolean isObbMounted(in String rawPath) = 23;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700163 /**
164 * Gets the path to the mounted Opaque Binary Blob (OBB).
165 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700166 String getMountedObbPath(in String rawPath) = 24;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700167 /**
168 * Returns whether or not the external storage is emulated.
169 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700170 boolean isExternalStorageEmulated() = 25;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700171 /**
172 * Decrypts any encrypted volumes.
173 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700174 int decryptStorage(in String password) = 26;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700175 /**
176 * Encrypts storage.
177 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700178 int encryptStorage(int type, in String password) = 27;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700179 /**
180 * Changes the encryption password.
181 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700182 int changeEncryptionPassword(int type, in String password) = 28;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700183 /**
184 * Returns list of all mountable volumes.
185 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700186 StorageVolume[] getVolumeList(int uid, in String packageName, int flags) = 29;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700187 /**
188 * Gets the path on the filesystem for the ASEC container itself.
189 *
190 * @param cid ASEC container ID
191 * @return path to filesystem or {@code null} if it's not found
192 * @throws RemoteException
193 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700194 String getSecureContainerFilesystemPath(in String cid) = 30;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700195 /**
196 * Determines the encryption state of the volume.
197 * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible
198 * values.
199 * Note that this has been replaced in most cases by the APIs in
200 * StorageManager (see isEncryptable and below)
201 * This is still useful to get the error state when encryption has failed
202 * and CryptKeeper needs to throw up a screen advising the user what to do
203 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700204 int getEncryptionState() = 31;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700205 /**
206 * Verify the encryption password against the stored volume. This method
207 * may only be called by the system process.
208 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700209 int verifyEncryptionPassword(in String password) = 32;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700210 /*
211 * Fix permissions in a container which has just been created and populated.
Sudheer Shanka2250d562016-11-07 15:41:02 -0800212 * Returns an int consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700213 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700214 int fixPermissionsSecureContainer(in String id, int gid, in String filename) = 33;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700215 /**
216 * Ensure that all directories along given path exist, creating parent
217 * directories as needed. Validates that given path is absolute and that it
218 * contains no relative "." or ".." paths or symlinks. Also ensures that
219 * path belongs to a volume managed by vold, and that path is either
220 * external storage data or OBB directory belonging to calling app.
221 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700222 int mkdirs(in String callingPkg, in String path) = 34;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700223 /**
224 * Determines the type of the encryption password
225 * @return PasswordType
226 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700227 int getPasswordType() = 35;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700228 /**
229 * Get password from vold
230 * @return password or empty string
231 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700232 String getPassword() = 36;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700233 /**
234 * Securely clear password from vold
235 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700236 oneway void clearPassword() = 37;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700237 /**
238 * Set a field in the crypto header.
239 * @param field field to set
240 * @param contents contents to set in field
241 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700242 oneway void setField(in String field, in String contents) = 38;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700243 /**
244 * Gets a field from the crypto header.
245 * @param field field to get
246 * @return contents of field
247 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700248 String getField(in String field) = 39;
249 int resizeSecureContainer(in String id, int sizeMb, in String key) = 40;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700250 /**
251 * Report the time of the last maintenance operation such as fstrim.
252 * @return Timestamp of the last maintenance operation, in the
253 * System.currentTimeMillis() time base
254 * @throws RemoteException
255 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700256 long lastMaintenance() = 41;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700257 /**
258 * Kick off an immediate maintenance operation
259 * @throws RemoteException
260 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700261 void runMaintenance() = 42;
262 void waitForAsecScan() = 43;
263 DiskInfo[] getDisks() = 44;
264 VolumeInfo[] getVolumes(int flags) = 45;
265 VolumeRecord[] getVolumeRecords(int flags) = 46;
266 void mount(in String volId) = 47;
267 void unmount(in String volId) = 48;
268 void format(in String volId) = 49;
269 void partitionPublic(in String diskId) = 50;
270 void partitionPrivate(in String diskId) = 51;
271 void partitionMixed(in String diskId, int ratio) = 52;
272 void setVolumeNickname(in String fsUuid, in String nickname) = 53;
273 void setVolumeUserFlags(in String fsUuid, int flags, int mask) = 54;
274 void forgetVolume(in String fsUuid) = 55;
275 void forgetAllVolumes() = 56;
276 String getPrimaryStorageUuid() = 57;
277 void setPrimaryStorageUuid(in String volumeUuid, IPackageMoveObserver callback) = 58;
278 long benchmark(in String volId) = 59;
279 void setDebugFlags(int flags, int mask) = 60;
280 void createUserKey(int userId, int serialNumber, boolean ephemeral) = 61;
281 void destroyUserKey(int userId) = 62;
282 void unlockUserKey(int userId, int serialNumber, in byte[] token, in byte[] secret) = 63;
283 void lockUserKey(int userId) = 64;
284 boolean isUserKeyUnlocked(int userId) = 65;
285 void prepareUserStorage(in String volumeUuid, int userId, int serialNumber, int flags) = 66;
286 void destroyUserStorage(in String volumeUuid, int userId, int flags) = 67;
287 boolean isConvertibleToFBE() = 68;
288 ParcelFileDescriptor mountAppFuse(in String name) = 69;
289 void addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 70;
290 void fixateNewestUserKeyAuth(int userId) = 71;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700291}