IMountService.java revision 493e3e7e6523fd94cc1acae3e45935a1227d58c3
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
17package android.os.storage;
18
19import android.os.Binder;
20import android.os.IBinder;
21import android.os.IInterface;
22import android.os.Parcel;
23import android.os.RemoteException;
24
25/**
26 * WARNING! Update IMountService.h and IMountService.cpp if you change this
27 * file. In particular, the ordering of the methods below must match the
28 * _TRANSACTION enum in IMountService.cpp
29 *
30 * @hide - Applications should use android.os.storage.StorageManager to access
31 *       storage functions.
32 */
33public interface IMountService extends IInterface {
34    /** Local-side IPC implementation stub class. */
35    public static abstract class Stub extends Binder implements IMountService {
36        private static class Proxy implements IMountService {
37            private final IBinder mRemote;
38
39            Proxy(IBinder remote) {
40                mRemote = remote;
41            }
42
43            public IBinder asBinder() {
44                return mRemote;
45            }
46
47            public String getInterfaceDescriptor() {
48                return DESCRIPTOR;
49            }
50
51            /**
52             * Registers an IMountServiceListener for receiving async
53             * notifications.
54             */
55            public void registerListener(IMountServiceListener listener) throws RemoteException {
56                Parcel _data = Parcel.obtain();
57                Parcel _reply = Parcel.obtain();
58                try {
59                    _data.writeInterfaceToken(DESCRIPTOR);
60                    _data.writeStrongBinder((listener != null ? listener.asBinder() : null));
61                    mRemote.transact(Stub.TRANSACTION_registerListener, _data, _reply, 0);
62                    _reply.readException();
63                } finally {
64                    _reply.recycle();
65                    _data.recycle();
66                }
67            }
68
69            /**
70             * Unregisters an IMountServiceListener
71             */
72            public void unregisterListener(IMountServiceListener listener) throws RemoteException {
73                Parcel _data = Parcel.obtain();
74                Parcel _reply = Parcel.obtain();
75                try {
76                    _data.writeInterfaceToken(DESCRIPTOR);
77                    _data.writeStrongBinder((listener != null ? listener.asBinder() : null));
78                    mRemote.transact(Stub.TRANSACTION_unregisterListener, _data, _reply, 0);
79                    _reply.readException();
80                } finally {
81                    _reply.recycle();
82                    _data.recycle();
83                }
84            }
85
86            /**
87             * Returns true if a USB mass storage host is connected
88             */
89            public boolean isUsbMassStorageConnected() throws RemoteException {
90                Parcel _data = Parcel.obtain();
91                Parcel _reply = Parcel.obtain();
92                boolean _result;
93                try {
94                    _data.writeInterfaceToken(DESCRIPTOR);
95                    mRemote.transact(Stub.TRANSACTION_isUsbMassStorageConnected, _data, _reply, 0);
96                    _reply.readException();
97                    _result = 0 != _reply.readInt();
98                } finally {
99                    _reply.recycle();
100                    _data.recycle();
101                }
102                return _result;
103            }
104
105            /**
106             * Enables / disables USB mass storage. The caller should check
107             * actual status of enabling/disabling USB mass storage via
108             * StorageEventListener.
109             */
110            public void setUsbMassStorageEnabled(boolean enable) throws RemoteException {
111                Parcel _data = Parcel.obtain();
112                Parcel _reply = Parcel.obtain();
113                try {
114                    _data.writeInterfaceToken(DESCRIPTOR);
115                    _data.writeInt((enable ? 1 : 0));
116                    mRemote.transact(Stub.TRANSACTION_setUsbMassStorageEnabled, _data, _reply, 0);
117                    _reply.readException();
118                } finally {
119                    _reply.recycle();
120                    _data.recycle();
121                }
122            }
123
124            /**
125             * Returns true if a USB mass storage host is enabled (media is
126             * shared)
127             */
128            public boolean isUsbMassStorageEnabled() throws RemoteException {
129                Parcel _data = Parcel.obtain();
130                Parcel _reply = Parcel.obtain();
131                boolean _result;
132                try {
133                    _data.writeInterfaceToken(DESCRIPTOR);
134                    mRemote.transact(Stub.TRANSACTION_isUsbMassStorageEnabled, _data, _reply, 0);
135                    _reply.readException();
136                    _result = 0 != _reply.readInt();
137                } finally {
138                    _reply.recycle();
139                    _data.recycle();
140                }
141                return _result;
142            }
143
144            /**
145             * Mount external storage at given mount point. Returns an int
146             * consistent with MountServiceResultCode
147             */
148            public int mountVolume(String mountPoint) throws RemoteException {
149                Parcel _data = Parcel.obtain();
150                Parcel _reply = Parcel.obtain();
151                int _result;
152                try {
153                    _data.writeInterfaceToken(DESCRIPTOR);
154                    _data.writeString(mountPoint);
155                    mRemote.transact(Stub.TRANSACTION_mountVolume, _data, _reply, 0);
156                    _reply.readException();
157                    _result = _reply.readInt();
158                } finally {
159                    _reply.recycle();
160                    _data.recycle();
161                }
162                return _result;
163            }
164
165            /**
166             * Safely unmount external storage at given mount point. The unmount
167             * is an asynchronous operation. Applications should register
168             * StorageEventListener for storage related status changes.
169             */
170            public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption)
171                    throws RemoteException {
172                Parcel _data = Parcel.obtain();
173                Parcel _reply = Parcel.obtain();
174                try {
175                    _data.writeInterfaceToken(DESCRIPTOR);
176                    _data.writeString(mountPoint);
177                    _data.writeInt((force ? 1 : 0));
178                    _data.writeInt((removeEncryption ? 1 : 0));
179                    mRemote.transact(Stub.TRANSACTION_unmountVolume, _data, _reply, 0);
180                    _reply.readException();
181                } finally {
182                    _reply.recycle();
183                    _data.recycle();
184                }
185            }
186
187            /**
188             * Format external storage given a mount point. Returns an int
189             * consistent with MountServiceResultCode
190             */
191            public int formatVolume(String mountPoint) throws RemoteException {
192                Parcel _data = Parcel.obtain();
193                Parcel _reply = Parcel.obtain();
194                int _result;
195                try {
196                    _data.writeInterfaceToken(DESCRIPTOR);
197                    _data.writeString(mountPoint);
198                    mRemote.transact(Stub.TRANSACTION_formatVolume, _data, _reply, 0);
199                    _reply.readException();
200                    _result = _reply.readInt();
201                } finally {
202                    _reply.recycle();
203                    _data.recycle();
204                }
205                return _result;
206            }
207
208            /**
209             * Returns an array of pids with open files on the specified path.
210             */
211            public int[] getStorageUsers(String path) throws RemoteException {
212                Parcel _data = Parcel.obtain();
213                Parcel _reply = Parcel.obtain();
214                int[] _result;
215                try {
216                    _data.writeInterfaceToken(DESCRIPTOR);
217                    _data.writeString(path);
218                    mRemote.transact(Stub.TRANSACTION_getStorageUsers, _data, _reply, 0);
219                    _reply.readException();
220                    _result = _reply.createIntArray();
221                } finally {
222                    _reply.recycle();
223                    _data.recycle();
224                }
225                return _result;
226            }
227
228            /**
229             * Gets the state of a volume via its mountpoint.
230             */
231            public String getVolumeState(String mountPoint) throws RemoteException {
232                Parcel _data = Parcel.obtain();
233                Parcel _reply = Parcel.obtain();
234                String _result;
235                try {
236                    _data.writeInterfaceToken(DESCRIPTOR);
237                    _data.writeString(mountPoint);
238                    mRemote.transact(Stub.TRANSACTION_getVolumeState, _data, _reply, 0);
239                    _reply.readException();
240                    _result = _reply.readString();
241                } finally {
242                    _reply.recycle();
243                    _data.recycle();
244                }
245                return _result;
246            }
247
248            /*
249             * Creates a secure container with the specified parameters. Returns
250             * an int consistent with MountServiceResultCode
251             */
252            public int createSecureContainer(String id, int sizeMb, String fstype, String key,
253                    int ownerUid, boolean external) throws RemoteException {
254                Parcel _data = Parcel.obtain();
255                Parcel _reply = Parcel.obtain();
256                int _result;
257                try {
258                    _data.writeInterfaceToken(DESCRIPTOR);
259                    _data.writeString(id);
260                    _data.writeInt(sizeMb);
261                    _data.writeString(fstype);
262                    _data.writeString(key);
263                    _data.writeInt(ownerUid);
264                    _data.writeInt(external ? 1 : 0);
265                    mRemote.transact(Stub.TRANSACTION_createSecureContainer, _data, _reply, 0);
266                    _reply.readException();
267                    _result = _reply.readInt();
268                } finally {
269                    _reply.recycle();
270                    _data.recycle();
271                }
272                return _result;
273            }
274
275            /*
276             * Destroy a secure container, and free up all resources associated
277             * with it. NOTE: Ensure all references are released prior to
278             * deleting. Returns an int consistent with MountServiceResultCode
279             */
280            public int destroySecureContainer(String id, boolean force) throws RemoteException {
281                Parcel _data = Parcel.obtain();
282                Parcel _reply = Parcel.obtain();
283                int _result;
284                try {
285                    _data.writeInterfaceToken(DESCRIPTOR);
286                    _data.writeString(id);
287                    _data.writeInt((force ? 1 : 0));
288                    mRemote.transact(Stub.TRANSACTION_destroySecureContainer, _data, _reply, 0);
289                    _reply.readException();
290                    _result = _reply.readInt();
291                } finally {
292                    _reply.recycle();
293                    _data.recycle();
294                }
295                return _result;
296            }
297
298            /*
299             * Finalize a container which has just been created and populated.
300             * After finalization, the container is immutable. Returns an int
301             * consistent with MountServiceResultCode
302             */
303            public int finalizeSecureContainer(String id) throws RemoteException {
304                Parcel _data = Parcel.obtain();
305                Parcel _reply = Parcel.obtain();
306                int _result;
307                try {
308                    _data.writeInterfaceToken(DESCRIPTOR);
309                    _data.writeString(id);
310                    mRemote.transact(Stub.TRANSACTION_finalizeSecureContainer, _data, _reply, 0);
311                    _reply.readException();
312                    _result = _reply.readInt();
313                } finally {
314                    _reply.recycle();
315                    _data.recycle();
316                }
317                return _result;
318            }
319
320            /*
321             * Mount a secure container with the specified key and owner UID.
322             * Returns an int consistent with MountServiceResultCode
323             */
324            public int mountSecureContainer(String id, String key, int ownerUid)
325                    throws RemoteException {
326                Parcel _data = Parcel.obtain();
327                Parcel _reply = Parcel.obtain();
328                int _result;
329                try {
330                    _data.writeInterfaceToken(DESCRIPTOR);
331                    _data.writeString(id);
332                    _data.writeString(key);
333                    _data.writeInt(ownerUid);
334                    mRemote.transact(Stub.TRANSACTION_mountSecureContainer, _data, _reply, 0);
335                    _reply.readException();
336                    _result = _reply.readInt();
337                } finally {
338                    _reply.recycle();
339                    _data.recycle();
340                }
341                return _result;
342            }
343
344            /*
345             * Unount a secure container. Returns an int consistent with
346             * MountServiceResultCode
347             */
348            public int unmountSecureContainer(String id, boolean force) throws RemoteException {
349                Parcel _data = Parcel.obtain();
350                Parcel _reply = Parcel.obtain();
351                int _result;
352                try {
353                    _data.writeInterfaceToken(DESCRIPTOR);
354                    _data.writeString(id);
355                    _data.writeInt((force ? 1 : 0));
356                    mRemote.transact(Stub.TRANSACTION_unmountSecureContainer, _data, _reply, 0);
357                    _reply.readException();
358                    _result = _reply.readInt();
359                } finally {
360                    _reply.recycle();
361                    _data.recycle();
362                }
363                return _result;
364            }
365
366            /*
367             * Returns true if the specified container is mounted
368             */
369            public boolean isSecureContainerMounted(String id) throws RemoteException {
370                Parcel _data = Parcel.obtain();
371                Parcel _reply = Parcel.obtain();
372                boolean _result;
373                try {
374                    _data.writeInterfaceToken(DESCRIPTOR);
375                    _data.writeString(id);
376                    mRemote.transact(Stub.TRANSACTION_isSecureContainerMounted, _data, _reply, 0);
377                    _reply.readException();
378                    _result = 0 != _reply.readInt();
379                } finally {
380                    _reply.recycle();
381                    _data.recycle();
382                }
383                return _result;
384            }
385
386            /*
387             * Rename an unmounted secure container. Returns an int consistent
388             * with MountServiceResultCode
389             */
390            public int renameSecureContainer(String oldId, String newId) throws RemoteException {
391                Parcel _data = Parcel.obtain();
392                Parcel _reply = Parcel.obtain();
393                int _result;
394                try {
395                    _data.writeInterfaceToken(DESCRIPTOR);
396                    _data.writeString(oldId);
397                    _data.writeString(newId);
398                    mRemote.transact(Stub.TRANSACTION_renameSecureContainer, _data, _reply, 0);
399                    _reply.readException();
400                    _result = _reply.readInt();
401                } finally {
402                    _reply.recycle();
403                    _data.recycle();
404                }
405                return _result;
406            }
407
408            /*
409             * Returns the filesystem path of a mounted secure container.
410             */
411            public String getSecureContainerPath(String id) throws RemoteException {
412                Parcel _data = Parcel.obtain();
413                Parcel _reply = Parcel.obtain();
414                String _result;
415                try {
416                    _data.writeInterfaceToken(DESCRIPTOR);
417                    _data.writeString(id);
418                    mRemote.transact(Stub.TRANSACTION_getSecureContainerPath, _data, _reply, 0);
419                    _reply.readException();
420                    _result = _reply.readString();
421                } finally {
422                    _reply.recycle();
423                    _data.recycle();
424                }
425                return _result;
426            }
427
428            /**
429             * Gets an Array of currently known secure container IDs
430             */
431            public String[] getSecureContainerList() throws RemoteException {
432                Parcel _data = Parcel.obtain();
433                Parcel _reply = Parcel.obtain();
434                String[] _result;
435                try {
436                    _data.writeInterfaceToken(DESCRIPTOR);
437                    mRemote.transact(Stub.TRANSACTION_getSecureContainerList, _data, _reply, 0);
438                    _reply.readException();
439                    _result = _reply.createStringArray();
440                } finally {
441                    _reply.recycle();
442                    _data.recycle();
443                }
444                return _result;
445            }
446
447            /**
448             * Shuts down the MountService and gracefully unmounts all external
449             * media. Invokes call back once the shutdown is complete.
450             */
451            public void shutdown(IMountShutdownObserver observer)
452                    throws RemoteException {
453                Parcel _data = Parcel.obtain();
454                Parcel _reply = Parcel.obtain();
455                try {
456                    _data.writeInterfaceToken(DESCRIPTOR);
457                    _data.writeStrongBinder((observer != null ? observer.asBinder() : null));
458                    mRemote.transact(Stub.TRANSACTION_shutdown, _data, _reply, 0);
459                    _reply.readException();
460                } finally {
461                    _reply.recycle();
462                    _data.recycle();
463                }
464            }
465
466            /**
467             * Call into MountService by PackageManager to notify that its done
468             * processing the media status update request.
469             */
470            public void finishMediaUpdate() throws RemoteException {
471                Parcel _data = Parcel.obtain();
472                Parcel _reply = Parcel.obtain();
473                try {
474                    _data.writeInterfaceToken(DESCRIPTOR);
475                    mRemote.transact(Stub.TRANSACTION_finishMediaUpdate, _data, _reply, 0);
476                    _reply.readException();
477                } finally {
478                    _reply.recycle();
479                    _data.recycle();
480                }
481            }
482
483            /**
484             * Mounts an Opaque Binary Blob (OBB) with the specified decryption
485             * key and only allows the calling process's UID access to the
486             * contents. MountService will call back to the supplied
487             * IObbActionListener to inform it of the terminal state of the
488             * call.
489             */
490            public void mountObb(String rawPath, String canonicalPath, String key,
491                    IObbActionListener token, int nonce) throws RemoteException {
492                Parcel _data = Parcel.obtain();
493                Parcel _reply = Parcel.obtain();
494                try {
495                    _data.writeInterfaceToken(DESCRIPTOR);
496                    _data.writeString(rawPath);
497                    _data.writeString(canonicalPath);
498                    _data.writeString(key);
499                    _data.writeStrongBinder((token != null ? token.asBinder() : null));
500                    _data.writeInt(nonce);
501                    mRemote.transact(Stub.TRANSACTION_mountObb, _data, _reply, 0);
502                    _reply.readException();
503                } finally {
504                    _reply.recycle();
505                    _data.recycle();
506                }
507            }
508
509            /**
510             * Unmounts an Opaque Binary Blob (OBB). When the force flag is
511             * specified, any program using it will be forcibly killed to
512             * unmount the image. MountService will call back to the supplied
513             * IObbActionListener to inform it of the terminal state of the
514             * call.
515             */
516            public void unmountObb(
517                    String rawPath, boolean force, IObbActionListener token, int nonce)
518                    throws RemoteException {
519                Parcel _data = Parcel.obtain();
520                Parcel _reply = Parcel.obtain();
521                try {
522                    _data.writeInterfaceToken(DESCRIPTOR);
523                    _data.writeString(rawPath);
524                    _data.writeInt((force ? 1 : 0));
525                    _data.writeStrongBinder((token != null ? token.asBinder() : null));
526                    _data.writeInt(nonce);
527                    mRemote.transact(Stub.TRANSACTION_unmountObb, _data, _reply, 0);
528                    _reply.readException();
529                } finally {
530                    _reply.recycle();
531                    _data.recycle();
532                }
533            }
534
535            /**
536             * Checks whether the specified Opaque Binary Blob (OBB) is mounted
537             * somewhere.
538             */
539            public boolean isObbMounted(String rawPath) throws RemoteException {
540                Parcel _data = Parcel.obtain();
541                Parcel _reply = Parcel.obtain();
542                boolean _result;
543                try {
544                    _data.writeInterfaceToken(DESCRIPTOR);
545                    _data.writeString(rawPath);
546                    mRemote.transact(Stub.TRANSACTION_isObbMounted, _data, _reply, 0);
547                    _reply.readException();
548                    _result = 0 != _reply.readInt();
549                } finally {
550                    _reply.recycle();
551                    _data.recycle();
552                }
553                return _result;
554            }
555
556            /**
557             * Gets the path to the mounted Opaque Binary Blob (OBB).
558             */
559            public String getMountedObbPath(String rawPath) throws RemoteException {
560                Parcel _data = Parcel.obtain();
561                Parcel _reply = Parcel.obtain();
562                String _result;
563                try {
564                    _data.writeInterfaceToken(DESCRIPTOR);
565                    _data.writeString(rawPath);
566                    mRemote.transact(Stub.TRANSACTION_getMountedObbPath, _data, _reply, 0);
567                    _reply.readException();
568                    _result = _reply.readString();
569                } finally {
570                    _reply.recycle();
571                    _data.recycle();
572                }
573                return _result;
574            }
575
576            /**
577             * Returns whether the external storage is emulated.
578             */
579            public boolean isExternalStorageEmulated() throws RemoteException {
580                Parcel _data = Parcel.obtain();
581                Parcel _reply = Parcel.obtain();
582                boolean _result;
583                try {
584                    _data.writeInterfaceToken(DESCRIPTOR);
585                    mRemote.transact(Stub.TRANSACTION_isExternalStorageEmulated, _data, _reply, 0);
586                    _reply.readException();
587                    _result = 0 != _reply.readInt();
588                } finally {
589                    _reply.recycle();
590                    _data.recycle();
591                }
592                return _result;
593            }
594
595            public int getEncryptionState() throws RemoteException {
596                Parcel _data = Parcel.obtain();
597                Parcel _reply = Parcel.obtain();
598                int _result;
599                try {
600                    _data.writeInterfaceToken(DESCRIPTOR);
601                    mRemote.transact(Stub.TRANSACTION_getEncryptionState, _data, _reply, 0);
602                    _reply.readException();
603                    _result = _reply.readInt();
604                } finally {
605                    _reply.recycle();
606                    _data.recycle();
607                }
608                return _result;
609            }
610
611            public int decryptStorage(String password) throws RemoteException {
612                Parcel _data = Parcel.obtain();
613                Parcel _reply = Parcel.obtain();
614                int _result;
615                try {
616                    _data.writeInterfaceToken(DESCRIPTOR);
617                    _data.writeString(password);
618                    mRemote.transact(Stub.TRANSACTION_decryptStorage, _data, _reply, 0);
619                    _reply.readException();
620                    _result = _reply.readInt();
621                } finally {
622                    _reply.recycle();
623                    _data.recycle();
624                }
625                return _result;
626            }
627
628            public int encryptStorage(String password) throws RemoteException {
629                Parcel _data = Parcel.obtain();
630                Parcel _reply = Parcel.obtain();
631                int _result;
632                try {
633                    _data.writeInterfaceToken(DESCRIPTOR);
634                    _data.writeString(password);
635                    mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0);
636                    _reply.readException();
637                    _result = _reply.readInt();
638                } finally {
639                    _reply.recycle();
640                    _data.recycle();
641                }
642                return _result;
643            }
644
645            public int changeEncryptionPassword(int type, String password) throws RemoteException {
646                Parcel _data = Parcel.obtain();
647                Parcel _reply = Parcel.obtain();
648                int _result;
649                try {
650                    _data.writeInterfaceToken(DESCRIPTOR);
651                    _data.writeInt(type);
652                    _data.writeString(password);
653                    mRemote.transact(Stub.TRANSACTION_changeEncryptionPassword, _data, _reply, 0);
654                    _reply.readException();
655                    _result = _reply.readInt();
656                } finally {
657                    _reply.recycle();
658                    _data.recycle();
659                }
660                return _result;
661            }
662
663            @Override
664            public int verifyEncryptionPassword(String password) throws RemoteException {
665                Parcel _data = Parcel.obtain();
666                Parcel _reply = Parcel.obtain();
667                int _result;
668                try {
669                    _data.writeInterfaceToken(DESCRIPTOR);
670                    _data.writeString(password);
671                    mRemote.transact(Stub.TRANSACTION_verifyEncryptionPassword, _data, _reply, 0);
672                    _reply.readException();
673                    _result = _reply.readInt();
674                } finally {
675                    _reply.recycle();
676                    _data.recycle();
677                }
678                return _result;
679            }
680
681            public int getPasswordType() throws RemoteException {
682                Parcel _data = Parcel.obtain();
683                Parcel _reply = Parcel.obtain();
684                int _result;
685                try {
686                    _data.writeInterfaceToken(DESCRIPTOR);
687                    mRemote.transact(Stub.TRANSACTION_getPasswordType, _data, _reply, 0);
688                    _reply.readException();
689                    _result = _reply.readInt();
690                } finally {
691                    _reply.recycle();
692                    _data.recycle();
693                }
694                return _result;
695            }
696
697            public String getPassword() throws RemoteException {
698                Parcel _data = Parcel.obtain();
699                Parcel _reply = Parcel.obtain();
700                String _result;
701                try {
702                    _data.writeInterfaceToken(DESCRIPTOR);
703                    mRemote.transact(Stub.TRANSACTION_getPassword, _data, _reply, 0);
704                    _reply.readException();
705                    _result = _reply.readString();
706                } finally {
707                    _reply.recycle();
708                    _data.recycle();
709                }
710                return _result;
711            }
712
713            public void clearPassword() throws RemoteException {
714                Parcel _data = Parcel.obtain();
715                Parcel _reply = Parcel.obtain();
716                String _result;
717                try {
718                    _data.writeInterfaceToken(DESCRIPTOR);
719                    mRemote.transact(Stub.TRANSACTION_clearPassword, _data, _reply, 0);
720                    _reply.readException();
721                } finally {
722                    _reply.recycle();
723                    _data.recycle();
724                }
725            }
726
727            public StorageVolume[] getVolumeList() throws RemoteException {
728                Parcel _data = Parcel.obtain();
729                Parcel _reply = Parcel.obtain();
730                StorageVolume[] _result;
731                try {
732                    _data.writeInterfaceToken(DESCRIPTOR);
733                    mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0);
734                    _reply.readException();
735                    _result = _reply.createTypedArray(StorageVolume.CREATOR);
736                } finally {
737                    _reply.recycle();
738                    _data.recycle();
739                }
740                return _result;
741            }
742
743            /*
744             * Returns the filesystem path of a mounted secure container.
745             */
746            public String getSecureContainerFilesystemPath(String id) throws RemoteException {
747                Parcel _data = Parcel.obtain();
748                Parcel _reply = Parcel.obtain();
749                String _result;
750                try {
751                    _data.writeInterfaceToken(DESCRIPTOR);
752                    _data.writeString(id);
753                    mRemote.transact(Stub.TRANSACTION_getSecureContainerFilesystemPath, _data, _reply, 0);
754                    _reply.readException();
755                    _result = _reply.readString();
756                } finally {
757                    _reply.recycle();
758                    _data.recycle();
759                }
760                return _result;
761            }
762
763            /**
764             * Fix permissions in a container which has just been created and
765             * populated. Returns an int consistent with MountServiceResultCode
766             */
767            public int fixPermissionsSecureContainer(String id, int gid, String filename)
768                    throws RemoteException {
769                Parcel _data = Parcel.obtain();
770                Parcel _reply = Parcel.obtain();
771                int _result;
772                try {
773                    _data.writeInterfaceToken(DESCRIPTOR);
774                    _data.writeString(id);
775                    _data.writeInt(gid);
776                    _data.writeString(filename);
777                    mRemote.transact(Stub.TRANSACTION_fixPermissionsSecureContainer, _data, _reply, 0);
778                    _reply.readException();
779                    _result = _reply.readInt();
780                } finally {
781                    _reply.recycle();
782                    _data.recycle();
783                }
784                return _result;
785            }
786
787            @Override
788            public int mkdirs(String callingPkg, String path) throws RemoteException {
789                Parcel _data = Parcel.obtain();
790                Parcel _reply = Parcel.obtain();
791                int _result;
792                try {
793                    _data.writeInterfaceToken(DESCRIPTOR);
794                    _data.writeString(callingPkg);
795                    _data.writeString(path);
796                    mRemote.transact(Stub.TRANSACTION_mkdirs, _data, _reply, 0);
797                    _reply.readException();
798                    _result = _reply.readInt();
799                } finally {
800                    _reply.recycle();
801                    _data.recycle();
802                }
803                return _result;
804            }
805        }
806
807        private static final String DESCRIPTOR = "IMountService";
808
809        static final int TRANSACTION_registerListener = IBinder.FIRST_CALL_TRANSACTION + 0;
810
811        static final int TRANSACTION_unregisterListener = IBinder.FIRST_CALL_TRANSACTION + 1;
812
813        static final int TRANSACTION_isUsbMassStorageConnected = IBinder.FIRST_CALL_TRANSACTION + 2;
814
815        static final int TRANSACTION_setUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 3;
816
817        static final int TRANSACTION_isUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 4;
818
819        static final int TRANSACTION_mountVolume = IBinder.FIRST_CALL_TRANSACTION + 5;
820
821        static final int TRANSACTION_unmountVolume = IBinder.FIRST_CALL_TRANSACTION + 6;
822
823        static final int TRANSACTION_formatVolume = IBinder.FIRST_CALL_TRANSACTION + 7;
824
825        static final int TRANSACTION_getStorageUsers = IBinder.FIRST_CALL_TRANSACTION + 8;
826
827        static final int TRANSACTION_getVolumeState = IBinder.FIRST_CALL_TRANSACTION + 9;
828
829        static final int TRANSACTION_createSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 10;
830
831        static final int TRANSACTION_finalizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 11;
832
833        static final int TRANSACTION_destroySecureContainer = IBinder.FIRST_CALL_TRANSACTION + 12;
834
835        static final int TRANSACTION_mountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 13;
836
837        static final int TRANSACTION_unmountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 14;
838
839        static final int TRANSACTION_isSecureContainerMounted = IBinder.FIRST_CALL_TRANSACTION + 15;
840
841        static final int TRANSACTION_renameSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 16;
842
843        static final int TRANSACTION_getSecureContainerPath = IBinder.FIRST_CALL_TRANSACTION + 17;
844
845        static final int TRANSACTION_getSecureContainerList = IBinder.FIRST_CALL_TRANSACTION + 18;
846
847        static final int TRANSACTION_shutdown = IBinder.FIRST_CALL_TRANSACTION + 19;
848
849        static final int TRANSACTION_finishMediaUpdate = IBinder.FIRST_CALL_TRANSACTION + 20;
850
851        static final int TRANSACTION_mountObb = IBinder.FIRST_CALL_TRANSACTION + 21;
852
853        static final int TRANSACTION_unmountObb = IBinder.FIRST_CALL_TRANSACTION + 22;
854
855        static final int TRANSACTION_isObbMounted = IBinder.FIRST_CALL_TRANSACTION + 23;
856
857        static final int TRANSACTION_getMountedObbPath = IBinder.FIRST_CALL_TRANSACTION + 24;
858
859        static final int TRANSACTION_isExternalStorageEmulated = IBinder.FIRST_CALL_TRANSACTION + 25;
860
861        static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26;
862
863        static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27;
864
865        static final int TRANSACTION_changeEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 28;
866
867        static final int TRANSACTION_getVolumeList = IBinder.FIRST_CALL_TRANSACTION + 29;
868
869        static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30;
870
871        static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31;
872
873        static final int TRANSACTION_verifyEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 32;
874
875        static final int TRANSACTION_fixPermissionsSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 33;
876
877        static final int TRANSACTION_mkdirs = IBinder.FIRST_CALL_TRANSACTION + 34;
878
879        static final int TRANSACTION_getPasswordType = IBinder.FIRST_CALL_TRANSACTION + 35;
880
881        static final int TRANSACTION_getPassword = IBinder.FIRST_CALL_TRANSACTION + 36;
882
883        static final int TRANSACTION_clearPassword = IBinder.FIRST_CALL_TRANSACTION + 37;
884
885        /**
886         * Cast an IBinder object into an IMountService interface, generating a
887         * proxy if needed.
888         */
889        public static IMountService asInterface(IBinder obj) {
890            if (obj == null) {
891                return null;
892            }
893            IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
894            if (iin != null && iin instanceof IMountService) {
895                return (IMountService) iin;
896            }
897            return new IMountService.Stub.Proxy(obj);
898        }
899
900        /** Construct the stub at attach it to the interface. */
901        public Stub() {
902            attachInterface(this, DESCRIPTOR);
903        }
904
905        public IBinder asBinder() {
906            return this;
907        }
908
909        @Override
910        public boolean onTransact(int code, Parcel data, Parcel reply,
911                int flags) throws RemoteException {
912            switch (code) {
913                case INTERFACE_TRANSACTION: {
914                    reply.writeString(DESCRIPTOR);
915                    return true;
916                }
917                case TRANSACTION_registerListener: {
918                    data.enforceInterface(DESCRIPTOR);
919                    IMountServiceListener listener;
920                    listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder());
921                    registerListener(listener);
922                    reply.writeNoException();
923                    return true;
924                }
925                case TRANSACTION_unregisterListener: {
926                    data.enforceInterface(DESCRIPTOR);
927                    IMountServiceListener listener;
928                    listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder());
929                    unregisterListener(listener);
930                    reply.writeNoException();
931                    return true;
932                }
933                case TRANSACTION_isUsbMassStorageConnected: {
934                    data.enforceInterface(DESCRIPTOR);
935                    boolean result = isUsbMassStorageConnected();
936                    reply.writeNoException();
937                    reply.writeInt((result ? 1 : 0));
938                    return true;
939                }
940                case TRANSACTION_setUsbMassStorageEnabled: {
941                    data.enforceInterface(DESCRIPTOR);
942                    boolean enable;
943                    enable = 0 != data.readInt();
944                    setUsbMassStorageEnabled(enable);
945                    reply.writeNoException();
946                    return true;
947                }
948                case TRANSACTION_isUsbMassStorageEnabled: {
949                    data.enforceInterface(DESCRIPTOR);
950                    boolean result = isUsbMassStorageEnabled();
951                    reply.writeNoException();
952                    reply.writeInt((result ? 1 : 0));
953                    return true;
954                }
955                case TRANSACTION_mountVolume: {
956                    data.enforceInterface(DESCRIPTOR);
957                    String mountPoint;
958                    mountPoint = data.readString();
959                    int resultCode = mountVolume(mountPoint);
960                    reply.writeNoException();
961                    reply.writeInt(resultCode);
962                    return true;
963                }
964                case TRANSACTION_unmountVolume: {
965                    data.enforceInterface(DESCRIPTOR);
966                    String mountPoint;
967                    mountPoint = data.readString();
968                    boolean force = 0 != data.readInt();
969                    boolean removeEncrypt = 0 != data.readInt();
970                    unmountVolume(mountPoint, force, removeEncrypt);
971                    reply.writeNoException();
972                    return true;
973                }
974                case TRANSACTION_formatVolume: {
975                    data.enforceInterface(DESCRIPTOR);
976                    String mountPoint;
977                    mountPoint = data.readString();
978                    int result = formatVolume(mountPoint);
979                    reply.writeNoException();
980                    reply.writeInt(result);
981                    return true;
982                }
983                case TRANSACTION_getStorageUsers: {
984                    data.enforceInterface(DESCRIPTOR);
985                    String path;
986                    path = data.readString();
987                    int[] pids = getStorageUsers(path);
988                    reply.writeNoException();
989                    reply.writeIntArray(pids);
990                    return true;
991                }
992                case TRANSACTION_getVolumeState: {
993                    data.enforceInterface(DESCRIPTOR);
994                    String mountPoint;
995                    mountPoint = data.readString();
996                    String state = getVolumeState(mountPoint);
997                    reply.writeNoException();
998                    reply.writeString(state);
999                    return true;
1000                }
1001                case TRANSACTION_createSecureContainer: {
1002                    data.enforceInterface(DESCRIPTOR);
1003                    String id;
1004                    id = data.readString();
1005                    int sizeMb;
1006                    sizeMb = data.readInt();
1007                    String fstype;
1008                    fstype = data.readString();
1009                    String key;
1010                    key = data.readString();
1011                    int ownerUid;
1012                    ownerUid = data.readInt();
1013                    boolean external;
1014                    external = 0 != data.readInt();
1015                    int resultCode = createSecureContainer(id, sizeMb, fstype, key, ownerUid,
1016                            external);
1017                    reply.writeNoException();
1018                    reply.writeInt(resultCode);
1019                    return true;
1020                }
1021                case TRANSACTION_finalizeSecureContainer: {
1022                    data.enforceInterface(DESCRIPTOR);
1023                    String id;
1024                    id = data.readString();
1025                    int resultCode = finalizeSecureContainer(id);
1026                    reply.writeNoException();
1027                    reply.writeInt(resultCode);
1028                    return true;
1029                }
1030                case TRANSACTION_destroySecureContainer: {
1031                    data.enforceInterface(DESCRIPTOR);
1032                    String id;
1033                    id = data.readString();
1034                    boolean force;
1035                    force = 0 != data.readInt();
1036                    int resultCode = destroySecureContainer(id, force);
1037                    reply.writeNoException();
1038                    reply.writeInt(resultCode);
1039                    return true;
1040                }
1041                case TRANSACTION_mountSecureContainer: {
1042                    data.enforceInterface(DESCRIPTOR);
1043                    String id;
1044                    id = data.readString();
1045                    String key;
1046                    key = data.readString();
1047                    int ownerUid;
1048                    ownerUid = data.readInt();
1049                    int resultCode = mountSecureContainer(id, key, ownerUid);
1050                    reply.writeNoException();
1051                    reply.writeInt(resultCode);
1052                    return true;
1053                }
1054                case TRANSACTION_unmountSecureContainer: {
1055                    data.enforceInterface(DESCRIPTOR);
1056                    String id;
1057                    id = data.readString();
1058                    boolean force;
1059                    force = 0 != data.readInt();
1060                    int resultCode = unmountSecureContainer(id, force);
1061                    reply.writeNoException();
1062                    reply.writeInt(resultCode);
1063                    return true;
1064                }
1065                case TRANSACTION_isSecureContainerMounted: {
1066                    data.enforceInterface(DESCRIPTOR);
1067                    String id;
1068                    id = data.readString();
1069                    boolean status = isSecureContainerMounted(id);
1070                    reply.writeNoException();
1071                    reply.writeInt((status ? 1 : 0));
1072                    return true;
1073                }
1074                case TRANSACTION_renameSecureContainer: {
1075                    data.enforceInterface(DESCRIPTOR);
1076                    String oldId;
1077                    oldId = data.readString();
1078                    String newId;
1079                    newId = data.readString();
1080                    int resultCode = renameSecureContainer(oldId, newId);
1081                    reply.writeNoException();
1082                    reply.writeInt(resultCode);
1083                    return true;
1084                }
1085                case TRANSACTION_getSecureContainerPath: {
1086                    data.enforceInterface(DESCRIPTOR);
1087                    String id;
1088                    id = data.readString();
1089                    String path = getSecureContainerPath(id);
1090                    reply.writeNoException();
1091                    reply.writeString(path);
1092                    return true;
1093                }
1094                case TRANSACTION_getSecureContainerList: {
1095                    data.enforceInterface(DESCRIPTOR);
1096                    String[] ids = getSecureContainerList();
1097                    reply.writeNoException();
1098                    reply.writeStringArray(ids);
1099                    return true;
1100                }
1101                case TRANSACTION_shutdown: {
1102                    data.enforceInterface(DESCRIPTOR);
1103                    IMountShutdownObserver observer;
1104                    observer = IMountShutdownObserver.Stub.asInterface(data
1105                            .readStrongBinder());
1106                    shutdown(observer);
1107                    reply.writeNoException();
1108                    return true;
1109                }
1110                case TRANSACTION_finishMediaUpdate: {
1111                    data.enforceInterface(DESCRIPTOR);
1112                    finishMediaUpdate();
1113                    reply.writeNoException();
1114                    return true;
1115                }
1116                case TRANSACTION_mountObb: {
1117                    data.enforceInterface(DESCRIPTOR);
1118                    final String rawPath = data.readString();
1119                    final String canonicalPath = data.readString();
1120                    final String key = data.readString();
1121                    IObbActionListener observer;
1122                    observer = IObbActionListener.Stub.asInterface(data.readStrongBinder());
1123                    int nonce;
1124                    nonce = data.readInt();
1125                    mountObb(rawPath, canonicalPath, key, observer, nonce);
1126                    reply.writeNoException();
1127                    return true;
1128                }
1129                case TRANSACTION_unmountObb: {
1130                    data.enforceInterface(DESCRIPTOR);
1131                    String filename;
1132                    filename = data.readString();
1133                    boolean force;
1134                    force = 0 != data.readInt();
1135                    IObbActionListener observer;
1136                    observer = IObbActionListener.Stub.asInterface(data.readStrongBinder());
1137                    int nonce;
1138                    nonce = data.readInt();
1139                    unmountObb(filename, force, observer, nonce);
1140                    reply.writeNoException();
1141                    return true;
1142                }
1143                case TRANSACTION_isObbMounted: {
1144                    data.enforceInterface(DESCRIPTOR);
1145                    String filename;
1146                    filename = data.readString();
1147                    boolean status = isObbMounted(filename);
1148                    reply.writeNoException();
1149                    reply.writeInt((status ? 1 : 0));
1150                    return true;
1151                }
1152                case TRANSACTION_getMountedObbPath: {
1153                    data.enforceInterface(DESCRIPTOR);
1154                    String filename;
1155                    filename = data.readString();
1156                    String mountedPath = getMountedObbPath(filename);
1157                    reply.writeNoException();
1158                    reply.writeString(mountedPath);
1159                    return true;
1160                }
1161                case TRANSACTION_isExternalStorageEmulated: {
1162                    data.enforceInterface(DESCRIPTOR);
1163                    boolean emulated = isExternalStorageEmulated();
1164                    reply.writeNoException();
1165                    reply.writeInt(emulated ? 1 : 0);
1166                    return true;
1167                }
1168                case TRANSACTION_decryptStorage: {
1169                    data.enforceInterface(DESCRIPTOR);
1170                    String password = data.readString();
1171                    int result = decryptStorage(password);
1172                    reply.writeNoException();
1173                    reply.writeInt(result);
1174                    return true;
1175                }
1176                case TRANSACTION_encryptStorage: {
1177                    data.enforceInterface(DESCRIPTOR);
1178                    String password = data.readString();
1179                    int result = encryptStorage(password);
1180                    reply.writeNoException();
1181                    reply.writeInt(result);
1182                    return true;
1183                }
1184                case TRANSACTION_changeEncryptionPassword: {
1185                    data.enforceInterface(DESCRIPTOR);
1186                    int type = data.readInt();
1187                    String password = data.readString();
1188                    int result = changeEncryptionPassword(type, password);
1189                    reply.writeNoException();
1190                    reply.writeInt(result);
1191                    return true;
1192                }
1193                case TRANSACTION_getVolumeList: {
1194                    data.enforceInterface(DESCRIPTOR);
1195                    StorageVolume[] result = getVolumeList();
1196                    reply.writeNoException();
1197                    reply.writeTypedArray(result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1198                    return true;
1199                }
1200                case TRANSACTION_getSecureContainerFilesystemPath: {
1201                    data.enforceInterface(DESCRIPTOR);
1202                    String id;
1203                    id = data.readString();
1204                    String path = getSecureContainerFilesystemPath(id);
1205                    reply.writeNoException();
1206                    reply.writeString(path);
1207                    return true;
1208                }
1209                case TRANSACTION_getEncryptionState: {
1210                    data.enforceInterface(DESCRIPTOR);
1211                    int result = getEncryptionState();
1212                    reply.writeNoException();
1213                    reply.writeInt(result);
1214                    return true;
1215                }
1216                case TRANSACTION_fixPermissionsSecureContainer: {
1217                    data.enforceInterface(DESCRIPTOR);
1218                    String id;
1219                    id = data.readString();
1220                    int gid;
1221                    gid = data.readInt();
1222                    String filename;
1223                    filename = data.readString();
1224                    int resultCode = fixPermissionsSecureContainer(id, gid, filename);
1225                    reply.writeNoException();
1226                    reply.writeInt(resultCode);
1227                    return true;
1228                }
1229                case TRANSACTION_mkdirs: {
1230                    data.enforceInterface(DESCRIPTOR);
1231                    String callingPkg = data.readString();
1232                    String path = data.readString();
1233                    int result = mkdirs(callingPkg, path);
1234                    reply.writeNoException();
1235                    reply.writeInt(result);
1236                    return true;
1237                }
1238                case TRANSACTION_getPasswordType: {
1239                    data.enforceInterface(DESCRIPTOR);
1240                    int result = getPasswordType();
1241                    reply.writeNoException();
1242                    reply.writeInt(result);
1243                    return true;
1244                }
1245                case TRANSACTION_getPassword: {
1246                    data.enforceInterface(DESCRIPTOR);
1247                    String result = getPassword();
1248                    reply.writeNoException();
1249                    reply.writeString(result);
1250                    return true;
1251                }
1252                case TRANSACTION_clearPassword: {
1253                    data.enforceInterface(DESCRIPTOR);
1254                    clearPassword();
1255                    reply.writeNoException();
1256                    return true;
1257                }
1258            }
1259            return super.onTransact(code, data, reply, flags);
1260        }
1261    }
1262
1263    /*
1264     * Creates a secure container with the specified parameters. Returns an int
1265     * consistent with MountServiceResultCode
1266     */
1267    public int createSecureContainer(String id, int sizeMb, String fstype, String key,
1268            int ownerUid, boolean external) throws RemoteException;
1269
1270    /*
1271     * Destroy a secure container, and free up all resources associated with it.
1272     * NOTE: Ensure all references are released prior to deleting. Returns an
1273     * int consistent with MountServiceResultCode
1274     */
1275    public int destroySecureContainer(String id, boolean force) throws RemoteException;
1276
1277    /*
1278     * Finalize a container which has just been created and populated. After
1279     * finalization, the container is immutable. Returns an int consistent with
1280     * MountServiceResultCode
1281     */
1282    public int finalizeSecureContainer(String id) throws RemoteException;
1283
1284    /**
1285     * Call into MountService by PackageManager to notify that its done
1286     * processing the media status update request.
1287     */
1288    public void finishMediaUpdate() throws RemoteException;
1289
1290    /**
1291     * Format external storage given a mount point. Returns an int consistent
1292     * with MountServiceResultCode
1293     */
1294    public int formatVolume(String mountPoint) throws RemoteException;
1295
1296    /**
1297     * Gets the path to the mounted Opaque Binary Blob (OBB).
1298     */
1299    public String getMountedObbPath(String rawPath) throws RemoteException;
1300
1301    /**
1302     * Gets an Array of currently known secure container IDs
1303     */
1304    public String[] getSecureContainerList() throws RemoteException;
1305
1306    /*
1307     * Returns the filesystem path of a mounted secure container.
1308     */
1309    public String getSecureContainerPath(String id) throws RemoteException;
1310
1311    /**
1312     * Returns an array of pids with open files on the specified path.
1313     */
1314    public int[] getStorageUsers(String path) throws RemoteException;
1315
1316    /**
1317     * Gets the state of a volume via its mountpoint.
1318     */
1319    public String getVolumeState(String mountPoint) throws RemoteException;
1320
1321    /**
1322     * Checks whether the specified Opaque Binary Blob (OBB) is mounted
1323     * somewhere.
1324     */
1325    public boolean isObbMounted(String rawPath) throws RemoteException;
1326
1327    /*
1328     * Returns true if the specified container is mounted
1329     */
1330    public boolean isSecureContainerMounted(String id) throws RemoteException;
1331
1332    /**
1333     * Returns true if a USB mass storage host is connected
1334     */
1335    public boolean isUsbMassStorageConnected() throws RemoteException;
1336
1337    /**
1338     * Returns true if a USB mass storage host is enabled (media is shared)
1339     */
1340    public boolean isUsbMassStorageEnabled() throws RemoteException;
1341
1342    /**
1343     * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
1344     * only allows the calling process's UID access to the contents.
1345     * MountService will call back to the supplied IObbActionListener to inform
1346     * it of the terminal state of the call.
1347     */
1348    public void mountObb(String rawPath, String canonicalPath, String key,
1349            IObbActionListener token, int nonce) throws RemoteException;
1350
1351    /*
1352     * Mount a secure container with the specified key and owner UID. Returns an
1353     * int consistent with MountServiceResultCode
1354     */
1355    public int mountSecureContainer(String id, String key, int ownerUid) throws RemoteException;
1356
1357    /**
1358     * Mount external storage at given mount point. Returns an int consistent
1359     * with MountServiceResultCode
1360     */
1361    public int mountVolume(String mountPoint) throws RemoteException;
1362
1363    /**
1364     * Registers an IMountServiceListener for receiving async notifications.
1365     */
1366    public void registerListener(IMountServiceListener listener) throws RemoteException;
1367
1368    /*
1369     * Rename an unmounted secure container. Returns an int consistent with
1370     * MountServiceResultCode
1371     */
1372    public int renameSecureContainer(String oldId, String newId) throws RemoteException;
1373
1374    /**
1375     * Enables / disables USB mass storage. The caller should check actual
1376     * status of enabling/disabling USB mass storage via StorageEventListener.
1377     */
1378    public void setUsbMassStorageEnabled(boolean enable) throws RemoteException;
1379
1380    /**
1381     * Shuts down the MountService and gracefully unmounts all external media.
1382     * Invokes call back once the shutdown is complete.
1383     */
1384    public void shutdown(IMountShutdownObserver observer) throws RemoteException;
1385
1386    /**
1387     * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
1388     * any program using it will be forcibly killed to unmount the image.
1389     * MountService will call back to the supplied IObbActionListener to inform
1390     * it of the terminal state of the call.
1391     */
1392    public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce)
1393            throws RemoteException;
1394
1395    /*
1396     * Unount a secure container. Returns an int consistent with
1397     * MountServiceResultCode
1398     */
1399    public int unmountSecureContainer(String id, boolean force) throws RemoteException;
1400
1401    /**
1402     * Safely unmount external storage at given mount point. The unmount is an
1403     * asynchronous operation. Applications should register StorageEventListener
1404     * for storage related status changes.
1405     * @param mountPoint the mount point
1406     * @param force whether or not to forcefully unmount it (e.g. even if programs are using this
1407     *     data currently)
1408     * @param removeEncryption whether or not encryption mapping should be removed from the volume.
1409     *     This value implies {@code force}.
1410     */
1411    public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption)
1412            throws RemoteException;
1413
1414    /**
1415     * Unregisters an IMountServiceListener
1416     */
1417    public void unregisterListener(IMountServiceListener listener) throws RemoteException;
1418
1419    /**
1420     * Returns whether or not the external storage is emulated.
1421     */
1422    public boolean isExternalStorageEmulated() throws RemoteException;
1423
1424    /** The volume is not encrypted. */
1425    static final int ENCRYPTION_STATE_NONE = 1;
1426    /** The volume has been encrypted succesfully. */
1427    static final int ENCRYPTION_STATE_OK = 0;
1428    /** The volume is in a bad state. */
1429    static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1;
1430    /** The volume is in a bad state - partially encrypted. Data is likely irrecoverable. */
1431    static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2;
1432
1433    /**
1434     * Determines the encryption state of the volume.
1435     * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values.
1436     */
1437    public int getEncryptionState() throws RemoteException;
1438
1439    /**
1440     * Decrypts any encrypted volumes.
1441     */
1442    public int decryptStorage(String password) throws RemoteException;
1443
1444    /**
1445     * Encrypts storage.
1446     */
1447    public int encryptStorage(String password) throws RemoteException;
1448
1449    /**
1450     * Changes the encryption password.
1451     */
1452    public int changeEncryptionPassword(int type, String password)
1453        throws RemoteException;
1454
1455    /**
1456     * Verify the encryption password against the stored volume.  This method
1457     * may only be called by the system process.
1458     */
1459    public int verifyEncryptionPassword(String password) throws RemoteException;
1460
1461    /**
1462     * Returns list of all mountable volumes.
1463     */
1464    public StorageVolume[] getVolumeList() throws RemoteException;
1465
1466    /**
1467     * Gets the path on the filesystem for the ASEC container itself.
1468     *
1469     * @param cid ASEC container ID
1470     * @return path to filesystem or {@code null} if it's not found
1471     * @throws RemoteException
1472     */
1473    public String getSecureContainerFilesystemPath(String cid) throws RemoteException;
1474
1475    /*
1476     * Fix permissions in a container which has just been created and populated.
1477     * Returns an int consistent with MountServiceResultCode
1478     */
1479    public int fixPermissionsSecureContainer(String id, int gid, String filename)
1480            throws RemoteException;
1481
1482    /**
1483     * Ensure that all directories along given path exist, creating parent
1484     * directories as needed. Validates that given path is absolute and that it
1485     * contains no relative "." or ".." paths or symlinks. Also ensures that
1486     * path belongs to a volume managed by vold, and that path is either
1487     * external storage data or OBB directory belonging to calling app.
1488     */
1489    public int mkdirs(String callingPkg, String path) throws RemoteException;
1490
1491    /**
1492     * Determines the type of the encryption password
1493     * @return PasswordType
1494     */
1495    public int getPasswordType() throws RemoteException;
1496
1497    /**
1498     * Get password from vold
1499     * @return password or empty string
1500     */
1501    public String getPassword() throws RemoteException;
1502
1503    /**
1504     * Securely clear password from vold
1505     */
1506    public void clearPassword() throws RemoteException;
1507}
1508