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