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 
17 package android.os.storage;
18 
19 import android.content.pm.IPackageMoveObserver;
20 import android.content.res.ObbInfo;
21 import android.os.IVoldTaskListener;
22 import android.os.ParcelFileDescriptor;
23 import android.os.storage.DiskInfo;
24 import android.os.storage.IStorageEventListener;
25 import android.os.storage.IStorageShutdownObserver;
26 import android.os.storage.IObbActionListener;
27 import android.os.storage.StorageVolume;
28 import android.os.storage.VolumeInfo;
29 import android.os.storage.VolumeRecord;
30 import com.android.internal.os.AppFuseMount;
31 
32 /**
33  * WARNING! Update IMountService.h and IMountService.cpp if you change this
34  * file. In particular, the transaction ids below must match the
35  * _TRANSACTION enum in IMountService.cpp
36  *
37  * @hide - Applications should use android.os.storage.StorageManager to access
38  *       storage functions.
39  */
40 interface IStorageManager {
41     /**
42      * Registers an IStorageEventListener for receiving async notifications.
43      */
44     void registerListener(IStorageEventListener listener) = 0;
45     /**
46      * Unregisters an IStorageEventListener
47      */
48     void unregisterListener(IStorageEventListener listener) = 1;
49     /**
50      * Shuts down the StorageManagerService and gracefully unmounts all external media.
51      * Invokes call back once the shutdown is complete.
52      */
53     void shutdown(IStorageShutdownObserver observer) = 19;
54     /**
55      * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
56      * only allows the calling process's UID access to the contents.
57      * StorageManagerService will call back to the supplied IObbActionListener to inform
58      * it of the terminal state of the call.
59      */
mountObb(in String rawPath, in String canonicalPath, in String key, IObbActionListener token, int nonce, in ObbInfo obbInfo)60     void mountObb(in String rawPath, in String canonicalPath, in String key,
61             IObbActionListener token, int nonce, in ObbInfo obbInfo) = 21;
62     /**
63      * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
64      * any program using it will be forcibly killed to unmount the image.
65      * StorageManagerService will call back to the supplied IObbActionListener to inform
66      * it of the terminal state of the call.
67      */
unmountObb(in String rawPath, boolean force, IObbActionListener token, int nonce)68     void unmountObb(in String rawPath, boolean force, IObbActionListener token, int nonce) = 22;
69     /**
70      * Checks whether the specified Opaque Binary Blob (OBB) is mounted
71      * somewhere.
72      */
73     boolean isObbMounted(in String rawPath) = 23;
74     /**
75      * Gets the path to the mounted Opaque Binary Blob (OBB).
76      */
77     String getMountedObbPath(in String rawPath) = 24;
78     /**
79      * Decrypts any encrypted volumes.
80      */
81     int decryptStorage(in String password) = 26;
82     /**
83      * Encrypts storage.
84      */
encryptStorage(int type, in String password)85     int encryptStorage(int type, in String password) = 27;
86     /**
87      * Changes the encryption password.
88      */
changeEncryptionPassword(int type, in String password)89     int changeEncryptionPassword(int type, in String password) = 28;
90     /**
91      * Returns list of all mountable volumes.
92      */
getVolumeList(int uid, in String packageName, int flags)93     StorageVolume[] getVolumeList(int uid, in String packageName, int flags) = 29;
94     /**
95      * Determines the encryption state of the volume.
96      * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible
97      * values.
98      * Note that this has been replaced in most cases by the APIs in
99      * StorageManager (see isEncryptable and below)
100      * This is still useful to get the error state when encryption has failed
101      * and CryptKeeper needs to throw up a screen advising the user what to do
102      */
getEncryptionState()103     int getEncryptionState() = 31;
104     /**
105      * Verify the encryption password against the stored volume.  This method
106      * may only be called by the system process.
107      */
108     int verifyEncryptionPassword(in String password) = 32;
109     /**
110      * Ensure that all directories along given path exist, creating parent
111      * directories as needed. Validates that given path is absolute and that it
112      * contains no relative "." or ".." paths or symlinks. Also ensures that
113      * path belongs to a volume managed by vold, and that path is either
114      * external storage data or OBB directory belonging to calling app.
115      */
mkdirs(in String callingPkg, in String path)116     void mkdirs(in String callingPkg, in String path) = 34;
117     /**
118      * Determines the type of the encryption password
119      * @return PasswordType
120      */
getPasswordType()121     int getPasswordType() = 35;
122     /**
123      * Get password from vold
124      * @return password or empty string
125      */
getPassword()126     String getPassword() = 36;
127     /**
128      * Securely clear password from vold
129      */
clearPassword()130     oneway void clearPassword() = 37;
131     /**
132      * Set a field in the crypto header.
133      * @param field field to set
134      * @param contents contents to set in field
135      */
setField(in String field, in String contents)136     oneway void setField(in String field, in String contents) = 38;
137     /**
138      * Gets a field from the crypto header.
139      * @param field field to get
140      * @return contents of field
141      */
142     String getField(in String field) = 39;
143     /**
144      * Report the time of the last maintenance operation such as fstrim.
145      * @return Timestamp of the last maintenance operation, in the
146      *     System.currentTimeMillis() time base
147      * @throws RemoteException
148      */
lastMaintenance()149     long lastMaintenance() = 41;
150     /**
151      * Kick off an immediate maintenance operation
152      * @throws RemoteException
153      */
runMaintenance()154     void runMaintenance() = 42;
getDisks()155     DiskInfo[] getDisks() = 44;
getVolumes(int flags)156     VolumeInfo[] getVolumes(int flags) = 45;
getVolumeRecords(int flags)157     VolumeRecord[] getVolumeRecords(int flags) = 46;
158     void mount(in String volId) = 47;
159     void unmount(in String volId) = 48;
160     void format(in String volId) = 49;
161     void partitionPublic(in String diskId) = 50;
162     void partitionPrivate(in String diskId) = 51;
partitionMixed(in String diskId, int ratio)163     void partitionMixed(in String diskId, int ratio) = 52;
setVolumeNickname(in String fsUuid, in String nickname)164     void setVolumeNickname(in String fsUuid, in String nickname) = 53;
setVolumeUserFlags(in String fsUuid, int flags, int mask)165     void setVolumeUserFlags(in String fsUuid, int flags, int mask) = 54;
166     void forgetVolume(in String fsUuid) = 55;
forgetAllVolumes()167     void forgetAllVolumes() = 56;
getPrimaryStorageUuid()168     String getPrimaryStorageUuid() = 57;
setPrimaryStorageUuid(in String volumeUuid, IPackageMoveObserver callback)169     void setPrimaryStorageUuid(in String volumeUuid, IPackageMoveObserver callback) = 58;
benchmark(in String volId, IVoldTaskListener listener)170     void benchmark(in String volId, IVoldTaskListener listener) = 59;
setDebugFlags(int flags, int mask)171     void setDebugFlags(int flags, int mask) = 60;
createUserKey(int userId, int serialNumber, boolean ephemeral)172     void createUserKey(int userId, int serialNumber, boolean ephemeral) = 61;
destroyUserKey(int userId)173     void destroyUserKey(int userId) = 62;
unlockUserKey(int userId, int serialNumber, in byte[] token, in byte[] secret)174     void unlockUserKey(int userId, int serialNumber, in byte[] token, in byte[] secret) = 63;
lockUserKey(int userId)175     void lockUserKey(int userId) = 64;
isUserKeyUnlocked(int userId)176     boolean isUserKeyUnlocked(int userId) = 65;
prepareUserStorage(in String volumeUuid, int userId, int serialNumber, int flags)177     void prepareUserStorage(in String volumeUuid, int userId, int serialNumber, int flags) = 66;
destroyUserStorage(in String volumeUuid, int userId, int flags)178     void destroyUserStorage(in String volumeUuid, int userId, int flags) = 67;
isConvertibleToFBE()179     boolean isConvertibleToFBE() = 68;
addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret)180     void addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 70;
fixateNewestUserKeyAuth(int userId)181     void fixateNewestUserKeyAuth(int userId) = 71;
fstrim(int flags, IVoldTaskListener listener)182     void fstrim(int flags, IVoldTaskListener listener) = 72;
mountProxyFileDescriptorBridge()183     AppFuseMount mountProxyFileDescriptorBridge() = 73;
openProxyFileDescriptor(int mountPointId, int fileId, int mode)184     ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74;
getCacheQuotaBytes(String volumeUuid, int uid)185     long getCacheQuotaBytes(String volumeUuid, int uid) = 75;
getCacheSizeBytes(String volumeUuid, int uid)186     long getCacheSizeBytes(String volumeUuid, int uid) = 76;
getAllocatableBytes(String volumeUuid, int flags, String callingPackage)187     long getAllocatableBytes(String volumeUuid, int flags, String callingPackage) = 77;
allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage)188     void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78;
runIdleMaintenance()189     void runIdleMaintenance() = 79;
abortIdleMaintenance()190     void abortIdleMaintenance() = 80;
commitChanges()191     void commitChanges() = 83;
supportsCheckpoint()192     boolean supportsCheckpoint() = 84;
startCheckpoint(int numTries)193     void startCheckpoint(int numTries) = 85;
needsCheckpoint()194     boolean needsCheckpoint() = 86;
abortChanges(in String message, boolean retry)195     void abortChanges(in String message, boolean retry) = 87;
clearUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret)196     void clearUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 88;
197 }
198