IMountService.java revision 2d8b4e801332e02d6aad615b85cc9dd056ef805c
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(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.writeString(password);
652                    mRemote.transact(Stub.TRANSACTION_changeEncryptionPassword, _data, _reply, 0);
653                    _reply.readException();
654                    _result = _reply.readInt();
655                } finally {
656                    _reply.recycle();
657                    _data.recycle();
658                }
659                return _result;
660            }
661
662            @Override
663            public int verifyEncryptionPassword(String password) throws RemoteException {
664                Parcel _data = Parcel.obtain();
665                Parcel _reply = Parcel.obtain();
666                int _result;
667                try {
668                    _data.writeInterfaceToken(DESCRIPTOR);
669                    _data.writeString(password);
670                    mRemote.transact(Stub.TRANSACTION_verifyEncryptionPassword, _data, _reply, 0);
671                    _reply.readException();
672                    _result = _reply.readInt();
673                } finally {
674                    _reply.recycle();
675                    _data.recycle();
676                }
677                return _result;
678            }
679
680            public StorageVolume[] getVolumeList() throws RemoteException {
681                Parcel _data = Parcel.obtain();
682                Parcel _reply = Parcel.obtain();
683                StorageVolume[] _result;
684                try {
685                    _data.writeInterfaceToken(DESCRIPTOR);
686                    mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0);
687                    _reply.readException();
688                    _result = _reply.createTypedArray(StorageVolume.CREATOR);
689                } finally {
690                    _reply.recycle();
691                    _data.recycle();
692                }
693                return _result;
694            }
695
696            /*
697             * Returns the filesystem path of a mounted secure container.
698             */
699            public String getSecureContainerFilesystemPath(String id) throws RemoteException {
700                Parcel _data = Parcel.obtain();
701                Parcel _reply = Parcel.obtain();
702                String _result;
703                try {
704                    _data.writeInterfaceToken(DESCRIPTOR);
705                    _data.writeString(id);
706                    mRemote.transact(Stub.TRANSACTION_getSecureContainerFilesystemPath, _data, _reply, 0);
707                    _reply.readException();
708                    _result = _reply.readString();
709                } finally {
710                    _reply.recycle();
711                    _data.recycle();
712                }
713                return _result;
714            }
715
716            /**
717             * Fix permissions in a container which has just been created and
718             * populated. Returns an int consistent with MountServiceResultCode
719             */
720            public int fixPermissionsSecureContainer(String id, int gid, String filename)
721                    throws RemoteException {
722                Parcel _data = Parcel.obtain();
723                Parcel _reply = Parcel.obtain();
724                int _result;
725                try {
726                    _data.writeInterfaceToken(DESCRIPTOR);
727                    _data.writeString(id);
728                    _data.writeInt(gid);
729                    _data.writeString(filename);
730                    mRemote.transact(Stub.TRANSACTION_fixPermissionsSecureContainer, _data, _reply, 0);
731                    _reply.readException();
732                    _result = _reply.readInt();
733                } finally {
734                    _reply.recycle();
735                    _data.recycle();
736                }
737                return _result;
738            }
739
740            @Override
741            public int mkdirs(String callingPkg, String path) throws RemoteException {
742                Parcel _data = Parcel.obtain();
743                Parcel _reply = Parcel.obtain();
744                int _result;
745                try {
746                    _data.writeInterfaceToken(DESCRIPTOR);
747                    _data.writeString(callingPkg);
748                    _data.writeString(path);
749                    mRemote.transact(Stub.TRANSACTION_mkdirs, _data, _reply, 0);
750                    _reply.readException();
751                    _result = _reply.readInt();
752                } finally {
753                    _reply.recycle();
754                    _data.recycle();
755                }
756                return _result;
757            }
758        }
759
760        private static final String DESCRIPTOR = "IMountService";
761
762        static final int TRANSACTION_registerListener = IBinder.FIRST_CALL_TRANSACTION + 0;
763
764        static final int TRANSACTION_unregisterListener = IBinder.FIRST_CALL_TRANSACTION + 1;
765
766        static final int TRANSACTION_isUsbMassStorageConnected = IBinder.FIRST_CALL_TRANSACTION + 2;
767
768        static final int TRANSACTION_setUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 3;
769
770        static final int TRANSACTION_isUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 4;
771
772        static final int TRANSACTION_mountVolume = IBinder.FIRST_CALL_TRANSACTION + 5;
773
774        static final int TRANSACTION_unmountVolume = IBinder.FIRST_CALL_TRANSACTION + 6;
775
776        static final int TRANSACTION_formatVolume = IBinder.FIRST_CALL_TRANSACTION + 7;
777
778        static final int TRANSACTION_getStorageUsers = IBinder.FIRST_CALL_TRANSACTION + 8;
779
780        static final int TRANSACTION_getVolumeState = IBinder.FIRST_CALL_TRANSACTION + 9;
781
782        static final int TRANSACTION_createSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 10;
783
784        static final int TRANSACTION_finalizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 11;
785
786        static final int TRANSACTION_destroySecureContainer = IBinder.FIRST_CALL_TRANSACTION + 12;
787
788        static final int TRANSACTION_mountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 13;
789
790        static final int TRANSACTION_unmountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 14;
791
792        static final int TRANSACTION_isSecureContainerMounted = IBinder.FIRST_CALL_TRANSACTION + 15;
793
794        static final int TRANSACTION_renameSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 16;
795
796        static final int TRANSACTION_getSecureContainerPath = IBinder.FIRST_CALL_TRANSACTION + 17;
797
798        static final int TRANSACTION_getSecureContainerList = IBinder.FIRST_CALL_TRANSACTION + 18;
799
800        static final int TRANSACTION_shutdown = IBinder.FIRST_CALL_TRANSACTION + 19;
801
802        static final int TRANSACTION_finishMediaUpdate = IBinder.FIRST_CALL_TRANSACTION + 20;
803
804        static final int TRANSACTION_mountObb = IBinder.FIRST_CALL_TRANSACTION + 21;
805
806        static final int TRANSACTION_unmountObb = IBinder.FIRST_CALL_TRANSACTION + 22;
807
808        static final int TRANSACTION_isObbMounted = IBinder.FIRST_CALL_TRANSACTION + 23;
809
810        static final int TRANSACTION_getMountedObbPath = IBinder.FIRST_CALL_TRANSACTION + 24;
811
812        static final int TRANSACTION_isExternalStorageEmulated = IBinder.FIRST_CALL_TRANSACTION + 25;
813
814        static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26;
815
816        static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27;
817
818        static final int TRANSACTION_changeEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 28;
819
820        static final int TRANSACTION_getVolumeList = IBinder.FIRST_CALL_TRANSACTION + 29;
821
822        static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30;
823
824        static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31;
825
826        static final int TRANSACTION_verifyEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 32;
827
828        static final int TRANSACTION_fixPermissionsSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 33;
829
830        static final int TRANSACTION_mkdirs = IBinder.FIRST_CALL_TRANSACTION + 34;
831
832        /**
833         * Cast an IBinder object into an IMountService interface, generating a
834         * proxy if needed.
835         */
836        public static IMountService asInterface(IBinder obj) {
837            if (obj == null) {
838                return null;
839            }
840            IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
841            if (iin != null && iin instanceof IMountService) {
842                return (IMountService) iin;
843            }
844            return new IMountService.Stub.Proxy(obj);
845        }
846
847        /** Construct the stub at attach it to the interface. */
848        public Stub() {
849            attachInterface(this, DESCRIPTOR);
850        }
851
852        public IBinder asBinder() {
853            return this;
854        }
855
856        @Override
857        public boolean onTransact(int code, Parcel data, Parcel reply,
858                int flags) throws RemoteException {
859            switch (code) {
860                case INTERFACE_TRANSACTION: {
861                    reply.writeString(DESCRIPTOR);
862                    return true;
863                }
864                case TRANSACTION_registerListener: {
865                    data.enforceInterface(DESCRIPTOR);
866                    IMountServiceListener listener;
867                    listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder());
868                    registerListener(listener);
869                    reply.writeNoException();
870                    return true;
871                }
872                case TRANSACTION_unregisterListener: {
873                    data.enforceInterface(DESCRIPTOR);
874                    IMountServiceListener listener;
875                    listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder());
876                    unregisterListener(listener);
877                    reply.writeNoException();
878                    return true;
879                }
880                case TRANSACTION_isUsbMassStorageConnected: {
881                    data.enforceInterface(DESCRIPTOR);
882                    boolean result = isUsbMassStorageConnected();
883                    reply.writeNoException();
884                    reply.writeInt((result ? 1 : 0));
885                    return true;
886                }
887                case TRANSACTION_setUsbMassStorageEnabled: {
888                    data.enforceInterface(DESCRIPTOR);
889                    boolean enable;
890                    enable = 0 != data.readInt();
891                    setUsbMassStorageEnabled(enable);
892                    reply.writeNoException();
893                    return true;
894                }
895                case TRANSACTION_isUsbMassStorageEnabled: {
896                    data.enforceInterface(DESCRIPTOR);
897                    boolean result = isUsbMassStorageEnabled();
898                    reply.writeNoException();
899                    reply.writeInt((result ? 1 : 0));
900                    return true;
901                }
902                case TRANSACTION_mountVolume: {
903                    data.enforceInterface(DESCRIPTOR);
904                    String mountPoint;
905                    mountPoint = data.readString();
906                    int resultCode = mountVolume(mountPoint);
907                    reply.writeNoException();
908                    reply.writeInt(resultCode);
909                    return true;
910                }
911                case TRANSACTION_unmountVolume: {
912                    data.enforceInterface(DESCRIPTOR);
913                    String mountPoint;
914                    mountPoint = data.readString();
915                    boolean force = 0 != data.readInt();
916                    boolean removeEncrypt = 0 != data.readInt();
917                    unmountVolume(mountPoint, force, removeEncrypt);
918                    reply.writeNoException();
919                    return true;
920                }
921                case TRANSACTION_formatVolume: {
922                    data.enforceInterface(DESCRIPTOR);
923                    String mountPoint;
924                    mountPoint = data.readString();
925                    int result = formatVolume(mountPoint);
926                    reply.writeNoException();
927                    reply.writeInt(result);
928                    return true;
929                }
930                case TRANSACTION_getStorageUsers: {
931                    data.enforceInterface(DESCRIPTOR);
932                    String path;
933                    path = data.readString();
934                    int[] pids = getStorageUsers(path);
935                    reply.writeNoException();
936                    reply.writeIntArray(pids);
937                    return true;
938                }
939                case TRANSACTION_getVolumeState: {
940                    data.enforceInterface(DESCRIPTOR);
941                    String mountPoint;
942                    mountPoint = data.readString();
943                    String state = getVolumeState(mountPoint);
944                    reply.writeNoException();
945                    reply.writeString(state);
946                    return true;
947                }
948                case TRANSACTION_createSecureContainer: {
949                    data.enforceInterface(DESCRIPTOR);
950                    String id;
951                    id = data.readString();
952                    int sizeMb;
953                    sizeMb = data.readInt();
954                    String fstype;
955                    fstype = data.readString();
956                    String key;
957                    key = data.readString();
958                    int ownerUid;
959                    ownerUid = data.readInt();
960                    boolean external;
961                    external = 0 != data.readInt();
962                    int resultCode = createSecureContainer(id, sizeMb, fstype, key, ownerUid,
963                            external);
964                    reply.writeNoException();
965                    reply.writeInt(resultCode);
966                    return true;
967                }
968                case TRANSACTION_finalizeSecureContainer: {
969                    data.enforceInterface(DESCRIPTOR);
970                    String id;
971                    id = data.readString();
972                    int resultCode = finalizeSecureContainer(id);
973                    reply.writeNoException();
974                    reply.writeInt(resultCode);
975                    return true;
976                }
977                case TRANSACTION_destroySecureContainer: {
978                    data.enforceInterface(DESCRIPTOR);
979                    String id;
980                    id = data.readString();
981                    boolean force;
982                    force = 0 != data.readInt();
983                    int resultCode = destroySecureContainer(id, force);
984                    reply.writeNoException();
985                    reply.writeInt(resultCode);
986                    return true;
987                }
988                case TRANSACTION_mountSecureContainer: {
989                    data.enforceInterface(DESCRIPTOR);
990                    String id;
991                    id = data.readString();
992                    String key;
993                    key = data.readString();
994                    int ownerUid;
995                    ownerUid = data.readInt();
996                    int resultCode = mountSecureContainer(id, key, ownerUid);
997                    reply.writeNoException();
998                    reply.writeInt(resultCode);
999                    return true;
1000                }
1001                case TRANSACTION_unmountSecureContainer: {
1002                    data.enforceInterface(DESCRIPTOR);
1003                    String id;
1004                    id = data.readString();
1005                    boolean force;
1006                    force = 0 != data.readInt();
1007                    int resultCode = unmountSecureContainer(id, force);
1008                    reply.writeNoException();
1009                    reply.writeInt(resultCode);
1010                    return true;
1011                }
1012                case TRANSACTION_isSecureContainerMounted: {
1013                    data.enforceInterface(DESCRIPTOR);
1014                    String id;
1015                    id = data.readString();
1016                    boolean status = isSecureContainerMounted(id);
1017                    reply.writeNoException();
1018                    reply.writeInt((status ? 1 : 0));
1019                    return true;
1020                }
1021                case TRANSACTION_renameSecureContainer: {
1022                    data.enforceInterface(DESCRIPTOR);
1023                    String oldId;
1024                    oldId = data.readString();
1025                    String newId;
1026                    newId = data.readString();
1027                    int resultCode = renameSecureContainer(oldId, newId);
1028                    reply.writeNoException();
1029                    reply.writeInt(resultCode);
1030                    return true;
1031                }
1032                case TRANSACTION_getSecureContainerPath: {
1033                    data.enforceInterface(DESCRIPTOR);
1034                    String id;
1035                    id = data.readString();
1036                    String path = getSecureContainerPath(id);
1037                    reply.writeNoException();
1038                    reply.writeString(path);
1039                    return true;
1040                }
1041                case TRANSACTION_getSecureContainerList: {
1042                    data.enforceInterface(DESCRIPTOR);
1043                    String[] ids = getSecureContainerList();
1044                    reply.writeNoException();
1045                    reply.writeStringArray(ids);
1046                    return true;
1047                }
1048                case TRANSACTION_shutdown: {
1049                    data.enforceInterface(DESCRIPTOR);
1050                    IMountShutdownObserver observer;
1051                    observer = IMountShutdownObserver.Stub.asInterface(data
1052                            .readStrongBinder());
1053                    shutdown(observer);
1054                    reply.writeNoException();
1055                    return true;
1056                }
1057                case TRANSACTION_finishMediaUpdate: {
1058                    data.enforceInterface(DESCRIPTOR);
1059                    finishMediaUpdate();
1060                    reply.writeNoException();
1061                    return true;
1062                }
1063                case TRANSACTION_mountObb: {
1064                    data.enforceInterface(DESCRIPTOR);
1065                    final String rawPath = data.readString();
1066                    final String canonicalPath = data.readString();
1067                    final String key = data.readString();
1068                    IObbActionListener observer;
1069                    observer = IObbActionListener.Stub.asInterface(data.readStrongBinder());
1070                    int nonce;
1071                    nonce = data.readInt();
1072                    mountObb(rawPath, canonicalPath, key, observer, nonce);
1073                    reply.writeNoException();
1074                    return true;
1075                }
1076                case TRANSACTION_unmountObb: {
1077                    data.enforceInterface(DESCRIPTOR);
1078                    String filename;
1079                    filename = data.readString();
1080                    boolean force;
1081                    force = 0 != data.readInt();
1082                    IObbActionListener observer;
1083                    observer = IObbActionListener.Stub.asInterface(data.readStrongBinder());
1084                    int nonce;
1085                    nonce = data.readInt();
1086                    unmountObb(filename, force, observer, nonce);
1087                    reply.writeNoException();
1088                    return true;
1089                }
1090                case TRANSACTION_isObbMounted: {
1091                    data.enforceInterface(DESCRIPTOR);
1092                    String filename;
1093                    filename = data.readString();
1094                    boolean status = isObbMounted(filename);
1095                    reply.writeNoException();
1096                    reply.writeInt((status ? 1 : 0));
1097                    return true;
1098                }
1099                case TRANSACTION_getMountedObbPath: {
1100                    data.enforceInterface(DESCRIPTOR);
1101                    String filename;
1102                    filename = data.readString();
1103                    String mountedPath = getMountedObbPath(filename);
1104                    reply.writeNoException();
1105                    reply.writeString(mountedPath);
1106                    return true;
1107                }
1108                case TRANSACTION_isExternalStorageEmulated: {
1109                    data.enforceInterface(DESCRIPTOR);
1110                    boolean emulated = isExternalStorageEmulated();
1111                    reply.writeNoException();
1112                    reply.writeInt(emulated ? 1 : 0);
1113                    return true;
1114                }
1115                case TRANSACTION_decryptStorage: {
1116                    data.enforceInterface(DESCRIPTOR);
1117                    String password = data.readString();
1118                    int result = decryptStorage(password);
1119                    reply.writeNoException();
1120                    reply.writeInt(result);
1121                    return true;
1122                }
1123                case TRANSACTION_encryptStorage: {
1124                    data.enforceInterface(DESCRIPTOR);
1125                    String password = data.readString();
1126                    int result = encryptStorage(password);
1127                    reply.writeNoException();
1128                    reply.writeInt(result);
1129                    return true;
1130                }
1131                case TRANSACTION_changeEncryptionPassword: {
1132                    data.enforceInterface(DESCRIPTOR);
1133                    String password = data.readString();
1134                    int result = changeEncryptionPassword(password);
1135                    reply.writeNoException();
1136                    reply.writeInt(result);
1137                    return true;
1138                }
1139                case TRANSACTION_getVolumeList: {
1140                    data.enforceInterface(DESCRIPTOR);
1141                    StorageVolume[] result = getVolumeList();
1142                    reply.writeNoException();
1143                    reply.writeTypedArray(result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1144                    return true;
1145                }
1146                case TRANSACTION_getSecureContainerFilesystemPath: {
1147                    data.enforceInterface(DESCRIPTOR);
1148                    String id;
1149                    id = data.readString();
1150                    String path = getSecureContainerFilesystemPath(id);
1151                    reply.writeNoException();
1152                    reply.writeString(path);
1153                    return true;
1154                }
1155                case TRANSACTION_getEncryptionState: {
1156                    data.enforceInterface(DESCRIPTOR);
1157                    int result = getEncryptionState();
1158                    reply.writeNoException();
1159                    reply.writeInt(result);
1160                    return true;
1161                }
1162                case TRANSACTION_fixPermissionsSecureContainer: {
1163                    data.enforceInterface(DESCRIPTOR);
1164                    String id;
1165                    id = data.readString();
1166                    int gid;
1167                    gid = data.readInt();
1168                    String filename;
1169                    filename = data.readString();
1170                    int resultCode = fixPermissionsSecureContainer(id, gid, filename);
1171                    reply.writeNoException();
1172                    reply.writeInt(resultCode);
1173                    return true;
1174                }
1175                case TRANSACTION_mkdirs: {
1176                    data.enforceInterface(DESCRIPTOR);
1177                    String callingPkg = data.readString();
1178                    String path = data.readString();
1179                    int result = mkdirs(callingPkg, path);
1180                    reply.writeNoException();
1181                    reply.writeInt(result);
1182                    return true;
1183                }
1184            }
1185            return super.onTransact(code, data, reply, flags);
1186        }
1187    }
1188
1189    /*
1190     * Creates a secure container with the specified parameters. Returns an int
1191     * consistent with MountServiceResultCode
1192     */
1193    public int createSecureContainer(String id, int sizeMb, String fstype, String key,
1194            int ownerUid, boolean external) throws RemoteException;
1195
1196    /*
1197     * Destroy a secure container, and free up all resources associated with it.
1198     * NOTE: Ensure all references are released prior to deleting. Returns an
1199     * int consistent with MountServiceResultCode
1200     */
1201    public int destroySecureContainer(String id, boolean force) throws RemoteException;
1202
1203    /*
1204     * Finalize a container which has just been created and populated. After
1205     * finalization, the container is immutable. Returns an int consistent with
1206     * MountServiceResultCode
1207     */
1208    public int finalizeSecureContainer(String id) throws RemoteException;
1209
1210    /**
1211     * Call into MountService by PackageManager to notify that its done
1212     * processing the media status update request.
1213     */
1214    public void finishMediaUpdate() throws RemoteException;
1215
1216    /**
1217     * Format external storage given a mount point. Returns an int consistent
1218     * with MountServiceResultCode
1219     */
1220    public int formatVolume(String mountPoint) throws RemoteException;
1221
1222    /**
1223     * Gets the path to the mounted Opaque Binary Blob (OBB).
1224     */
1225    public String getMountedObbPath(String rawPath) throws RemoteException;
1226
1227    /**
1228     * Gets an Array of currently known secure container IDs
1229     */
1230    public String[] getSecureContainerList() throws RemoteException;
1231
1232    /*
1233     * Returns the filesystem path of a mounted secure container.
1234     */
1235    public String getSecureContainerPath(String id) throws RemoteException;
1236
1237    /**
1238     * Returns an array of pids with open files on the specified path.
1239     */
1240    public int[] getStorageUsers(String path) throws RemoteException;
1241
1242    /**
1243     * Gets the state of a volume via its mountpoint.
1244     */
1245    public String getVolumeState(String mountPoint) throws RemoteException;
1246
1247    /**
1248     * Checks whether the specified Opaque Binary Blob (OBB) is mounted
1249     * somewhere.
1250     */
1251    public boolean isObbMounted(String rawPath) throws RemoteException;
1252
1253    /*
1254     * Returns true if the specified container is mounted
1255     */
1256    public boolean isSecureContainerMounted(String id) throws RemoteException;
1257
1258    /**
1259     * Returns true if a USB mass storage host is connected
1260     */
1261    public boolean isUsbMassStorageConnected() throws RemoteException;
1262
1263    /**
1264     * Returns true if a USB mass storage host is enabled (media is shared)
1265     */
1266    public boolean isUsbMassStorageEnabled() throws RemoteException;
1267
1268    /**
1269     * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and
1270     * only allows the calling process's UID access to the contents.
1271     * MountService will call back to the supplied IObbActionListener to inform
1272     * it of the terminal state of the call.
1273     */
1274    public void mountObb(String rawPath, String canonicalPath, String key,
1275            IObbActionListener token, int nonce) throws RemoteException;
1276
1277    /*
1278     * Mount a secure container with the specified key and owner UID. Returns an
1279     * int consistent with MountServiceResultCode
1280     */
1281    public int mountSecureContainer(String id, String key, int ownerUid) throws RemoteException;
1282
1283    /**
1284     * Mount external storage at given mount point. Returns an int consistent
1285     * with MountServiceResultCode
1286     */
1287    public int mountVolume(String mountPoint) throws RemoteException;
1288
1289    /**
1290     * Registers an IMountServiceListener for receiving async notifications.
1291     */
1292    public void registerListener(IMountServiceListener listener) throws RemoteException;
1293
1294    /*
1295     * Rename an unmounted secure container. Returns an int consistent with
1296     * MountServiceResultCode
1297     */
1298    public int renameSecureContainer(String oldId, String newId) throws RemoteException;
1299
1300    /**
1301     * Enables / disables USB mass storage. The caller should check actual
1302     * status of enabling/disabling USB mass storage via StorageEventListener.
1303     */
1304    public void setUsbMassStorageEnabled(boolean enable) throws RemoteException;
1305
1306    /**
1307     * Shuts down the MountService and gracefully unmounts all external media.
1308     * Invokes call back once the shutdown is complete.
1309     */
1310    public void shutdown(IMountShutdownObserver observer) throws RemoteException;
1311
1312    /**
1313     * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified,
1314     * any program using it will be forcibly killed to unmount the image.
1315     * MountService will call back to the supplied IObbActionListener to inform
1316     * it of the terminal state of the call.
1317     */
1318    public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce)
1319            throws RemoteException;
1320
1321    /*
1322     * Unount a secure container. Returns an int consistent with
1323     * MountServiceResultCode
1324     */
1325    public int unmountSecureContainer(String id, boolean force) throws RemoteException;
1326
1327    /**
1328     * Safely unmount external storage at given mount point. The unmount is an
1329     * asynchronous operation. Applications should register StorageEventListener
1330     * for storage related status changes.
1331     * @param mountPoint the mount point
1332     * @param force whether or not to forcefully unmount it (e.g. even if programs are using this
1333     *     data currently)
1334     * @param removeEncryption whether or not encryption mapping should be removed from the volume.
1335     *     This value implies {@code force}.
1336     */
1337    public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption)
1338            throws RemoteException;
1339
1340    /**
1341     * Unregisters an IMountServiceListener
1342     */
1343    public void unregisterListener(IMountServiceListener listener) throws RemoteException;
1344
1345    /**
1346     * Returns whether or not the external storage is emulated.
1347     */
1348    public boolean isExternalStorageEmulated() throws RemoteException;
1349
1350    /** The volume is not encrypted. */
1351    static final int ENCRYPTION_STATE_NONE = 1;
1352    /** The volume has been encrypted succesfully. */
1353    static final int ENCRYPTION_STATE_OK = 0;
1354    /** The volume is in a bad state. */
1355    static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1;
1356    /** The volume is in a bad state - partially encrypted. Data is likely irrecoverable. */
1357    static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2;
1358
1359    /**
1360     * Determines the encryption state of the volume.
1361     * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values.
1362     */
1363    public int getEncryptionState() throws RemoteException;
1364
1365    /**
1366     * Decrypts any encrypted volumes.
1367     */
1368    public int decryptStorage(String password) throws RemoteException;
1369
1370    /**
1371     * Encrypts storage.
1372     */
1373    public int encryptStorage(String password) throws RemoteException;
1374
1375    /**
1376     * Changes the encryption password.
1377     */
1378    public int changeEncryptionPassword(String password) throws RemoteException;
1379
1380    /**
1381     * Verify the encryption password against the stored volume.  This method
1382     * may only be called by the system process.
1383     */
1384    public int verifyEncryptionPassword(String password) throws RemoteException;
1385
1386    /**
1387     * Returns list of all mountable volumes.
1388     */
1389    public StorageVolume[] getVolumeList() throws RemoteException;
1390
1391    /**
1392     * Gets the path on the filesystem for the ASEC container itself.
1393     *
1394     * @param cid ASEC container ID
1395     * @return path to filesystem or {@code null} if it's not found
1396     * @throws RemoteException
1397     */
1398    public String getSecureContainerFilesystemPath(String cid) throws RemoteException;
1399
1400    /*
1401     * Fix permissions in a container which has just been created and populated.
1402     * Returns an int consistent with MountServiceResultCode
1403     */
1404    public int fixPermissionsSecureContainer(String id, int gid, String filename)
1405            throws RemoteException;
1406
1407    /**
1408     * Ensure that all directories along given path exist, creating parent
1409     * directories as needed. Validates that given path is absolute and that it
1410     * contains no relative "." or ".." paths or symlinks. Also ensures that
1411     * path belongs to a volume managed by vold, and that path is either
1412     * external storage data or OBB directory belonging to calling app.
1413     */
1414    public int mkdirs(String callingPkg, String path) throws RemoteException;
1415}
1416