• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.os.Binder;
21 import android.os.IBinder;
22 import android.os.IInterface;
23 import android.os.Parcel;
24 import android.os.RemoteException;
25 
26 /**
27  * WARNING! Update IMountService.h and IMountService.cpp if you change this
28  * file. In particular, the ordering of the methods below must match the
29  * _TRANSACTION enum in IMountService.cpp
30  *
31  * @hide - Applications should use android.os.storage.StorageManager to access
32  *       storage functions.
33  */
34 public interface IMountService extends IInterface {
35     /** Local-side IPC implementation stub class. */
36     public static abstract class Stub extends Binder implements IMountService {
37         private static class Proxy implements IMountService {
38             private final IBinder mRemote;
39 
Proxy(IBinder remote)40             Proxy(IBinder remote) {
41                 mRemote = remote;
42             }
43 
asBinder()44             public IBinder asBinder() {
45                 return mRemote;
46             }
47 
getInterfaceDescriptor()48             public String getInterfaceDescriptor() {
49                 return DESCRIPTOR;
50             }
51 
52             /**
53              * Registers an IMountServiceListener for receiving async
54              * notifications.
55              */
registerListener(IMountServiceListener listener)56             public void registerListener(IMountServiceListener listener) throws RemoteException {
57                 Parcel _data = Parcel.obtain();
58                 Parcel _reply = Parcel.obtain();
59                 try {
60                     _data.writeInterfaceToken(DESCRIPTOR);
61                     _data.writeStrongBinder((listener != null ? listener.asBinder() : null));
62                     mRemote.transact(Stub.TRANSACTION_registerListener, _data, _reply, 0);
63                     _reply.readException();
64                 } finally {
65                     _reply.recycle();
66                     _data.recycle();
67                 }
68             }
69 
70             /**
71              * Unregisters an IMountServiceListener
72              */
unregisterListener(IMountServiceListener listener)73             public void unregisterListener(IMountServiceListener listener) throws RemoteException {
74                 Parcel _data = Parcel.obtain();
75                 Parcel _reply = Parcel.obtain();
76                 try {
77                     _data.writeInterfaceToken(DESCRIPTOR);
78                     _data.writeStrongBinder((listener != null ? listener.asBinder() : null));
79                     mRemote.transact(Stub.TRANSACTION_unregisterListener, _data, _reply, 0);
80                     _reply.readException();
81                 } finally {
82                     _reply.recycle();
83                     _data.recycle();
84                 }
85             }
86 
87             /**
88              * Returns true if a USB mass storage host is connected
89              */
isUsbMassStorageConnected()90             public boolean isUsbMassStorageConnected() throws RemoteException {
91                 Parcel _data = Parcel.obtain();
92                 Parcel _reply = Parcel.obtain();
93                 boolean _result;
94                 try {
95                     _data.writeInterfaceToken(DESCRIPTOR);
96                     mRemote.transact(Stub.TRANSACTION_isUsbMassStorageConnected, _data, _reply, 0);
97                     _reply.readException();
98                     _result = 0 != _reply.readInt();
99                 } finally {
100                     _reply.recycle();
101                     _data.recycle();
102                 }
103                 return _result;
104             }
105 
106             /**
107              * Enables / disables USB mass storage. The caller should check
108              * actual status of enabling/disabling USB mass storage via
109              * StorageEventListener.
110              */
setUsbMassStorageEnabled(boolean enable)111             public void setUsbMassStorageEnabled(boolean enable) throws RemoteException {
112                 Parcel _data = Parcel.obtain();
113                 Parcel _reply = Parcel.obtain();
114                 try {
115                     _data.writeInterfaceToken(DESCRIPTOR);
116                     _data.writeInt((enable ? 1 : 0));
117                     mRemote.transact(Stub.TRANSACTION_setUsbMassStorageEnabled, _data, _reply, 0);
118                     _reply.readException();
119                 } finally {
120                     _reply.recycle();
121                     _data.recycle();
122                 }
123             }
124 
125             /**
126              * Returns true if a USB mass storage host is enabled (media is
127              * shared)
128              */
isUsbMassStorageEnabled()129             public boolean isUsbMassStorageEnabled() throws RemoteException {
130                 Parcel _data = Parcel.obtain();
131                 Parcel _reply = Parcel.obtain();
132                 boolean _result;
133                 try {
134                     _data.writeInterfaceToken(DESCRIPTOR);
135                     mRemote.transact(Stub.TRANSACTION_isUsbMassStorageEnabled, _data, _reply, 0);
136                     _reply.readException();
137                     _result = 0 != _reply.readInt();
138                 } finally {
139                     _reply.recycle();
140                     _data.recycle();
141                 }
142                 return _result;
143             }
144 
145             /**
146              * Mount external storage at given mount point. Returns an int
147              * consistent with MountServiceResultCode
148              */
mountVolume(String mountPoint)149             public int mountVolume(String mountPoint) throws RemoteException {
150                 Parcel _data = Parcel.obtain();
151                 Parcel _reply = Parcel.obtain();
152                 int _result;
153                 try {
154                     _data.writeInterfaceToken(DESCRIPTOR);
155                     _data.writeString(mountPoint);
156                     mRemote.transact(Stub.TRANSACTION_mountVolume, _data, _reply, 0);
157                     _reply.readException();
158                     _result = _reply.readInt();
159                 } finally {
160                     _reply.recycle();
161                     _data.recycle();
162                 }
163                 return _result;
164             }
165 
166             /**
167              * Safely unmount external storage at given mount point. The unmount
168              * is an asynchronous operation. Applications should register
169              * StorageEventListener for storage related status changes.
170              */
unmountVolume(String mountPoint, boolean force, boolean removeEncryption)171             public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption)
172                     throws RemoteException {
173                 Parcel _data = Parcel.obtain();
174                 Parcel _reply = Parcel.obtain();
175                 try {
176                     _data.writeInterfaceToken(DESCRIPTOR);
177                     _data.writeString(mountPoint);
178                     _data.writeInt((force ? 1 : 0));
179                     _data.writeInt((removeEncryption ? 1 : 0));
180                     mRemote.transact(Stub.TRANSACTION_unmountVolume, _data, _reply, 0);
181                     _reply.readException();
182                 } finally {
183                     _reply.recycle();
184                     _data.recycle();
185                 }
186             }
187 
188             /**
189              * Format external storage given a mount point. Returns an int
190              * consistent with MountServiceResultCode
191              */
formatVolume(String mountPoint)192             public int formatVolume(String mountPoint) throws RemoteException {
193                 Parcel _data = Parcel.obtain();
194                 Parcel _reply = Parcel.obtain();
195                 int _result;
196                 try {
197                     _data.writeInterfaceToken(DESCRIPTOR);
198                     _data.writeString(mountPoint);
199                     mRemote.transact(Stub.TRANSACTION_formatVolume, _data, _reply, 0);
200                     _reply.readException();
201                     _result = _reply.readInt();
202                 } finally {
203                     _reply.recycle();
204                     _data.recycle();
205                 }
206                 return _result;
207             }
208 
209             /**
210              * Returns an array of pids with open files on the specified path.
211              */
getStorageUsers(String path)212             public int[] getStorageUsers(String path) throws RemoteException {
213                 Parcel _data = Parcel.obtain();
214                 Parcel _reply = Parcel.obtain();
215                 int[] _result;
216                 try {
217                     _data.writeInterfaceToken(DESCRIPTOR);
218                     _data.writeString(path);
219                     mRemote.transact(Stub.TRANSACTION_getStorageUsers, _data, _reply, 0);
220                     _reply.readException();
221                     _result = _reply.createIntArray();
222                 } finally {
223                     _reply.recycle();
224                     _data.recycle();
225                 }
226                 return _result;
227             }
228 
229             /**
230              * Gets the state of a volume via its mountpoint.
231              */
getVolumeState(String mountPoint)232             public String getVolumeState(String mountPoint) throws RemoteException {
233                 Parcel _data = Parcel.obtain();
234                 Parcel _reply = Parcel.obtain();
235                 String _result;
236                 try {
237                     _data.writeInterfaceToken(DESCRIPTOR);
238                     _data.writeString(mountPoint);
239                     mRemote.transact(Stub.TRANSACTION_getVolumeState, _data, _reply, 0);
240                     _reply.readException();
241                     _result = _reply.readString();
242                 } finally {
243                     _reply.recycle();
244                     _data.recycle();
245                 }
246                 return _result;
247             }
248 
249             /*
250              * Creates a secure container with the specified parameters. Returns
251              * an int consistent with MountServiceResultCode
252              */
createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid, boolean external)253             public int createSecureContainer(String id, int sizeMb, String fstype, String key,
254                     int ownerUid, boolean external) throws RemoteException {
255                 Parcel _data = Parcel.obtain();
256                 Parcel _reply = Parcel.obtain();
257                 int _result;
258                 try {
259                     _data.writeInterfaceToken(DESCRIPTOR);
260                     _data.writeString(id);
261                     _data.writeInt(sizeMb);
262                     _data.writeString(fstype);
263                     _data.writeString(key);
264                     _data.writeInt(ownerUid);
265                     _data.writeInt(external ? 1 : 0);
266                     mRemote.transact(Stub.TRANSACTION_createSecureContainer, _data, _reply, 0);
267                     _reply.readException();
268                     _result = _reply.readInt();
269                 } finally {
270                     _reply.recycle();
271                     _data.recycle();
272                 }
273                 return _result;
274             }
275 
276             /*
277              * Destroy a secure container, and free up all resources associated
278              * with it. NOTE: Ensure all references are released prior to
279              * deleting. Returns an int consistent with MountServiceResultCode
280              */
destroySecureContainer(String id, boolean force)281             public int destroySecureContainer(String id, boolean force) throws RemoteException {
282                 Parcel _data = Parcel.obtain();
283                 Parcel _reply = Parcel.obtain();
284                 int _result;
285                 try {
286                     _data.writeInterfaceToken(DESCRIPTOR);
287                     _data.writeString(id);
288                     _data.writeInt((force ? 1 : 0));
289                     mRemote.transact(Stub.TRANSACTION_destroySecureContainer, _data, _reply, 0);
290                     _reply.readException();
291                     _result = _reply.readInt();
292                 } finally {
293                     _reply.recycle();
294                     _data.recycle();
295                 }
296                 return _result;
297             }
298 
299             /*
300              * Finalize a container which has just been created and populated.
301              * After finalization, the container is immutable. Returns an int
302              * consistent with MountServiceResultCode
303              */
finalizeSecureContainer(String id)304             public int finalizeSecureContainer(String id) throws RemoteException {
305                 Parcel _data = Parcel.obtain();
306                 Parcel _reply = Parcel.obtain();
307                 int _result;
308                 try {
309                     _data.writeInterfaceToken(DESCRIPTOR);
310                     _data.writeString(id);
311                     mRemote.transact(Stub.TRANSACTION_finalizeSecureContainer, _data, _reply, 0);
312                     _reply.readException();
313                     _result = _reply.readInt();
314                 } finally {
315                     _reply.recycle();
316                     _data.recycle();
317                 }
318                 return _result;
319             }
320 
321             /*
322              * Mount a secure container with the specified key and owner UID.
323              * Returns an int consistent with MountServiceResultCode
324              */
mountSecureContainer(String id, String key, int ownerUid, boolean readOnly)325             public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly)
326                     throws RemoteException {
327                 Parcel _data = Parcel.obtain();
328                 Parcel _reply = Parcel.obtain();
329                 int _result;
330                 try {
331                     _data.writeInterfaceToken(DESCRIPTOR);
332                     _data.writeString(id);
333                     _data.writeString(key);
334                     _data.writeInt(ownerUid);
335                     _data.writeInt(readOnly ? 1 : 0);
336                     mRemote.transact(Stub.TRANSACTION_mountSecureContainer, _data, _reply, 0);
337                     _reply.readException();
338                     _result = _reply.readInt();
339                 } finally {
340                     _reply.recycle();
341                     _data.recycle();
342                 }
343                 return _result;
344             }
345 
346             /*
347              * Unount a secure container. Returns an int consistent with
348              * MountServiceResultCode
349              */
unmountSecureContainer(String id, boolean force)350             public int unmountSecureContainer(String id, boolean force) throws RemoteException {
351                 Parcel _data = Parcel.obtain();
352                 Parcel _reply = Parcel.obtain();
353                 int _result;
354                 try {
355                     _data.writeInterfaceToken(DESCRIPTOR);
356                     _data.writeString(id);
357                     _data.writeInt((force ? 1 : 0));
358                     mRemote.transact(Stub.TRANSACTION_unmountSecureContainer, _data, _reply, 0);
359                     _reply.readException();
360                     _result = _reply.readInt();
361                 } finally {
362                     _reply.recycle();
363                     _data.recycle();
364                 }
365                 return _result;
366             }
367 
368             /*
369              * Returns true if the specified container is mounted
370              */
isSecureContainerMounted(String id)371             public boolean isSecureContainerMounted(String id) throws RemoteException {
372                 Parcel _data = Parcel.obtain();
373                 Parcel _reply = Parcel.obtain();
374                 boolean _result;
375                 try {
376                     _data.writeInterfaceToken(DESCRIPTOR);
377                     _data.writeString(id);
378                     mRemote.transact(Stub.TRANSACTION_isSecureContainerMounted, _data, _reply, 0);
379                     _reply.readException();
380                     _result = 0 != _reply.readInt();
381                 } finally {
382                     _reply.recycle();
383                     _data.recycle();
384                 }
385                 return _result;
386             }
387 
388             /*
389              * Rename an unmounted secure container. Returns an int consistent
390              * with MountServiceResultCode
391              */
renameSecureContainer(String oldId, String newId)392             public int renameSecureContainer(String oldId, String newId) throws RemoteException {
393                 Parcel _data = Parcel.obtain();
394                 Parcel _reply = Parcel.obtain();
395                 int _result;
396                 try {
397                     _data.writeInterfaceToken(DESCRIPTOR);
398                     _data.writeString(oldId);
399                     _data.writeString(newId);
400                     mRemote.transact(Stub.TRANSACTION_renameSecureContainer, _data, _reply, 0);
401                     _reply.readException();
402                     _result = _reply.readInt();
403                 } finally {
404                     _reply.recycle();
405                     _data.recycle();
406                 }
407                 return _result;
408             }
409 
410             /*
411              * Returns the filesystem path of a mounted secure container.
412              */
getSecureContainerPath(String id)413             public String getSecureContainerPath(String id) throws RemoteException {
414                 Parcel _data = Parcel.obtain();
415                 Parcel _reply = Parcel.obtain();
416                 String _result;
417                 try {
418                     _data.writeInterfaceToken(DESCRIPTOR);
419                     _data.writeString(id);
420                     mRemote.transact(Stub.TRANSACTION_getSecureContainerPath, _data, _reply, 0);
421                     _reply.readException();
422                     _result = _reply.readString();
423                 } finally {
424                     _reply.recycle();
425                     _data.recycle();
426                 }
427                 return _result;
428             }
429 
430             /**
431              * Gets an Array of currently known secure container IDs
432              */
getSecureContainerList()433             public String[] getSecureContainerList() throws RemoteException {
434                 Parcel _data = Parcel.obtain();
435                 Parcel _reply = Parcel.obtain();
436                 String[] _result;
437                 try {
438                     _data.writeInterfaceToken(DESCRIPTOR);
439                     mRemote.transact(Stub.TRANSACTION_getSecureContainerList, _data, _reply, 0);
440                     _reply.readException();
441                     _result = _reply.createStringArray();
442                 } finally {
443                     _reply.recycle();
444                     _data.recycle();
445                 }
446                 return _result;
447             }
448 
449             /**
450              * Shuts down the MountService and gracefully unmounts all external
451              * media. Invokes call back once the shutdown is complete.
452              */
shutdown(IMountShutdownObserver observer)453             public void shutdown(IMountShutdownObserver observer)
454                     throws RemoteException {
455                 Parcel _data = Parcel.obtain();
456                 Parcel _reply = Parcel.obtain();
457                 try {
458                     _data.writeInterfaceToken(DESCRIPTOR);
459                     _data.writeStrongBinder((observer != null ? observer.asBinder() : null));
460                     mRemote.transact(Stub.TRANSACTION_shutdown, _data, _reply, 0);
461                     _reply.readException();
462                 } finally {
463                     _reply.recycle();
464                     _data.recycle();
465                 }
466             }
467 
468             /**
469              * Call into MountService by PackageManager to notify that its done
470              * processing the media status update request.
471              */
finishMediaUpdate()472             public void finishMediaUpdate() throws RemoteException {
473                 Parcel _data = Parcel.obtain();
474                 Parcel _reply = Parcel.obtain();
475                 try {
476                     _data.writeInterfaceToken(DESCRIPTOR);
477                     mRemote.transact(Stub.TRANSACTION_finishMediaUpdate, _data, _reply, 0);
478                     _reply.readException();
479                 } finally {
480                     _reply.recycle();
481                     _data.recycle();
482                 }
483             }
484 
485             /**
486              * Mounts an Opaque Binary Blob (OBB) with the specified decryption
487              * key and only allows the calling process's UID access to the
488              * contents. MountService will call back to the supplied
489              * IObbActionListener to inform it of the terminal state of the
490              * call.
491              */
mountObb(String rawPath, String canonicalPath, String key, IObbActionListener token, int nonce)492             public void mountObb(String rawPath, String canonicalPath, String key,
493                     IObbActionListener token, int nonce) throws RemoteException {
494                 Parcel _data = Parcel.obtain();
495                 Parcel _reply = Parcel.obtain();
496                 try {
497                     _data.writeInterfaceToken(DESCRIPTOR);
498                     _data.writeString(rawPath);
499                     _data.writeString(canonicalPath);
500                     _data.writeString(key);
501                     _data.writeStrongBinder((token != null ? token.asBinder() : null));
502                     _data.writeInt(nonce);
503                     mRemote.transact(Stub.TRANSACTION_mountObb, _data, _reply, 0);
504                     _reply.readException();
505                 } finally {
506                     _reply.recycle();
507                     _data.recycle();
508                 }
509             }
510 
511             /**
512              * Unmounts an Opaque Binary Blob (OBB). When the force flag is
513              * specified, any program using it will be forcibly killed to
514              * unmount the image. MountService will call back to the supplied
515              * IObbActionListener to inform it of the terminal state of the
516              * call.
517              */
unmountObb( String rawPath, boolean force, IObbActionListener token, int nonce)518             public void unmountObb(
519                     String rawPath, boolean force, IObbActionListener token, int nonce)
520                     throws RemoteException {
521                 Parcel _data = Parcel.obtain();
522                 Parcel _reply = Parcel.obtain();
523                 try {
524                     _data.writeInterfaceToken(DESCRIPTOR);
525                     _data.writeString(rawPath);
526                     _data.writeInt((force ? 1 : 0));
527                     _data.writeStrongBinder((token != null ? token.asBinder() : null));
528                     _data.writeInt(nonce);
529                     mRemote.transact(Stub.TRANSACTION_unmountObb, _data, _reply, 0);
530                     _reply.readException();
531                 } finally {
532                     _reply.recycle();
533                     _data.recycle();
534                 }
535             }
536 
537             /**
538              * Checks whether the specified Opaque Binary Blob (OBB) is mounted
539              * somewhere.
540              */
isObbMounted(String rawPath)541             public boolean isObbMounted(String rawPath) throws RemoteException {
542                 Parcel _data = Parcel.obtain();
543                 Parcel _reply = Parcel.obtain();
544                 boolean _result;
545                 try {
546                     _data.writeInterfaceToken(DESCRIPTOR);
547                     _data.writeString(rawPath);
548                     mRemote.transact(Stub.TRANSACTION_isObbMounted, _data, _reply, 0);
549                     _reply.readException();
550                     _result = 0 != _reply.readInt();
551                 } finally {
552                     _reply.recycle();
553                     _data.recycle();
554                 }
555                 return _result;
556             }
557 
558             /**
559              * Gets the path to the mounted Opaque Binary Blob (OBB).
560              */
getMountedObbPath(String rawPath)561             public String getMountedObbPath(String rawPath) throws RemoteException {
562                 Parcel _data = Parcel.obtain();
563                 Parcel _reply = Parcel.obtain();
564                 String _result;
565                 try {
566                     _data.writeInterfaceToken(DESCRIPTOR);
567                     _data.writeString(rawPath);
568                     mRemote.transact(Stub.TRANSACTION_getMountedObbPath, _data, _reply, 0);
569                     _reply.readException();
570                     _result = _reply.readString();
571                 } finally {
572                     _reply.recycle();
573                     _data.recycle();
574                 }
575                 return _result;
576             }
577 
578             /**
579              * Returns whether the external storage is emulated.
580              */
isExternalStorageEmulated()581             public boolean isExternalStorageEmulated() throws RemoteException {
582                 Parcel _data = Parcel.obtain();
583                 Parcel _reply = Parcel.obtain();
584                 boolean _result;
585                 try {
586                     _data.writeInterfaceToken(DESCRIPTOR);
587                     mRemote.transact(Stub.TRANSACTION_isExternalStorageEmulated, _data, _reply, 0);
588                     _reply.readException();
589                     _result = 0 != _reply.readInt();
590                 } finally {
591                     _reply.recycle();
592                     _data.recycle();
593                 }
594                 return _result;
595             }
596 
getEncryptionState()597             public int getEncryptionState() throws RemoteException {
598                 Parcel _data = Parcel.obtain();
599                 Parcel _reply = Parcel.obtain();
600                 int _result;
601                 try {
602                     _data.writeInterfaceToken(DESCRIPTOR);
603                     mRemote.transact(Stub.TRANSACTION_getEncryptionState, _data, _reply, 0);
604                     _reply.readException();
605                     _result = _reply.readInt();
606                 } finally {
607                     _reply.recycle();
608                     _data.recycle();
609                 }
610                 return _result;
611             }
612 
decryptStorage(String password)613             public int decryptStorage(String password) throws RemoteException {
614                 Parcel _data = Parcel.obtain();
615                 Parcel _reply = Parcel.obtain();
616                 int _result;
617                 try {
618                     _data.writeInterfaceToken(DESCRIPTOR);
619                     _data.writeString(password);
620                     mRemote.transact(Stub.TRANSACTION_decryptStorage, _data, _reply, 0);
621                     _reply.readException();
622                     _result = _reply.readInt();
623                 } finally {
624                     _reply.recycle();
625                     _data.recycle();
626                 }
627                 return _result;
628             }
629 
encryptStorage(int type, String password)630             public int encryptStorage(int type, String password) throws RemoteException {
631                 Parcel _data = Parcel.obtain();
632                 Parcel _reply = Parcel.obtain();
633                 int _result;
634                 try {
635                     _data.writeInterfaceToken(DESCRIPTOR);
636                     _data.writeInt(type);
637                     _data.writeString(password);
638                     mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0);
639                     _reply.readException();
640                     _result = _reply.readInt();
641                 } finally {
642                     _reply.recycle();
643                     _data.recycle();
644                 }
645                 return _result;
646             }
647 
changeEncryptionPassword(int type, String password)648             public int changeEncryptionPassword(int type, String password) throws RemoteException {
649                 Parcel _data = Parcel.obtain();
650                 Parcel _reply = Parcel.obtain();
651                 int _result;
652                 try {
653                     _data.writeInterfaceToken(DESCRIPTOR);
654                     _data.writeInt(type);
655                     _data.writeString(password);
656                     mRemote.transact(Stub.TRANSACTION_changeEncryptionPassword, _data, _reply, 0);
657                     _reply.readException();
658                     _result = _reply.readInt();
659                 } finally {
660                     _reply.recycle();
661                     _data.recycle();
662                 }
663                 return _result;
664             }
665 
666             @Override
verifyEncryptionPassword(String password)667             public int verifyEncryptionPassword(String password) throws RemoteException {
668                 Parcel _data = Parcel.obtain();
669                 Parcel _reply = Parcel.obtain();
670                 int _result;
671                 try {
672                     _data.writeInterfaceToken(DESCRIPTOR);
673                     _data.writeString(password);
674                     mRemote.transact(Stub.TRANSACTION_verifyEncryptionPassword, _data, _reply, 0);
675                     _reply.readException();
676                     _result = _reply.readInt();
677                 } finally {
678                     _reply.recycle();
679                     _data.recycle();
680                 }
681                 return _result;
682             }
683 
getPasswordType()684             public int getPasswordType() throws RemoteException {
685                 Parcel _data = Parcel.obtain();
686                 Parcel _reply = Parcel.obtain();
687                 int _result;
688                 try {
689                     _data.writeInterfaceToken(DESCRIPTOR);
690                     mRemote.transact(Stub.TRANSACTION_getPasswordType, _data, _reply, 0);
691                     _reply.readException();
692                     _result = _reply.readInt();
693                 } finally {
694                     _reply.recycle();
695                     _data.recycle();
696                 }
697                 return _result;
698             }
699 
getPassword()700             public String getPassword() throws RemoteException {
701                 Parcel _data = Parcel.obtain();
702                 Parcel _reply = Parcel.obtain();
703                 String _result;
704                 try {
705                     _data.writeInterfaceToken(DESCRIPTOR);
706                     mRemote.transact(Stub.TRANSACTION_getPassword, _data, _reply, 0);
707                     _reply.readException();
708                     _result = _reply.readString();
709                 } finally {
710                     _reply.recycle();
711                     _data.recycle();
712                 }
713                 return _result;
714             }
715 
clearPassword()716             public void clearPassword() throws RemoteException {
717                 Parcel _data = Parcel.obtain();
718                 Parcel _reply = Parcel.obtain();
719                 try {
720                     _data.writeInterfaceToken(DESCRIPTOR);
721                     mRemote.transact(Stub.TRANSACTION_clearPassword, _data, _reply, IBinder.FLAG_ONEWAY);
722                     _reply.readException();
723                 } finally {
724                     _reply.recycle();
725                     _data.recycle();
726                 }
727             }
728 
setField(String field, String data)729             public void setField(String field, String data) throws RemoteException {
730                 Parcel _data = Parcel.obtain();
731                 Parcel _reply = Parcel.obtain();
732                 try {
733                     _data.writeInterfaceToken(DESCRIPTOR);
734                     _data.writeString(field);
735                     _data.writeString(data);
736                     mRemote.transact(Stub.TRANSACTION_setField, _data, _reply, IBinder.FLAG_ONEWAY);
737                     _reply.readException();
738                 } finally {
739                     _reply.recycle();
740                     _data.recycle();
741                 }
742             }
743 
getField(String field)744             public String getField(String field) throws RemoteException {
745                 Parcel _data = Parcel.obtain();
746                 Parcel _reply = Parcel.obtain();
747                 String _result;
748                 try {
749                     _data.writeInterfaceToken(DESCRIPTOR);
750                     _data.writeString(field);
751                     mRemote.transact(Stub.TRANSACTION_getField, _data, _reply, 0);
752                     _reply.readException();
753                     _result = _reply.readString();
754                 } finally {
755                     _reply.recycle();
756                     _data.recycle();
757                 }
758                 return _result;
759             }
760 
getVolumeList(int uid, String packageName, int flags)761             public StorageVolume[] getVolumeList(int uid, String packageName, int flags)
762                     throws RemoteException {
763                 Parcel _data = Parcel.obtain();
764                 Parcel _reply = Parcel.obtain();
765                 StorageVolume[] _result;
766                 try {
767                     _data.writeInterfaceToken(DESCRIPTOR);
768                     _data.writeInt(uid);
769                     _data.writeString(packageName);
770                     _data.writeInt(flags);
771                     mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0);
772                     _reply.readException();
773                     _result = _reply.createTypedArray(StorageVolume.CREATOR);
774                 } finally {
775                     _reply.recycle();
776                     _data.recycle();
777                 }
778                 return _result;
779             }
780 
781             /*
782              * Returns the filesystem path of a mounted secure container.
783              */
getSecureContainerFilesystemPath(String id)784             public String getSecureContainerFilesystemPath(String id) throws RemoteException {
785                 Parcel _data = Parcel.obtain();
786                 Parcel _reply = Parcel.obtain();
787                 String _result;
788                 try {
789                     _data.writeInterfaceToken(DESCRIPTOR);
790                     _data.writeString(id);
791                     mRemote.transact(Stub.TRANSACTION_getSecureContainerFilesystemPath, _data, _reply, 0);
792                     _reply.readException();
793                     _result = _reply.readString();
794                 } finally {
795                     _reply.recycle();
796                     _data.recycle();
797                 }
798                 return _result;
799             }
800 
801             /**
802              * Fix permissions in a container which has just been created and
803              * populated. Returns an int consistent with MountServiceResultCode
804              */
fixPermissionsSecureContainer(String id, int gid, String filename)805             public int fixPermissionsSecureContainer(String id, int gid, String filename)
806                     throws RemoteException {
807                 Parcel _data = Parcel.obtain();
808                 Parcel _reply = Parcel.obtain();
809                 int _result;
810                 try {
811                     _data.writeInterfaceToken(DESCRIPTOR);
812                     _data.writeString(id);
813                     _data.writeInt(gid);
814                     _data.writeString(filename);
815                     mRemote.transact(Stub.TRANSACTION_fixPermissionsSecureContainer, _data, _reply, 0);
816                     _reply.readException();
817                     _result = _reply.readInt();
818                 } finally {
819                     _reply.recycle();
820                     _data.recycle();
821                 }
822                 return _result;
823             }
824 
825             @Override
mkdirs(String callingPkg, String path)826             public int mkdirs(String callingPkg, String path) throws RemoteException {
827                 Parcel _data = Parcel.obtain();
828                 Parcel _reply = Parcel.obtain();
829                 int _result;
830                 try {
831                     _data.writeInterfaceToken(DESCRIPTOR);
832                     _data.writeString(callingPkg);
833                     _data.writeString(path);
834                     mRemote.transact(Stub.TRANSACTION_mkdirs, _data, _reply, 0);
835                     _reply.readException();
836                     _result = _reply.readInt();
837                 } finally {
838                     _reply.recycle();
839                     _data.recycle();
840                 }
841                 return _result;
842             }
843 
844             @Override
resizeSecureContainer(String id, int sizeMb, String key)845             public int resizeSecureContainer(String id, int sizeMb, String key)
846                     throws RemoteException {
847                 Parcel _data = Parcel.obtain();
848                 Parcel _reply = Parcel.obtain();
849                 int _result;
850                 try {
851                     _data.writeInterfaceToken(DESCRIPTOR);
852                     _data.writeString(id);
853                     _data.writeInt(sizeMb);
854                     _data.writeString(key);
855                     mRemote.transact(Stub.TRANSACTION_resizeSecureContainer, _data, _reply, 0);
856                     _reply.readException();
857                     _result = _reply.readInt();
858                 } finally {
859                     _reply.recycle();
860                     _data.recycle();
861                 }
862                 return _result;
863             }
864 
865             @Override
lastMaintenance()866             public long lastMaintenance() throws RemoteException {
867                 Parcel _data = Parcel.obtain();
868                 Parcel _reply = Parcel.obtain();
869                 long _result;
870                 try {
871                     _data.writeInterfaceToken(DESCRIPTOR);
872                     mRemote.transact(Stub.TRANSACTION_lastMaintenance, _data, _reply, 0);
873                     _reply.readException();
874                     _result = _reply.readLong();
875                 } finally {
876                     _reply.recycle();
877                     _data.recycle();
878                 }
879                 return _result;
880             }
881 
882             @Override
runMaintenance()883             public void runMaintenance() throws RemoteException {
884                 Parcel _data = Parcel.obtain();
885                 Parcel _reply = Parcel.obtain();
886                 try {
887                     _data.writeInterfaceToken(DESCRIPTOR);
888                     mRemote.transact(Stub.TRANSACTION_runMaintenance, _data, _reply, 0);
889                     _reply.readException();
890                 } finally {
891                     _reply.recycle();
892                     _data.recycle();
893                 }
894                 return;
895             }
896 
897             @Override
waitForAsecScan()898             public void waitForAsecScan() throws RemoteException {
899                 Parcel _data = Parcel.obtain();
900                 Parcel _reply = Parcel.obtain();
901                 try {
902                     _data.writeInterfaceToken(DESCRIPTOR);
903                     mRemote.transact(Stub.TRANSACTION_waitForAsecScan, _data, _reply, 0);
904                     _reply.readException();
905                 } finally {
906                     _reply.recycle();
907                     _data.recycle();
908                 }
909                 return;
910             }
911 
912             @Override
getDisks()913             public DiskInfo[] getDisks() throws RemoteException {
914                 Parcel _data = Parcel.obtain();
915                 Parcel _reply = Parcel.obtain();
916                 DiskInfo[] _result;
917                 try {
918                     _data.writeInterfaceToken(DESCRIPTOR);
919                     mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0);
920                     _reply.readException();
921                     _result = _reply.createTypedArray(DiskInfo.CREATOR);
922                 } finally {
923                     _reply.recycle();
924                     _data.recycle();
925                 }
926                 return _result;
927             }
928 
929             @Override
getVolumes(int _flags)930             public VolumeInfo[] getVolumes(int _flags) throws RemoteException {
931                 Parcel _data = Parcel.obtain();
932                 Parcel _reply = Parcel.obtain();
933                 VolumeInfo[] _result;
934                 try {
935                     _data.writeInterfaceToken(DESCRIPTOR);
936                     _data.writeInt(_flags);
937                     mRemote.transact(Stub.TRANSACTION_getVolumes, _data, _reply, 0);
938                     _reply.readException();
939                     _result = _reply.createTypedArray(VolumeInfo.CREATOR);
940                 } finally {
941                     _reply.recycle();
942                     _data.recycle();
943                 }
944                 return _result;
945             }
946 
947             @Override
getVolumeRecords(int _flags)948             public VolumeRecord[] getVolumeRecords(int _flags) throws RemoteException {
949                 Parcel _data = Parcel.obtain();
950                 Parcel _reply = Parcel.obtain();
951                 VolumeRecord[] _result;
952                 try {
953                     _data.writeInterfaceToken(DESCRIPTOR);
954                     _data.writeInt(_flags);
955                     mRemote.transact(Stub.TRANSACTION_getVolumeRecords, _data, _reply, 0);
956                     _reply.readException();
957                     _result = _reply.createTypedArray(VolumeRecord.CREATOR);
958                 } finally {
959                     _reply.recycle();
960                     _data.recycle();
961                 }
962                 return _result;
963             }
964 
965             @Override
mount(String volId)966             public void mount(String volId) throws RemoteException {
967                 Parcel _data = Parcel.obtain();
968                 Parcel _reply = Parcel.obtain();
969                 try {
970                     _data.writeInterfaceToken(DESCRIPTOR);
971                     _data.writeString(volId);
972                     mRemote.transact(Stub.TRANSACTION_mount, _data, _reply, 0);
973                     _reply.readException();
974                 } finally {
975                     _reply.recycle();
976                     _data.recycle();
977                 }
978             }
979 
980             @Override
unmount(String volId)981             public void unmount(String volId) throws RemoteException {
982                 Parcel _data = Parcel.obtain();
983                 Parcel _reply = Parcel.obtain();
984                 try {
985                     _data.writeInterfaceToken(DESCRIPTOR);
986                     _data.writeString(volId);
987                     mRemote.transact(Stub.TRANSACTION_unmount, _data, _reply, 0);
988                     _reply.readException();
989                 } finally {
990                     _reply.recycle();
991                     _data.recycle();
992                 }
993             }
994 
995             @Override
format(String volId)996             public void format(String volId) throws RemoteException {
997                 Parcel _data = Parcel.obtain();
998                 Parcel _reply = Parcel.obtain();
999                 try {
1000                     _data.writeInterfaceToken(DESCRIPTOR);
1001                     _data.writeString(volId);
1002                     mRemote.transact(Stub.TRANSACTION_format, _data, _reply, 0);
1003                     _reply.readException();
1004                 } finally {
1005                     _reply.recycle();
1006                     _data.recycle();
1007                 }
1008             }
1009 
1010             @Override
benchmark(String volId)1011             public long benchmark(String volId) throws RemoteException {
1012                 Parcel _data = Parcel.obtain();
1013                 Parcel _reply = Parcel.obtain();
1014                 try {
1015                     _data.writeInterfaceToken(DESCRIPTOR);
1016                     _data.writeString(volId);
1017                     mRemote.transact(Stub.TRANSACTION_benchmark, _data, _reply, 0);
1018                     _reply.readException();
1019                     return _reply.readLong();
1020                 } finally {
1021                     _reply.recycle();
1022                     _data.recycle();
1023                 }
1024             }
1025 
1026             @Override
partitionPublic(String diskId)1027             public void partitionPublic(String diskId) throws RemoteException {
1028                 Parcel _data = Parcel.obtain();
1029                 Parcel _reply = Parcel.obtain();
1030                 try {
1031                     _data.writeInterfaceToken(DESCRIPTOR);
1032                     _data.writeString(diskId);
1033                     mRemote.transact(Stub.TRANSACTION_partitionPublic, _data, _reply, 0);
1034                     _reply.readException();
1035                 } finally {
1036                     _reply.recycle();
1037                     _data.recycle();
1038                 }
1039             }
1040 
1041             @Override
partitionPrivate(String diskId)1042             public void partitionPrivate(String diskId) throws RemoteException {
1043                 Parcel _data = Parcel.obtain();
1044                 Parcel _reply = Parcel.obtain();
1045                 try {
1046                     _data.writeInterfaceToken(DESCRIPTOR);
1047                     _data.writeString(diskId);
1048                     mRemote.transact(Stub.TRANSACTION_partitionPrivate, _data, _reply, 0);
1049                     _reply.readException();
1050                 } finally {
1051                     _reply.recycle();
1052                     _data.recycle();
1053                 }
1054             }
1055 
1056             @Override
partitionMixed(String diskId, int ratio)1057             public void partitionMixed(String diskId, int ratio) throws RemoteException {
1058                 Parcel _data = Parcel.obtain();
1059                 Parcel _reply = Parcel.obtain();
1060                 try {
1061                     _data.writeInterfaceToken(DESCRIPTOR);
1062                     _data.writeString(diskId);
1063                     _data.writeInt(ratio);
1064                     mRemote.transact(Stub.TRANSACTION_partitionMixed, _data, _reply, 0);
1065                     _reply.readException();
1066                 } finally {
1067                     _reply.recycle();
1068                     _data.recycle();
1069                 }
1070             }
1071 
1072             @Override
setVolumeNickname(String fsUuid, String nickname)1073             public void setVolumeNickname(String fsUuid, String nickname) throws RemoteException {
1074                 Parcel _data = Parcel.obtain();
1075                 Parcel _reply = Parcel.obtain();
1076                 try {
1077                     _data.writeInterfaceToken(DESCRIPTOR);
1078                     _data.writeString(fsUuid);
1079                     _data.writeString(nickname);
1080                     mRemote.transact(Stub.TRANSACTION_setVolumeNickname, _data, _reply, 0);
1081                     _reply.readException();
1082                 } finally {
1083                     _reply.recycle();
1084                     _data.recycle();
1085                 }
1086             }
1087 
1088             @Override
setVolumeUserFlags(String fsUuid, int flags, int mask)1089             public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException {
1090                 Parcel _data = Parcel.obtain();
1091                 Parcel _reply = Parcel.obtain();
1092                 try {
1093                     _data.writeInterfaceToken(DESCRIPTOR);
1094                     _data.writeString(fsUuid);
1095                     _data.writeInt(flags);
1096                     _data.writeInt(mask);
1097                     mRemote.transact(Stub.TRANSACTION_setVolumeUserFlags, _data, _reply, 0);
1098                     _reply.readException();
1099                 } finally {
1100                     _reply.recycle();
1101                     _data.recycle();
1102                 }
1103             }
1104 
1105             @Override
forgetVolume(String fsUuid)1106             public void forgetVolume(String fsUuid) throws RemoteException {
1107                 Parcel _data = Parcel.obtain();
1108                 Parcel _reply = Parcel.obtain();
1109                 try {
1110                     _data.writeInterfaceToken(DESCRIPTOR);
1111                     _data.writeString(fsUuid);
1112                     mRemote.transact(Stub.TRANSACTION_forgetVolume, _data, _reply, 0);
1113                     _reply.readException();
1114                 } finally {
1115                     _reply.recycle();
1116                     _data.recycle();
1117                 }
1118             }
1119 
1120             @Override
forgetAllVolumes()1121             public void forgetAllVolumes() throws RemoteException {
1122                 Parcel _data = Parcel.obtain();
1123                 Parcel _reply = Parcel.obtain();
1124                 try {
1125                     _data.writeInterfaceToken(DESCRIPTOR);
1126                     mRemote.transact(Stub.TRANSACTION_forgetAllVolumes, _data, _reply, 0);
1127                     _reply.readException();
1128                 } finally {
1129                     _reply.recycle();
1130                     _data.recycle();
1131                 }
1132             }
1133 
1134             @Override
setDebugFlags(int _flags, int _mask)1135             public void setDebugFlags(int _flags, int _mask) throws RemoteException {
1136                 Parcel _data = Parcel.obtain();
1137                 Parcel _reply = Parcel.obtain();
1138                 try {
1139                     _data.writeInterfaceToken(DESCRIPTOR);
1140                     _data.writeInt(_flags);
1141                     _data.writeInt(_mask);
1142                     mRemote.transact(Stub.TRANSACTION_setDebugFlags, _data, _reply, 0);
1143                     _reply.readException();
1144                 } finally {
1145                     _reply.recycle();
1146                     _data.recycle();
1147                 }
1148             }
1149 
1150             @Override
getPrimaryStorageUuid()1151             public String getPrimaryStorageUuid() throws RemoteException {
1152                 Parcel _data = Parcel.obtain();
1153                 Parcel _reply = Parcel.obtain();
1154                 String _result;
1155                 try {
1156                     _data.writeInterfaceToken(DESCRIPTOR);
1157                     mRemote.transact(Stub.TRANSACTION_getPrimaryStorageUuid, _data, _reply, 0);
1158                     _reply.readException();
1159                     _result = _reply.readString();
1160                 } finally {
1161                     _reply.recycle();
1162                     _data.recycle();
1163                 }
1164                 return _result;
1165             }
1166 
1167             @Override
setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback)1168             public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback)
1169                     throws RemoteException {
1170                 Parcel _data = Parcel.obtain();
1171                 Parcel _reply = Parcel.obtain();
1172                 try {
1173                     _data.writeInterfaceToken(DESCRIPTOR);
1174                     _data.writeString(volumeUuid);
1175                     _data.writeStrongBinder((callback != null ? callback.asBinder() : null));
1176                     mRemote.transact(Stub.TRANSACTION_setPrimaryStorageUuid, _data, _reply, 0);
1177                     _reply.readException();
1178                 } finally {
1179                     _reply.recycle();
1180                     _data.recycle();
1181                 }
1182             }
1183 
1184             @Override
createNewUserDir(int userHandle, String path)1185             public void createNewUserDir(int userHandle, String path) throws RemoteException {
1186                 Parcel _data = Parcel.obtain();
1187                 Parcel _reply = Parcel.obtain();
1188                 try {
1189                     _data.writeInterfaceToken(DESCRIPTOR);
1190                     _data.writeInt(userHandle);
1191                     _data.writeString(path);
1192                     mRemote.transact(Stub.TRANSACTION_createNewUserDir, _data, _reply, 0);
1193                     _reply.readException();
1194                 } finally {
1195                     _reply.recycle();
1196                     _data.recycle();
1197                 }
1198             }
1199 
1200             @Override
deleteUserKey(int userHandle)1201             public void deleteUserKey(int userHandle) throws RemoteException {
1202                 Parcel _data = Parcel.obtain();
1203                 Parcel _reply = Parcel.obtain();
1204                 try {
1205                     _data.writeInterfaceToken(DESCRIPTOR);
1206                     _data.writeInt(userHandle);
1207                     mRemote.transact(Stub.TRANSACTION_deleteUserKey, _data, _reply, 0);
1208                     _reply.readException();
1209                 } finally {
1210                     _reply.recycle();
1211                     _data.recycle();
1212                 }
1213             }
1214         }
1215 
1216         private static final String DESCRIPTOR = "IMountService";
1217 
1218         static final int TRANSACTION_registerListener = IBinder.FIRST_CALL_TRANSACTION + 0;
1219 
1220         static final int TRANSACTION_unregisterListener = IBinder.FIRST_CALL_TRANSACTION + 1;
1221 
1222         static final int TRANSACTION_isUsbMassStorageConnected = IBinder.FIRST_CALL_TRANSACTION + 2;
1223 
1224         static final int TRANSACTION_setUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 3;
1225 
1226         static final int TRANSACTION_isUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 4;
1227 
1228         static final int TRANSACTION_mountVolume = IBinder.FIRST_CALL_TRANSACTION + 5;
1229 
1230         static final int TRANSACTION_unmountVolume = IBinder.FIRST_CALL_TRANSACTION + 6;
1231 
1232         static final int TRANSACTION_formatVolume = IBinder.FIRST_CALL_TRANSACTION + 7;
1233 
1234         static final int TRANSACTION_getStorageUsers = IBinder.FIRST_CALL_TRANSACTION + 8;
1235 
1236         static final int TRANSACTION_getVolumeState = IBinder.FIRST_CALL_TRANSACTION + 9;
1237 
1238         static final int TRANSACTION_createSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 10;
1239 
1240         static final int TRANSACTION_finalizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 11;
1241 
1242         static final int TRANSACTION_destroySecureContainer = IBinder.FIRST_CALL_TRANSACTION + 12;
1243 
1244         static final int TRANSACTION_mountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 13;
1245 
1246         static final int TRANSACTION_unmountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 14;
1247 
1248         static final int TRANSACTION_isSecureContainerMounted = IBinder.FIRST_CALL_TRANSACTION + 15;
1249 
1250         static final int TRANSACTION_renameSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 16;
1251 
1252         static final int TRANSACTION_getSecureContainerPath = IBinder.FIRST_CALL_TRANSACTION + 17;
1253 
1254         static final int TRANSACTION_getSecureContainerList = IBinder.FIRST_CALL_TRANSACTION + 18;
1255 
1256         static final int TRANSACTION_shutdown = IBinder.FIRST_CALL_TRANSACTION + 19;
1257 
1258         static final int TRANSACTION_finishMediaUpdate = IBinder.FIRST_CALL_TRANSACTION + 20;
1259 
1260         static final int TRANSACTION_mountObb = IBinder.FIRST_CALL_TRANSACTION + 21;
1261 
1262         static final int TRANSACTION_unmountObb = IBinder.FIRST_CALL_TRANSACTION + 22;
1263 
1264         static final int TRANSACTION_isObbMounted = IBinder.FIRST_CALL_TRANSACTION + 23;
1265 
1266         static final int TRANSACTION_getMountedObbPath = IBinder.FIRST_CALL_TRANSACTION + 24;
1267 
1268         static final int TRANSACTION_isExternalStorageEmulated = IBinder.FIRST_CALL_TRANSACTION + 25;
1269 
1270         static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26;
1271 
1272         static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27;
1273 
1274         static final int TRANSACTION_changeEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 28;
1275 
1276         static final int TRANSACTION_getVolumeList = IBinder.FIRST_CALL_TRANSACTION + 29;
1277 
1278         static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30;
1279 
1280         static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31;
1281 
1282         static final int TRANSACTION_verifyEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 32;
1283 
1284         static final int TRANSACTION_fixPermissionsSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 33;
1285 
1286         static final int TRANSACTION_mkdirs = IBinder.FIRST_CALL_TRANSACTION + 34;
1287 
1288         static final int TRANSACTION_getPasswordType = IBinder.FIRST_CALL_TRANSACTION + 35;
1289 
1290         static final int TRANSACTION_getPassword = IBinder.FIRST_CALL_TRANSACTION + 36;
1291 
1292         static final int TRANSACTION_clearPassword = IBinder.FIRST_CALL_TRANSACTION + 37;
1293 
1294         static final int TRANSACTION_setField = IBinder.FIRST_CALL_TRANSACTION + 38;
1295 
1296         static final int TRANSACTION_getField = IBinder.FIRST_CALL_TRANSACTION + 39;
1297 
1298         static final int TRANSACTION_resizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 40;
1299 
1300         static final int TRANSACTION_lastMaintenance = IBinder.FIRST_CALL_TRANSACTION + 41;
1301 
1302         static final int TRANSACTION_runMaintenance = IBinder.FIRST_CALL_TRANSACTION + 42;
1303 
1304         static final int TRANSACTION_waitForAsecScan = IBinder.FIRST_CALL_TRANSACTION + 43;
1305 
1306         static final int TRANSACTION_getDisks = IBinder.FIRST_CALL_TRANSACTION + 44;
1307         static final int TRANSACTION_getVolumes = IBinder.FIRST_CALL_TRANSACTION + 45;
1308         static final int TRANSACTION_getVolumeRecords = IBinder.FIRST_CALL_TRANSACTION + 46;
1309 
1310         static final int TRANSACTION_mount = IBinder.FIRST_CALL_TRANSACTION + 47;
1311         static final int TRANSACTION_unmount = IBinder.FIRST_CALL_TRANSACTION + 48;
1312         static final int TRANSACTION_format = IBinder.FIRST_CALL_TRANSACTION + 49;
1313 
1314         static final int TRANSACTION_partitionPublic = IBinder.FIRST_CALL_TRANSACTION + 50;
1315         static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 51;
1316         static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 52;
1317 
1318         static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 53;
1319         static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 54;
1320         static final int TRANSACTION_forgetVolume = IBinder.FIRST_CALL_TRANSACTION + 55;
1321         static final int TRANSACTION_forgetAllVolumes = IBinder.FIRST_CALL_TRANSACTION + 56;
1322 
1323         static final int TRANSACTION_getPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 57;
1324         static final int TRANSACTION_setPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 58;
1325 
1326         static final int TRANSACTION_benchmark = IBinder.FIRST_CALL_TRANSACTION + 59;
1327         static final int TRANSACTION_setDebugFlags = IBinder.FIRST_CALL_TRANSACTION + 60;
1328 
1329         static final int TRANSACTION_createNewUserDir = IBinder.FIRST_CALL_TRANSACTION + 62;
1330         static final int TRANSACTION_deleteUserKey = IBinder.FIRST_CALL_TRANSACTION + 63;
1331 
1332         /**
1333          * Cast an IBinder object into an IMountService interface, generating a
1334          * proxy if needed.
1335          */
asInterface(IBinder obj)1336         public static IMountService asInterface(IBinder obj) {
1337             if (obj == null) {
1338                 return null;
1339             }
1340             IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
1341             if (iin != null && iin instanceof IMountService) {
1342                 return (IMountService) iin;
1343             }
1344             return new IMountService.Stub.Proxy(obj);
1345         }
1346 
1347         /** Construct the stub at attach it to the interface. */
Stub()1348         public Stub() {
1349             attachInterface(this, DESCRIPTOR);
1350         }
1351 
asBinder()1352         public IBinder asBinder() {
1353             return this;
1354         }
1355 
1356         @Override
onTransact(int code, Parcel data, Parcel reply, int flags)1357         public boolean onTransact(int code, Parcel data, Parcel reply,
1358                 int flags) throws RemoteException {
1359             switch (code) {
1360                 case INTERFACE_TRANSACTION: {
1361                     reply.writeString(DESCRIPTOR);
1362                     return true;
1363                 }
1364                 case TRANSACTION_registerListener: {
1365                     data.enforceInterface(DESCRIPTOR);
1366                     IMountServiceListener listener;
1367                     listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder());
1368                     registerListener(listener);
1369                     reply.writeNoException();
1370                     return true;
1371                 }
1372                 case TRANSACTION_unregisterListener: {
1373                     data.enforceInterface(DESCRIPTOR);
1374                     IMountServiceListener listener;
1375                     listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder());
1376                     unregisterListener(listener);
1377                     reply.writeNoException();
1378                     return true;
1379                 }
1380                 case TRANSACTION_isUsbMassStorageConnected: {
1381                     data.enforceInterface(DESCRIPTOR);
1382                     boolean result = isUsbMassStorageConnected();
1383                     reply.writeNoException();
1384                     reply.writeInt((result ? 1 : 0));
1385                     return true;
1386                 }
1387                 case TRANSACTION_setUsbMassStorageEnabled: {
1388                     data.enforceInterface(DESCRIPTOR);
1389                     boolean enable;
1390                     enable = 0 != data.readInt();
1391                     setUsbMassStorageEnabled(enable);
1392                     reply.writeNoException();
1393                     return true;
1394                 }
1395                 case TRANSACTION_isUsbMassStorageEnabled: {
1396                     data.enforceInterface(DESCRIPTOR);
1397                     boolean result = isUsbMassStorageEnabled();
1398                     reply.writeNoException();
1399                     reply.writeInt((result ? 1 : 0));
1400                     return true;
1401                 }
1402                 case TRANSACTION_mountVolume: {
1403                     data.enforceInterface(DESCRIPTOR);
1404                     String mountPoint;
1405                     mountPoint = data.readString();
1406                     int resultCode = mountVolume(mountPoint);
1407                     reply.writeNoException();
1408                     reply.writeInt(resultCode);
1409                     return true;
1410                 }
1411                 case TRANSACTION_unmountVolume: {
1412                     data.enforceInterface(DESCRIPTOR);
1413                     String mountPoint;
1414                     mountPoint = data.readString();
1415                     boolean force = 0 != data.readInt();
1416                     boolean removeEncrypt = 0 != data.readInt();
1417                     unmountVolume(mountPoint, force, removeEncrypt);
1418                     reply.writeNoException();
1419                     return true;
1420                 }
1421                 case TRANSACTION_formatVolume: {
1422                     data.enforceInterface(DESCRIPTOR);
1423                     String mountPoint;
1424                     mountPoint = data.readString();
1425                     int result = formatVolume(mountPoint);
1426                     reply.writeNoException();
1427                     reply.writeInt(result);
1428                     return true;
1429                 }
1430                 case TRANSACTION_getStorageUsers: {
1431                     data.enforceInterface(DESCRIPTOR);
1432                     String path;
1433                     path = data.readString();
1434                     int[] pids = getStorageUsers(path);
1435                     reply.writeNoException();
1436                     reply.writeIntArray(pids);
1437                     return true;
1438                 }
1439                 case TRANSACTION_getVolumeState: {
1440                     data.enforceInterface(DESCRIPTOR);
1441                     String mountPoint;
1442                     mountPoint = data.readString();
1443                     String state = getVolumeState(mountPoint);
1444                     reply.writeNoException();
1445                     reply.writeString(state);
1446                     return true;
1447                 }
1448                 case TRANSACTION_createSecureContainer: {
1449                     data.enforceInterface(DESCRIPTOR);
1450                     String id;
1451                     id = data.readString();
1452                     int sizeMb;
1453                     sizeMb = data.readInt();
1454                     String fstype;
1455                     fstype = data.readString();
1456                     String key;
1457                     key = data.readString();
1458                     int ownerUid;
1459                     ownerUid = data.readInt();
1460                     boolean external;
1461                     external = 0 != data.readInt();
1462                     int resultCode = createSecureContainer(id, sizeMb, fstype, key, ownerUid,
1463                             external);
1464                     reply.writeNoException();
1465                     reply.writeInt(resultCode);
1466                     return true;
1467                 }
1468                 case TRANSACTION_finalizeSecureContainer: {
1469                     data.enforceInterface(DESCRIPTOR);
1470                     String id;
1471                     id = data.readString();
1472                     int resultCode = finalizeSecureContainer(id);
1473                     reply.writeNoException();
1474                     reply.writeInt(resultCode);
1475                     return true;
1476                 }
1477                 case TRANSACTION_destroySecureContainer: {
1478                     data.enforceInterface(DESCRIPTOR);
1479                     String id;
1480                     id = data.readString();
1481                     boolean force;
1482                     force = 0 != data.readInt();
1483                     int resultCode = destroySecureContainer(id, force);
1484                     reply.writeNoException();
1485                     reply.writeInt(resultCode);
1486                     return true;
1487                 }
1488                 case TRANSACTION_mountSecureContainer: {
1489                     data.enforceInterface(DESCRIPTOR);
1490                     String id;
1491                     id = data.readString();
1492                     String key;
1493                     key = data.readString();
1494                     int ownerUid;
1495                     ownerUid = data.readInt();
1496                     boolean readOnly;
1497                     readOnly = data.readInt() != 0;
1498                     int resultCode = mountSecureContainer(id, key, ownerUid, readOnly);
1499                     reply.writeNoException();
1500                     reply.writeInt(resultCode);
1501                     return true;
1502                 }
1503                 case TRANSACTION_unmountSecureContainer: {
1504                     data.enforceInterface(DESCRIPTOR);
1505                     String id;
1506                     id = data.readString();
1507                     boolean force;
1508                     force = 0 != data.readInt();
1509                     int resultCode = unmountSecureContainer(id, force);
1510                     reply.writeNoException();
1511                     reply.writeInt(resultCode);
1512                     return true;
1513                 }
1514                 case TRANSACTION_isSecureContainerMounted: {
1515                     data.enforceInterface(DESCRIPTOR);
1516                     String id;
1517                     id = data.readString();
1518                     boolean status = isSecureContainerMounted(id);
1519                     reply.writeNoException();
1520                     reply.writeInt((status ? 1 : 0));
1521                     return true;
1522                 }
1523                 case TRANSACTION_renameSecureContainer: {
1524                     data.enforceInterface(DESCRIPTOR);
1525                     String oldId;
1526                     oldId = data.readString();
1527                     String newId;
1528                     newId = data.readString();
1529                     int resultCode = renameSecureContainer(oldId, newId);
1530                     reply.writeNoException();
1531                     reply.writeInt(resultCode);
1532                     return true;
1533                 }
1534                 case TRANSACTION_getSecureContainerPath: {
1535                     data.enforceInterface(DESCRIPTOR);
1536                     String id;
1537                     id = data.readString();
1538                     String path = getSecureContainerPath(id);
1539                     reply.writeNoException();
1540                     reply.writeString(path);
1541                     return true;
1542                 }
1543                 case TRANSACTION_getSecureContainerList: {
1544                     data.enforceInterface(DESCRIPTOR);
1545                     String[] ids = getSecureContainerList();
1546                     reply.writeNoException();
1547                     reply.writeStringArray(ids);
1548                     return true;
1549                 }
1550                 case TRANSACTION_shutdown: {
1551                     data.enforceInterface(DESCRIPTOR);
1552                     IMountShutdownObserver observer;
1553                     observer = IMountShutdownObserver.Stub.asInterface(data
1554                             .readStrongBinder());
1555                     shutdown(observer);
1556                     reply.writeNoException();
1557                     return true;
1558                 }
1559                 case TRANSACTION_finishMediaUpdate: {
1560                     data.enforceInterface(DESCRIPTOR);
1561                     finishMediaUpdate();
1562                     reply.writeNoException();
1563                     return true;
1564                 }
1565                 case TRANSACTION_mountObb: {
1566                     data.enforceInterface(DESCRIPTOR);
1567                     final String rawPath = data.readString();
1568                     final String canonicalPath = data.readString();
1569                     final String key = data.readString();
1570                     IObbActionListener observer;
1571                     observer = IObbActionListener.Stub.asInterface(data.readStrongBinder());
1572                     int nonce;
1573                     nonce = data.readInt();
1574                     mountObb(rawPath, canonicalPath, key, observer, nonce);
1575                     reply.writeNoException();
1576                     return true;
1577                 }
1578                 case TRANSACTION_unmountObb: {
1579                     data.enforceInterface(DESCRIPTOR);
1580                     String filename;
1581                     filename = data.readString();
1582                     boolean force;
1583                     force = 0 != data.readInt();
1584                     IObbActionListener observer;
1585                     observer = IObbActionListener.Stub.asInterface(data.readStrongBinder());
1586                     int nonce;
1587                     nonce = data.readInt();
1588                     unmountObb(filename, force, observer, nonce);
1589                     reply.writeNoException();
1590                     return true;
1591                 }
1592                 case TRANSACTION_isObbMounted: {
1593                     data.enforceInterface(DESCRIPTOR);
1594                     String filename;
1595                     filename = data.readString();
1596                     boolean status = isObbMounted(filename);
1597                     reply.writeNoException();
1598                     reply.writeInt((status ? 1 : 0));
1599                     return true;
1600                 }
1601                 case TRANSACTION_getMountedObbPath: {
1602                     data.enforceInterface(DESCRIPTOR);
1603                     String filename;
1604                     filename = data.readString();
1605                     String mountedPath = getMountedObbPath(filename);
1606                     reply.writeNoException();
1607                     reply.writeString(mountedPath);
1608                     return true;
1609                 }
1610                 case TRANSACTION_isExternalStorageEmulated: {
1611                     data.enforceInterface(DESCRIPTOR);
1612                     boolean emulated = isExternalStorageEmulated();
1613                     reply.writeNoException();
1614                     reply.writeInt(emulated ? 1 : 0);
1615                     return true;
1616                 }
1617                 case TRANSACTION_decryptStorage: {
1618                     data.enforceInterface(DESCRIPTOR);
1619                     String password = data.readString();
1620                     int result = decryptStorage(password);
1621                     reply.writeNoException();
1622                     reply.writeInt(result);
1623                     return true;
1624                 }
1625                 case TRANSACTION_encryptStorage: {
1626                     data.enforceInterface(DESCRIPTOR);
1627                     int type = data.readInt();
1628                     String password = data.readString();
1629                     int result = encryptStorage(type, password);
1630                     reply.writeNoException();
1631                     reply.writeInt(result);
1632                     return true;
1633                 }
1634                 case TRANSACTION_changeEncryptionPassword: {
1635                     data.enforceInterface(DESCRIPTOR);
1636                     int type = data.readInt();
1637                     String password = data.readString();
1638                     int result = changeEncryptionPassword(type, password);
1639                     reply.writeNoException();
1640                     reply.writeInt(result);
1641                     return true;
1642                 }
1643                 case TRANSACTION_getVolumeList: {
1644                     data.enforceInterface(DESCRIPTOR);
1645                     int uid = data.readInt();
1646                     String packageName = data.readString();
1647                     int _flags = data.readInt();
1648                     StorageVolume[] result = getVolumeList(uid, packageName, _flags);
1649                     reply.writeNoException();
1650                     reply.writeTypedArray(result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1651                     return true;
1652                 }
1653                 case TRANSACTION_getSecureContainerFilesystemPath: {
1654                     data.enforceInterface(DESCRIPTOR);
1655                     String id;
1656                     id = data.readString();
1657                     String path = getSecureContainerFilesystemPath(id);
1658                     reply.writeNoException();
1659                     reply.writeString(path);
1660                     return true;
1661                 }
1662                 case TRANSACTION_getEncryptionState: {
1663                     data.enforceInterface(DESCRIPTOR);
1664                     int result = getEncryptionState();
1665                     reply.writeNoException();
1666                     reply.writeInt(result);
1667                     return true;
1668                 }
1669                 case TRANSACTION_fixPermissionsSecureContainer: {
1670                     data.enforceInterface(DESCRIPTOR);
1671                     String id;
1672                     id = data.readString();
1673                     int gid;
1674                     gid = data.readInt();
1675                     String filename;
1676                     filename = data.readString();
1677                     int resultCode = fixPermissionsSecureContainer(id, gid, filename);
1678                     reply.writeNoException();
1679                     reply.writeInt(resultCode);
1680                     return true;
1681                 }
1682                 case TRANSACTION_mkdirs: {
1683                     data.enforceInterface(DESCRIPTOR);
1684                     String callingPkg = data.readString();
1685                     String path = data.readString();
1686                     int result = mkdirs(callingPkg, path);
1687                     reply.writeNoException();
1688                     reply.writeInt(result);
1689                     return true;
1690                 }
1691                 case TRANSACTION_getPasswordType: {
1692                     data.enforceInterface(DESCRIPTOR);
1693                     int result = getPasswordType();
1694                     reply.writeNoException();
1695                     reply.writeInt(result);
1696                     return true;
1697                 }
1698                 case TRANSACTION_getPassword: {
1699                     data.enforceInterface(DESCRIPTOR);
1700                     String result = getPassword();
1701                     reply.writeNoException();
1702                     reply.writeString(result);
1703                     return true;
1704                 }
1705                 case TRANSACTION_clearPassword: {
1706                     data.enforceInterface(DESCRIPTOR);
1707                     clearPassword();
1708                     reply.writeNoException();
1709                     return true;
1710                 }
1711                 case TRANSACTION_setField: {
1712                     data.enforceInterface(DESCRIPTOR);
1713                     String field = data.readString();
1714                     String contents = data.readString();
1715                     setField(field, contents);
1716                     reply.writeNoException();
1717                     return true;
1718                 }
1719                 case TRANSACTION_getField: {
1720                     data.enforceInterface(DESCRIPTOR);
1721                     String field = data.readString();
1722                     String contents = getField(field);
1723                     reply.writeNoException();
1724                     reply.writeString(contents);
1725                     return true;
1726                 }
1727                 case TRANSACTION_resizeSecureContainer: {
1728                     data.enforceInterface(DESCRIPTOR);
1729                     String id;
1730                     id = data.readString();
1731                     int sizeMb;
1732                     sizeMb = data.readInt();
1733                     String key;
1734                     key = data.readString();
1735                     int resultCode = resizeSecureContainer(id, sizeMb, key);
1736                     reply.writeNoException();
1737                     reply.writeInt(resultCode);
1738                     return true;
1739                 }
1740                 case TRANSACTION_lastMaintenance: {
1741                     data.enforceInterface(DESCRIPTOR);
1742                     long lastMaintenance = lastMaintenance();
1743                     reply.writeNoException();
1744                     reply.writeLong(lastMaintenance);
1745                     return true;
1746                 }
1747                 case TRANSACTION_runMaintenance: {
1748                     data.enforceInterface(DESCRIPTOR);
1749                     runMaintenance();
1750                     reply.writeNoException();
1751                     return true;
1752                 }
1753                 case TRANSACTION_waitForAsecScan: {
1754                     data.enforceInterface(DESCRIPTOR);
1755                     waitForAsecScan();
1756                     reply.writeNoException();
1757                     return true;
1758                 }
1759                 case TRANSACTION_getDisks: {
1760                     data.enforceInterface(DESCRIPTOR);
1761                     DiskInfo[] disks = getDisks();
1762                     reply.writeNoException();
1763                     reply.writeTypedArray(disks, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1764                     return true;
1765                 }
1766                 case TRANSACTION_getVolumes: {
1767                     data.enforceInterface(DESCRIPTOR);
1768                     int _flags = data.readInt();
1769                     VolumeInfo[] volumes = getVolumes(_flags);
1770                     reply.writeNoException();
1771                     reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1772                     return true;
1773                 }
1774                 case TRANSACTION_getVolumeRecords: {
1775                     data.enforceInterface(DESCRIPTOR);
1776                     int _flags = data.readInt();
1777                     VolumeRecord[] volumes = getVolumeRecords(_flags);
1778                     reply.writeNoException();
1779                     reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1780                     return true;
1781                 }
1782                 case TRANSACTION_mount: {
1783                     data.enforceInterface(DESCRIPTOR);
1784                     String volId = data.readString();
1785                     mount(volId);
1786                     reply.writeNoException();
1787                     return true;
1788                 }
1789                 case TRANSACTION_unmount: {
1790                     data.enforceInterface(DESCRIPTOR);
1791                     String volId = data.readString();
1792                     unmount(volId);
1793                     reply.writeNoException();
1794                     return true;
1795                 }
1796                 case TRANSACTION_format: {
1797                     data.enforceInterface(DESCRIPTOR);
1798                     String volId = data.readString();
1799                     format(volId);
1800                     reply.writeNoException();
1801                     return true;
1802                 }
1803                 case TRANSACTION_benchmark: {
1804                     data.enforceInterface(DESCRIPTOR);
1805                     String volId = data.readString();
1806                     long res = benchmark(volId);
1807                     reply.writeNoException();
1808                     reply.writeLong(res);
1809                     return true;
1810                 }
1811                 case TRANSACTION_partitionPublic: {
1812                     data.enforceInterface(DESCRIPTOR);
1813                     String diskId = data.readString();
1814                     partitionPublic(diskId);
1815                     reply.writeNoException();
1816                     return true;
1817                 }
1818                 case TRANSACTION_partitionPrivate: {
1819                     data.enforceInterface(DESCRIPTOR);
1820                     String diskId = data.readString();
1821                     partitionPrivate(diskId);
1822                     reply.writeNoException();
1823                     return true;
1824                 }
1825                 case TRANSACTION_partitionMixed: {
1826                     data.enforceInterface(DESCRIPTOR);
1827                     String diskId = data.readString();
1828                     int ratio = data.readInt();
1829                     partitionMixed(diskId, ratio);
1830                     reply.writeNoException();
1831                     return true;
1832                 }
1833                 case TRANSACTION_setVolumeNickname: {
1834                     data.enforceInterface(DESCRIPTOR);
1835                     String volId = data.readString();
1836                     String nickname = data.readString();
1837                     setVolumeNickname(volId, nickname);
1838                     reply.writeNoException();
1839                     return true;
1840                 }
1841                 case TRANSACTION_setVolumeUserFlags: {
1842                     data.enforceInterface(DESCRIPTOR);
1843                     String volId = data.readString();
1844                     int _flags = data.readInt();
1845                     int _mask = data.readInt();
1846                     setVolumeUserFlags(volId, _flags, _mask);
1847                     reply.writeNoException();
1848                     return true;
1849                 }
1850                 case TRANSACTION_forgetVolume: {
1851                     data.enforceInterface(DESCRIPTOR);
1852                     String fsUuid = data.readString();
1853                     forgetVolume(fsUuid);
1854                     reply.writeNoException();
1855                     return true;
1856                 }
1857                 case TRANSACTION_forgetAllVolumes: {
1858                     data.enforceInterface(DESCRIPTOR);
1859                     forgetAllVolumes();
1860                     reply.writeNoException();
1861                     return true;
1862                 }
1863                 case TRANSACTION_setDebugFlags: {
1864                     data.enforceInterface(DESCRIPTOR);
1865                     int _flags = data.readInt();
1866                     int _mask = data.readInt();
1867                     setDebugFlags(_flags, _mask);
1868                     reply.writeNoException();
1869                     return true;
1870                 }
1871                 case TRANSACTION_getPrimaryStorageUuid: {
1872                     data.enforceInterface(DESCRIPTOR);
1873                     String volumeUuid = getPrimaryStorageUuid();
1874                     reply.writeNoException();
1875                     reply.writeString(volumeUuid);
1876                     return true;
1877                 }
1878                 case TRANSACTION_setPrimaryStorageUuid: {
1879                     data.enforceInterface(DESCRIPTOR);
1880                     String volumeUuid = data.readString();
1881                     IPackageMoveObserver listener = IPackageMoveObserver.Stub.asInterface(
1882                             data.readStrongBinder());
1883                     setPrimaryStorageUuid(volumeUuid, listener);
1884                     reply.writeNoException();
1885                     return true;
1886                 }
1887                 case TRANSACTION_createNewUserDir: {
1888                     data.enforceInterface(DESCRIPTOR);
1889                     int userHandle = data.readInt();
1890                     String path = data.readString();
1891                     createNewUserDir(userHandle, path);
1892                     reply.writeNoException();
1893                     return true;
1894                 }
1895                 case TRANSACTION_deleteUserKey: {
1896                     data.enforceInterface(DESCRIPTOR);
1897                     int userHandle = data.readInt();
1898                     deleteUserKey(userHandle);
1899                     reply.writeNoException();
1900                     return true;
1901                 }
1902             }
1903             return super.onTransact(code, data, reply, flags);
1904         }
1905     }
1906 
1907     /*
1908      * Creates a secure container with the specified parameters. Returns an int
1909      * consistent with MountServiceResultCode
1910      */
createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid, boolean external)1911     public int createSecureContainer(String id, int sizeMb, String fstype, String key,
1912             int ownerUid, boolean external) throws RemoteException;
1913 
1914     /*
1915      * Destroy a secure container, and free up all resources associated with it.
1916      * NOTE: Ensure all references are released prior to deleting. Returns an
1917      * int consistent with MountServiceResultCode
1918      */
destroySecureContainer(String id, boolean force)1919     public int destroySecureContainer(String id, boolean force) throws RemoteException;
1920 
1921     /*
1922      * Finalize a container which has just been created and populated. After
1923      * finalization, the container is immutable. Returns an int consistent with
1924      * MountServiceResultCode
1925      */
finalizeSecureContainer(String id)1926     public int finalizeSecureContainer(String id) throws RemoteException;
1927 
1928     /**
1929      * Call into MountService by PackageManager to notify that its done
1930      * processing the media status update request.
1931      */
finishMediaUpdate()1932     public void finishMediaUpdate() throws RemoteException;
1933 
1934     /**
1935      * Format external storage given a mount point. Returns an int consistent
1936      * with MountServiceResultCode
1937      */
formatVolume(String mountPoint)1938     public int formatVolume(String mountPoint) throws RemoteException;
1939 
1940     /**
1941      * Gets the path to the mounted Opaque Binary Blob (OBB).
1942      */
getMountedObbPath(String rawPath)1943     public String getMountedObbPath(String rawPath) throws RemoteException;
1944 
1945     /**
1946      * Gets an Array of currently known secure container IDs
1947      */
getSecureContainerList()1948     public String[] getSecureContainerList() throws RemoteException;
1949 
1950     /*
1951      * Returns the filesystem path of a mounted secure container.
1952      */
getSecureContainerPath(String id)1953     public String getSecureContainerPath(String id) throws RemoteException;
1954 
1955     /**
1956      * Returns an array of pids with open files on the specified path.
1957      */
getStorageUsers(String path)1958     public int[] getStorageUsers(String path) throws RemoteException;
1959 
1960     /**
1961      * Gets the state of a volume via its mountpoint.
1962      */
getVolumeState(String mountPoint)1963     public String getVolumeState(String mountPoint) throws RemoteException;
1964 
1965     /**
1966      * Checks whether the specified Opaque Binary Blob (OBB) is mounted
1967      * somewhere.
1968      */
isObbMounted(String rawPath)1969     public boolean isObbMounted(String rawPath) throws RemoteException;
1970 
1971     /*
1972      * Returns true if the specified container is mounted
1973      */
isSecureContainerMounted(String id)1974     public boolean isSecureContainerMounted(String id) throws RemoteException;
1975 
1976     /**
1977      * Returns true if a USB mass storage host is connected
1978      */
isUsbMassStorageConnected()1979     public boolean isUsbMassStorageConnected() throws RemoteException;
1980 
1981     /**
1982      * Returns true if a USB mass storage host is enabled (media is shared)
1983      */
isUsbMassStorageEnabled()1984     public boolean isUsbMassStorageEnabled() throws RemoteException;
1985 
1986     /**
1987      * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
1988      * only allows the calling process's UID access to the contents.
1989      * MountService will call back to the supplied IObbActionListener to inform
1990      * it of the terminal state of the call.
1991      */
mountObb(String rawPath, String canonicalPath, String key, IObbActionListener token, int nonce)1992     public void mountObb(String rawPath, String canonicalPath, String key,
1993             IObbActionListener token, int nonce) throws RemoteException;
1994 
1995     /*
1996      * Mount a secure container with the specified key and owner UID. Returns an
1997      * int consistent with MountServiceResultCode
1998      */
mountSecureContainer(String id, String key, int ownerUid, boolean readOnly)1999     public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly)
2000             throws RemoteException;
2001 
2002     /**
2003      * Mount external storage at given mount point. Returns an int consistent
2004      * with MountServiceResultCode
2005      */
mountVolume(String mountPoint)2006     public int mountVolume(String mountPoint) throws RemoteException;
2007 
2008     /**
2009      * Registers an IMountServiceListener for receiving async notifications.
2010      */
registerListener(IMountServiceListener listener)2011     public void registerListener(IMountServiceListener listener) throws RemoteException;
2012 
2013     /*
2014      * Rename an unmounted secure container. Returns an int consistent with
2015      * MountServiceResultCode
2016      */
renameSecureContainer(String oldId, String newId)2017     public int renameSecureContainer(String oldId, String newId) throws RemoteException;
2018 
2019     /**
2020      * Enables / disables USB mass storage. The caller should check actual
2021      * status of enabling/disabling USB mass storage via StorageEventListener.
2022      */
setUsbMassStorageEnabled(boolean enable)2023     public void setUsbMassStorageEnabled(boolean enable) throws RemoteException;
2024 
2025     /**
2026      * Shuts down the MountService and gracefully unmounts all external media.
2027      * Invokes call back once the shutdown is complete.
2028      */
shutdown(IMountShutdownObserver observer)2029     public void shutdown(IMountShutdownObserver observer) throws RemoteException;
2030 
2031     /**
2032      * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
2033      * any program using it will be forcibly killed to unmount the image.
2034      * MountService will call back to the supplied IObbActionListener to inform
2035      * it of the terminal state of the call.
2036      */
unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce)2037     public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce)
2038             throws RemoteException;
2039 
2040     /*
2041      * Unount a secure container. Returns an int consistent with
2042      * MountServiceResultCode
2043      */
unmountSecureContainer(String id, boolean force)2044     public int unmountSecureContainer(String id, boolean force) throws RemoteException;
2045 
2046     /**
2047      * Safely unmount external storage at given mount point. The unmount is an
2048      * asynchronous operation. Applications should register StorageEventListener
2049      * for storage related status changes.
2050      * @param mountPoint the mount point
2051      * @param force whether or not to forcefully unmount it (e.g. even if programs are using this
2052      *     data currently)
2053      * @param removeEncryption whether or not encryption mapping should be removed from the volume.
2054      *     This value implies {@code force}.
2055      */
unmountVolume(String mountPoint, boolean force, boolean removeEncryption)2056     public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption)
2057             throws RemoteException;
2058 
2059     /**
2060      * Unregisters an IMountServiceListener
2061      */
unregisterListener(IMountServiceListener listener)2062     public void unregisterListener(IMountServiceListener listener) throws RemoteException;
2063 
2064     /**
2065      * Returns whether or not the external storage is emulated.
2066      */
isExternalStorageEmulated()2067     public boolean isExternalStorageEmulated() throws RemoteException;
2068 
2069     /** The volume is not encrypted. */
2070     static final int ENCRYPTION_STATE_NONE = 1;
2071     /** The volume has been encrypted succesfully. */
2072     static final int ENCRYPTION_STATE_OK = 0;
2073     /** The volume is in a bad state.*/
2074     static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1;
2075     /** Encryption is incomplete */
2076     static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2;
2077     /** Encryption is incomplete and irrecoverable */
2078     static final int ENCRYPTION_STATE_ERROR_INCONSISTENT = -3;
2079     /** Underlying data is corrupt */
2080     static final int ENCRYPTION_STATE_ERROR_CORRUPT = -4;
2081 
2082     /**
2083      * Determines the encryption state of the volume.
2084      * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values.
2085      */
getEncryptionState()2086     public int getEncryptionState() throws RemoteException;
2087 
2088     /**
2089      * Decrypts any encrypted volumes.
2090      */
decryptStorage(String password)2091     public int decryptStorage(String password) throws RemoteException;
2092 
2093     /**
2094      * Encrypts storage.
2095      */
encryptStorage(int type, String password)2096     public int encryptStorage(int type, String password) throws RemoteException;
2097 
2098     /**
2099      * Changes the encryption password.
2100      */
changeEncryptionPassword(int type, String password)2101     public int changeEncryptionPassword(int type, String password)
2102         throws RemoteException;
2103 
2104     /**
2105      * Verify the encryption password against the stored volume.  This method
2106      * may only be called by the system process.
2107      */
verifyEncryptionPassword(String password)2108     public int verifyEncryptionPassword(String password) throws RemoteException;
2109 
2110     /**
2111      * Returns list of all mountable volumes.
2112      */
getVolumeList(int uid, String packageName, int flags)2113     public StorageVolume[] getVolumeList(int uid, String packageName, int flags) throws RemoteException;
2114 
2115     /**
2116      * Gets the path on the filesystem for the ASEC container itself.
2117      *
2118      * @param cid ASEC container ID
2119      * @return path to filesystem or {@code null} if it's not found
2120      * @throws RemoteException
2121      */
getSecureContainerFilesystemPath(String cid)2122     public String getSecureContainerFilesystemPath(String cid) throws RemoteException;
2123 
2124     /*
2125      * Fix permissions in a container which has just been created and populated.
2126      * Returns an int consistent with MountServiceResultCode
2127      */
fixPermissionsSecureContainer(String id, int gid, String filename)2128     public int fixPermissionsSecureContainer(String id, int gid, String filename)
2129             throws RemoteException;
2130 
2131     /**
2132      * Ensure that all directories along given path exist, creating parent
2133      * directories as needed. Validates that given path is absolute and that it
2134      * contains no relative "." or ".." paths or symlinks. Also ensures that
2135      * path belongs to a volume managed by vold, and that path is either
2136      * external storage data or OBB directory belonging to calling app.
2137      */
mkdirs(String callingPkg, String path)2138     public int mkdirs(String callingPkg, String path) throws RemoteException;
2139 
2140     /**
2141      * Determines the type of the encryption password
2142      * @return PasswordType
2143      */
getPasswordType()2144     public int getPasswordType() throws RemoteException;
2145 
2146     /**
2147      * Get password from vold
2148      * @return password or empty string
2149      */
getPassword()2150     public String getPassword() throws RemoteException;
2151 
2152     /**
2153      * Securely clear password from vold
2154      */
clearPassword()2155     public void clearPassword() throws RemoteException;
2156 
2157     /**
2158      * Set a field in the crypto header.
2159      * @param field field to set
2160      * @param contents contents to set in field
2161      */
setField(String field, String contents)2162     public void setField(String field, String contents) throws RemoteException;
2163 
2164     /**
2165      * Gets a field from the crypto header.
2166      * @param field field to get
2167      * @return contents of field
2168      */
getField(String field)2169     public String getField(String field) throws RemoteException;
2170 
resizeSecureContainer(String id, int sizeMb, String key)2171     public int resizeSecureContainer(String id, int sizeMb, String key) throws RemoteException;
2172 
2173     /**
2174      * Report the time of the last maintenance operation such as fstrim.
2175      * @return Timestamp of the last maintenance operation, in the
2176      *     System.currentTimeMillis() time base
2177      * @throws RemoteException
2178      */
lastMaintenance()2179     public long lastMaintenance() throws RemoteException;
2180 
2181     /**
2182      * Kick off an immediate maintenance operation
2183      * @throws RemoteException
2184      */
runMaintenance()2185     public void runMaintenance() throws RemoteException;
2186 
waitForAsecScan()2187     public void waitForAsecScan() throws RemoteException;
2188 
getDisks()2189     public DiskInfo[] getDisks() throws RemoteException;
getVolumes(int flags)2190     public VolumeInfo[] getVolumes(int flags) throws RemoteException;
getVolumeRecords(int flags)2191     public VolumeRecord[] getVolumeRecords(int flags) throws RemoteException;
2192 
mount(String volId)2193     public void mount(String volId) throws RemoteException;
unmount(String volId)2194     public void unmount(String volId) throws RemoteException;
format(String volId)2195     public void format(String volId) throws RemoteException;
benchmark(String volId)2196     public long benchmark(String volId) throws RemoteException;
2197 
partitionPublic(String diskId)2198     public void partitionPublic(String diskId) throws RemoteException;
partitionPrivate(String diskId)2199     public void partitionPrivate(String diskId) throws RemoteException;
partitionMixed(String diskId, int ratio)2200     public void partitionMixed(String diskId, int ratio) throws RemoteException;
2201 
setVolumeNickname(String fsUuid, String nickname)2202     public void setVolumeNickname(String fsUuid, String nickname) throws RemoteException;
setVolumeUserFlags(String fsUuid, int flags, int mask)2203     public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException;
forgetVolume(String fsUuid)2204     public void forgetVolume(String fsUuid) throws RemoteException;
forgetAllVolumes()2205     public void forgetAllVolumes() throws RemoteException;
setDebugFlags(int flags, int mask)2206     public void setDebugFlags(int flags, int mask) throws RemoteException;
2207 
getPrimaryStorageUuid()2208     public String getPrimaryStorageUuid() throws RemoteException;
setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback)2209     public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback)
2210             throws RemoteException;
2211 
2212     /**
2213      * Creates the user data directory, possibly encrypted
2214      * @param userHandle Handle of the user whose directory we are creating
2215      * @param path Path at which to create the directory.
2216      */
createNewUserDir(int userHandle, String path)2217     public void createNewUserDir(int userHandle, String path)
2218         throws RemoteException;
2219 
2220     /**
2221      * Securely delete the user's encryption key
2222      * @param userHandle Handle of the user whose key we are deleting
2223      */
deleteUserKey(int userHandle)2224     public void deleteUserKey(int userHandle)
2225         throws RemoteException;
2226 }
2227