1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.os.storage; 18 19 import android.os.Binder; 20 import android.os.IBinder; 21 import android.os.IInterface; 22 import android.os.Parcel; 23 import 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 */ 33 public 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 Proxy(IBinder remote)39 Proxy(IBinder remote) { 40 mRemote = remote; 41 } 42 asBinder()43 public IBinder asBinder() { 44 return mRemote; 45 } 46 getInterfaceDescriptor()47 public String getInterfaceDescriptor() { 48 return DESCRIPTOR; 49 } 50 51 /** 52 * Registers an IMountServiceListener for receiving async 53 * notifications. 54 */ registerListener(IMountServiceListener listener)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 */ unregisterListener(IMountServiceListener listener)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 */ isUsbMassStorageConnected()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 */ setUsbMassStorageEnabled(boolean enable)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 */ isUsbMassStorageEnabled()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 */ mountVolume(String mountPoint)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 */ unmountVolume(String mountPoint, boolean force, boolean removeEncryption)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 */ formatVolume(String mountPoint)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 */ getStorageUsers(String path)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 */ getVolumeState(String mountPoint)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 */ createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid, boolean external)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 */ destroySecureContainer(String id, boolean force)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 */ finalizeSecureContainer(String id)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 */ mountSecureContainer(String id, String key, int ownerUid, boolean readOnly)324 public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly) 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 _data.writeInt(readOnly ? 1 : 0); 335 mRemote.transact(Stub.TRANSACTION_mountSecureContainer, _data, _reply, 0); 336 _reply.readException(); 337 _result = _reply.readInt(); 338 } finally { 339 _reply.recycle(); 340 _data.recycle(); 341 } 342 return _result; 343 } 344 345 /* 346 * Unount a secure container. Returns an int consistent with 347 * MountServiceResultCode 348 */ unmountSecureContainer(String id, boolean force)349 public int unmountSecureContainer(String id, boolean force) throws RemoteException { 350 Parcel _data = Parcel.obtain(); 351 Parcel _reply = Parcel.obtain(); 352 int _result; 353 try { 354 _data.writeInterfaceToken(DESCRIPTOR); 355 _data.writeString(id); 356 _data.writeInt((force ? 1 : 0)); 357 mRemote.transact(Stub.TRANSACTION_unmountSecureContainer, _data, _reply, 0); 358 _reply.readException(); 359 _result = _reply.readInt(); 360 } finally { 361 _reply.recycle(); 362 _data.recycle(); 363 } 364 return _result; 365 } 366 367 /* 368 * Returns true if the specified container is mounted 369 */ isSecureContainerMounted(String id)370 public boolean isSecureContainerMounted(String id) throws RemoteException { 371 Parcel _data = Parcel.obtain(); 372 Parcel _reply = Parcel.obtain(); 373 boolean _result; 374 try { 375 _data.writeInterfaceToken(DESCRIPTOR); 376 _data.writeString(id); 377 mRemote.transact(Stub.TRANSACTION_isSecureContainerMounted, _data, _reply, 0); 378 _reply.readException(); 379 _result = 0 != _reply.readInt(); 380 } finally { 381 _reply.recycle(); 382 _data.recycle(); 383 } 384 return _result; 385 } 386 387 /* 388 * Rename an unmounted secure container. Returns an int consistent 389 * with MountServiceResultCode 390 */ renameSecureContainer(String oldId, String newId)391 public int renameSecureContainer(String oldId, String newId) throws RemoteException { 392 Parcel _data = Parcel.obtain(); 393 Parcel _reply = Parcel.obtain(); 394 int _result; 395 try { 396 _data.writeInterfaceToken(DESCRIPTOR); 397 _data.writeString(oldId); 398 _data.writeString(newId); 399 mRemote.transact(Stub.TRANSACTION_renameSecureContainer, _data, _reply, 0); 400 _reply.readException(); 401 _result = _reply.readInt(); 402 } finally { 403 _reply.recycle(); 404 _data.recycle(); 405 } 406 return _result; 407 } 408 409 /* 410 * Returns the filesystem path of a mounted secure container. 411 */ getSecureContainerPath(String id)412 public String getSecureContainerPath(String id) throws RemoteException { 413 Parcel _data = Parcel.obtain(); 414 Parcel _reply = Parcel.obtain(); 415 String _result; 416 try { 417 _data.writeInterfaceToken(DESCRIPTOR); 418 _data.writeString(id); 419 mRemote.transact(Stub.TRANSACTION_getSecureContainerPath, _data, _reply, 0); 420 _reply.readException(); 421 _result = _reply.readString(); 422 } finally { 423 _reply.recycle(); 424 _data.recycle(); 425 } 426 return _result; 427 } 428 429 /** 430 * Gets an Array of currently known secure container IDs 431 */ getSecureContainerList()432 public String[] getSecureContainerList() throws RemoteException { 433 Parcel _data = Parcel.obtain(); 434 Parcel _reply = Parcel.obtain(); 435 String[] _result; 436 try { 437 _data.writeInterfaceToken(DESCRIPTOR); 438 mRemote.transact(Stub.TRANSACTION_getSecureContainerList, _data, _reply, 0); 439 _reply.readException(); 440 _result = _reply.createStringArray(); 441 } finally { 442 _reply.recycle(); 443 _data.recycle(); 444 } 445 return _result; 446 } 447 448 /** 449 * Shuts down the MountService and gracefully unmounts all external 450 * media. Invokes call back once the shutdown is complete. 451 */ shutdown(IMountShutdownObserver observer)452 public void shutdown(IMountShutdownObserver observer) 453 throws RemoteException { 454 Parcel _data = Parcel.obtain(); 455 Parcel _reply = Parcel.obtain(); 456 try { 457 _data.writeInterfaceToken(DESCRIPTOR); 458 _data.writeStrongBinder((observer != null ? observer.asBinder() : null)); 459 mRemote.transact(Stub.TRANSACTION_shutdown, _data, _reply, 0); 460 _reply.readException(); 461 } finally { 462 _reply.recycle(); 463 _data.recycle(); 464 } 465 } 466 467 /** 468 * Call into MountService by PackageManager to notify that its done 469 * processing the media status update request. 470 */ finishMediaUpdate()471 public void finishMediaUpdate() throws RemoteException { 472 Parcel _data = Parcel.obtain(); 473 Parcel _reply = Parcel.obtain(); 474 try { 475 _data.writeInterfaceToken(DESCRIPTOR); 476 mRemote.transact(Stub.TRANSACTION_finishMediaUpdate, _data, _reply, 0); 477 _reply.readException(); 478 } finally { 479 _reply.recycle(); 480 _data.recycle(); 481 } 482 } 483 484 /** 485 * Mounts an Opaque Binary Blob (OBB) with the specified decryption 486 * key and only allows the calling process's UID access to the 487 * contents. MountService will call back to the supplied 488 * IObbActionListener to inform it of the terminal state of the 489 * call. 490 */ mountObb(String rawPath, String canonicalPath, String key, IObbActionListener token, int nonce)491 public void mountObb(String rawPath, String canonicalPath, String key, 492 IObbActionListener token, int nonce) throws RemoteException { 493 Parcel _data = Parcel.obtain(); 494 Parcel _reply = Parcel.obtain(); 495 try { 496 _data.writeInterfaceToken(DESCRIPTOR); 497 _data.writeString(rawPath); 498 _data.writeString(canonicalPath); 499 _data.writeString(key); 500 _data.writeStrongBinder((token != null ? token.asBinder() : null)); 501 _data.writeInt(nonce); 502 mRemote.transact(Stub.TRANSACTION_mountObb, _data, _reply, 0); 503 _reply.readException(); 504 } finally { 505 _reply.recycle(); 506 _data.recycle(); 507 } 508 } 509 510 /** 511 * Unmounts an Opaque Binary Blob (OBB). When the force flag is 512 * specified, any program using it will be forcibly killed to 513 * unmount the image. MountService will call back to the supplied 514 * IObbActionListener to inform it of the terminal state of the 515 * call. 516 */ unmountObb( String rawPath, boolean force, IObbActionListener token, int nonce)517 public void unmountObb( 518 String rawPath, boolean force, IObbActionListener token, int nonce) 519 throws RemoteException { 520 Parcel _data = Parcel.obtain(); 521 Parcel _reply = Parcel.obtain(); 522 try { 523 _data.writeInterfaceToken(DESCRIPTOR); 524 _data.writeString(rawPath); 525 _data.writeInt((force ? 1 : 0)); 526 _data.writeStrongBinder((token != null ? token.asBinder() : null)); 527 _data.writeInt(nonce); 528 mRemote.transact(Stub.TRANSACTION_unmountObb, _data, _reply, 0); 529 _reply.readException(); 530 } finally { 531 _reply.recycle(); 532 _data.recycle(); 533 } 534 } 535 536 /** 537 * Checks whether the specified Opaque Binary Blob (OBB) is mounted 538 * somewhere. 539 */ isObbMounted(String rawPath)540 public boolean isObbMounted(String rawPath) throws RemoteException { 541 Parcel _data = Parcel.obtain(); 542 Parcel _reply = Parcel.obtain(); 543 boolean _result; 544 try { 545 _data.writeInterfaceToken(DESCRIPTOR); 546 _data.writeString(rawPath); 547 mRemote.transact(Stub.TRANSACTION_isObbMounted, _data, _reply, 0); 548 _reply.readException(); 549 _result = 0 != _reply.readInt(); 550 } finally { 551 _reply.recycle(); 552 _data.recycle(); 553 } 554 return _result; 555 } 556 557 /** 558 * Gets the path to the mounted Opaque Binary Blob (OBB). 559 */ getMountedObbPath(String rawPath)560 public String getMountedObbPath(String rawPath) throws RemoteException { 561 Parcel _data = Parcel.obtain(); 562 Parcel _reply = Parcel.obtain(); 563 String _result; 564 try { 565 _data.writeInterfaceToken(DESCRIPTOR); 566 _data.writeString(rawPath); 567 mRemote.transact(Stub.TRANSACTION_getMountedObbPath, _data, _reply, 0); 568 _reply.readException(); 569 _result = _reply.readString(); 570 } finally { 571 _reply.recycle(); 572 _data.recycle(); 573 } 574 return _result; 575 } 576 577 /** 578 * Returns whether the external storage is emulated. 579 */ isExternalStorageEmulated()580 public boolean isExternalStorageEmulated() throws RemoteException { 581 Parcel _data = Parcel.obtain(); 582 Parcel _reply = Parcel.obtain(); 583 boolean _result; 584 try { 585 _data.writeInterfaceToken(DESCRIPTOR); 586 mRemote.transact(Stub.TRANSACTION_isExternalStorageEmulated, _data, _reply, 0); 587 _reply.readException(); 588 _result = 0 != _reply.readInt(); 589 } finally { 590 _reply.recycle(); 591 _data.recycle(); 592 } 593 return _result; 594 } 595 getEncryptionState()596 public int getEncryptionState() throws RemoteException { 597 Parcel _data = Parcel.obtain(); 598 Parcel _reply = Parcel.obtain(); 599 int _result; 600 try { 601 _data.writeInterfaceToken(DESCRIPTOR); 602 mRemote.transact(Stub.TRANSACTION_getEncryptionState, _data, _reply, 0); 603 _reply.readException(); 604 _result = _reply.readInt(); 605 } finally { 606 _reply.recycle(); 607 _data.recycle(); 608 } 609 return _result; 610 } 611 decryptStorage(String password)612 public int decryptStorage(String password) throws RemoteException { 613 Parcel _data = Parcel.obtain(); 614 Parcel _reply = Parcel.obtain(); 615 int _result; 616 try { 617 _data.writeInterfaceToken(DESCRIPTOR); 618 _data.writeString(password); 619 mRemote.transact(Stub.TRANSACTION_decryptStorage, _data, _reply, 0); 620 _reply.readException(); 621 _result = _reply.readInt(); 622 } finally { 623 _reply.recycle(); 624 _data.recycle(); 625 } 626 return _result; 627 } 628 encryptStorage(int type, String password)629 public int encryptStorage(int type, String password) throws RemoteException { 630 Parcel _data = Parcel.obtain(); 631 Parcel _reply = Parcel.obtain(); 632 int _result; 633 try { 634 _data.writeInterfaceToken(DESCRIPTOR); 635 _data.writeInt(type); 636 _data.writeString(password); 637 mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0); 638 _reply.readException(); 639 _result = _reply.readInt(); 640 } finally { 641 _reply.recycle(); 642 _data.recycle(); 643 } 644 return _result; 645 } 646 changeEncryptionPassword(int type, String password)647 public int changeEncryptionPassword(int type, String password) throws RemoteException { 648 Parcel _data = Parcel.obtain(); 649 Parcel _reply = Parcel.obtain(); 650 int _result; 651 try { 652 _data.writeInterfaceToken(DESCRIPTOR); 653 _data.writeInt(type); 654 _data.writeString(password); 655 mRemote.transact(Stub.TRANSACTION_changeEncryptionPassword, _data, _reply, 0); 656 _reply.readException(); 657 _result = _reply.readInt(); 658 } finally { 659 _reply.recycle(); 660 _data.recycle(); 661 } 662 return _result; 663 } 664 665 @Override verifyEncryptionPassword(String password)666 public int verifyEncryptionPassword(String password) throws RemoteException { 667 Parcel _data = Parcel.obtain(); 668 Parcel _reply = Parcel.obtain(); 669 int _result; 670 try { 671 _data.writeInterfaceToken(DESCRIPTOR); 672 _data.writeString(password); 673 mRemote.transact(Stub.TRANSACTION_verifyEncryptionPassword, _data, _reply, 0); 674 _reply.readException(); 675 _result = _reply.readInt(); 676 } finally { 677 _reply.recycle(); 678 _data.recycle(); 679 } 680 return _result; 681 } 682 getPasswordType()683 public int getPasswordType() throws RemoteException { 684 Parcel _data = Parcel.obtain(); 685 Parcel _reply = Parcel.obtain(); 686 int _result; 687 try { 688 _data.writeInterfaceToken(DESCRIPTOR); 689 mRemote.transact(Stub.TRANSACTION_getPasswordType, _data, _reply, 0); 690 _reply.readException(); 691 _result = _reply.readInt(); 692 } finally { 693 _reply.recycle(); 694 _data.recycle(); 695 } 696 return _result; 697 } 698 getPassword()699 public String getPassword() throws RemoteException { 700 Parcel _data = Parcel.obtain(); 701 Parcel _reply = Parcel.obtain(); 702 String _result; 703 try { 704 _data.writeInterfaceToken(DESCRIPTOR); 705 mRemote.transact(Stub.TRANSACTION_getPassword, _data, _reply, 0); 706 _reply.readException(); 707 _result = _reply.readString(); 708 } finally { 709 _reply.recycle(); 710 _data.recycle(); 711 } 712 return _result; 713 } 714 clearPassword()715 public void clearPassword() throws RemoteException { 716 Parcel _data = Parcel.obtain(); 717 Parcel _reply = Parcel.obtain(); 718 try { 719 _data.writeInterfaceToken(DESCRIPTOR); 720 mRemote.transact(Stub.TRANSACTION_clearPassword, _data, _reply, IBinder.FLAG_ONEWAY); 721 _reply.readException(); 722 } finally { 723 _reply.recycle(); 724 _data.recycle(); 725 } 726 } 727 setField(String field, String data)728 public void setField(String field, String data) throws RemoteException { 729 Parcel _data = Parcel.obtain(); 730 Parcel _reply = Parcel.obtain(); 731 try { 732 _data.writeInterfaceToken(DESCRIPTOR); 733 _data.writeString(field); 734 _data.writeString(data); 735 mRemote.transact(Stub.TRANSACTION_setField, _data, _reply, IBinder.FLAG_ONEWAY); 736 _reply.readException(); 737 } finally { 738 _reply.recycle(); 739 _data.recycle(); 740 } 741 } 742 getField(String field)743 public String getField(String field) throws RemoteException { 744 Parcel _data = Parcel.obtain(); 745 Parcel _reply = Parcel.obtain(); 746 String _result; 747 try { 748 _data.writeInterfaceToken(DESCRIPTOR); 749 _data.writeString(field); 750 mRemote.transact(Stub.TRANSACTION_getField, _data, _reply, 0); 751 _reply.readException(); 752 _result = _reply.readString(); 753 } finally { 754 _reply.recycle(); 755 _data.recycle(); 756 } 757 return _result; 758 } 759 getVolumeList()760 public StorageVolume[] getVolumeList() throws RemoteException { 761 Parcel _data = Parcel.obtain(); 762 Parcel _reply = Parcel.obtain(); 763 StorageVolume[] _result; 764 try { 765 _data.writeInterfaceToken(DESCRIPTOR); 766 mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0); 767 _reply.readException(); 768 _result = _reply.createTypedArray(StorageVolume.CREATOR); 769 } finally { 770 _reply.recycle(); 771 _data.recycle(); 772 } 773 return _result; 774 } 775 776 /* 777 * Returns the filesystem path of a mounted secure container. 778 */ getSecureContainerFilesystemPath(String id)779 public String getSecureContainerFilesystemPath(String id) throws RemoteException { 780 Parcel _data = Parcel.obtain(); 781 Parcel _reply = Parcel.obtain(); 782 String _result; 783 try { 784 _data.writeInterfaceToken(DESCRIPTOR); 785 _data.writeString(id); 786 mRemote.transact(Stub.TRANSACTION_getSecureContainerFilesystemPath, _data, _reply, 0); 787 _reply.readException(); 788 _result = _reply.readString(); 789 } finally { 790 _reply.recycle(); 791 _data.recycle(); 792 } 793 return _result; 794 } 795 796 /** 797 * Fix permissions in a container which has just been created and 798 * populated. Returns an int consistent with MountServiceResultCode 799 */ fixPermissionsSecureContainer(String id, int gid, String filename)800 public int fixPermissionsSecureContainer(String id, int gid, String filename) 801 throws RemoteException { 802 Parcel _data = Parcel.obtain(); 803 Parcel _reply = Parcel.obtain(); 804 int _result; 805 try { 806 _data.writeInterfaceToken(DESCRIPTOR); 807 _data.writeString(id); 808 _data.writeInt(gid); 809 _data.writeString(filename); 810 mRemote.transact(Stub.TRANSACTION_fixPermissionsSecureContainer, _data, _reply, 0); 811 _reply.readException(); 812 _result = _reply.readInt(); 813 } finally { 814 _reply.recycle(); 815 _data.recycle(); 816 } 817 return _result; 818 } 819 820 @Override mkdirs(String callingPkg, String path)821 public int mkdirs(String callingPkg, String path) throws RemoteException { 822 Parcel _data = Parcel.obtain(); 823 Parcel _reply = Parcel.obtain(); 824 int _result; 825 try { 826 _data.writeInterfaceToken(DESCRIPTOR); 827 _data.writeString(callingPkg); 828 _data.writeString(path); 829 mRemote.transact(Stub.TRANSACTION_mkdirs, _data, _reply, 0); 830 _reply.readException(); 831 _result = _reply.readInt(); 832 } finally { 833 _reply.recycle(); 834 _data.recycle(); 835 } 836 return _result; 837 } 838 839 @Override resizeSecureContainer(String id, int sizeMb, String key)840 public int resizeSecureContainer(String id, int sizeMb, String key) 841 throws RemoteException { 842 Parcel _data = Parcel.obtain(); 843 Parcel _reply = Parcel.obtain(); 844 int _result; 845 try { 846 _data.writeInterfaceToken(DESCRIPTOR); 847 _data.writeString(id); 848 _data.writeInt(sizeMb); 849 _data.writeString(key); 850 mRemote.transact(Stub.TRANSACTION_resizeSecureContainer, _data, _reply, 0); 851 _reply.readException(); 852 _result = _reply.readInt(); 853 } finally { 854 _reply.recycle(); 855 _data.recycle(); 856 } 857 return _result; 858 } 859 860 @Override lastMaintenance()861 public long lastMaintenance() throws RemoteException { 862 Parcel _data = Parcel.obtain(); 863 Parcel _reply = Parcel.obtain(); 864 long _result; 865 try { 866 _data.writeInterfaceToken(DESCRIPTOR); 867 mRemote.transact(Stub.TRANSACTION_lastMaintenance, _data, _reply, 0); 868 _reply.readException(); 869 _result = _reply.readLong(); 870 } finally { 871 _reply.recycle(); 872 _data.recycle(); 873 } 874 return _result; 875 } 876 877 @Override runMaintenance()878 public void runMaintenance() throws RemoteException { 879 Parcel _data = Parcel.obtain(); 880 Parcel _reply = Parcel.obtain(); 881 try { 882 _data.writeInterfaceToken(DESCRIPTOR); 883 mRemote.transact(Stub.TRANSACTION_runMaintenance, _data, _reply, 0); 884 _reply.readException(); 885 } finally { 886 _reply.recycle(); 887 _data.recycle(); 888 } 889 return; 890 } 891 } 892 893 private static final String DESCRIPTOR = "IMountService"; 894 895 static final int TRANSACTION_registerListener = IBinder.FIRST_CALL_TRANSACTION + 0; 896 897 static final int TRANSACTION_unregisterListener = IBinder.FIRST_CALL_TRANSACTION + 1; 898 899 static final int TRANSACTION_isUsbMassStorageConnected = IBinder.FIRST_CALL_TRANSACTION + 2; 900 901 static final int TRANSACTION_setUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 3; 902 903 static final int TRANSACTION_isUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 4; 904 905 static final int TRANSACTION_mountVolume = IBinder.FIRST_CALL_TRANSACTION + 5; 906 907 static final int TRANSACTION_unmountVolume = IBinder.FIRST_CALL_TRANSACTION + 6; 908 909 static final int TRANSACTION_formatVolume = IBinder.FIRST_CALL_TRANSACTION + 7; 910 911 static final int TRANSACTION_getStorageUsers = IBinder.FIRST_CALL_TRANSACTION + 8; 912 913 static final int TRANSACTION_getVolumeState = IBinder.FIRST_CALL_TRANSACTION + 9; 914 915 static final int TRANSACTION_createSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 10; 916 917 static final int TRANSACTION_finalizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 11; 918 919 static final int TRANSACTION_destroySecureContainer = IBinder.FIRST_CALL_TRANSACTION + 12; 920 921 static final int TRANSACTION_mountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 13; 922 923 static final int TRANSACTION_unmountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 14; 924 925 static final int TRANSACTION_isSecureContainerMounted = IBinder.FIRST_CALL_TRANSACTION + 15; 926 927 static final int TRANSACTION_renameSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 16; 928 929 static final int TRANSACTION_getSecureContainerPath = IBinder.FIRST_CALL_TRANSACTION + 17; 930 931 static final int TRANSACTION_getSecureContainerList = IBinder.FIRST_CALL_TRANSACTION + 18; 932 933 static final int TRANSACTION_shutdown = IBinder.FIRST_CALL_TRANSACTION + 19; 934 935 static final int TRANSACTION_finishMediaUpdate = IBinder.FIRST_CALL_TRANSACTION + 20; 936 937 static final int TRANSACTION_mountObb = IBinder.FIRST_CALL_TRANSACTION + 21; 938 939 static final int TRANSACTION_unmountObb = IBinder.FIRST_CALL_TRANSACTION + 22; 940 941 static final int TRANSACTION_isObbMounted = IBinder.FIRST_CALL_TRANSACTION + 23; 942 943 static final int TRANSACTION_getMountedObbPath = IBinder.FIRST_CALL_TRANSACTION + 24; 944 945 static final int TRANSACTION_isExternalStorageEmulated = IBinder.FIRST_CALL_TRANSACTION + 25; 946 947 static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26; 948 949 static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27; 950 951 static final int TRANSACTION_changeEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 28; 952 953 static final int TRANSACTION_getVolumeList = IBinder.FIRST_CALL_TRANSACTION + 29; 954 955 static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30; 956 957 static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31; 958 959 static final int TRANSACTION_verifyEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 32; 960 961 static final int TRANSACTION_fixPermissionsSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 33; 962 963 static final int TRANSACTION_mkdirs = IBinder.FIRST_CALL_TRANSACTION + 34; 964 965 static final int TRANSACTION_getPasswordType = IBinder.FIRST_CALL_TRANSACTION + 35; 966 967 static final int TRANSACTION_getPassword = IBinder.FIRST_CALL_TRANSACTION + 36; 968 969 static final int TRANSACTION_clearPassword = IBinder.FIRST_CALL_TRANSACTION + 37; 970 971 static final int TRANSACTION_setField = IBinder.FIRST_CALL_TRANSACTION + 38; 972 973 static final int TRANSACTION_getField = IBinder.FIRST_CALL_TRANSACTION + 39; 974 975 static final int TRANSACTION_resizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 40; 976 977 static final int TRANSACTION_lastMaintenance = IBinder.FIRST_CALL_TRANSACTION + 41; 978 979 static final int TRANSACTION_runMaintenance = IBinder.FIRST_CALL_TRANSACTION + 42; 980 981 /** 982 * Cast an IBinder object into an IMountService interface, generating a 983 * proxy if needed. 984 */ asInterface(IBinder obj)985 public static IMountService asInterface(IBinder obj) { 986 if (obj == null) { 987 return null; 988 } 989 IInterface iin = obj.queryLocalInterface(DESCRIPTOR); 990 if (iin != null && iin instanceof IMountService) { 991 return (IMountService) iin; 992 } 993 return new IMountService.Stub.Proxy(obj); 994 } 995 996 /** Construct the stub at attach it to the interface. */ Stub()997 public Stub() { 998 attachInterface(this, DESCRIPTOR); 999 } 1000 asBinder()1001 public IBinder asBinder() { 1002 return this; 1003 } 1004 1005 @Override onTransact(int code, Parcel data, Parcel reply, int flags)1006 public boolean onTransact(int code, Parcel data, Parcel reply, 1007 int flags) throws RemoteException { 1008 switch (code) { 1009 case INTERFACE_TRANSACTION: { 1010 reply.writeString(DESCRIPTOR); 1011 return true; 1012 } 1013 case TRANSACTION_registerListener: { 1014 data.enforceInterface(DESCRIPTOR); 1015 IMountServiceListener listener; 1016 listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder()); 1017 registerListener(listener); 1018 reply.writeNoException(); 1019 return true; 1020 } 1021 case TRANSACTION_unregisterListener: { 1022 data.enforceInterface(DESCRIPTOR); 1023 IMountServiceListener listener; 1024 listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder()); 1025 unregisterListener(listener); 1026 reply.writeNoException(); 1027 return true; 1028 } 1029 case TRANSACTION_isUsbMassStorageConnected: { 1030 data.enforceInterface(DESCRIPTOR); 1031 boolean result = isUsbMassStorageConnected(); 1032 reply.writeNoException(); 1033 reply.writeInt((result ? 1 : 0)); 1034 return true; 1035 } 1036 case TRANSACTION_setUsbMassStorageEnabled: { 1037 data.enforceInterface(DESCRIPTOR); 1038 boolean enable; 1039 enable = 0 != data.readInt(); 1040 setUsbMassStorageEnabled(enable); 1041 reply.writeNoException(); 1042 return true; 1043 } 1044 case TRANSACTION_isUsbMassStorageEnabled: { 1045 data.enforceInterface(DESCRIPTOR); 1046 boolean result = isUsbMassStorageEnabled(); 1047 reply.writeNoException(); 1048 reply.writeInt((result ? 1 : 0)); 1049 return true; 1050 } 1051 case TRANSACTION_mountVolume: { 1052 data.enforceInterface(DESCRIPTOR); 1053 String mountPoint; 1054 mountPoint = data.readString(); 1055 int resultCode = mountVolume(mountPoint); 1056 reply.writeNoException(); 1057 reply.writeInt(resultCode); 1058 return true; 1059 } 1060 case TRANSACTION_unmountVolume: { 1061 data.enforceInterface(DESCRIPTOR); 1062 String mountPoint; 1063 mountPoint = data.readString(); 1064 boolean force = 0 != data.readInt(); 1065 boolean removeEncrypt = 0 != data.readInt(); 1066 unmountVolume(mountPoint, force, removeEncrypt); 1067 reply.writeNoException(); 1068 return true; 1069 } 1070 case TRANSACTION_formatVolume: { 1071 data.enforceInterface(DESCRIPTOR); 1072 String mountPoint; 1073 mountPoint = data.readString(); 1074 int result = formatVolume(mountPoint); 1075 reply.writeNoException(); 1076 reply.writeInt(result); 1077 return true; 1078 } 1079 case TRANSACTION_getStorageUsers: { 1080 data.enforceInterface(DESCRIPTOR); 1081 String path; 1082 path = data.readString(); 1083 int[] pids = getStorageUsers(path); 1084 reply.writeNoException(); 1085 reply.writeIntArray(pids); 1086 return true; 1087 } 1088 case TRANSACTION_getVolumeState: { 1089 data.enforceInterface(DESCRIPTOR); 1090 String mountPoint; 1091 mountPoint = data.readString(); 1092 String state = getVolumeState(mountPoint); 1093 reply.writeNoException(); 1094 reply.writeString(state); 1095 return true; 1096 } 1097 case TRANSACTION_createSecureContainer: { 1098 data.enforceInterface(DESCRIPTOR); 1099 String id; 1100 id = data.readString(); 1101 int sizeMb; 1102 sizeMb = data.readInt(); 1103 String fstype; 1104 fstype = data.readString(); 1105 String key; 1106 key = data.readString(); 1107 int ownerUid; 1108 ownerUid = data.readInt(); 1109 boolean external; 1110 external = 0 != data.readInt(); 1111 int resultCode = createSecureContainer(id, sizeMb, fstype, key, ownerUid, 1112 external); 1113 reply.writeNoException(); 1114 reply.writeInt(resultCode); 1115 return true; 1116 } 1117 case TRANSACTION_finalizeSecureContainer: { 1118 data.enforceInterface(DESCRIPTOR); 1119 String id; 1120 id = data.readString(); 1121 int resultCode = finalizeSecureContainer(id); 1122 reply.writeNoException(); 1123 reply.writeInt(resultCode); 1124 return true; 1125 } 1126 case TRANSACTION_destroySecureContainer: { 1127 data.enforceInterface(DESCRIPTOR); 1128 String id; 1129 id = data.readString(); 1130 boolean force; 1131 force = 0 != data.readInt(); 1132 int resultCode = destroySecureContainer(id, force); 1133 reply.writeNoException(); 1134 reply.writeInt(resultCode); 1135 return true; 1136 } 1137 case TRANSACTION_mountSecureContainer: { 1138 data.enforceInterface(DESCRIPTOR); 1139 String id; 1140 id = data.readString(); 1141 String key; 1142 key = data.readString(); 1143 int ownerUid; 1144 ownerUid = data.readInt(); 1145 boolean readOnly; 1146 readOnly = data.readInt() != 0; 1147 int resultCode = mountSecureContainer(id, key, ownerUid, readOnly); 1148 reply.writeNoException(); 1149 reply.writeInt(resultCode); 1150 return true; 1151 } 1152 case TRANSACTION_unmountSecureContainer: { 1153 data.enforceInterface(DESCRIPTOR); 1154 String id; 1155 id = data.readString(); 1156 boolean force; 1157 force = 0 != data.readInt(); 1158 int resultCode = unmountSecureContainer(id, force); 1159 reply.writeNoException(); 1160 reply.writeInt(resultCode); 1161 return true; 1162 } 1163 case TRANSACTION_isSecureContainerMounted: { 1164 data.enforceInterface(DESCRIPTOR); 1165 String id; 1166 id = data.readString(); 1167 boolean status = isSecureContainerMounted(id); 1168 reply.writeNoException(); 1169 reply.writeInt((status ? 1 : 0)); 1170 return true; 1171 } 1172 case TRANSACTION_renameSecureContainer: { 1173 data.enforceInterface(DESCRIPTOR); 1174 String oldId; 1175 oldId = data.readString(); 1176 String newId; 1177 newId = data.readString(); 1178 int resultCode = renameSecureContainer(oldId, newId); 1179 reply.writeNoException(); 1180 reply.writeInt(resultCode); 1181 return true; 1182 } 1183 case TRANSACTION_getSecureContainerPath: { 1184 data.enforceInterface(DESCRIPTOR); 1185 String id; 1186 id = data.readString(); 1187 String path = getSecureContainerPath(id); 1188 reply.writeNoException(); 1189 reply.writeString(path); 1190 return true; 1191 } 1192 case TRANSACTION_getSecureContainerList: { 1193 data.enforceInterface(DESCRIPTOR); 1194 String[] ids = getSecureContainerList(); 1195 reply.writeNoException(); 1196 reply.writeStringArray(ids); 1197 return true; 1198 } 1199 case TRANSACTION_shutdown: { 1200 data.enforceInterface(DESCRIPTOR); 1201 IMountShutdownObserver observer; 1202 observer = IMountShutdownObserver.Stub.asInterface(data 1203 .readStrongBinder()); 1204 shutdown(observer); 1205 reply.writeNoException(); 1206 return true; 1207 } 1208 case TRANSACTION_finishMediaUpdate: { 1209 data.enforceInterface(DESCRIPTOR); 1210 finishMediaUpdate(); 1211 reply.writeNoException(); 1212 return true; 1213 } 1214 case TRANSACTION_mountObb: { 1215 data.enforceInterface(DESCRIPTOR); 1216 final String rawPath = data.readString(); 1217 final String canonicalPath = data.readString(); 1218 final String key = data.readString(); 1219 IObbActionListener observer; 1220 observer = IObbActionListener.Stub.asInterface(data.readStrongBinder()); 1221 int nonce; 1222 nonce = data.readInt(); 1223 mountObb(rawPath, canonicalPath, key, observer, nonce); 1224 reply.writeNoException(); 1225 return true; 1226 } 1227 case TRANSACTION_unmountObb: { 1228 data.enforceInterface(DESCRIPTOR); 1229 String filename; 1230 filename = data.readString(); 1231 boolean force; 1232 force = 0 != data.readInt(); 1233 IObbActionListener observer; 1234 observer = IObbActionListener.Stub.asInterface(data.readStrongBinder()); 1235 int nonce; 1236 nonce = data.readInt(); 1237 unmountObb(filename, force, observer, nonce); 1238 reply.writeNoException(); 1239 return true; 1240 } 1241 case TRANSACTION_isObbMounted: { 1242 data.enforceInterface(DESCRIPTOR); 1243 String filename; 1244 filename = data.readString(); 1245 boolean status = isObbMounted(filename); 1246 reply.writeNoException(); 1247 reply.writeInt((status ? 1 : 0)); 1248 return true; 1249 } 1250 case TRANSACTION_getMountedObbPath: { 1251 data.enforceInterface(DESCRIPTOR); 1252 String filename; 1253 filename = data.readString(); 1254 String mountedPath = getMountedObbPath(filename); 1255 reply.writeNoException(); 1256 reply.writeString(mountedPath); 1257 return true; 1258 } 1259 case TRANSACTION_isExternalStorageEmulated: { 1260 data.enforceInterface(DESCRIPTOR); 1261 boolean emulated = isExternalStorageEmulated(); 1262 reply.writeNoException(); 1263 reply.writeInt(emulated ? 1 : 0); 1264 return true; 1265 } 1266 case TRANSACTION_decryptStorage: { 1267 data.enforceInterface(DESCRIPTOR); 1268 String password = data.readString(); 1269 int result = decryptStorage(password); 1270 reply.writeNoException(); 1271 reply.writeInt(result); 1272 return true; 1273 } 1274 case TRANSACTION_encryptStorage: { 1275 data.enforceInterface(DESCRIPTOR); 1276 int type = data.readInt(); 1277 String password = data.readString(); 1278 int result = encryptStorage(type, password); 1279 reply.writeNoException(); 1280 reply.writeInt(result); 1281 return true; 1282 } 1283 case TRANSACTION_changeEncryptionPassword: { 1284 data.enforceInterface(DESCRIPTOR); 1285 int type = data.readInt(); 1286 String password = data.readString(); 1287 int result = changeEncryptionPassword(type, password); 1288 reply.writeNoException(); 1289 reply.writeInt(result); 1290 return true; 1291 } 1292 case TRANSACTION_getVolumeList: { 1293 data.enforceInterface(DESCRIPTOR); 1294 StorageVolume[] result = getVolumeList(); 1295 reply.writeNoException(); 1296 reply.writeTypedArray(result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1297 return true; 1298 } 1299 case TRANSACTION_getSecureContainerFilesystemPath: { 1300 data.enforceInterface(DESCRIPTOR); 1301 String id; 1302 id = data.readString(); 1303 String path = getSecureContainerFilesystemPath(id); 1304 reply.writeNoException(); 1305 reply.writeString(path); 1306 return true; 1307 } 1308 case TRANSACTION_getEncryptionState: { 1309 data.enforceInterface(DESCRIPTOR); 1310 int result = getEncryptionState(); 1311 reply.writeNoException(); 1312 reply.writeInt(result); 1313 return true; 1314 } 1315 case TRANSACTION_fixPermissionsSecureContainer: { 1316 data.enforceInterface(DESCRIPTOR); 1317 String id; 1318 id = data.readString(); 1319 int gid; 1320 gid = data.readInt(); 1321 String filename; 1322 filename = data.readString(); 1323 int resultCode = fixPermissionsSecureContainer(id, gid, filename); 1324 reply.writeNoException(); 1325 reply.writeInt(resultCode); 1326 return true; 1327 } 1328 case TRANSACTION_mkdirs: { 1329 data.enforceInterface(DESCRIPTOR); 1330 String callingPkg = data.readString(); 1331 String path = data.readString(); 1332 int result = mkdirs(callingPkg, path); 1333 reply.writeNoException(); 1334 reply.writeInt(result); 1335 return true; 1336 } 1337 case TRANSACTION_getPasswordType: { 1338 data.enforceInterface(DESCRIPTOR); 1339 int result = getPasswordType(); 1340 reply.writeNoException(); 1341 reply.writeInt(result); 1342 return true; 1343 } 1344 case TRANSACTION_getPassword: { 1345 data.enforceInterface(DESCRIPTOR); 1346 String result = getPassword(); 1347 reply.writeNoException(); 1348 reply.writeString(result); 1349 return true; 1350 } 1351 case TRANSACTION_clearPassword: { 1352 data.enforceInterface(DESCRIPTOR); 1353 clearPassword(); 1354 reply.writeNoException(); 1355 return true; 1356 } 1357 case TRANSACTION_setField: { 1358 data.enforceInterface(DESCRIPTOR); 1359 String field = data.readString(); 1360 String contents = data.readString(); 1361 setField(field, contents); 1362 reply.writeNoException(); 1363 return true; 1364 } 1365 case TRANSACTION_getField: { 1366 data.enforceInterface(DESCRIPTOR); 1367 String field = data.readString(); 1368 String contents = getField(field); 1369 reply.writeNoException(); 1370 reply.writeString(contents); 1371 return true; 1372 } 1373 case TRANSACTION_resizeSecureContainer: { 1374 data.enforceInterface(DESCRIPTOR); 1375 String id; 1376 id = data.readString(); 1377 int sizeMb; 1378 sizeMb = data.readInt(); 1379 String key; 1380 key = data.readString(); 1381 int resultCode = resizeSecureContainer(id, sizeMb, key); 1382 reply.writeNoException(); 1383 reply.writeInt(resultCode); 1384 return true; 1385 } 1386 case TRANSACTION_lastMaintenance: { 1387 data.enforceInterface(DESCRIPTOR); 1388 long lastMaintenance = lastMaintenance(); 1389 reply.writeNoException(); 1390 reply.writeLong(lastMaintenance); 1391 return true; 1392 } 1393 case TRANSACTION_runMaintenance: { 1394 data.enforceInterface(DESCRIPTOR); 1395 runMaintenance(); 1396 reply.writeNoException(); 1397 return true; 1398 } 1399 } 1400 return super.onTransact(code, data, reply, flags); 1401 } 1402 } 1403 1404 /* 1405 * Creates a secure container with the specified parameters. Returns an int 1406 * consistent with MountServiceResultCode 1407 */ createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid, boolean external)1408 public int createSecureContainer(String id, int sizeMb, String fstype, String key, 1409 int ownerUid, boolean external) throws RemoteException; 1410 1411 /* 1412 * Destroy a secure container, and free up all resources associated with it. 1413 * NOTE: Ensure all references are released prior to deleting. Returns an 1414 * int consistent with MountServiceResultCode 1415 */ destroySecureContainer(String id, boolean force)1416 public int destroySecureContainer(String id, boolean force) throws RemoteException; 1417 1418 /* 1419 * Finalize a container which has just been created and populated. After 1420 * finalization, the container is immutable. Returns an int consistent with 1421 * MountServiceResultCode 1422 */ finalizeSecureContainer(String id)1423 public int finalizeSecureContainer(String id) throws RemoteException; 1424 1425 /** 1426 * Call into MountService by PackageManager to notify that its done 1427 * processing the media status update request. 1428 */ finishMediaUpdate()1429 public void finishMediaUpdate() throws RemoteException; 1430 1431 /** 1432 * Format external storage given a mount point. Returns an int consistent 1433 * with MountServiceResultCode 1434 */ formatVolume(String mountPoint)1435 public int formatVolume(String mountPoint) throws RemoteException; 1436 1437 /** 1438 * Gets the path to the mounted Opaque Binary Blob (OBB). 1439 */ getMountedObbPath(String rawPath)1440 public String getMountedObbPath(String rawPath) throws RemoteException; 1441 1442 /** 1443 * Gets an Array of currently known secure container IDs 1444 */ getSecureContainerList()1445 public String[] getSecureContainerList() throws RemoteException; 1446 1447 /* 1448 * Returns the filesystem path of a mounted secure container. 1449 */ getSecureContainerPath(String id)1450 public String getSecureContainerPath(String id) throws RemoteException; 1451 1452 /** 1453 * Returns an array of pids with open files on the specified path. 1454 */ getStorageUsers(String path)1455 public int[] getStorageUsers(String path) throws RemoteException; 1456 1457 /** 1458 * Gets the state of a volume via its mountpoint. 1459 */ getVolumeState(String mountPoint)1460 public String getVolumeState(String mountPoint) throws RemoteException; 1461 1462 /** 1463 * Checks whether the specified Opaque Binary Blob (OBB) is mounted 1464 * somewhere. 1465 */ isObbMounted(String rawPath)1466 public boolean isObbMounted(String rawPath) throws RemoteException; 1467 1468 /* 1469 * Returns true if the specified container is mounted 1470 */ isSecureContainerMounted(String id)1471 public boolean isSecureContainerMounted(String id) throws RemoteException; 1472 1473 /** 1474 * Returns true if a USB mass storage host is connected 1475 */ isUsbMassStorageConnected()1476 public boolean isUsbMassStorageConnected() throws RemoteException; 1477 1478 /** 1479 * Returns true if a USB mass storage host is enabled (media is shared) 1480 */ isUsbMassStorageEnabled()1481 public boolean isUsbMassStorageEnabled() throws RemoteException; 1482 1483 /** 1484 * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and 1485 * only allows the calling process's UID access to the contents. 1486 * MountService will call back to the supplied IObbActionListener to inform 1487 * it of the terminal state of the call. 1488 */ mountObb(String rawPath, String canonicalPath, String key, IObbActionListener token, int nonce)1489 public void mountObb(String rawPath, String canonicalPath, String key, 1490 IObbActionListener token, int nonce) throws RemoteException; 1491 1492 /* 1493 * Mount a secure container with the specified key and owner UID. Returns an 1494 * int consistent with MountServiceResultCode 1495 */ mountSecureContainer(String id, String key, int ownerUid, boolean readOnly)1496 public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly) 1497 throws RemoteException; 1498 1499 /** 1500 * Mount external storage at given mount point. Returns an int consistent 1501 * with MountServiceResultCode 1502 */ mountVolume(String mountPoint)1503 public int mountVolume(String mountPoint) throws RemoteException; 1504 1505 /** 1506 * Registers an IMountServiceListener for receiving async notifications. 1507 */ registerListener(IMountServiceListener listener)1508 public void registerListener(IMountServiceListener listener) throws RemoteException; 1509 1510 /* 1511 * Rename an unmounted secure container. Returns an int consistent with 1512 * MountServiceResultCode 1513 */ renameSecureContainer(String oldId, String newId)1514 public int renameSecureContainer(String oldId, String newId) throws RemoteException; 1515 1516 /** 1517 * Enables / disables USB mass storage. The caller should check actual 1518 * status of enabling/disabling USB mass storage via StorageEventListener. 1519 */ setUsbMassStorageEnabled(boolean enable)1520 public void setUsbMassStorageEnabled(boolean enable) throws RemoteException; 1521 1522 /** 1523 * Shuts down the MountService and gracefully unmounts all external media. 1524 * Invokes call back once the shutdown is complete. 1525 */ shutdown(IMountShutdownObserver observer)1526 public void shutdown(IMountShutdownObserver observer) throws RemoteException; 1527 1528 /** 1529 * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified, 1530 * any program using it will be forcibly killed to unmount the image. 1531 * MountService will call back to the supplied IObbActionListener to inform 1532 * it of the terminal state of the call. 1533 */ unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce)1534 public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce) 1535 throws RemoteException; 1536 1537 /* 1538 * Unount a secure container. Returns an int consistent with 1539 * MountServiceResultCode 1540 */ unmountSecureContainer(String id, boolean force)1541 public int unmountSecureContainer(String id, boolean force) throws RemoteException; 1542 1543 /** 1544 * Safely unmount external storage at given mount point. The unmount is an 1545 * asynchronous operation. Applications should register StorageEventListener 1546 * for storage related status changes. 1547 * @param mountPoint the mount point 1548 * @param force whether or not to forcefully unmount it (e.g. even if programs are using this 1549 * data currently) 1550 * @param removeEncryption whether or not encryption mapping should be removed from the volume. 1551 * This value implies {@code force}. 1552 */ unmountVolume(String mountPoint, boolean force, boolean removeEncryption)1553 public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption) 1554 throws RemoteException; 1555 1556 /** 1557 * Unregisters an IMountServiceListener 1558 */ unregisterListener(IMountServiceListener listener)1559 public void unregisterListener(IMountServiceListener listener) throws RemoteException; 1560 1561 /** 1562 * Returns whether or not the external storage is emulated. 1563 */ isExternalStorageEmulated()1564 public boolean isExternalStorageEmulated() throws RemoteException; 1565 1566 /** The volume is not encrypted. */ 1567 static final int ENCRYPTION_STATE_NONE = 1; 1568 /** The volume has been encrypted succesfully. */ 1569 static final int ENCRYPTION_STATE_OK = 0; 1570 /** The volume is in a bad state.*/ 1571 static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1; 1572 /** Encryption is incomplete */ 1573 static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2; 1574 /** Encryption is incomplete and irrecoverable */ 1575 static final int ENCRYPTION_STATE_ERROR_INCONSISTENT = -3; 1576 /** Underlying data is corrupt */ 1577 static final int ENCRYPTION_STATE_ERROR_CORRUPT = -4; 1578 1579 /** 1580 * Determines the encryption state of the volume. 1581 * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values. 1582 */ getEncryptionState()1583 public int getEncryptionState() throws RemoteException; 1584 1585 /** 1586 * Decrypts any encrypted volumes. 1587 */ decryptStorage(String password)1588 public int decryptStorage(String password) throws RemoteException; 1589 1590 /** 1591 * Encrypts storage. 1592 */ encryptStorage(int type, String password)1593 public int encryptStorage(int type, String password) throws RemoteException; 1594 1595 /** 1596 * Changes the encryption password. 1597 */ changeEncryptionPassword(int type, String password)1598 public int changeEncryptionPassword(int type, String password) 1599 throws RemoteException; 1600 1601 /** 1602 * Verify the encryption password against the stored volume. This method 1603 * may only be called by the system process. 1604 */ verifyEncryptionPassword(String password)1605 public int verifyEncryptionPassword(String password) throws RemoteException; 1606 1607 /** 1608 * Returns list of all mountable volumes. 1609 */ getVolumeList()1610 public StorageVolume[] getVolumeList() throws RemoteException; 1611 1612 /** 1613 * Gets the path on the filesystem for the ASEC container itself. 1614 * 1615 * @param cid ASEC container ID 1616 * @return path to filesystem or {@code null} if it's not found 1617 * @throws RemoteException 1618 */ getSecureContainerFilesystemPath(String cid)1619 public String getSecureContainerFilesystemPath(String cid) throws RemoteException; 1620 1621 /* 1622 * Fix permissions in a container which has just been created and populated. 1623 * Returns an int consistent with MountServiceResultCode 1624 */ fixPermissionsSecureContainer(String id, int gid, String filename)1625 public int fixPermissionsSecureContainer(String id, int gid, String filename) 1626 throws RemoteException; 1627 1628 /** 1629 * Ensure that all directories along given path exist, creating parent 1630 * directories as needed. Validates that given path is absolute and that it 1631 * contains no relative "." or ".." paths or symlinks. Also ensures that 1632 * path belongs to a volume managed by vold, and that path is either 1633 * external storage data or OBB directory belonging to calling app. 1634 */ mkdirs(String callingPkg, String path)1635 public int mkdirs(String callingPkg, String path) throws RemoteException; 1636 1637 /** 1638 * Determines the type of the encryption password 1639 * @return PasswordType 1640 */ getPasswordType()1641 public int getPasswordType() throws RemoteException; 1642 1643 /** 1644 * Get password from vold 1645 * @return password or empty string 1646 */ getPassword()1647 public String getPassword() throws RemoteException; 1648 1649 /** 1650 * Securely clear password from vold 1651 */ clearPassword()1652 public void clearPassword() throws RemoteException; 1653 1654 /** 1655 * Set a field in the crypto header. 1656 * @param field field to set 1657 * @param contents contents to set in field 1658 */ setField(String field, String contents)1659 public void setField(String field, String contents) throws RemoteException; 1660 1661 /** 1662 * Gets a field from the crypto header. 1663 * @param field field to get 1664 * @return contents of field 1665 */ getField(String field)1666 public String getField(String field) throws RemoteException; 1667 resizeSecureContainer(String id, int sizeMb, String key)1668 public int resizeSecureContainer(String id, int sizeMb, String key) throws RemoteException; 1669 1670 /** 1671 * Report the time of the last maintenance operation such as fstrim. 1672 * @return Timestamp of the last maintenance operation, in the 1673 * System.currentTimeMillis() time base 1674 * @throws RemoteException 1675 */ lastMaintenance()1676 public long lastMaintenance() throws RemoteException; 1677 1678 /** 1679 * Kick off an immediate maintenance operation 1680 * @throws RemoteException 1681 */ runMaintenance()1682 public void runMaintenance() throws RemoteException; 1683 } 1684