blob: 50855bb349d9308089333b96f25dc7c7df59c6f9 [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;
Daichi Hirono9fb00182016-11-08 14:12:17 +090028import com.android.internal.os.AppFuseMount;
Sudheer Shankaf7341142016-10-18 17:15:18 -070029
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 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080038interface IStorageManager {
Sudheer Shankaf7341142016-10-18 17:15:18 -070039 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -080040 * Registers an IStorageEventListener for receiving async notifications.
Sudheer Shankaf7341142016-10-18 17:15:18 -070041 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080042 void registerListener(IStorageEventListener listener) = 0;
Sudheer Shankaf7341142016-10-18 17:15:18 -070043 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -080044 * Unregisters an IStorageEventListener
Sudheer Shankaf7341142016-10-18 17:15:18 -070045 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080046 void unregisterListener(IStorageEventListener listener) = 1;
Sudheer Shankaf7341142016-10-18 17:15:18 -070047 /**
48 * Returns true if a USB mass storage host is connected
49 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070050 boolean isUsbMassStorageConnected() = 2;
Sudheer Shankaf7341142016-10-18 17:15:18 -070051 /**
52 * Enables / disables USB mass storage. The caller should check actual
53 * status of enabling/disabling USB mass storage via StorageEventListener.
54 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070055 void setUsbMassStorageEnabled(boolean enable) = 3;
Sudheer Shankaf7341142016-10-18 17:15:18 -070056 /**
57 * Returns true if a USB mass storage host is enabled (media is shared)
58 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070059 boolean isUsbMassStorageEnabled() = 4;
Sudheer Shankaf7341142016-10-18 17:15:18 -070060 /**
61 * Mount external storage at given mount point. Returns an int consistent
Sudheer Shanka2250d562016-11-07 15:41:02 -080062 * with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070063 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070064 int mountVolume(in String mountPoint) = 5;
Sudheer Shankaf7341142016-10-18 17:15:18 -070065 /**
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 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070075 void unmountVolume(in String mountPoint, boolean force, boolean removeEncryption) = 6;
Sudheer Shankaf7341142016-10-18 17:15:18 -070076 /**
77 * Format external storage given a mount point. Returns an int consistent
Sudheer Shanka2250d562016-11-07 15:41:02 -080078 * with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070079 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070080 int formatVolume(in String mountPoint) = 7;
Sudheer Shankaf7341142016-10-18 17:15:18 -070081 /**
82 * Returns an array of pids with open files on the specified path.
83 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070084 int[] getStorageUsers(in String path) = 8;
Sudheer Shankaf7341142016-10-18 17:15:18 -070085 /**
86 * Gets the state of a volume via its mountpoint.
87 */
Sudheer Shanka34b33882016-11-01 00:13:51 -070088 String getVolumeState(in String mountPoint) = 9;
Sudheer Shankaf7341142016-10-18 17:15:18 -070089 /*
90 * Creates a secure container with the specified parameters. Returns an int
Sudheer Shanka2250d562016-11-07 15:41:02 -080091 * consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070092 */
93 int createSecureContainer(in String id, int sizeMb, in String fstype, in String key,
Sudheer Shanka34b33882016-11-01 00:13:51 -070094 int ownerUid, boolean external) = 10;
Sudheer Shankaf7341142016-10-18 17:15:18 -070095 /*
96 * Finalize a container which has just been created and populated. After
97 * finalization, the container is immutable. Returns an int consistent with
Sudheer Shanka2250d562016-11-07 15:41:02 -080098 * StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -070099 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700100 int finalizeSecureContainer(in String id) = 11;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700101 /*
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
Sudheer Shanka2250d562016-11-07 15:41:02 -0800104 * int consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700105 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700106 int destroySecureContainer(in String id, boolean force) = 12;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700107 /*
108 * Mount a secure container with the specified key and owner UID. Returns an
Sudheer Shanka2250d562016-11-07 15:41:02 -0800109 * int consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700110 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700111 int mountSecureContainer(in String id, in String key, int ownerUid, boolean readOnly) = 13;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700112 /*
113 * Unount a secure container. Returns an int consistent with
Sudheer Shanka2250d562016-11-07 15:41:02 -0800114 * StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700115 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700116 int unmountSecureContainer(in String id, boolean force) = 14;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700117 /*
118 * Returns true if the specified container is mounted
119 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700120 boolean isSecureContainerMounted(in String id) = 15;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700121 /*
122 * Rename an unmounted secure container. Returns an int consistent with
Sudheer Shanka2250d562016-11-07 15:41:02 -0800123 * StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700124 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700125 int renameSecureContainer(in String oldId, in String newId) = 16;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700126 /*
127 * Returns the filesystem path of a mounted secure container.
128 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700129 String getSecureContainerPath(in String id) = 17;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700130 /**
131 * Gets an Array of currently known secure container IDs
132 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700133 String[] getSecureContainerList() = 18;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700134 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -0800135 * Shuts down the StorageManagerService and gracefully unmounts all external media.
Sudheer Shankaf7341142016-10-18 17:15:18 -0700136 * Invokes call back once the shutdown is complete.
137 */
Sudheer Shanka2250d562016-11-07 15:41:02 -0800138 void shutdown(IStorageShutdownObserver observer) = 19;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700139 /**
Sudheer Shanka2250d562016-11-07 15:41:02 -0800140 * Call into StorageManagerService by PackageManager to notify that its done
Sudheer Shankaf7341142016-10-18 17:15:18 -0700141 * processing the media status update request.
142 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700143 void finishMediaUpdate() = 20;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700144 /**
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.
Sudheer Shanka2250d562016-11-07 15:41:02 -0800147 * StorageManagerService will call back to the supplied IObbActionListener to inform
Sudheer Shankaf7341142016-10-18 17:15:18 -0700148 * it of the terminal state of the call.
149 */
150 void mountObb(in String rawPath, in String canonicalPath, in String key,
Sudheer Shanka34b33882016-11-01 00:13:51 -0700151 IObbActionListener token, int nonce) = 21;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700152 /**
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.
Sudheer Shanka2250d562016-11-07 15:41:02 -0800155 * StorageManagerService will call back to the supplied IObbActionListener to inform
Sudheer Shankaf7341142016-10-18 17:15:18 -0700156 * it of the terminal state of the call.
157 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700158 void unmountObb(in String rawPath, boolean force, IObbActionListener token, int nonce) = 22;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700159 /**
160 * Checks whether the specified Opaque Binary Blob (OBB) is mounted
161 * somewhere.
162 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700163 boolean isObbMounted(in String rawPath) = 23;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700164 /**
165 * Gets the path to the mounted Opaque Binary Blob (OBB).
166 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700167 String getMountedObbPath(in String rawPath) = 24;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700168 /**
169 * Returns whether or not the external storage is emulated.
170 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700171 boolean isExternalStorageEmulated() = 25;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700172 /**
173 * Decrypts any encrypted volumes.
174 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700175 int decryptStorage(in String password) = 26;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700176 /**
177 * Encrypts storage.
178 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700179 int encryptStorage(int type, in String password) = 27;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700180 /**
181 * Changes the encryption password.
182 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700183 int changeEncryptionPassword(int type, in String password) = 28;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700184 /**
185 * Returns list of all mountable volumes.
186 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700187 StorageVolume[] getVolumeList(int uid, in String packageName, int flags) = 29;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700188 /**
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 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700195 String getSecureContainerFilesystemPath(in String cid) = 30;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700196 /**
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 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700205 int getEncryptionState() = 31;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700206 /**
207 * Verify the encryption password against the stored volume. This method
208 * may only be called by the system process.
209 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700210 int verifyEncryptionPassword(in String password) = 32;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700211 /*
212 * Fix permissions in a container which has just been created and populated.
Sudheer Shanka2250d562016-11-07 15:41:02 -0800213 * Returns an int consistent with StorageResultCode
Sudheer Shankaf7341142016-10-18 17:15:18 -0700214 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700215 int fixPermissionsSecureContainer(in String id, int gid, in String filename) = 33;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700216 /**
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 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700223 int mkdirs(in String callingPkg, in String path) = 34;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700224 /**
225 * Determines the type of the encryption password
226 * @return PasswordType
227 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700228 int getPasswordType() = 35;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700229 /**
230 * Get password from vold
231 * @return password or empty string
232 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700233 String getPassword() = 36;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700234 /**
235 * Securely clear password from vold
236 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700237 oneway void clearPassword() = 37;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700238 /**
239 * Set a field in the crypto header.
240 * @param field field to set
241 * @param contents contents to set in field
242 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700243 oneway void setField(in String field, in String contents) = 38;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700244 /**
245 * Gets a field from the crypto header.
246 * @param field field to get
247 * @return contents of field
248 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700249 String getField(in String field) = 39;
250 int resizeSecureContainer(in String id, int sizeMb, in String key) = 40;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700251 /**
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 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700257 long lastMaintenance() = 41;
Sudheer Shankaf7341142016-10-18 17:15:18 -0700258 /**
259 * Kick off an immediate maintenance operation
260 * @throws RemoteException
261 */
Sudheer Shanka34b33882016-11-01 00:13:51 -0700262 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;
Sudheer Shanka34b33882016-11-01 00:13:51 -0700289 void addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 70;
290 void fixateNewestUserKeyAuth(int userId) = 71;
Jeff Sharkey31d0b702016-11-21 14:16:53 -0700291 void fstrim(int flags) = 72;
Daichi Hirono9fb00182016-11-08 14:12:17 +0900292 AppFuseMount mountProxyFileDescriptorBridge() = 73;
293 ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74;
Jeff Sharkey9bed0702017-01-23 20:37:05 -0700294 long getCacheQuotaBytes(String volumeUuid, int uid) = 75;
295 long getCacheSizeBytes(String volumeUuid, int uid) = 76;
Jeff Sharkey35e46d22017-06-09 10:01:20 -0600296 long getAllocatableBytes(String volumeUuid, int flags, String callingPackage) = 77;
297 void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78;
Rubin Xuaa32d152017-04-27 17:01:05 +0100298 void secdiscard(in String path) = 79;
Jeff Sharkey31d0b702016-11-21 14:16:53 -0700299}