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