IMountService.java revision d95d3bfb2b28a4f21f3fdcd740160c9a61eb0363
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, 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 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 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 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 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 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 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 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 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 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 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 760 public StorageVolume[] getVolumeList(int userId) throws RemoteException { 761 Parcel _data = Parcel.obtain(); 762 Parcel _reply = Parcel.obtain(); 763 StorageVolume[] _result; 764 try { 765 _data.writeInterfaceToken(DESCRIPTOR); 766 _data.writeInt(userId); 767 mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0); 768 _reply.readException(); 769 _result = _reply.createTypedArray(StorageVolume.CREATOR); 770 } finally { 771 _reply.recycle(); 772 _data.recycle(); 773 } 774 return _result; 775 } 776 777 /* 778 * Returns the filesystem path of a mounted secure container. 779 */ 780 public String getSecureContainerFilesystemPath(String id) throws RemoteException { 781 Parcel _data = Parcel.obtain(); 782 Parcel _reply = Parcel.obtain(); 783 String _result; 784 try { 785 _data.writeInterfaceToken(DESCRIPTOR); 786 _data.writeString(id); 787 mRemote.transact(Stub.TRANSACTION_getSecureContainerFilesystemPath, _data, _reply, 0); 788 _reply.readException(); 789 _result = _reply.readString(); 790 } finally { 791 _reply.recycle(); 792 _data.recycle(); 793 } 794 return _result; 795 } 796 797 /** 798 * Fix permissions in a container which has just been created and 799 * populated. Returns an int consistent with MountServiceResultCode 800 */ 801 public int fixPermissionsSecureContainer(String id, int gid, String filename) 802 throws RemoteException { 803 Parcel _data = Parcel.obtain(); 804 Parcel _reply = Parcel.obtain(); 805 int _result; 806 try { 807 _data.writeInterfaceToken(DESCRIPTOR); 808 _data.writeString(id); 809 _data.writeInt(gid); 810 _data.writeString(filename); 811 mRemote.transact(Stub.TRANSACTION_fixPermissionsSecureContainer, _data, _reply, 0); 812 _reply.readException(); 813 _result = _reply.readInt(); 814 } finally { 815 _reply.recycle(); 816 _data.recycle(); 817 } 818 return _result; 819 } 820 821 @Override 822 public int mkdirs(String callingPkg, String path) throws RemoteException { 823 Parcel _data = Parcel.obtain(); 824 Parcel _reply = Parcel.obtain(); 825 int _result; 826 try { 827 _data.writeInterfaceToken(DESCRIPTOR); 828 _data.writeString(callingPkg); 829 _data.writeString(path); 830 mRemote.transact(Stub.TRANSACTION_mkdirs, _data, _reply, 0); 831 _reply.readException(); 832 _result = _reply.readInt(); 833 } finally { 834 _reply.recycle(); 835 _data.recycle(); 836 } 837 return _result; 838 } 839 840 @Override 841 public int resizeSecureContainer(String id, int sizeMb, String key) 842 throws RemoteException { 843 Parcel _data = Parcel.obtain(); 844 Parcel _reply = Parcel.obtain(); 845 int _result; 846 try { 847 _data.writeInterfaceToken(DESCRIPTOR); 848 _data.writeString(id); 849 _data.writeInt(sizeMb); 850 _data.writeString(key); 851 mRemote.transact(Stub.TRANSACTION_resizeSecureContainer, _data, _reply, 0); 852 _reply.readException(); 853 _result = _reply.readInt(); 854 } finally { 855 _reply.recycle(); 856 _data.recycle(); 857 } 858 return _result; 859 } 860 861 @Override 862 public long lastMaintenance() throws RemoteException { 863 Parcel _data = Parcel.obtain(); 864 Parcel _reply = Parcel.obtain(); 865 long _result; 866 try { 867 _data.writeInterfaceToken(DESCRIPTOR); 868 mRemote.transact(Stub.TRANSACTION_lastMaintenance, _data, _reply, 0); 869 _reply.readException(); 870 _result = _reply.readLong(); 871 } finally { 872 _reply.recycle(); 873 _data.recycle(); 874 } 875 return _result; 876 } 877 878 @Override 879 public void runMaintenance() throws RemoteException { 880 Parcel _data = Parcel.obtain(); 881 Parcel _reply = Parcel.obtain(); 882 try { 883 _data.writeInterfaceToken(DESCRIPTOR); 884 mRemote.transact(Stub.TRANSACTION_runMaintenance, _data, _reply, 0); 885 _reply.readException(); 886 } finally { 887 _reply.recycle(); 888 _data.recycle(); 889 } 890 return; 891 } 892 893 @Override 894 public void waitForAsecScan() throws RemoteException { 895 Parcel _data = Parcel.obtain(); 896 Parcel _reply = Parcel.obtain(); 897 try { 898 _data.writeInterfaceToken(DESCRIPTOR); 899 mRemote.transact(Stub.TRANSACTION_waitForAsecScan, _data, _reply, 0); 900 _reply.readException(); 901 } finally { 902 _reply.recycle(); 903 _data.recycle(); 904 } 905 return; 906 } 907 908 @Override 909 public DiskInfo[] getDisks() throws RemoteException { 910 Parcel _data = Parcel.obtain(); 911 Parcel _reply = Parcel.obtain(); 912 DiskInfo[] _result; 913 try { 914 _data.writeInterfaceToken(DESCRIPTOR); 915 mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0); 916 _reply.readException(); 917 _result = _reply.createTypedArray(DiskInfo.CREATOR); 918 } finally { 919 _reply.recycle(); 920 _data.recycle(); 921 } 922 return _result; 923 } 924 925 @Override 926 public VolumeInfo[] getVolumes(int _flags) throws RemoteException { 927 Parcel _data = Parcel.obtain(); 928 Parcel _reply = Parcel.obtain(); 929 VolumeInfo[] _result; 930 try { 931 _data.writeInterfaceToken(DESCRIPTOR); 932 _data.writeInt(_flags); 933 mRemote.transact(Stub.TRANSACTION_getVolumes, _data, _reply, 0); 934 _reply.readException(); 935 _result = _reply.createTypedArray(VolumeInfo.CREATOR); 936 } finally { 937 _reply.recycle(); 938 _data.recycle(); 939 } 940 return _result; 941 } 942 943 @Override 944 public void mount(String volId) throws RemoteException { 945 Parcel _data = Parcel.obtain(); 946 Parcel _reply = Parcel.obtain(); 947 try { 948 _data.writeInterfaceToken(DESCRIPTOR); 949 _data.writeString(volId); 950 mRemote.transact(Stub.TRANSACTION_mount, _data, _reply, 0); 951 _reply.readException(); 952 } finally { 953 _reply.recycle(); 954 _data.recycle(); 955 } 956 } 957 958 @Override 959 public void unmount(String volId) throws RemoteException { 960 Parcel _data = Parcel.obtain(); 961 Parcel _reply = Parcel.obtain(); 962 try { 963 _data.writeInterfaceToken(DESCRIPTOR); 964 _data.writeString(volId); 965 mRemote.transact(Stub.TRANSACTION_unmount, _data, _reply, 0); 966 _reply.readException(); 967 } finally { 968 _reply.recycle(); 969 _data.recycle(); 970 } 971 } 972 973 @Override 974 public void format(String volId) throws RemoteException { 975 Parcel _data = Parcel.obtain(); 976 Parcel _reply = Parcel.obtain(); 977 try { 978 _data.writeInterfaceToken(DESCRIPTOR); 979 _data.writeString(volId); 980 mRemote.transact(Stub.TRANSACTION_format, _data, _reply, 0); 981 _reply.readException(); 982 } finally { 983 _reply.recycle(); 984 _data.recycle(); 985 } 986 } 987 988 @Override 989 public void partitionPublic(String diskId) throws RemoteException { 990 Parcel _data = Parcel.obtain(); 991 Parcel _reply = Parcel.obtain(); 992 try { 993 _data.writeInterfaceToken(DESCRIPTOR); 994 _data.writeString(diskId); 995 mRemote.transact(Stub.TRANSACTION_partitionPublic, _data, _reply, 0); 996 _reply.readException(); 997 } finally { 998 _reply.recycle(); 999 _data.recycle(); 1000 } 1001 } 1002 1003 @Override 1004 public void partitionPrivate(String diskId) throws RemoteException { 1005 Parcel _data = Parcel.obtain(); 1006 Parcel _reply = Parcel.obtain(); 1007 try { 1008 _data.writeInterfaceToken(DESCRIPTOR); 1009 _data.writeString(diskId); 1010 mRemote.transact(Stub.TRANSACTION_partitionPrivate, _data, _reply, 0); 1011 _reply.readException(); 1012 } finally { 1013 _reply.recycle(); 1014 _data.recycle(); 1015 } 1016 } 1017 1018 @Override 1019 public void partitionMixed(String diskId, int ratio) throws RemoteException { 1020 Parcel _data = Parcel.obtain(); 1021 Parcel _reply = Parcel.obtain(); 1022 try { 1023 _data.writeInterfaceToken(DESCRIPTOR); 1024 _data.writeString(diskId); 1025 _data.writeInt(ratio); 1026 mRemote.transact(Stub.TRANSACTION_partitionMixed, _data, _reply, 0); 1027 _reply.readException(); 1028 } finally { 1029 _reply.recycle(); 1030 _data.recycle(); 1031 } 1032 } 1033 1034 @Override 1035 public void setVolumeNickname(String volId, String nickname) throws RemoteException { 1036 Parcel _data = Parcel.obtain(); 1037 Parcel _reply = Parcel.obtain(); 1038 try { 1039 _data.writeInterfaceToken(DESCRIPTOR); 1040 _data.writeString(volId); 1041 _data.writeString(nickname); 1042 mRemote.transact(Stub.TRANSACTION_setVolumeNickname, _data, _reply, 0); 1043 _reply.readException(); 1044 } finally { 1045 _reply.recycle(); 1046 _data.recycle(); 1047 } 1048 } 1049 1050 @Override 1051 public void setVolumeUserFlags(String volId, int flags, int mask) throws RemoteException { 1052 Parcel _data = Parcel.obtain(); 1053 Parcel _reply = Parcel.obtain(); 1054 try { 1055 _data.writeInterfaceToken(DESCRIPTOR); 1056 _data.writeString(volId); 1057 _data.writeInt(flags); 1058 _data.writeInt(mask); 1059 mRemote.transact(Stub.TRANSACTION_setVolumeUserFlags, _data, _reply, 0); 1060 _reply.readException(); 1061 } finally { 1062 _reply.recycle(); 1063 _data.recycle(); 1064 } 1065 } 1066 } 1067 1068 private static final String DESCRIPTOR = "IMountService"; 1069 1070 static final int TRANSACTION_registerListener = IBinder.FIRST_CALL_TRANSACTION + 0; 1071 1072 static final int TRANSACTION_unregisterListener = IBinder.FIRST_CALL_TRANSACTION + 1; 1073 1074 static final int TRANSACTION_isUsbMassStorageConnected = IBinder.FIRST_CALL_TRANSACTION + 2; 1075 1076 static final int TRANSACTION_setUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 3; 1077 1078 static final int TRANSACTION_isUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 4; 1079 1080 static final int TRANSACTION_mountVolume = IBinder.FIRST_CALL_TRANSACTION + 5; 1081 1082 static final int TRANSACTION_unmountVolume = IBinder.FIRST_CALL_TRANSACTION + 6; 1083 1084 static final int TRANSACTION_formatVolume = IBinder.FIRST_CALL_TRANSACTION + 7; 1085 1086 static final int TRANSACTION_getStorageUsers = IBinder.FIRST_CALL_TRANSACTION + 8; 1087 1088 static final int TRANSACTION_getVolumeState = IBinder.FIRST_CALL_TRANSACTION + 9; 1089 1090 static final int TRANSACTION_createSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 10; 1091 1092 static final int TRANSACTION_finalizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 11; 1093 1094 static final int TRANSACTION_destroySecureContainer = IBinder.FIRST_CALL_TRANSACTION + 12; 1095 1096 static final int TRANSACTION_mountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 13; 1097 1098 static final int TRANSACTION_unmountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 14; 1099 1100 static final int TRANSACTION_isSecureContainerMounted = IBinder.FIRST_CALL_TRANSACTION + 15; 1101 1102 static final int TRANSACTION_renameSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 16; 1103 1104 static final int TRANSACTION_getSecureContainerPath = IBinder.FIRST_CALL_TRANSACTION + 17; 1105 1106 static final int TRANSACTION_getSecureContainerList = IBinder.FIRST_CALL_TRANSACTION + 18; 1107 1108 static final int TRANSACTION_shutdown = IBinder.FIRST_CALL_TRANSACTION + 19; 1109 1110 static final int TRANSACTION_finishMediaUpdate = IBinder.FIRST_CALL_TRANSACTION + 20; 1111 1112 static final int TRANSACTION_mountObb = IBinder.FIRST_CALL_TRANSACTION + 21; 1113 1114 static final int TRANSACTION_unmountObb = IBinder.FIRST_CALL_TRANSACTION + 22; 1115 1116 static final int TRANSACTION_isObbMounted = IBinder.FIRST_CALL_TRANSACTION + 23; 1117 1118 static final int TRANSACTION_getMountedObbPath = IBinder.FIRST_CALL_TRANSACTION + 24; 1119 1120 static final int TRANSACTION_isExternalStorageEmulated = IBinder.FIRST_CALL_TRANSACTION + 25; 1121 1122 static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26; 1123 1124 static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27; 1125 1126 static final int TRANSACTION_changeEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 28; 1127 1128 static final int TRANSACTION_getVolumeList = IBinder.FIRST_CALL_TRANSACTION + 29; 1129 1130 static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30; 1131 1132 static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31; 1133 1134 static final int TRANSACTION_verifyEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 32; 1135 1136 static final int TRANSACTION_fixPermissionsSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 33; 1137 1138 static final int TRANSACTION_mkdirs = IBinder.FIRST_CALL_TRANSACTION + 34; 1139 1140 static final int TRANSACTION_getPasswordType = IBinder.FIRST_CALL_TRANSACTION + 35; 1141 1142 static final int TRANSACTION_getPassword = IBinder.FIRST_CALL_TRANSACTION + 36; 1143 1144 static final int TRANSACTION_clearPassword = IBinder.FIRST_CALL_TRANSACTION + 37; 1145 1146 static final int TRANSACTION_setField = IBinder.FIRST_CALL_TRANSACTION + 38; 1147 1148 static final int TRANSACTION_getField = IBinder.FIRST_CALL_TRANSACTION + 39; 1149 1150 static final int TRANSACTION_resizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 40; 1151 1152 static final int TRANSACTION_lastMaintenance = IBinder.FIRST_CALL_TRANSACTION + 41; 1153 1154 static final int TRANSACTION_runMaintenance = IBinder.FIRST_CALL_TRANSACTION + 42; 1155 1156 static final int TRANSACTION_waitForAsecScan = IBinder.FIRST_CALL_TRANSACTION + 43; 1157 1158 static final int TRANSACTION_getDisks = IBinder.FIRST_CALL_TRANSACTION + 44; 1159 static final int TRANSACTION_getVolumes = IBinder.FIRST_CALL_TRANSACTION + 45; 1160 1161 static final int TRANSACTION_mount = IBinder.FIRST_CALL_TRANSACTION + 46; 1162 static final int TRANSACTION_unmount = IBinder.FIRST_CALL_TRANSACTION + 47; 1163 static final int TRANSACTION_format = IBinder.FIRST_CALL_TRANSACTION + 48; 1164 1165 static final int TRANSACTION_partitionPublic = IBinder.FIRST_CALL_TRANSACTION + 49; 1166 static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 50; 1167 static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 51; 1168 1169 static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 52; 1170 static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 53; 1171 1172 /** 1173 * Cast an IBinder object into an IMountService interface, generating a 1174 * proxy if needed. 1175 */ 1176 public static IMountService asInterface(IBinder obj) { 1177 if (obj == null) { 1178 return null; 1179 } 1180 IInterface iin = obj.queryLocalInterface(DESCRIPTOR); 1181 if (iin != null && iin instanceof IMountService) { 1182 return (IMountService) iin; 1183 } 1184 return new IMountService.Stub.Proxy(obj); 1185 } 1186 1187 /** Construct the stub at attach it to the interface. */ 1188 public Stub() { 1189 attachInterface(this, DESCRIPTOR); 1190 } 1191 1192 public IBinder asBinder() { 1193 return this; 1194 } 1195 1196 @Override 1197 public boolean onTransact(int code, Parcel data, Parcel reply, 1198 int flags) throws RemoteException { 1199 switch (code) { 1200 case INTERFACE_TRANSACTION: { 1201 reply.writeString(DESCRIPTOR); 1202 return true; 1203 } 1204 case TRANSACTION_registerListener: { 1205 data.enforceInterface(DESCRIPTOR); 1206 IMountServiceListener listener; 1207 listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder()); 1208 registerListener(listener); 1209 reply.writeNoException(); 1210 return true; 1211 } 1212 case TRANSACTION_unregisterListener: { 1213 data.enforceInterface(DESCRIPTOR); 1214 IMountServiceListener listener; 1215 listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder()); 1216 unregisterListener(listener); 1217 reply.writeNoException(); 1218 return true; 1219 } 1220 case TRANSACTION_isUsbMassStorageConnected: { 1221 data.enforceInterface(DESCRIPTOR); 1222 boolean result = isUsbMassStorageConnected(); 1223 reply.writeNoException(); 1224 reply.writeInt((result ? 1 : 0)); 1225 return true; 1226 } 1227 case TRANSACTION_setUsbMassStorageEnabled: { 1228 data.enforceInterface(DESCRIPTOR); 1229 boolean enable; 1230 enable = 0 != data.readInt(); 1231 setUsbMassStorageEnabled(enable); 1232 reply.writeNoException(); 1233 return true; 1234 } 1235 case TRANSACTION_isUsbMassStorageEnabled: { 1236 data.enforceInterface(DESCRIPTOR); 1237 boolean result = isUsbMassStorageEnabled(); 1238 reply.writeNoException(); 1239 reply.writeInt((result ? 1 : 0)); 1240 return true; 1241 } 1242 case TRANSACTION_mountVolume: { 1243 data.enforceInterface(DESCRIPTOR); 1244 String mountPoint; 1245 mountPoint = data.readString(); 1246 int resultCode = mountVolume(mountPoint); 1247 reply.writeNoException(); 1248 reply.writeInt(resultCode); 1249 return true; 1250 } 1251 case TRANSACTION_unmountVolume: { 1252 data.enforceInterface(DESCRIPTOR); 1253 String mountPoint; 1254 mountPoint = data.readString(); 1255 boolean force = 0 != data.readInt(); 1256 boolean removeEncrypt = 0 != data.readInt(); 1257 unmountVolume(mountPoint, force, removeEncrypt); 1258 reply.writeNoException(); 1259 return true; 1260 } 1261 case TRANSACTION_formatVolume: { 1262 data.enforceInterface(DESCRIPTOR); 1263 String mountPoint; 1264 mountPoint = data.readString(); 1265 int result = formatVolume(mountPoint); 1266 reply.writeNoException(); 1267 reply.writeInt(result); 1268 return true; 1269 } 1270 case TRANSACTION_getStorageUsers: { 1271 data.enforceInterface(DESCRIPTOR); 1272 String path; 1273 path = data.readString(); 1274 int[] pids = getStorageUsers(path); 1275 reply.writeNoException(); 1276 reply.writeIntArray(pids); 1277 return true; 1278 } 1279 case TRANSACTION_getVolumeState: { 1280 data.enforceInterface(DESCRIPTOR); 1281 String mountPoint; 1282 mountPoint = data.readString(); 1283 String state = getVolumeState(mountPoint); 1284 reply.writeNoException(); 1285 reply.writeString(state); 1286 return true; 1287 } 1288 case TRANSACTION_createSecureContainer: { 1289 data.enforceInterface(DESCRIPTOR); 1290 String id; 1291 id = data.readString(); 1292 int sizeMb; 1293 sizeMb = data.readInt(); 1294 String fstype; 1295 fstype = data.readString(); 1296 String key; 1297 key = data.readString(); 1298 int ownerUid; 1299 ownerUid = data.readInt(); 1300 boolean external; 1301 external = 0 != data.readInt(); 1302 int resultCode = createSecureContainer(id, sizeMb, fstype, key, ownerUid, 1303 external); 1304 reply.writeNoException(); 1305 reply.writeInt(resultCode); 1306 return true; 1307 } 1308 case TRANSACTION_finalizeSecureContainer: { 1309 data.enforceInterface(DESCRIPTOR); 1310 String id; 1311 id = data.readString(); 1312 int resultCode = finalizeSecureContainer(id); 1313 reply.writeNoException(); 1314 reply.writeInt(resultCode); 1315 return true; 1316 } 1317 case TRANSACTION_destroySecureContainer: { 1318 data.enforceInterface(DESCRIPTOR); 1319 String id; 1320 id = data.readString(); 1321 boolean force; 1322 force = 0 != data.readInt(); 1323 int resultCode = destroySecureContainer(id, force); 1324 reply.writeNoException(); 1325 reply.writeInt(resultCode); 1326 return true; 1327 } 1328 case TRANSACTION_mountSecureContainer: { 1329 data.enforceInterface(DESCRIPTOR); 1330 String id; 1331 id = data.readString(); 1332 String key; 1333 key = data.readString(); 1334 int ownerUid; 1335 ownerUid = data.readInt(); 1336 boolean readOnly; 1337 readOnly = data.readInt() != 0; 1338 int resultCode = mountSecureContainer(id, key, ownerUid, readOnly); 1339 reply.writeNoException(); 1340 reply.writeInt(resultCode); 1341 return true; 1342 } 1343 case TRANSACTION_unmountSecureContainer: { 1344 data.enforceInterface(DESCRIPTOR); 1345 String id; 1346 id = data.readString(); 1347 boolean force; 1348 force = 0 != data.readInt(); 1349 int resultCode = unmountSecureContainer(id, force); 1350 reply.writeNoException(); 1351 reply.writeInt(resultCode); 1352 return true; 1353 } 1354 case TRANSACTION_isSecureContainerMounted: { 1355 data.enforceInterface(DESCRIPTOR); 1356 String id; 1357 id = data.readString(); 1358 boolean status = isSecureContainerMounted(id); 1359 reply.writeNoException(); 1360 reply.writeInt((status ? 1 : 0)); 1361 return true; 1362 } 1363 case TRANSACTION_renameSecureContainer: { 1364 data.enforceInterface(DESCRIPTOR); 1365 String oldId; 1366 oldId = data.readString(); 1367 String newId; 1368 newId = data.readString(); 1369 int resultCode = renameSecureContainer(oldId, newId); 1370 reply.writeNoException(); 1371 reply.writeInt(resultCode); 1372 return true; 1373 } 1374 case TRANSACTION_getSecureContainerPath: { 1375 data.enforceInterface(DESCRIPTOR); 1376 String id; 1377 id = data.readString(); 1378 String path = getSecureContainerPath(id); 1379 reply.writeNoException(); 1380 reply.writeString(path); 1381 return true; 1382 } 1383 case TRANSACTION_getSecureContainerList: { 1384 data.enforceInterface(DESCRIPTOR); 1385 String[] ids = getSecureContainerList(); 1386 reply.writeNoException(); 1387 reply.writeStringArray(ids); 1388 return true; 1389 } 1390 case TRANSACTION_shutdown: { 1391 data.enforceInterface(DESCRIPTOR); 1392 IMountShutdownObserver observer; 1393 observer = IMountShutdownObserver.Stub.asInterface(data 1394 .readStrongBinder()); 1395 shutdown(observer); 1396 reply.writeNoException(); 1397 return true; 1398 } 1399 case TRANSACTION_finishMediaUpdate: { 1400 data.enforceInterface(DESCRIPTOR); 1401 finishMediaUpdate(); 1402 reply.writeNoException(); 1403 return true; 1404 } 1405 case TRANSACTION_mountObb: { 1406 data.enforceInterface(DESCRIPTOR); 1407 final String rawPath = data.readString(); 1408 final String canonicalPath = data.readString(); 1409 final String key = data.readString(); 1410 IObbActionListener observer; 1411 observer = IObbActionListener.Stub.asInterface(data.readStrongBinder()); 1412 int nonce; 1413 nonce = data.readInt(); 1414 mountObb(rawPath, canonicalPath, key, observer, nonce); 1415 reply.writeNoException(); 1416 return true; 1417 } 1418 case TRANSACTION_unmountObb: { 1419 data.enforceInterface(DESCRIPTOR); 1420 String filename; 1421 filename = data.readString(); 1422 boolean force; 1423 force = 0 != data.readInt(); 1424 IObbActionListener observer; 1425 observer = IObbActionListener.Stub.asInterface(data.readStrongBinder()); 1426 int nonce; 1427 nonce = data.readInt(); 1428 unmountObb(filename, force, observer, nonce); 1429 reply.writeNoException(); 1430 return true; 1431 } 1432 case TRANSACTION_isObbMounted: { 1433 data.enforceInterface(DESCRIPTOR); 1434 String filename; 1435 filename = data.readString(); 1436 boolean status = isObbMounted(filename); 1437 reply.writeNoException(); 1438 reply.writeInt((status ? 1 : 0)); 1439 return true; 1440 } 1441 case TRANSACTION_getMountedObbPath: { 1442 data.enforceInterface(DESCRIPTOR); 1443 String filename; 1444 filename = data.readString(); 1445 String mountedPath = getMountedObbPath(filename); 1446 reply.writeNoException(); 1447 reply.writeString(mountedPath); 1448 return true; 1449 } 1450 case TRANSACTION_isExternalStorageEmulated: { 1451 data.enforceInterface(DESCRIPTOR); 1452 boolean emulated = isExternalStorageEmulated(); 1453 reply.writeNoException(); 1454 reply.writeInt(emulated ? 1 : 0); 1455 return true; 1456 } 1457 case TRANSACTION_decryptStorage: { 1458 data.enforceInterface(DESCRIPTOR); 1459 String password = data.readString(); 1460 int result = decryptStorage(password); 1461 reply.writeNoException(); 1462 reply.writeInt(result); 1463 return true; 1464 } 1465 case TRANSACTION_encryptStorage: { 1466 data.enforceInterface(DESCRIPTOR); 1467 int type = data.readInt(); 1468 String password = data.readString(); 1469 int result = encryptStorage(type, password); 1470 reply.writeNoException(); 1471 reply.writeInt(result); 1472 return true; 1473 } 1474 case TRANSACTION_changeEncryptionPassword: { 1475 data.enforceInterface(DESCRIPTOR); 1476 int type = data.readInt(); 1477 String password = data.readString(); 1478 int result = changeEncryptionPassword(type, password); 1479 reply.writeNoException(); 1480 reply.writeInt(result); 1481 return true; 1482 } 1483 case TRANSACTION_getVolumeList: { 1484 data.enforceInterface(DESCRIPTOR); 1485 int userId = data.readInt(); 1486 StorageVolume[] result = getVolumeList(userId); 1487 reply.writeNoException(); 1488 reply.writeTypedArray(result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1489 return true; 1490 } 1491 case TRANSACTION_getSecureContainerFilesystemPath: { 1492 data.enforceInterface(DESCRIPTOR); 1493 String id; 1494 id = data.readString(); 1495 String path = getSecureContainerFilesystemPath(id); 1496 reply.writeNoException(); 1497 reply.writeString(path); 1498 return true; 1499 } 1500 case TRANSACTION_getEncryptionState: { 1501 data.enforceInterface(DESCRIPTOR); 1502 int result = getEncryptionState(); 1503 reply.writeNoException(); 1504 reply.writeInt(result); 1505 return true; 1506 } 1507 case TRANSACTION_fixPermissionsSecureContainer: { 1508 data.enforceInterface(DESCRIPTOR); 1509 String id; 1510 id = data.readString(); 1511 int gid; 1512 gid = data.readInt(); 1513 String filename; 1514 filename = data.readString(); 1515 int resultCode = fixPermissionsSecureContainer(id, gid, filename); 1516 reply.writeNoException(); 1517 reply.writeInt(resultCode); 1518 return true; 1519 } 1520 case TRANSACTION_mkdirs: { 1521 data.enforceInterface(DESCRIPTOR); 1522 String callingPkg = data.readString(); 1523 String path = data.readString(); 1524 int result = mkdirs(callingPkg, path); 1525 reply.writeNoException(); 1526 reply.writeInt(result); 1527 return true; 1528 } 1529 case TRANSACTION_getPasswordType: { 1530 data.enforceInterface(DESCRIPTOR); 1531 int result = getPasswordType(); 1532 reply.writeNoException(); 1533 reply.writeInt(result); 1534 return true; 1535 } 1536 case TRANSACTION_getPassword: { 1537 data.enforceInterface(DESCRIPTOR); 1538 String result = getPassword(); 1539 reply.writeNoException(); 1540 reply.writeString(result); 1541 return true; 1542 } 1543 case TRANSACTION_clearPassword: { 1544 data.enforceInterface(DESCRIPTOR); 1545 clearPassword(); 1546 reply.writeNoException(); 1547 return true; 1548 } 1549 case TRANSACTION_setField: { 1550 data.enforceInterface(DESCRIPTOR); 1551 String field = data.readString(); 1552 String contents = data.readString(); 1553 setField(field, contents); 1554 reply.writeNoException(); 1555 return true; 1556 } 1557 case TRANSACTION_getField: { 1558 data.enforceInterface(DESCRIPTOR); 1559 String field = data.readString(); 1560 String contents = getField(field); 1561 reply.writeNoException(); 1562 reply.writeString(contents); 1563 return true; 1564 } 1565 case TRANSACTION_resizeSecureContainer: { 1566 data.enforceInterface(DESCRIPTOR); 1567 String id; 1568 id = data.readString(); 1569 int sizeMb; 1570 sizeMb = data.readInt(); 1571 String key; 1572 key = data.readString(); 1573 int resultCode = resizeSecureContainer(id, sizeMb, key); 1574 reply.writeNoException(); 1575 reply.writeInt(resultCode); 1576 return true; 1577 } 1578 case TRANSACTION_lastMaintenance: { 1579 data.enforceInterface(DESCRIPTOR); 1580 long lastMaintenance = lastMaintenance(); 1581 reply.writeNoException(); 1582 reply.writeLong(lastMaintenance); 1583 return true; 1584 } 1585 case TRANSACTION_runMaintenance: { 1586 data.enforceInterface(DESCRIPTOR); 1587 runMaintenance(); 1588 reply.writeNoException(); 1589 return true; 1590 } 1591 case TRANSACTION_waitForAsecScan: { 1592 data.enforceInterface(DESCRIPTOR); 1593 waitForAsecScan(); 1594 reply.writeNoException(); 1595 return true; 1596 } 1597 case TRANSACTION_getDisks: { 1598 data.enforceInterface(DESCRIPTOR); 1599 DiskInfo[] disks = getDisks(); 1600 reply.writeNoException(); 1601 reply.writeTypedArray(disks, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1602 return true; 1603 } 1604 case TRANSACTION_getVolumes: { 1605 data.enforceInterface(DESCRIPTOR); 1606 int _flags = data.readInt(); 1607 VolumeInfo[] volumes = getVolumes(_flags); 1608 reply.writeNoException(); 1609 reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1610 return true; 1611 } 1612 case TRANSACTION_mount: { 1613 data.enforceInterface(DESCRIPTOR); 1614 String volId = data.readString(); 1615 mount(volId); 1616 reply.writeNoException(); 1617 return true; 1618 } 1619 case TRANSACTION_unmount: { 1620 data.enforceInterface(DESCRIPTOR); 1621 String volId = data.readString(); 1622 unmount(volId); 1623 reply.writeNoException(); 1624 return true; 1625 } 1626 case TRANSACTION_format: { 1627 data.enforceInterface(DESCRIPTOR); 1628 String volId = data.readString(); 1629 format(volId); 1630 reply.writeNoException(); 1631 return true; 1632 } 1633 case TRANSACTION_partitionPublic: { 1634 data.enforceInterface(DESCRIPTOR); 1635 String diskId = data.readString(); 1636 partitionPublic(diskId); 1637 reply.writeNoException(); 1638 return true; 1639 } 1640 case TRANSACTION_partitionPrivate: { 1641 data.enforceInterface(DESCRIPTOR); 1642 String diskId = data.readString(); 1643 partitionPrivate(diskId); 1644 reply.writeNoException(); 1645 return true; 1646 } 1647 case TRANSACTION_partitionMixed: { 1648 data.enforceInterface(DESCRIPTOR); 1649 String diskId = data.readString(); 1650 int ratio = data.readInt(); 1651 partitionMixed(diskId, ratio); 1652 reply.writeNoException(); 1653 return true; 1654 } 1655 case TRANSACTION_setVolumeNickname: { 1656 data.enforceInterface(DESCRIPTOR); 1657 String volId = data.readString(); 1658 String nickname = data.readString(); 1659 setVolumeNickname(volId, nickname); 1660 reply.writeNoException(); 1661 return true; 1662 } 1663 case TRANSACTION_setVolumeUserFlags: { 1664 data.enforceInterface(DESCRIPTOR); 1665 String volId = data.readString(); 1666 int _flags = data.readInt(); 1667 int _mask = data.readInt(); 1668 setVolumeUserFlags(volId, _flags, _mask); 1669 reply.writeNoException(); 1670 return true; 1671 } 1672 } 1673 return super.onTransact(code, data, reply, flags); 1674 } 1675 } 1676 1677 /* 1678 * Creates a secure container with the specified parameters. Returns an int 1679 * consistent with MountServiceResultCode 1680 */ 1681 public int createSecureContainer(String id, int sizeMb, String fstype, String key, 1682 int ownerUid, boolean external) throws RemoteException; 1683 1684 /* 1685 * Destroy a secure container, and free up all resources associated with it. 1686 * NOTE: Ensure all references are released prior to deleting. Returns an 1687 * int consistent with MountServiceResultCode 1688 */ 1689 public int destroySecureContainer(String id, boolean force) throws RemoteException; 1690 1691 /* 1692 * Finalize a container which has just been created and populated. After 1693 * finalization, the container is immutable. Returns an int consistent with 1694 * MountServiceResultCode 1695 */ 1696 public int finalizeSecureContainer(String id) throws RemoteException; 1697 1698 /** 1699 * Call into MountService by PackageManager to notify that its done 1700 * processing the media status update request. 1701 */ 1702 public void finishMediaUpdate() throws RemoteException; 1703 1704 /** 1705 * Format external storage given a mount point. Returns an int consistent 1706 * with MountServiceResultCode 1707 */ 1708 public int formatVolume(String mountPoint) throws RemoteException; 1709 1710 /** 1711 * Gets the path to the mounted Opaque Binary Blob (OBB). 1712 */ 1713 public String getMountedObbPath(String rawPath) throws RemoteException; 1714 1715 /** 1716 * Gets an Array of currently known secure container IDs 1717 */ 1718 public String[] getSecureContainerList() throws RemoteException; 1719 1720 /* 1721 * Returns the filesystem path of a mounted secure container. 1722 */ 1723 public String getSecureContainerPath(String id) throws RemoteException; 1724 1725 /** 1726 * Returns an array of pids with open files on the specified path. 1727 */ 1728 public int[] getStorageUsers(String path) throws RemoteException; 1729 1730 /** 1731 * Gets the state of a volume via its mountpoint. 1732 */ 1733 public String getVolumeState(String mountPoint) throws RemoteException; 1734 1735 /** 1736 * Checks whether the specified Opaque Binary Blob (OBB) is mounted 1737 * somewhere. 1738 */ 1739 public boolean isObbMounted(String rawPath) throws RemoteException; 1740 1741 /* 1742 * Returns true if the specified container is mounted 1743 */ 1744 public boolean isSecureContainerMounted(String id) throws RemoteException; 1745 1746 /** 1747 * Returns true if a USB mass storage host is connected 1748 */ 1749 public boolean isUsbMassStorageConnected() throws RemoteException; 1750 1751 /** 1752 * Returns true if a USB mass storage host is enabled (media is shared) 1753 */ 1754 public boolean isUsbMassStorageEnabled() throws RemoteException; 1755 1756 /** 1757 * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and 1758 * only allows the calling process's UID access to the contents. 1759 * MountService will call back to the supplied IObbActionListener to inform 1760 * it of the terminal state of the call. 1761 */ 1762 public void mountObb(String rawPath, String canonicalPath, String key, 1763 IObbActionListener token, int nonce) throws RemoteException; 1764 1765 /* 1766 * Mount a secure container with the specified key and owner UID. Returns an 1767 * int consistent with MountServiceResultCode 1768 */ 1769 public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly) 1770 throws RemoteException; 1771 1772 /** 1773 * Mount external storage at given mount point. Returns an int consistent 1774 * with MountServiceResultCode 1775 */ 1776 public int mountVolume(String mountPoint) throws RemoteException; 1777 1778 /** 1779 * Registers an IMountServiceListener for receiving async notifications. 1780 */ 1781 public void registerListener(IMountServiceListener listener) throws RemoteException; 1782 1783 /* 1784 * Rename an unmounted secure container. Returns an int consistent with 1785 * MountServiceResultCode 1786 */ 1787 public int renameSecureContainer(String oldId, String newId) throws RemoteException; 1788 1789 /** 1790 * Enables / disables USB mass storage. The caller should check actual 1791 * status of enabling/disabling USB mass storage via StorageEventListener. 1792 */ 1793 public void setUsbMassStorageEnabled(boolean enable) throws RemoteException; 1794 1795 /** 1796 * Shuts down the MountService and gracefully unmounts all external media. 1797 * Invokes call back once the shutdown is complete. 1798 */ 1799 public void shutdown(IMountShutdownObserver observer) throws RemoteException; 1800 1801 /** 1802 * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified, 1803 * any program using it will be forcibly killed to unmount the image. 1804 * MountService will call back to the supplied IObbActionListener to inform 1805 * it of the terminal state of the call. 1806 */ 1807 public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce) 1808 throws RemoteException; 1809 1810 /* 1811 * Unount a secure container. Returns an int consistent with 1812 * MountServiceResultCode 1813 */ 1814 public int unmountSecureContainer(String id, boolean force) throws RemoteException; 1815 1816 /** 1817 * Safely unmount external storage at given mount point. The unmount is an 1818 * asynchronous operation. Applications should register StorageEventListener 1819 * for storage related status changes. 1820 * @param mountPoint the mount point 1821 * @param force whether or not to forcefully unmount it (e.g. even if programs are using this 1822 * data currently) 1823 * @param removeEncryption whether or not encryption mapping should be removed from the volume. 1824 * This value implies {@code force}. 1825 */ 1826 public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption) 1827 throws RemoteException; 1828 1829 /** 1830 * Unregisters an IMountServiceListener 1831 */ 1832 public void unregisterListener(IMountServiceListener listener) throws RemoteException; 1833 1834 /** 1835 * Returns whether or not the external storage is emulated. 1836 */ 1837 public boolean isExternalStorageEmulated() throws RemoteException; 1838 1839 /** The volume is not encrypted. */ 1840 static final int ENCRYPTION_STATE_NONE = 1; 1841 /** The volume has been encrypted succesfully. */ 1842 static final int ENCRYPTION_STATE_OK = 0; 1843 /** The volume is in a bad state.*/ 1844 static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1; 1845 /** Encryption is incomplete */ 1846 static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2; 1847 /** Encryption is incomplete and irrecoverable */ 1848 static final int ENCRYPTION_STATE_ERROR_INCONSISTENT = -3; 1849 /** Underlying data is corrupt */ 1850 static final int ENCRYPTION_STATE_ERROR_CORRUPT = -4; 1851 1852 /** 1853 * Determines the encryption state of the volume. 1854 * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values. 1855 */ 1856 public int getEncryptionState() throws RemoteException; 1857 1858 /** 1859 * Decrypts any encrypted volumes. 1860 */ 1861 public int decryptStorage(String password) throws RemoteException; 1862 1863 /** 1864 * Encrypts storage. 1865 */ 1866 public int encryptStorage(int type, String password) throws RemoteException; 1867 1868 /** 1869 * Changes the encryption password. 1870 */ 1871 public int changeEncryptionPassword(int type, String password) 1872 throws RemoteException; 1873 1874 /** 1875 * Verify the encryption password against the stored volume. This method 1876 * may only be called by the system process. 1877 */ 1878 public int verifyEncryptionPassword(String password) throws RemoteException; 1879 1880 /** 1881 * Returns list of all mountable volumes. 1882 */ 1883 public StorageVolume[] getVolumeList(int userId) throws RemoteException; 1884 1885 /** 1886 * Gets the path on the filesystem for the ASEC container itself. 1887 * 1888 * @param cid ASEC container ID 1889 * @return path to filesystem or {@code null} if it's not found 1890 * @throws RemoteException 1891 */ 1892 public String getSecureContainerFilesystemPath(String cid) throws RemoteException; 1893 1894 /* 1895 * Fix permissions in a container which has just been created and populated. 1896 * Returns an int consistent with MountServiceResultCode 1897 */ 1898 public int fixPermissionsSecureContainer(String id, int gid, String filename) 1899 throws RemoteException; 1900 1901 /** 1902 * Ensure that all directories along given path exist, creating parent 1903 * directories as needed. Validates that given path is absolute and that it 1904 * contains no relative "." or ".." paths or symlinks. Also ensures that 1905 * path belongs to a volume managed by vold, and that path is either 1906 * external storage data or OBB directory belonging to calling app. 1907 */ 1908 public int mkdirs(String callingPkg, String path) throws RemoteException; 1909 1910 /** 1911 * Determines the type of the encryption password 1912 * @return PasswordType 1913 */ 1914 public int getPasswordType() throws RemoteException; 1915 1916 /** 1917 * Get password from vold 1918 * @return password or empty string 1919 */ 1920 public String getPassword() throws RemoteException; 1921 1922 /** 1923 * Securely clear password from vold 1924 */ 1925 public void clearPassword() throws RemoteException; 1926 1927 /** 1928 * Set a field in the crypto header. 1929 * @param field field to set 1930 * @param contents contents to set in field 1931 */ 1932 public void setField(String field, String contents) throws RemoteException; 1933 1934 /** 1935 * Gets a field from the crypto header. 1936 * @param field field to get 1937 * @return contents of field 1938 */ 1939 public String getField(String field) throws RemoteException; 1940 1941 public int resizeSecureContainer(String id, int sizeMb, String key) throws RemoteException; 1942 1943 /** 1944 * Report the time of the last maintenance operation such as fstrim. 1945 * @return Timestamp of the last maintenance operation, in the 1946 * System.currentTimeMillis() time base 1947 * @throws RemoteException 1948 */ 1949 public long lastMaintenance() throws RemoteException; 1950 1951 /** 1952 * Kick off an immediate maintenance operation 1953 * @throws RemoteException 1954 */ 1955 public void runMaintenance() throws RemoteException; 1956 1957 public void waitForAsecScan() throws RemoteException; 1958 1959 public DiskInfo[] getDisks() throws RemoteException; 1960 public VolumeInfo[] getVolumes(int flags) throws RemoteException; 1961 1962 public void mount(String volId) throws RemoteException; 1963 public void unmount(String volId) throws RemoteException; 1964 public void format(String volId) throws RemoteException; 1965 1966 public void partitionPublic(String diskId) throws RemoteException; 1967 public void partitionPrivate(String diskId) throws RemoteException; 1968 public void partitionMixed(String diskId, int ratio) throws RemoteException; 1969 1970 public void setVolumeNickname(String volId, String nickname) throws RemoteException; 1971 public void setVolumeUserFlags(String volId, int flags, int mask) throws RemoteException; 1972} 1973