IMountService.java revision 7ec733fad39ff9e439a67c9cf51b88bc84cdfda0
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.content.pm.IPackageMoveObserver; 20import android.os.Binder; 21import android.os.IBinder; 22import android.os.IInterface; 23import android.os.Parcel; 24import android.os.RemoteException; 25 26/** 27 * WARNING! Update IMountService.h and IMountService.cpp if you change this 28 * file. In particular, the ordering of the methods below must match the 29 * _TRANSACTION enum in IMountService.cpp 30 * 31 * @hide - Applications should use android.os.storage.StorageManager to access 32 * storage functions. 33 */ 34public interface IMountService extends IInterface { 35 /** Local-side IPC implementation stub class. */ 36 public static abstract class Stub extends Binder implements IMountService { 37 private static class Proxy implements IMountService { 38 private final IBinder mRemote; 39 40 Proxy(IBinder remote) { 41 mRemote = remote; 42 } 43 44 public IBinder asBinder() { 45 return mRemote; 46 } 47 48 public String getInterfaceDescriptor() { 49 return DESCRIPTOR; 50 } 51 52 /** 53 * Registers an IMountServiceListener for receiving async 54 * notifications. 55 */ 56 public void registerListener(IMountServiceListener listener) throws RemoteException { 57 Parcel _data = Parcel.obtain(); 58 Parcel _reply = Parcel.obtain(); 59 try { 60 _data.writeInterfaceToken(DESCRIPTOR); 61 _data.writeStrongBinder((listener != null ? listener.asBinder() : null)); 62 mRemote.transact(Stub.TRANSACTION_registerListener, _data, _reply, 0); 63 _reply.readException(); 64 } finally { 65 _reply.recycle(); 66 _data.recycle(); 67 } 68 } 69 70 /** 71 * Unregisters an IMountServiceListener 72 */ 73 public void unregisterListener(IMountServiceListener listener) throws RemoteException { 74 Parcel _data = Parcel.obtain(); 75 Parcel _reply = Parcel.obtain(); 76 try { 77 _data.writeInterfaceToken(DESCRIPTOR); 78 _data.writeStrongBinder((listener != null ? listener.asBinder() : null)); 79 mRemote.transact(Stub.TRANSACTION_unregisterListener, _data, _reply, 0); 80 _reply.readException(); 81 } finally { 82 _reply.recycle(); 83 _data.recycle(); 84 } 85 } 86 87 /** 88 * Returns true if a USB mass storage host is connected 89 */ 90 public boolean isUsbMassStorageConnected() throws RemoteException { 91 Parcel _data = Parcel.obtain(); 92 Parcel _reply = Parcel.obtain(); 93 boolean _result; 94 try { 95 _data.writeInterfaceToken(DESCRIPTOR); 96 mRemote.transact(Stub.TRANSACTION_isUsbMassStorageConnected, _data, _reply, 0); 97 _reply.readException(); 98 _result = 0 != _reply.readInt(); 99 } finally { 100 _reply.recycle(); 101 _data.recycle(); 102 } 103 return _result; 104 } 105 106 /** 107 * Enables / disables USB mass storage. The caller should check 108 * actual status of enabling/disabling USB mass storage via 109 * StorageEventListener. 110 */ 111 public void setUsbMassStorageEnabled(boolean enable) throws RemoteException { 112 Parcel _data = Parcel.obtain(); 113 Parcel _reply = Parcel.obtain(); 114 try { 115 _data.writeInterfaceToken(DESCRIPTOR); 116 _data.writeInt((enable ? 1 : 0)); 117 mRemote.transact(Stub.TRANSACTION_setUsbMassStorageEnabled, _data, _reply, 0); 118 _reply.readException(); 119 } finally { 120 _reply.recycle(); 121 _data.recycle(); 122 } 123 } 124 125 /** 126 * Returns true if a USB mass storage host is enabled (media is 127 * shared) 128 */ 129 public boolean isUsbMassStorageEnabled() throws RemoteException { 130 Parcel _data = Parcel.obtain(); 131 Parcel _reply = Parcel.obtain(); 132 boolean _result; 133 try { 134 _data.writeInterfaceToken(DESCRIPTOR); 135 mRemote.transact(Stub.TRANSACTION_isUsbMassStorageEnabled, _data, _reply, 0); 136 _reply.readException(); 137 _result = 0 != _reply.readInt(); 138 } finally { 139 _reply.recycle(); 140 _data.recycle(); 141 } 142 return _result; 143 } 144 145 /** 146 * Mount external storage at given mount point. Returns an int 147 * consistent with MountServiceResultCode 148 */ 149 public int mountVolume(String mountPoint) throws RemoteException { 150 Parcel _data = Parcel.obtain(); 151 Parcel _reply = Parcel.obtain(); 152 int _result; 153 try { 154 _data.writeInterfaceToken(DESCRIPTOR); 155 _data.writeString(mountPoint); 156 mRemote.transact(Stub.TRANSACTION_mountVolume, _data, _reply, 0); 157 _reply.readException(); 158 _result = _reply.readInt(); 159 } finally { 160 _reply.recycle(); 161 _data.recycle(); 162 } 163 return _result; 164 } 165 166 /** 167 * Safely unmount external storage at given mount point. The unmount 168 * is an asynchronous operation. Applications should register 169 * StorageEventListener for storage related status changes. 170 */ 171 public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption) 172 throws RemoteException { 173 Parcel _data = Parcel.obtain(); 174 Parcel _reply = Parcel.obtain(); 175 try { 176 _data.writeInterfaceToken(DESCRIPTOR); 177 _data.writeString(mountPoint); 178 _data.writeInt((force ? 1 : 0)); 179 _data.writeInt((removeEncryption ? 1 : 0)); 180 mRemote.transact(Stub.TRANSACTION_unmountVolume, _data, _reply, 0); 181 _reply.readException(); 182 } finally { 183 _reply.recycle(); 184 _data.recycle(); 185 } 186 } 187 188 /** 189 * Format external storage given a mount point. Returns an int 190 * consistent with MountServiceResultCode 191 */ 192 public int formatVolume(String mountPoint) throws RemoteException { 193 Parcel _data = Parcel.obtain(); 194 Parcel _reply = Parcel.obtain(); 195 int _result; 196 try { 197 _data.writeInterfaceToken(DESCRIPTOR); 198 _data.writeString(mountPoint); 199 mRemote.transact(Stub.TRANSACTION_formatVolume, _data, _reply, 0); 200 _reply.readException(); 201 _result = _reply.readInt(); 202 } finally { 203 _reply.recycle(); 204 _data.recycle(); 205 } 206 return _result; 207 } 208 209 /** 210 * Returns an array of pids with open files on the specified path. 211 */ 212 public int[] getStorageUsers(String path) throws RemoteException { 213 Parcel _data = Parcel.obtain(); 214 Parcel _reply = Parcel.obtain(); 215 int[] _result; 216 try { 217 _data.writeInterfaceToken(DESCRIPTOR); 218 _data.writeString(path); 219 mRemote.transact(Stub.TRANSACTION_getStorageUsers, _data, _reply, 0); 220 _reply.readException(); 221 _result = _reply.createIntArray(); 222 } finally { 223 _reply.recycle(); 224 _data.recycle(); 225 } 226 return _result; 227 } 228 229 /** 230 * Gets the state of a volume via its mountpoint. 231 */ 232 public String getVolumeState(String mountPoint) throws RemoteException { 233 Parcel _data = Parcel.obtain(); 234 Parcel _reply = Parcel.obtain(); 235 String _result; 236 try { 237 _data.writeInterfaceToken(DESCRIPTOR); 238 _data.writeString(mountPoint); 239 mRemote.transact(Stub.TRANSACTION_getVolumeState, _data, _reply, 0); 240 _reply.readException(); 241 _result = _reply.readString(); 242 } finally { 243 _reply.recycle(); 244 _data.recycle(); 245 } 246 return _result; 247 } 248 249 /* 250 * Creates a secure container with the specified parameters. Returns 251 * an int consistent with MountServiceResultCode 252 */ 253 public int createSecureContainer(String id, int sizeMb, String fstype, String key, 254 int ownerUid, boolean external) throws RemoteException { 255 Parcel _data = Parcel.obtain(); 256 Parcel _reply = Parcel.obtain(); 257 int _result; 258 try { 259 _data.writeInterfaceToken(DESCRIPTOR); 260 _data.writeString(id); 261 _data.writeInt(sizeMb); 262 _data.writeString(fstype); 263 _data.writeString(key); 264 _data.writeInt(ownerUid); 265 _data.writeInt(external ? 1 : 0); 266 mRemote.transact(Stub.TRANSACTION_createSecureContainer, _data, _reply, 0); 267 _reply.readException(); 268 _result = _reply.readInt(); 269 } finally { 270 _reply.recycle(); 271 _data.recycle(); 272 } 273 return _result; 274 } 275 276 /* 277 * Destroy a secure container, and free up all resources associated 278 * with it. NOTE: Ensure all references are released prior to 279 * deleting. Returns an int consistent with MountServiceResultCode 280 */ 281 public int destroySecureContainer(String id, boolean force) throws RemoteException { 282 Parcel _data = Parcel.obtain(); 283 Parcel _reply = Parcel.obtain(); 284 int _result; 285 try { 286 _data.writeInterfaceToken(DESCRIPTOR); 287 _data.writeString(id); 288 _data.writeInt((force ? 1 : 0)); 289 mRemote.transact(Stub.TRANSACTION_destroySecureContainer, _data, _reply, 0); 290 _reply.readException(); 291 _result = _reply.readInt(); 292 } finally { 293 _reply.recycle(); 294 _data.recycle(); 295 } 296 return _result; 297 } 298 299 /* 300 * Finalize a container which has just been created and populated. 301 * After finalization, the container is immutable. Returns an int 302 * consistent with MountServiceResultCode 303 */ 304 public int finalizeSecureContainer(String id) throws RemoteException { 305 Parcel _data = Parcel.obtain(); 306 Parcel _reply = Parcel.obtain(); 307 int _result; 308 try { 309 _data.writeInterfaceToken(DESCRIPTOR); 310 _data.writeString(id); 311 mRemote.transact(Stub.TRANSACTION_finalizeSecureContainer, _data, _reply, 0); 312 _reply.readException(); 313 _result = _reply.readInt(); 314 } finally { 315 _reply.recycle(); 316 _data.recycle(); 317 } 318 return _result; 319 } 320 321 /* 322 * Mount a secure container with the specified key and owner UID. 323 * Returns an int consistent with MountServiceResultCode 324 */ 325 public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly) 326 throws RemoteException { 327 Parcel _data = Parcel.obtain(); 328 Parcel _reply = Parcel.obtain(); 329 int _result; 330 try { 331 _data.writeInterfaceToken(DESCRIPTOR); 332 _data.writeString(id); 333 _data.writeString(key); 334 _data.writeInt(ownerUid); 335 _data.writeInt(readOnly ? 1 : 0); 336 mRemote.transact(Stub.TRANSACTION_mountSecureContainer, _data, _reply, 0); 337 _reply.readException(); 338 _result = _reply.readInt(); 339 } finally { 340 _reply.recycle(); 341 _data.recycle(); 342 } 343 return _result; 344 } 345 346 /* 347 * Unount a secure container. Returns an int consistent with 348 * MountServiceResultCode 349 */ 350 public int unmountSecureContainer(String id, boolean force) throws RemoteException { 351 Parcel _data = Parcel.obtain(); 352 Parcel _reply = Parcel.obtain(); 353 int _result; 354 try { 355 _data.writeInterfaceToken(DESCRIPTOR); 356 _data.writeString(id); 357 _data.writeInt((force ? 1 : 0)); 358 mRemote.transact(Stub.TRANSACTION_unmountSecureContainer, _data, _reply, 0); 359 _reply.readException(); 360 _result = _reply.readInt(); 361 } finally { 362 _reply.recycle(); 363 _data.recycle(); 364 } 365 return _result; 366 } 367 368 /* 369 * Returns true if the specified container is mounted 370 */ 371 public boolean isSecureContainerMounted(String id) throws RemoteException { 372 Parcel _data = Parcel.obtain(); 373 Parcel _reply = Parcel.obtain(); 374 boolean _result; 375 try { 376 _data.writeInterfaceToken(DESCRIPTOR); 377 _data.writeString(id); 378 mRemote.transact(Stub.TRANSACTION_isSecureContainerMounted, _data, _reply, 0); 379 _reply.readException(); 380 _result = 0 != _reply.readInt(); 381 } finally { 382 _reply.recycle(); 383 _data.recycle(); 384 } 385 return _result; 386 } 387 388 /* 389 * Rename an unmounted secure container. Returns an int consistent 390 * with MountServiceResultCode 391 */ 392 public int renameSecureContainer(String oldId, String newId) throws RemoteException { 393 Parcel _data = Parcel.obtain(); 394 Parcel _reply = Parcel.obtain(); 395 int _result; 396 try { 397 _data.writeInterfaceToken(DESCRIPTOR); 398 _data.writeString(oldId); 399 _data.writeString(newId); 400 mRemote.transact(Stub.TRANSACTION_renameSecureContainer, _data, _reply, 0); 401 _reply.readException(); 402 _result = _reply.readInt(); 403 } finally { 404 _reply.recycle(); 405 _data.recycle(); 406 } 407 return _result; 408 } 409 410 /* 411 * Returns the filesystem path of a mounted secure container. 412 */ 413 public String getSecureContainerPath(String id) throws RemoteException { 414 Parcel _data = Parcel.obtain(); 415 Parcel _reply = Parcel.obtain(); 416 String _result; 417 try { 418 _data.writeInterfaceToken(DESCRIPTOR); 419 _data.writeString(id); 420 mRemote.transact(Stub.TRANSACTION_getSecureContainerPath, _data, _reply, 0); 421 _reply.readException(); 422 _result = _reply.readString(); 423 } finally { 424 _reply.recycle(); 425 _data.recycle(); 426 } 427 return _result; 428 } 429 430 /** 431 * Gets an Array of currently known secure container IDs 432 */ 433 public String[] getSecureContainerList() throws RemoteException { 434 Parcel _data = Parcel.obtain(); 435 Parcel _reply = Parcel.obtain(); 436 String[] _result; 437 try { 438 _data.writeInterfaceToken(DESCRIPTOR); 439 mRemote.transact(Stub.TRANSACTION_getSecureContainerList, _data, _reply, 0); 440 _reply.readException(); 441 _result = _reply.createStringArray(); 442 } finally { 443 _reply.recycle(); 444 _data.recycle(); 445 } 446 return _result; 447 } 448 449 /** 450 * Shuts down the MountService and gracefully unmounts all external 451 * media. Invokes call back once the shutdown is complete. 452 */ 453 public void shutdown(IMountShutdownObserver observer) 454 throws RemoteException { 455 Parcel _data = Parcel.obtain(); 456 Parcel _reply = Parcel.obtain(); 457 try { 458 _data.writeInterfaceToken(DESCRIPTOR); 459 _data.writeStrongBinder((observer != null ? observer.asBinder() : null)); 460 mRemote.transact(Stub.TRANSACTION_shutdown, _data, _reply, 0); 461 _reply.readException(); 462 } finally { 463 _reply.recycle(); 464 _data.recycle(); 465 } 466 } 467 468 /** 469 * Call into MountService by PackageManager to notify that its done 470 * processing the media status update request. 471 */ 472 public void finishMediaUpdate() throws RemoteException { 473 Parcel _data = Parcel.obtain(); 474 Parcel _reply = Parcel.obtain(); 475 try { 476 _data.writeInterfaceToken(DESCRIPTOR); 477 mRemote.transact(Stub.TRANSACTION_finishMediaUpdate, _data, _reply, 0); 478 _reply.readException(); 479 } finally { 480 _reply.recycle(); 481 _data.recycle(); 482 } 483 } 484 485 /** 486 * Mounts an Opaque Binary Blob (OBB) with the specified decryption 487 * key and only allows the calling process's UID access to the 488 * contents. MountService will call back to the supplied 489 * IObbActionListener to inform it of the terminal state of the 490 * call. 491 */ 492 public void mountObb(String rawPath, String canonicalPath, String key, 493 IObbActionListener token, int nonce) throws RemoteException { 494 Parcel _data = Parcel.obtain(); 495 Parcel _reply = Parcel.obtain(); 496 try { 497 _data.writeInterfaceToken(DESCRIPTOR); 498 _data.writeString(rawPath); 499 _data.writeString(canonicalPath); 500 _data.writeString(key); 501 _data.writeStrongBinder((token != null ? token.asBinder() : null)); 502 _data.writeInt(nonce); 503 mRemote.transact(Stub.TRANSACTION_mountObb, _data, _reply, 0); 504 _reply.readException(); 505 } finally { 506 _reply.recycle(); 507 _data.recycle(); 508 } 509 } 510 511 /** 512 * Unmounts an Opaque Binary Blob (OBB). When the force flag is 513 * specified, any program using it will be forcibly killed to 514 * unmount the image. MountService will call back to the supplied 515 * IObbActionListener to inform it of the terminal state of the 516 * call. 517 */ 518 public void unmountObb( 519 String rawPath, boolean force, IObbActionListener token, int nonce) 520 throws RemoteException { 521 Parcel _data = Parcel.obtain(); 522 Parcel _reply = Parcel.obtain(); 523 try { 524 _data.writeInterfaceToken(DESCRIPTOR); 525 _data.writeString(rawPath); 526 _data.writeInt((force ? 1 : 0)); 527 _data.writeStrongBinder((token != null ? token.asBinder() : null)); 528 _data.writeInt(nonce); 529 mRemote.transact(Stub.TRANSACTION_unmountObb, _data, _reply, 0); 530 _reply.readException(); 531 } finally { 532 _reply.recycle(); 533 _data.recycle(); 534 } 535 } 536 537 /** 538 * Checks whether the specified Opaque Binary Blob (OBB) is mounted 539 * somewhere. 540 */ 541 public boolean isObbMounted(String rawPath) throws RemoteException { 542 Parcel _data = Parcel.obtain(); 543 Parcel _reply = Parcel.obtain(); 544 boolean _result; 545 try { 546 _data.writeInterfaceToken(DESCRIPTOR); 547 _data.writeString(rawPath); 548 mRemote.transact(Stub.TRANSACTION_isObbMounted, _data, _reply, 0); 549 _reply.readException(); 550 _result = 0 != _reply.readInt(); 551 } finally { 552 _reply.recycle(); 553 _data.recycle(); 554 } 555 return _result; 556 } 557 558 /** 559 * Gets the path to the mounted Opaque Binary Blob (OBB). 560 */ 561 public String getMountedObbPath(String rawPath) throws RemoteException { 562 Parcel _data = Parcel.obtain(); 563 Parcel _reply = Parcel.obtain(); 564 String _result; 565 try { 566 _data.writeInterfaceToken(DESCRIPTOR); 567 _data.writeString(rawPath); 568 mRemote.transact(Stub.TRANSACTION_getMountedObbPath, _data, _reply, 0); 569 _reply.readException(); 570 _result = _reply.readString(); 571 } finally { 572 _reply.recycle(); 573 _data.recycle(); 574 } 575 return _result; 576 } 577 578 /** 579 * Returns whether the external storage is emulated. 580 */ 581 public boolean isExternalStorageEmulated() throws RemoteException { 582 Parcel _data = Parcel.obtain(); 583 Parcel _reply = Parcel.obtain(); 584 boolean _result; 585 try { 586 _data.writeInterfaceToken(DESCRIPTOR); 587 mRemote.transact(Stub.TRANSACTION_isExternalStorageEmulated, _data, _reply, 0); 588 _reply.readException(); 589 _result = 0 != _reply.readInt(); 590 } finally { 591 _reply.recycle(); 592 _data.recycle(); 593 } 594 return _result; 595 } 596 597 public int getEncryptionState() throws RemoteException { 598 Parcel _data = Parcel.obtain(); 599 Parcel _reply = Parcel.obtain(); 600 int _result; 601 try { 602 _data.writeInterfaceToken(DESCRIPTOR); 603 mRemote.transact(Stub.TRANSACTION_getEncryptionState, _data, _reply, 0); 604 _reply.readException(); 605 _result = _reply.readInt(); 606 } finally { 607 _reply.recycle(); 608 _data.recycle(); 609 } 610 return _result; 611 } 612 613 public int decryptStorage(String password) throws RemoteException { 614 Parcel _data = Parcel.obtain(); 615 Parcel _reply = Parcel.obtain(); 616 int _result; 617 try { 618 _data.writeInterfaceToken(DESCRIPTOR); 619 _data.writeString(password); 620 mRemote.transact(Stub.TRANSACTION_decryptStorage, _data, _reply, 0); 621 _reply.readException(); 622 _result = _reply.readInt(); 623 } finally { 624 _reply.recycle(); 625 _data.recycle(); 626 } 627 return _result; 628 } 629 630 public int encryptStorage(int type, String password) throws RemoteException { 631 Parcel _data = Parcel.obtain(); 632 Parcel _reply = Parcel.obtain(); 633 int _result; 634 try { 635 _data.writeInterfaceToken(DESCRIPTOR); 636 _data.writeInt(type); 637 _data.writeString(password); 638 mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0); 639 _reply.readException(); 640 _result = _reply.readInt(); 641 } finally { 642 _reply.recycle(); 643 _data.recycle(); 644 } 645 return _result; 646 } 647 648 public int changeEncryptionPassword(int type, String password) throws RemoteException { 649 Parcel _data = Parcel.obtain(); 650 Parcel _reply = Parcel.obtain(); 651 int _result; 652 try { 653 _data.writeInterfaceToken(DESCRIPTOR); 654 _data.writeInt(type); 655 _data.writeString(password); 656 mRemote.transact(Stub.TRANSACTION_changeEncryptionPassword, _data, _reply, 0); 657 _reply.readException(); 658 _result = _reply.readInt(); 659 } finally { 660 _reply.recycle(); 661 _data.recycle(); 662 } 663 return _result; 664 } 665 666 @Override 667 public int verifyEncryptionPassword(String password) throws RemoteException { 668 Parcel _data = Parcel.obtain(); 669 Parcel _reply = Parcel.obtain(); 670 int _result; 671 try { 672 _data.writeInterfaceToken(DESCRIPTOR); 673 _data.writeString(password); 674 mRemote.transact(Stub.TRANSACTION_verifyEncryptionPassword, _data, _reply, 0); 675 _reply.readException(); 676 _result = _reply.readInt(); 677 } finally { 678 _reply.recycle(); 679 _data.recycle(); 680 } 681 return _result; 682 } 683 684 public int getPasswordType() throws RemoteException { 685 Parcel _data = Parcel.obtain(); 686 Parcel _reply = Parcel.obtain(); 687 int _result; 688 try { 689 _data.writeInterfaceToken(DESCRIPTOR); 690 mRemote.transact(Stub.TRANSACTION_getPasswordType, _data, _reply, 0); 691 _reply.readException(); 692 _result = _reply.readInt(); 693 } finally { 694 _reply.recycle(); 695 _data.recycle(); 696 } 697 return _result; 698 } 699 700 public String getPassword() throws RemoteException { 701 Parcel _data = Parcel.obtain(); 702 Parcel _reply = Parcel.obtain(); 703 String _result; 704 try { 705 _data.writeInterfaceToken(DESCRIPTOR); 706 mRemote.transact(Stub.TRANSACTION_getPassword, _data, _reply, 0); 707 _reply.readException(); 708 _result = _reply.readString(); 709 } finally { 710 _reply.recycle(); 711 _data.recycle(); 712 } 713 return _result; 714 } 715 716 public void clearPassword() throws RemoteException { 717 Parcel _data = Parcel.obtain(); 718 Parcel _reply = Parcel.obtain(); 719 try { 720 _data.writeInterfaceToken(DESCRIPTOR); 721 mRemote.transact(Stub.TRANSACTION_clearPassword, _data, _reply, IBinder.FLAG_ONEWAY); 722 _reply.readException(); 723 } finally { 724 _reply.recycle(); 725 _data.recycle(); 726 } 727 } 728 729 public void setField(String field, String data) throws RemoteException { 730 Parcel _data = Parcel.obtain(); 731 Parcel _reply = Parcel.obtain(); 732 try { 733 _data.writeInterfaceToken(DESCRIPTOR); 734 _data.writeString(field); 735 _data.writeString(data); 736 mRemote.transact(Stub.TRANSACTION_setField, _data, _reply, IBinder.FLAG_ONEWAY); 737 _reply.readException(); 738 } finally { 739 _reply.recycle(); 740 _data.recycle(); 741 } 742 } 743 744 public String getField(String field) throws RemoteException { 745 Parcel _data = Parcel.obtain(); 746 Parcel _reply = Parcel.obtain(); 747 String _result; 748 try { 749 _data.writeInterfaceToken(DESCRIPTOR); 750 _data.writeString(field); 751 mRemote.transact(Stub.TRANSACTION_getField, _data, _reply, 0); 752 _reply.readException(); 753 _result = _reply.readString(); 754 } finally { 755 _reply.recycle(); 756 _data.recycle(); 757 } 758 return _result; 759 } 760 761 public StorageVolume[] getVolumeList(int userId) throws RemoteException { 762 Parcel _data = Parcel.obtain(); 763 Parcel _reply = Parcel.obtain(); 764 StorageVolume[] _result; 765 try { 766 _data.writeInterfaceToken(DESCRIPTOR); 767 _data.writeInt(userId); 768 mRemote.transact(Stub.TRANSACTION_getVolumeList, _data, _reply, 0); 769 _reply.readException(); 770 _result = _reply.createTypedArray(StorageVolume.CREATOR); 771 } finally { 772 _reply.recycle(); 773 _data.recycle(); 774 } 775 return _result; 776 } 777 778 /* 779 * Returns the filesystem path of a mounted secure container. 780 */ 781 public String getSecureContainerFilesystemPath(String id) throws RemoteException { 782 Parcel _data = Parcel.obtain(); 783 Parcel _reply = Parcel.obtain(); 784 String _result; 785 try { 786 _data.writeInterfaceToken(DESCRIPTOR); 787 _data.writeString(id); 788 mRemote.transact(Stub.TRANSACTION_getSecureContainerFilesystemPath, _data, _reply, 0); 789 _reply.readException(); 790 _result = _reply.readString(); 791 } finally { 792 _reply.recycle(); 793 _data.recycle(); 794 } 795 return _result; 796 } 797 798 /** 799 * Fix permissions in a container which has just been created and 800 * populated. Returns an int consistent with MountServiceResultCode 801 */ 802 public int fixPermissionsSecureContainer(String id, int gid, String filename) 803 throws RemoteException { 804 Parcel _data = Parcel.obtain(); 805 Parcel _reply = Parcel.obtain(); 806 int _result; 807 try { 808 _data.writeInterfaceToken(DESCRIPTOR); 809 _data.writeString(id); 810 _data.writeInt(gid); 811 _data.writeString(filename); 812 mRemote.transact(Stub.TRANSACTION_fixPermissionsSecureContainer, _data, _reply, 0); 813 _reply.readException(); 814 _result = _reply.readInt(); 815 } finally { 816 _reply.recycle(); 817 _data.recycle(); 818 } 819 return _result; 820 } 821 822 @Override 823 public int mkdirs(String callingPkg, String path) throws RemoteException { 824 Parcel _data = Parcel.obtain(); 825 Parcel _reply = Parcel.obtain(); 826 int _result; 827 try { 828 _data.writeInterfaceToken(DESCRIPTOR); 829 _data.writeString(callingPkg); 830 _data.writeString(path); 831 mRemote.transact(Stub.TRANSACTION_mkdirs, _data, _reply, 0); 832 _reply.readException(); 833 _result = _reply.readInt(); 834 } finally { 835 _reply.recycle(); 836 _data.recycle(); 837 } 838 return _result; 839 } 840 841 @Override 842 public int resizeSecureContainer(String id, int sizeMb, String key) 843 throws RemoteException { 844 Parcel _data = Parcel.obtain(); 845 Parcel _reply = Parcel.obtain(); 846 int _result; 847 try { 848 _data.writeInterfaceToken(DESCRIPTOR); 849 _data.writeString(id); 850 _data.writeInt(sizeMb); 851 _data.writeString(key); 852 mRemote.transact(Stub.TRANSACTION_resizeSecureContainer, _data, _reply, 0); 853 _reply.readException(); 854 _result = _reply.readInt(); 855 } finally { 856 _reply.recycle(); 857 _data.recycle(); 858 } 859 return _result; 860 } 861 862 @Override 863 public long lastMaintenance() throws RemoteException { 864 Parcel _data = Parcel.obtain(); 865 Parcel _reply = Parcel.obtain(); 866 long _result; 867 try { 868 _data.writeInterfaceToken(DESCRIPTOR); 869 mRemote.transact(Stub.TRANSACTION_lastMaintenance, _data, _reply, 0); 870 _reply.readException(); 871 _result = _reply.readLong(); 872 } finally { 873 _reply.recycle(); 874 _data.recycle(); 875 } 876 return _result; 877 } 878 879 @Override 880 public void runMaintenance() throws RemoteException { 881 Parcel _data = Parcel.obtain(); 882 Parcel _reply = Parcel.obtain(); 883 try { 884 _data.writeInterfaceToken(DESCRIPTOR); 885 mRemote.transact(Stub.TRANSACTION_runMaintenance, _data, _reply, 0); 886 _reply.readException(); 887 } finally { 888 _reply.recycle(); 889 _data.recycle(); 890 } 891 return; 892 } 893 894 @Override 895 public void waitForAsecScan() throws RemoteException { 896 Parcel _data = Parcel.obtain(); 897 Parcel _reply = Parcel.obtain(); 898 try { 899 _data.writeInterfaceToken(DESCRIPTOR); 900 mRemote.transact(Stub.TRANSACTION_waitForAsecScan, _data, _reply, 0); 901 _reply.readException(); 902 } finally { 903 _reply.recycle(); 904 _data.recycle(); 905 } 906 return; 907 } 908 909 @Override 910 public DiskInfo[] getDisks() throws RemoteException { 911 Parcel _data = Parcel.obtain(); 912 Parcel _reply = Parcel.obtain(); 913 DiskInfo[] _result; 914 try { 915 _data.writeInterfaceToken(DESCRIPTOR); 916 mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0); 917 _reply.readException(); 918 _result = _reply.createTypedArray(DiskInfo.CREATOR); 919 } finally { 920 _reply.recycle(); 921 _data.recycle(); 922 } 923 return _result; 924 } 925 926 @Override 927 public VolumeInfo[] getVolumes(int _flags) throws RemoteException { 928 Parcel _data = Parcel.obtain(); 929 Parcel _reply = Parcel.obtain(); 930 VolumeInfo[] _result; 931 try { 932 _data.writeInterfaceToken(DESCRIPTOR); 933 _data.writeInt(_flags); 934 mRemote.transact(Stub.TRANSACTION_getVolumes, _data, _reply, 0); 935 _reply.readException(); 936 _result = _reply.createTypedArray(VolumeInfo.CREATOR); 937 } finally { 938 _reply.recycle(); 939 _data.recycle(); 940 } 941 return _result; 942 } 943 944 @Override 945 public VolumeRecord[] getVolumeRecords(int _flags) throws RemoteException { 946 Parcel _data = Parcel.obtain(); 947 Parcel _reply = Parcel.obtain(); 948 VolumeRecord[] _result; 949 try { 950 _data.writeInterfaceToken(DESCRIPTOR); 951 _data.writeInt(_flags); 952 mRemote.transact(Stub.TRANSACTION_getVolumeRecords, _data, _reply, 0); 953 _reply.readException(); 954 _result = _reply.createTypedArray(VolumeRecord.CREATOR); 955 } finally { 956 _reply.recycle(); 957 _data.recycle(); 958 } 959 return _result; 960 } 961 962 @Override 963 public void mount(String volId) throws RemoteException { 964 Parcel _data = Parcel.obtain(); 965 Parcel _reply = Parcel.obtain(); 966 try { 967 _data.writeInterfaceToken(DESCRIPTOR); 968 _data.writeString(volId); 969 mRemote.transact(Stub.TRANSACTION_mount, _data, _reply, 0); 970 _reply.readException(); 971 } finally { 972 _reply.recycle(); 973 _data.recycle(); 974 } 975 } 976 977 @Override 978 public void unmount(String volId) throws RemoteException { 979 Parcel _data = Parcel.obtain(); 980 Parcel _reply = Parcel.obtain(); 981 try { 982 _data.writeInterfaceToken(DESCRIPTOR); 983 _data.writeString(volId); 984 mRemote.transact(Stub.TRANSACTION_unmount, _data, _reply, 0); 985 _reply.readException(); 986 } finally { 987 _reply.recycle(); 988 _data.recycle(); 989 } 990 } 991 992 @Override 993 public void format(String volId) throws RemoteException { 994 Parcel _data = Parcel.obtain(); 995 Parcel _reply = Parcel.obtain(); 996 try { 997 _data.writeInterfaceToken(DESCRIPTOR); 998 _data.writeString(volId); 999 mRemote.transact(Stub.TRANSACTION_format, _data, _reply, 0); 1000 _reply.readException(); 1001 } finally { 1002 _reply.recycle(); 1003 _data.recycle(); 1004 } 1005 } 1006 1007 @Override 1008 public long benchmark(String volId) throws RemoteException { 1009 Parcel _data = Parcel.obtain(); 1010 Parcel _reply = Parcel.obtain(); 1011 try { 1012 _data.writeInterfaceToken(DESCRIPTOR); 1013 _data.writeString(volId); 1014 mRemote.transact(Stub.TRANSACTION_benchmark, _data, _reply, 0); 1015 _reply.readException(); 1016 return _reply.readLong(); 1017 } finally { 1018 _reply.recycle(); 1019 _data.recycle(); 1020 } 1021 } 1022 1023 @Override 1024 public void partitionPublic(String diskId) throws RemoteException { 1025 Parcel _data = Parcel.obtain(); 1026 Parcel _reply = Parcel.obtain(); 1027 try { 1028 _data.writeInterfaceToken(DESCRIPTOR); 1029 _data.writeString(diskId); 1030 mRemote.transact(Stub.TRANSACTION_partitionPublic, _data, _reply, 0); 1031 _reply.readException(); 1032 } finally { 1033 _reply.recycle(); 1034 _data.recycle(); 1035 } 1036 } 1037 1038 @Override 1039 public void partitionPrivate(String diskId) throws RemoteException { 1040 Parcel _data = Parcel.obtain(); 1041 Parcel _reply = Parcel.obtain(); 1042 try { 1043 _data.writeInterfaceToken(DESCRIPTOR); 1044 _data.writeString(diskId); 1045 mRemote.transact(Stub.TRANSACTION_partitionPrivate, _data, _reply, 0); 1046 _reply.readException(); 1047 } finally { 1048 _reply.recycle(); 1049 _data.recycle(); 1050 } 1051 } 1052 1053 @Override 1054 public void partitionMixed(String diskId, int ratio) throws RemoteException { 1055 Parcel _data = Parcel.obtain(); 1056 Parcel _reply = Parcel.obtain(); 1057 try { 1058 _data.writeInterfaceToken(DESCRIPTOR); 1059 _data.writeString(diskId); 1060 _data.writeInt(ratio); 1061 mRemote.transact(Stub.TRANSACTION_partitionMixed, _data, _reply, 0); 1062 _reply.readException(); 1063 } finally { 1064 _reply.recycle(); 1065 _data.recycle(); 1066 } 1067 } 1068 1069 @Override 1070 public void setVolumeNickname(String fsUuid, String nickname) throws RemoteException { 1071 Parcel _data = Parcel.obtain(); 1072 Parcel _reply = Parcel.obtain(); 1073 try { 1074 _data.writeInterfaceToken(DESCRIPTOR); 1075 _data.writeString(fsUuid); 1076 _data.writeString(nickname); 1077 mRemote.transact(Stub.TRANSACTION_setVolumeNickname, _data, _reply, 0); 1078 _reply.readException(); 1079 } finally { 1080 _reply.recycle(); 1081 _data.recycle(); 1082 } 1083 } 1084 1085 @Override 1086 public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException { 1087 Parcel _data = Parcel.obtain(); 1088 Parcel _reply = Parcel.obtain(); 1089 try { 1090 _data.writeInterfaceToken(DESCRIPTOR); 1091 _data.writeString(fsUuid); 1092 _data.writeInt(flags); 1093 _data.writeInt(mask); 1094 mRemote.transact(Stub.TRANSACTION_setVolumeUserFlags, _data, _reply, 0); 1095 _reply.readException(); 1096 } finally { 1097 _reply.recycle(); 1098 _data.recycle(); 1099 } 1100 } 1101 1102 @Override 1103 public void forgetVolume(String fsUuid) throws RemoteException { 1104 Parcel _data = Parcel.obtain(); 1105 Parcel _reply = Parcel.obtain(); 1106 try { 1107 _data.writeInterfaceToken(DESCRIPTOR); 1108 _data.writeString(fsUuid); 1109 mRemote.transact(Stub.TRANSACTION_forgetVolume, _data, _reply, 0); 1110 _reply.readException(); 1111 } finally { 1112 _reply.recycle(); 1113 _data.recycle(); 1114 } 1115 } 1116 1117 @Override 1118 public void forgetAllVolumes() throws RemoteException { 1119 Parcel _data = Parcel.obtain(); 1120 Parcel _reply = Parcel.obtain(); 1121 try { 1122 _data.writeInterfaceToken(DESCRIPTOR); 1123 mRemote.transact(Stub.TRANSACTION_forgetAllVolumes, _data, _reply, 0); 1124 _reply.readException(); 1125 } finally { 1126 _reply.recycle(); 1127 _data.recycle(); 1128 } 1129 } 1130 1131 @Override 1132 public void setDebugFlags(int _flags, int _mask) throws RemoteException { 1133 Parcel _data = Parcel.obtain(); 1134 Parcel _reply = Parcel.obtain(); 1135 try { 1136 _data.writeInterfaceToken(DESCRIPTOR); 1137 _data.writeInt(_flags); 1138 _data.writeInt(_mask); 1139 mRemote.transact(Stub.TRANSACTION_setDebugFlags, _data, _reply, 0); 1140 _reply.readException(); 1141 } finally { 1142 _reply.recycle(); 1143 _data.recycle(); 1144 } 1145 } 1146 1147 @Override 1148 public String getPrimaryStorageUuid() throws RemoteException { 1149 Parcel _data = Parcel.obtain(); 1150 Parcel _reply = Parcel.obtain(); 1151 String _result; 1152 try { 1153 _data.writeInterfaceToken(DESCRIPTOR); 1154 mRemote.transact(Stub.TRANSACTION_getPrimaryStorageUuid, _data, _reply, 0); 1155 _reply.readException(); 1156 _result = _reply.readString(); 1157 } finally { 1158 _reply.recycle(); 1159 _data.recycle(); 1160 } 1161 return _result; 1162 } 1163 1164 @Override 1165 public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback) 1166 throws RemoteException { 1167 Parcel _data = Parcel.obtain(); 1168 Parcel _reply = Parcel.obtain(); 1169 try { 1170 _data.writeInterfaceToken(DESCRIPTOR); 1171 _data.writeString(volumeUuid); 1172 _data.writeStrongBinder((callback != null ? callback.asBinder() : null)); 1173 mRemote.transact(Stub.TRANSACTION_setPrimaryStorageUuid, _data, _reply, 0); 1174 _reply.readException(); 1175 } finally { 1176 _reply.recycle(); 1177 _data.recycle(); 1178 } 1179 } 1180 1181 @Override 1182 public void remountUid(int uid) throws RemoteException { 1183 Parcel _data = Parcel.obtain(); 1184 Parcel _reply = Parcel.obtain(); 1185 try { 1186 _data.writeInterfaceToken(DESCRIPTOR); 1187 _data.writeInt(uid); 1188 mRemote.transact(Stub.TRANSACTION_remountUid, _data, _reply, 0); 1189 _reply.readException(); 1190 } finally { 1191 _reply.recycle(); 1192 _data.recycle(); 1193 } 1194 } 1195 1196 @Override 1197 public void createNewUserDir(int userHandle, String path) throws RemoteException { 1198 Parcel _data = Parcel.obtain(); 1199 Parcel _reply = Parcel.obtain(); 1200 try { 1201 _data.writeInterfaceToken(DESCRIPTOR); 1202 _data.writeInt(userHandle); 1203 _data.writeString(path); 1204 mRemote.transact(Stub.TRANSACTION_createNewUserDir, _data, _reply, 0); 1205 _reply.readException(); 1206 } finally { 1207 _reply.recycle(); 1208 _data.recycle(); 1209 } 1210 } 1211 1212 @Override 1213 public void deleteUserKey(int userHandle) throws RemoteException { 1214 Parcel _data = Parcel.obtain(); 1215 Parcel _reply = Parcel.obtain(); 1216 try { 1217 _data.writeInterfaceToken(DESCRIPTOR); 1218 _data.writeInt(userHandle); 1219 mRemote.transact(Stub.TRANSACTION_deleteUserKey, _data, _reply, 0); 1220 _reply.readException(); 1221 } finally { 1222 _reply.recycle(); 1223 _data.recycle(); 1224 } 1225 } 1226 } 1227 1228 private static final String DESCRIPTOR = "IMountService"; 1229 1230 static final int TRANSACTION_registerListener = IBinder.FIRST_CALL_TRANSACTION + 0; 1231 1232 static final int TRANSACTION_unregisterListener = IBinder.FIRST_CALL_TRANSACTION + 1; 1233 1234 static final int TRANSACTION_isUsbMassStorageConnected = IBinder.FIRST_CALL_TRANSACTION + 2; 1235 1236 static final int TRANSACTION_setUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 3; 1237 1238 static final int TRANSACTION_isUsbMassStorageEnabled = IBinder.FIRST_CALL_TRANSACTION + 4; 1239 1240 static final int TRANSACTION_mountVolume = IBinder.FIRST_CALL_TRANSACTION + 5; 1241 1242 static final int TRANSACTION_unmountVolume = IBinder.FIRST_CALL_TRANSACTION + 6; 1243 1244 static final int TRANSACTION_formatVolume = IBinder.FIRST_CALL_TRANSACTION + 7; 1245 1246 static final int TRANSACTION_getStorageUsers = IBinder.FIRST_CALL_TRANSACTION + 8; 1247 1248 static final int TRANSACTION_getVolumeState = IBinder.FIRST_CALL_TRANSACTION + 9; 1249 1250 static final int TRANSACTION_createSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 10; 1251 1252 static final int TRANSACTION_finalizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 11; 1253 1254 static final int TRANSACTION_destroySecureContainer = IBinder.FIRST_CALL_TRANSACTION + 12; 1255 1256 static final int TRANSACTION_mountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 13; 1257 1258 static final int TRANSACTION_unmountSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 14; 1259 1260 static final int TRANSACTION_isSecureContainerMounted = IBinder.FIRST_CALL_TRANSACTION + 15; 1261 1262 static final int TRANSACTION_renameSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 16; 1263 1264 static final int TRANSACTION_getSecureContainerPath = IBinder.FIRST_CALL_TRANSACTION + 17; 1265 1266 static final int TRANSACTION_getSecureContainerList = IBinder.FIRST_CALL_TRANSACTION + 18; 1267 1268 static final int TRANSACTION_shutdown = IBinder.FIRST_CALL_TRANSACTION + 19; 1269 1270 static final int TRANSACTION_finishMediaUpdate = IBinder.FIRST_CALL_TRANSACTION + 20; 1271 1272 static final int TRANSACTION_mountObb = IBinder.FIRST_CALL_TRANSACTION + 21; 1273 1274 static final int TRANSACTION_unmountObb = IBinder.FIRST_CALL_TRANSACTION + 22; 1275 1276 static final int TRANSACTION_isObbMounted = IBinder.FIRST_CALL_TRANSACTION + 23; 1277 1278 static final int TRANSACTION_getMountedObbPath = IBinder.FIRST_CALL_TRANSACTION + 24; 1279 1280 static final int TRANSACTION_isExternalStorageEmulated = IBinder.FIRST_CALL_TRANSACTION + 25; 1281 1282 static final int TRANSACTION_decryptStorage = IBinder.FIRST_CALL_TRANSACTION + 26; 1283 1284 static final int TRANSACTION_encryptStorage = IBinder.FIRST_CALL_TRANSACTION + 27; 1285 1286 static final int TRANSACTION_changeEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 28; 1287 1288 static final int TRANSACTION_getVolumeList = IBinder.FIRST_CALL_TRANSACTION + 29; 1289 1290 static final int TRANSACTION_getSecureContainerFilesystemPath = IBinder.FIRST_CALL_TRANSACTION + 30; 1291 1292 static final int TRANSACTION_getEncryptionState = IBinder.FIRST_CALL_TRANSACTION + 31; 1293 1294 static final int TRANSACTION_verifyEncryptionPassword = IBinder.FIRST_CALL_TRANSACTION + 32; 1295 1296 static final int TRANSACTION_fixPermissionsSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 33; 1297 1298 static final int TRANSACTION_mkdirs = IBinder.FIRST_CALL_TRANSACTION + 34; 1299 1300 static final int TRANSACTION_getPasswordType = IBinder.FIRST_CALL_TRANSACTION + 35; 1301 1302 static final int TRANSACTION_getPassword = IBinder.FIRST_CALL_TRANSACTION + 36; 1303 1304 static final int TRANSACTION_clearPassword = IBinder.FIRST_CALL_TRANSACTION + 37; 1305 1306 static final int TRANSACTION_setField = IBinder.FIRST_CALL_TRANSACTION + 38; 1307 1308 static final int TRANSACTION_getField = IBinder.FIRST_CALL_TRANSACTION + 39; 1309 1310 static final int TRANSACTION_resizeSecureContainer = IBinder.FIRST_CALL_TRANSACTION + 40; 1311 1312 static final int TRANSACTION_lastMaintenance = IBinder.FIRST_CALL_TRANSACTION + 41; 1313 1314 static final int TRANSACTION_runMaintenance = IBinder.FIRST_CALL_TRANSACTION + 42; 1315 1316 static final int TRANSACTION_waitForAsecScan = IBinder.FIRST_CALL_TRANSACTION + 43; 1317 1318 static final int TRANSACTION_getDisks = IBinder.FIRST_CALL_TRANSACTION + 44; 1319 static final int TRANSACTION_getVolumes = IBinder.FIRST_CALL_TRANSACTION + 45; 1320 static final int TRANSACTION_getVolumeRecords = IBinder.FIRST_CALL_TRANSACTION + 46; 1321 1322 static final int TRANSACTION_mount = IBinder.FIRST_CALL_TRANSACTION + 47; 1323 static final int TRANSACTION_unmount = IBinder.FIRST_CALL_TRANSACTION + 48; 1324 static final int TRANSACTION_format = IBinder.FIRST_CALL_TRANSACTION + 49; 1325 1326 static final int TRANSACTION_partitionPublic = IBinder.FIRST_CALL_TRANSACTION + 50; 1327 static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 51; 1328 static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 52; 1329 1330 static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 53; 1331 static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 54; 1332 static final int TRANSACTION_forgetVolume = IBinder.FIRST_CALL_TRANSACTION + 55; 1333 static final int TRANSACTION_forgetAllVolumes = IBinder.FIRST_CALL_TRANSACTION + 56; 1334 1335 static final int TRANSACTION_getPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 57; 1336 static final int TRANSACTION_setPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 58; 1337 1338 static final int TRANSACTION_benchmark = IBinder.FIRST_CALL_TRANSACTION + 59; 1339 static final int TRANSACTION_setDebugFlags = IBinder.FIRST_CALL_TRANSACTION + 60; 1340 1341 static final int TRANSACTION_remountUid = IBinder.FIRST_CALL_TRANSACTION + 61; 1342 1343 static final int TRANSACTION_createNewUserDir = IBinder.FIRST_CALL_TRANSACTION + 62; 1344 static final int TRANSACTION_deleteUserKey = IBinder.FIRST_CALL_TRANSACTION + 63; 1345 1346 /** 1347 * Cast an IBinder object into an IMountService interface, generating a 1348 * proxy if needed. 1349 */ 1350 public static IMountService asInterface(IBinder obj) { 1351 if (obj == null) { 1352 return null; 1353 } 1354 IInterface iin = obj.queryLocalInterface(DESCRIPTOR); 1355 if (iin != null && iin instanceof IMountService) { 1356 return (IMountService) iin; 1357 } 1358 return new IMountService.Stub.Proxy(obj); 1359 } 1360 1361 /** Construct the stub at attach it to the interface. */ 1362 public Stub() { 1363 attachInterface(this, DESCRIPTOR); 1364 } 1365 1366 public IBinder asBinder() { 1367 return this; 1368 } 1369 1370 @Override 1371 public boolean onTransact(int code, Parcel data, Parcel reply, 1372 int flags) throws RemoteException { 1373 switch (code) { 1374 case INTERFACE_TRANSACTION: { 1375 reply.writeString(DESCRIPTOR); 1376 return true; 1377 } 1378 case TRANSACTION_registerListener: { 1379 data.enforceInterface(DESCRIPTOR); 1380 IMountServiceListener listener; 1381 listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder()); 1382 registerListener(listener); 1383 reply.writeNoException(); 1384 return true; 1385 } 1386 case TRANSACTION_unregisterListener: { 1387 data.enforceInterface(DESCRIPTOR); 1388 IMountServiceListener listener; 1389 listener = IMountServiceListener.Stub.asInterface(data.readStrongBinder()); 1390 unregisterListener(listener); 1391 reply.writeNoException(); 1392 return true; 1393 } 1394 case TRANSACTION_isUsbMassStorageConnected: { 1395 data.enforceInterface(DESCRIPTOR); 1396 boolean result = isUsbMassStorageConnected(); 1397 reply.writeNoException(); 1398 reply.writeInt((result ? 1 : 0)); 1399 return true; 1400 } 1401 case TRANSACTION_setUsbMassStorageEnabled: { 1402 data.enforceInterface(DESCRIPTOR); 1403 boolean enable; 1404 enable = 0 != data.readInt(); 1405 setUsbMassStorageEnabled(enable); 1406 reply.writeNoException(); 1407 return true; 1408 } 1409 case TRANSACTION_isUsbMassStorageEnabled: { 1410 data.enforceInterface(DESCRIPTOR); 1411 boolean result = isUsbMassStorageEnabled(); 1412 reply.writeNoException(); 1413 reply.writeInt((result ? 1 : 0)); 1414 return true; 1415 } 1416 case TRANSACTION_mountVolume: { 1417 data.enforceInterface(DESCRIPTOR); 1418 String mountPoint; 1419 mountPoint = data.readString(); 1420 int resultCode = mountVolume(mountPoint); 1421 reply.writeNoException(); 1422 reply.writeInt(resultCode); 1423 return true; 1424 } 1425 case TRANSACTION_unmountVolume: { 1426 data.enforceInterface(DESCRIPTOR); 1427 String mountPoint; 1428 mountPoint = data.readString(); 1429 boolean force = 0 != data.readInt(); 1430 boolean removeEncrypt = 0 != data.readInt(); 1431 unmountVolume(mountPoint, force, removeEncrypt); 1432 reply.writeNoException(); 1433 return true; 1434 } 1435 case TRANSACTION_formatVolume: { 1436 data.enforceInterface(DESCRIPTOR); 1437 String mountPoint; 1438 mountPoint = data.readString(); 1439 int result = formatVolume(mountPoint); 1440 reply.writeNoException(); 1441 reply.writeInt(result); 1442 return true; 1443 } 1444 case TRANSACTION_getStorageUsers: { 1445 data.enforceInterface(DESCRIPTOR); 1446 String path; 1447 path = data.readString(); 1448 int[] pids = getStorageUsers(path); 1449 reply.writeNoException(); 1450 reply.writeIntArray(pids); 1451 return true; 1452 } 1453 case TRANSACTION_getVolumeState: { 1454 data.enforceInterface(DESCRIPTOR); 1455 String mountPoint; 1456 mountPoint = data.readString(); 1457 String state = getVolumeState(mountPoint); 1458 reply.writeNoException(); 1459 reply.writeString(state); 1460 return true; 1461 } 1462 case TRANSACTION_createSecureContainer: { 1463 data.enforceInterface(DESCRIPTOR); 1464 String id; 1465 id = data.readString(); 1466 int sizeMb; 1467 sizeMb = data.readInt(); 1468 String fstype; 1469 fstype = data.readString(); 1470 String key; 1471 key = data.readString(); 1472 int ownerUid; 1473 ownerUid = data.readInt(); 1474 boolean external; 1475 external = 0 != data.readInt(); 1476 int resultCode = createSecureContainer(id, sizeMb, fstype, key, ownerUid, 1477 external); 1478 reply.writeNoException(); 1479 reply.writeInt(resultCode); 1480 return true; 1481 } 1482 case TRANSACTION_finalizeSecureContainer: { 1483 data.enforceInterface(DESCRIPTOR); 1484 String id; 1485 id = data.readString(); 1486 int resultCode = finalizeSecureContainer(id); 1487 reply.writeNoException(); 1488 reply.writeInt(resultCode); 1489 return true; 1490 } 1491 case TRANSACTION_destroySecureContainer: { 1492 data.enforceInterface(DESCRIPTOR); 1493 String id; 1494 id = data.readString(); 1495 boolean force; 1496 force = 0 != data.readInt(); 1497 int resultCode = destroySecureContainer(id, force); 1498 reply.writeNoException(); 1499 reply.writeInt(resultCode); 1500 return true; 1501 } 1502 case TRANSACTION_mountSecureContainer: { 1503 data.enforceInterface(DESCRIPTOR); 1504 String id; 1505 id = data.readString(); 1506 String key; 1507 key = data.readString(); 1508 int ownerUid; 1509 ownerUid = data.readInt(); 1510 boolean readOnly; 1511 readOnly = data.readInt() != 0; 1512 int resultCode = mountSecureContainer(id, key, ownerUid, readOnly); 1513 reply.writeNoException(); 1514 reply.writeInt(resultCode); 1515 return true; 1516 } 1517 case TRANSACTION_unmountSecureContainer: { 1518 data.enforceInterface(DESCRIPTOR); 1519 String id; 1520 id = data.readString(); 1521 boolean force; 1522 force = 0 != data.readInt(); 1523 int resultCode = unmountSecureContainer(id, force); 1524 reply.writeNoException(); 1525 reply.writeInt(resultCode); 1526 return true; 1527 } 1528 case TRANSACTION_isSecureContainerMounted: { 1529 data.enforceInterface(DESCRIPTOR); 1530 String id; 1531 id = data.readString(); 1532 boolean status = isSecureContainerMounted(id); 1533 reply.writeNoException(); 1534 reply.writeInt((status ? 1 : 0)); 1535 return true; 1536 } 1537 case TRANSACTION_renameSecureContainer: { 1538 data.enforceInterface(DESCRIPTOR); 1539 String oldId; 1540 oldId = data.readString(); 1541 String newId; 1542 newId = data.readString(); 1543 int resultCode = renameSecureContainer(oldId, newId); 1544 reply.writeNoException(); 1545 reply.writeInt(resultCode); 1546 return true; 1547 } 1548 case TRANSACTION_getSecureContainerPath: { 1549 data.enforceInterface(DESCRIPTOR); 1550 String id; 1551 id = data.readString(); 1552 String path = getSecureContainerPath(id); 1553 reply.writeNoException(); 1554 reply.writeString(path); 1555 return true; 1556 } 1557 case TRANSACTION_getSecureContainerList: { 1558 data.enforceInterface(DESCRIPTOR); 1559 String[] ids = getSecureContainerList(); 1560 reply.writeNoException(); 1561 reply.writeStringArray(ids); 1562 return true; 1563 } 1564 case TRANSACTION_shutdown: { 1565 data.enforceInterface(DESCRIPTOR); 1566 IMountShutdownObserver observer; 1567 observer = IMountShutdownObserver.Stub.asInterface(data 1568 .readStrongBinder()); 1569 shutdown(observer); 1570 reply.writeNoException(); 1571 return true; 1572 } 1573 case TRANSACTION_finishMediaUpdate: { 1574 data.enforceInterface(DESCRIPTOR); 1575 finishMediaUpdate(); 1576 reply.writeNoException(); 1577 return true; 1578 } 1579 case TRANSACTION_mountObb: { 1580 data.enforceInterface(DESCRIPTOR); 1581 final String rawPath = data.readString(); 1582 final String canonicalPath = data.readString(); 1583 final String key = data.readString(); 1584 IObbActionListener observer; 1585 observer = IObbActionListener.Stub.asInterface(data.readStrongBinder()); 1586 int nonce; 1587 nonce = data.readInt(); 1588 mountObb(rawPath, canonicalPath, key, observer, nonce); 1589 reply.writeNoException(); 1590 return true; 1591 } 1592 case TRANSACTION_unmountObb: { 1593 data.enforceInterface(DESCRIPTOR); 1594 String filename; 1595 filename = data.readString(); 1596 boolean force; 1597 force = 0 != data.readInt(); 1598 IObbActionListener observer; 1599 observer = IObbActionListener.Stub.asInterface(data.readStrongBinder()); 1600 int nonce; 1601 nonce = data.readInt(); 1602 unmountObb(filename, force, observer, nonce); 1603 reply.writeNoException(); 1604 return true; 1605 } 1606 case TRANSACTION_isObbMounted: { 1607 data.enforceInterface(DESCRIPTOR); 1608 String filename; 1609 filename = data.readString(); 1610 boolean status = isObbMounted(filename); 1611 reply.writeNoException(); 1612 reply.writeInt((status ? 1 : 0)); 1613 return true; 1614 } 1615 case TRANSACTION_getMountedObbPath: { 1616 data.enforceInterface(DESCRIPTOR); 1617 String filename; 1618 filename = data.readString(); 1619 String mountedPath = getMountedObbPath(filename); 1620 reply.writeNoException(); 1621 reply.writeString(mountedPath); 1622 return true; 1623 } 1624 case TRANSACTION_isExternalStorageEmulated: { 1625 data.enforceInterface(DESCRIPTOR); 1626 boolean emulated = isExternalStorageEmulated(); 1627 reply.writeNoException(); 1628 reply.writeInt(emulated ? 1 : 0); 1629 return true; 1630 } 1631 case TRANSACTION_decryptStorage: { 1632 data.enforceInterface(DESCRIPTOR); 1633 String password = data.readString(); 1634 int result = decryptStorage(password); 1635 reply.writeNoException(); 1636 reply.writeInt(result); 1637 return true; 1638 } 1639 case TRANSACTION_encryptStorage: { 1640 data.enforceInterface(DESCRIPTOR); 1641 int type = data.readInt(); 1642 String password = data.readString(); 1643 int result = encryptStorage(type, password); 1644 reply.writeNoException(); 1645 reply.writeInt(result); 1646 return true; 1647 } 1648 case TRANSACTION_changeEncryptionPassword: { 1649 data.enforceInterface(DESCRIPTOR); 1650 int type = data.readInt(); 1651 String password = data.readString(); 1652 int result = changeEncryptionPassword(type, password); 1653 reply.writeNoException(); 1654 reply.writeInt(result); 1655 return true; 1656 } 1657 case TRANSACTION_getVolumeList: { 1658 data.enforceInterface(DESCRIPTOR); 1659 int userId = data.readInt(); 1660 StorageVolume[] result = getVolumeList(userId); 1661 reply.writeNoException(); 1662 reply.writeTypedArray(result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1663 return true; 1664 } 1665 case TRANSACTION_getSecureContainerFilesystemPath: { 1666 data.enforceInterface(DESCRIPTOR); 1667 String id; 1668 id = data.readString(); 1669 String path = getSecureContainerFilesystemPath(id); 1670 reply.writeNoException(); 1671 reply.writeString(path); 1672 return true; 1673 } 1674 case TRANSACTION_getEncryptionState: { 1675 data.enforceInterface(DESCRIPTOR); 1676 int result = getEncryptionState(); 1677 reply.writeNoException(); 1678 reply.writeInt(result); 1679 return true; 1680 } 1681 case TRANSACTION_fixPermissionsSecureContainer: { 1682 data.enforceInterface(DESCRIPTOR); 1683 String id; 1684 id = data.readString(); 1685 int gid; 1686 gid = data.readInt(); 1687 String filename; 1688 filename = data.readString(); 1689 int resultCode = fixPermissionsSecureContainer(id, gid, filename); 1690 reply.writeNoException(); 1691 reply.writeInt(resultCode); 1692 return true; 1693 } 1694 case TRANSACTION_mkdirs: { 1695 data.enforceInterface(DESCRIPTOR); 1696 String callingPkg = data.readString(); 1697 String path = data.readString(); 1698 int result = mkdirs(callingPkg, path); 1699 reply.writeNoException(); 1700 reply.writeInt(result); 1701 return true; 1702 } 1703 case TRANSACTION_getPasswordType: { 1704 data.enforceInterface(DESCRIPTOR); 1705 int result = getPasswordType(); 1706 reply.writeNoException(); 1707 reply.writeInt(result); 1708 return true; 1709 } 1710 case TRANSACTION_getPassword: { 1711 data.enforceInterface(DESCRIPTOR); 1712 String result = getPassword(); 1713 reply.writeNoException(); 1714 reply.writeString(result); 1715 return true; 1716 } 1717 case TRANSACTION_clearPassword: { 1718 data.enforceInterface(DESCRIPTOR); 1719 clearPassword(); 1720 reply.writeNoException(); 1721 return true; 1722 } 1723 case TRANSACTION_setField: { 1724 data.enforceInterface(DESCRIPTOR); 1725 String field = data.readString(); 1726 String contents = data.readString(); 1727 setField(field, contents); 1728 reply.writeNoException(); 1729 return true; 1730 } 1731 case TRANSACTION_getField: { 1732 data.enforceInterface(DESCRIPTOR); 1733 String field = data.readString(); 1734 String contents = getField(field); 1735 reply.writeNoException(); 1736 reply.writeString(contents); 1737 return true; 1738 } 1739 case TRANSACTION_resizeSecureContainer: { 1740 data.enforceInterface(DESCRIPTOR); 1741 String id; 1742 id = data.readString(); 1743 int sizeMb; 1744 sizeMb = data.readInt(); 1745 String key; 1746 key = data.readString(); 1747 int resultCode = resizeSecureContainer(id, sizeMb, key); 1748 reply.writeNoException(); 1749 reply.writeInt(resultCode); 1750 return true; 1751 } 1752 case TRANSACTION_lastMaintenance: { 1753 data.enforceInterface(DESCRIPTOR); 1754 long lastMaintenance = lastMaintenance(); 1755 reply.writeNoException(); 1756 reply.writeLong(lastMaintenance); 1757 return true; 1758 } 1759 case TRANSACTION_runMaintenance: { 1760 data.enforceInterface(DESCRIPTOR); 1761 runMaintenance(); 1762 reply.writeNoException(); 1763 return true; 1764 } 1765 case TRANSACTION_waitForAsecScan: { 1766 data.enforceInterface(DESCRIPTOR); 1767 waitForAsecScan(); 1768 reply.writeNoException(); 1769 return true; 1770 } 1771 case TRANSACTION_getDisks: { 1772 data.enforceInterface(DESCRIPTOR); 1773 DiskInfo[] disks = getDisks(); 1774 reply.writeNoException(); 1775 reply.writeTypedArray(disks, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1776 return true; 1777 } 1778 case TRANSACTION_getVolumes: { 1779 data.enforceInterface(DESCRIPTOR); 1780 int _flags = data.readInt(); 1781 VolumeInfo[] volumes = getVolumes(_flags); 1782 reply.writeNoException(); 1783 reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1784 return true; 1785 } 1786 case TRANSACTION_getVolumeRecords: { 1787 data.enforceInterface(DESCRIPTOR); 1788 int _flags = data.readInt(); 1789 VolumeRecord[] volumes = getVolumeRecords(_flags); 1790 reply.writeNoException(); 1791 reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 1792 return true; 1793 } 1794 case TRANSACTION_mount: { 1795 data.enforceInterface(DESCRIPTOR); 1796 String volId = data.readString(); 1797 mount(volId); 1798 reply.writeNoException(); 1799 return true; 1800 } 1801 case TRANSACTION_unmount: { 1802 data.enforceInterface(DESCRIPTOR); 1803 String volId = data.readString(); 1804 unmount(volId); 1805 reply.writeNoException(); 1806 return true; 1807 } 1808 case TRANSACTION_format: { 1809 data.enforceInterface(DESCRIPTOR); 1810 String volId = data.readString(); 1811 format(volId); 1812 reply.writeNoException(); 1813 return true; 1814 } 1815 case TRANSACTION_benchmark: { 1816 data.enforceInterface(DESCRIPTOR); 1817 String volId = data.readString(); 1818 long res = benchmark(volId); 1819 reply.writeNoException(); 1820 reply.writeLong(res); 1821 return true; 1822 } 1823 case TRANSACTION_partitionPublic: { 1824 data.enforceInterface(DESCRIPTOR); 1825 String diskId = data.readString(); 1826 partitionPublic(diskId); 1827 reply.writeNoException(); 1828 return true; 1829 } 1830 case TRANSACTION_partitionPrivate: { 1831 data.enforceInterface(DESCRIPTOR); 1832 String diskId = data.readString(); 1833 partitionPrivate(diskId); 1834 reply.writeNoException(); 1835 return true; 1836 } 1837 case TRANSACTION_partitionMixed: { 1838 data.enforceInterface(DESCRIPTOR); 1839 String diskId = data.readString(); 1840 int ratio = data.readInt(); 1841 partitionMixed(diskId, ratio); 1842 reply.writeNoException(); 1843 return true; 1844 } 1845 case TRANSACTION_setVolumeNickname: { 1846 data.enforceInterface(DESCRIPTOR); 1847 String volId = data.readString(); 1848 String nickname = data.readString(); 1849 setVolumeNickname(volId, nickname); 1850 reply.writeNoException(); 1851 return true; 1852 } 1853 case TRANSACTION_setVolumeUserFlags: { 1854 data.enforceInterface(DESCRIPTOR); 1855 String volId = data.readString(); 1856 int _flags = data.readInt(); 1857 int _mask = data.readInt(); 1858 setVolumeUserFlags(volId, _flags, _mask); 1859 reply.writeNoException(); 1860 return true; 1861 } 1862 case TRANSACTION_forgetVolume: { 1863 data.enforceInterface(DESCRIPTOR); 1864 String fsUuid = data.readString(); 1865 forgetVolume(fsUuid); 1866 reply.writeNoException(); 1867 return true; 1868 } 1869 case TRANSACTION_forgetAllVolumes: { 1870 data.enforceInterface(DESCRIPTOR); 1871 forgetAllVolumes(); 1872 reply.writeNoException(); 1873 return true; 1874 } 1875 case TRANSACTION_setDebugFlags: { 1876 data.enforceInterface(DESCRIPTOR); 1877 int _flags = data.readInt(); 1878 int _mask = data.readInt(); 1879 setDebugFlags(_flags, _mask); 1880 reply.writeNoException(); 1881 return true; 1882 } 1883 case TRANSACTION_getPrimaryStorageUuid: { 1884 data.enforceInterface(DESCRIPTOR); 1885 String volumeUuid = getPrimaryStorageUuid(); 1886 reply.writeNoException(); 1887 reply.writeString(volumeUuid); 1888 return true; 1889 } 1890 case TRANSACTION_setPrimaryStorageUuid: { 1891 data.enforceInterface(DESCRIPTOR); 1892 String volumeUuid = data.readString(); 1893 IPackageMoveObserver listener = IPackageMoveObserver.Stub.asInterface( 1894 data.readStrongBinder()); 1895 setPrimaryStorageUuid(volumeUuid, listener); 1896 reply.writeNoException(); 1897 return true; 1898 } 1899 case TRANSACTION_remountUid: { 1900 data.enforceInterface(DESCRIPTOR); 1901 int uid = data.readInt(); 1902 remountUid(uid); 1903 reply.writeNoException(); 1904 return true; 1905 } 1906 case TRANSACTION_createNewUserDir: { 1907 data.enforceInterface(DESCRIPTOR); 1908 int userHandle = data.readInt(); 1909 String path = data.readString(); 1910 createNewUserDir(userHandle, path); 1911 reply.writeNoException(); 1912 return true; 1913 } 1914 case TRANSACTION_deleteUserKey: { 1915 data.enforceInterface(DESCRIPTOR); 1916 int userHandle = data.readInt(); 1917 deleteUserKey(userHandle); 1918 reply.writeNoException(); 1919 return true; 1920 } 1921 } 1922 return super.onTransact(code, data, reply, flags); 1923 } 1924 } 1925 1926 /* 1927 * Creates a secure container with the specified parameters. Returns an int 1928 * consistent with MountServiceResultCode 1929 */ 1930 public int createSecureContainer(String id, int sizeMb, String fstype, String key, 1931 int ownerUid, boolean external) throws RemoteException; 1932 1933 /* 1934 * Destroy a secure container, and free up all resources associated with it. 1935 * NOTE: Ensure all references are released prior to deleting. Returns an 1936 * int consistent with MountServiceResultCode 1937 */ 1938 public int destroySecureContainer(String id, boolean force) throws RemoteException; 1939 1940 /* 1941 * Finalize a container which has just been created and populated. After 1942 * finalization, the container is immutable. Returns an int consistent with 1943 * MountServiceResultCode 1944 */ 1945 public int finalizeSecureContainer(String id) throws RemoteException; 1946 1947 /** 1948 * Call into MountService by PackageManager to notify that its done 1949 * processing the media status update request. 1950 */ 1951 public void finishMediaUpdate() throws RemoteException; 1952 1953 /** 1954 * Format external storage given a mount point. Returns an int consistent 1955 * with MountServiceResultCode 1956 */ 1957 public int formatVolume(String mountPoint) throws RemoteException; 1958 1959 /** 1960 * Gets the path to the mounted Opaque Binary Blob (OBB). 1961 */ 1962 public String getMountedObbPath(String rawPath) throws RemoteException; 1963 1964 /** 1965 * Gets an Array of currently known secure container IDs 1966 */ 1967 public String[] getSecureContainerList() throws RemoteException; 1968 1969 /* 1970 * Returns the filesystem path of a mounted secure container. 1971 */ 1972 public String getSecureContainerPath(String id) throws RemoteException; 1973 1974 /** 1975 * Returns an array of pids with open files on the specified path. 1976 */ 1977 public int[] getStorageUsers(String path) throws RemoteException; 1978 1979 /** 1980 * Gets the state of a volume via its mountpoint. 1981 */ 1982 public String getVolumeState(String mountPoint) throws RemoteException; 1983 1984 /** 1985 * Checks whether the specified Opaque Binary Blob (OBB) is mounted 1986 * somewhere. 1987 */ 1988 public boolean isObbMounted(String rawPath) throws RemoteException; 1989 1990 /* 1991 * Returns true if the specified container is mounted 1992 */ 1993 public boolean isSecureContainerMounted(String id) throws RemoteException; 1994 1995 /** 1996 * Returns true if a USB mass storage host is connected 1997 */ 1998 public boolean isUsbMassStorageConnected() throws RemoteException; 1999 2000 /** 2001 * Returns true if a USB mass storage host is enabled (media is shared) 2002 */ 2003 public boolean isUsbMassStorageEnabled() throws RemoteException; 2004 2005 /** 2006 * Mounts an Opaque Binary Blob (OBB) with the specified decryption key and 2007 * only allows the calling process's UID access to the contents. 2008 * MountService will call back to the supplied IObbActionListener to inform 2009 * it of the terminal state of the call. 2010 */ 2011 public void mountObb(String rawPath, String canonicalPath, String key, 2012 IObbActionListener token, int nonce) throws RemoteException; 2013 2014 /* 2015 * Mount a secure container with the specified key and owner UID. Returns an 2016 * int consistent with MountServiceResultCode 2017 */ 2018 public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly) 2019 throws RemoteException; 2020 2021 /** 2022 * Mount external storage at given mount point. Returns an int consistent 2023 * with MountServiceResultCode 2024 */ 2025 public int mountVolume(String mountPoint) throws RemoteException; 2026 2027 /** 2028 * Registers an IMountServiceListener for receiving async notifications. 2029 */ 2030 public void registerListener(IMountServiceListener listener) throws RemoteException; 2031 2032 /* 2033 * Rename an unmounted secure container. Returns an int consistent with 2034 * MountServiceResultCode 2035 */ 2036 public int renameSecureContainer(String oldId, String newId) throws RemoteException; 2037 2038 /** 2039 * Enables / disables USB mass storage. The caller should check actual 2040 * status of enabling/disabling USB mass storage via StorageEventListener. 2041 */ 2042 public void setUsbMassStorageEnabled(boolean enable) throws RemoteException; 2043 2044 /** 2045 * Shuts down the MountService and gracefully unmounts all external media. 2046 * Invokes call back once the shutdown is complete. 2047 */ 2048 public void shutdown(IMountShutdownObserver observer) throws RemoteException; 2049 2050 /** 2051 * Unmounts an Opaque Binary Blob (OBB). When the force flag is specified, 2052 * any program using it will be forcibly killed to unmount the image. 2053 * MountService will call back to the supplied IObbActionListener to inform 2054 * it of the terminal state of the call. 2055 */ 2056 public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce) 2057 throws RemoteException; 2058 2059 /* 2060 * Unount a secure container. Returns an int consistent with 2061 * MountServiceResultCode 2062 */ 2063 public int unmountSecureContainer(String id, boolean force) throws RemoteException; 2064 2065 /** 2066 * Safely unmount external storage at given mount point. The unmount is an 2067 * asynchronous operation. Applications should register StorageEventListener 2068 * for storage related status changes. 2069 * @param mountPoint the mount point 2070 * @param force whether or not to forcefully unmount it (e.g. even if programs are using this 2071 * data currently) 2072 * @param removeEncryption whether or not encryption mapping should be removed from the volume. 2073 * This value implies {@code force}. 2074 */ 2075 public void unmountVolume(String mountPoint, boolean force, boolean removeEncryption) 2076 throws RemoteException; 2077 2078 /** 2079 * Unregisters an IMountServiceListener 2080 */ 2081 public void unregisterListener(IMountServiceListener listener) throws RemoteException; 2082 2083 /** 2084 * Returns whether or not the external storage is emulated. 2085 */ 2086 public boolean isExternalStorageEmulated() throws RemoteException; 2087 2088 /** The volume is not encrypted. */ 2089 static final int ENCRYPTION_STATE_NONE = 1; 2090 /** The volume has been encrypted succesfully. */ 2091 static final int ENCRYPTION_STATE_OK = 0; 2092 /** The volume is in a bad state.*/ 2093 static final int ENCRYPTION_STATE_ERROR_UNKNOWN = -1; 2094 /** Encryption is incomplete */ 2095 static final int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2; 2096 /** Encryption is incomplete and irrecoverable */ 2097 static final int ENCRYPTION_STATE_ERROR_INCONSISTENT = -3; 2098 /** Underlying data is corrupt */ 2099 static final int ENCRYPTION_STATE_ERROR_CORRUPT = -4; 2100 2101 /** 2102 * Determines the encryption state of the volume. 2103 * @return a numerical value. See {@code ENCRYPTION_STATE_*} for possible values. 2104 */ 2105 public int getEncryptionState() throws RemoteException; 2106 2107 /** 2108 * Decrypts any encrypted volumes. 2109 */ 2110 public int decryptStorage(String password) throws RemoteException; 2111 2112 /** 2113 * Encrypts storage. 2114 */ 2115 public int encryptStorage(int type, String password) throws RemoteException; 2116 2117 /** 2118 * Changes the encryption password. 2119 */ 2120 public int changeEncryptionPassword(int type, String password) 2121 throws RemoteException; 2122 2123 /** 2124 * Verify the encryption password against the stored volume. This method 2125 * may only be called by the system process. 2126 */ 2127 public int verifyEncryptionPassword(String password) throws RemoteException; 2128 2129 /** 2130 * Returns list of all mountable volumes. 2131 */ 2132 public StorageVolume[] getVolumeList(int userId) throws RemoteException; 2133 2134 /** 2135 * Gets the path on the filesystem for the ASEC container itself. 2136 * 2137 * @param cid ASEC container ID 2138 * @return path to filesystem or {@code null} if it's not found 2139 * @throws RemoteException 2140 */ 2141 public String getSecureContainerFilesystemPath(String cid) throws RemoteException; 2142 2143 /* 2144 * Fix permissions in a container which has just been created and populated. 2145 * Returns an int consistent with MountServiceResultCode 2146 */ 2147 public int fixPermissionsSecureContainer(String id, int gid, String filename) 2148 throws RemoteException; 2149 2150 /** 2151 * Ensure that all directories along given path exist, creating parent 2152 * directories as needed. Validates that given path is absolute and that it 2153 * contains no relative "." or ".." paths or symlinks. Also ensures that 2154 * path belongs to a volume managed by vold, and that path is either 2155 * external storage data or OBB directory belonging to calling app. 2156 */ 2157 public int mkdirs(String callingPkg, String path) throws RemoteException; 2158 2159 /** 2160 * Determines the type of the encryption password 2161 * @return PasswordType 2162 */ 2163 public int getPasswordType() throws RemoteException; 2164 2165 /** 2166 * Get password from vold 2167 * @return password or empty string 2168 */ 2169 public String getPassword() throws RemoteException; 2170 2171 /** 2172 * Securely clear password from vold 2173 */ 2174 public void clearPassword() throws RemoteException; 2175 2176 /** 2177 * Set a field in the crypto header. 2178 * @param field field to set 2179 * @param contents contents to set in field 2180 */ 2181 public void setField(String field, String contents) throws RemoteException; 2182 2183 /** 2184 * Gets a field from the crypto header. 2185 * @param field field to get 2186 * @return contents of field 2187 */ 2188 public String getField(String field) throws RemoteException; 2189 2190 public int resizeSecureContainer(String id, int sizeMb, String key) throws RemoteException; 2191 2192 /** 2193 * Report the time of the last maintenance operation such as fstrim. 2194 * @return Timestamp of the last maintenance operation, in the 2195 * System.currentTimeMillis() time base 2196 * @throws RemoteException 2197 */ 2198 public long lastMaintenance() throws RemoteException; 2199 2200 /** 2201 * Kick off an immediate maintenance operation 2202 * @throws RemoteException 2203 */ 2204 public void runMaintenance() throws RemoteException; 2205 2206 public void waitForAsecScan() throws RemoteException; 2207 2208 public DiskInfo[] getDisks() throws RemoteException; 2209 public VolumeInfo[] getVolumes(int flags) throws RemoteException; 2210 public VolumeRecord[] getVolumeRecords(int flags) throws RemoteException; 2211 2212 public void mount(String volId) throws RemoteException; 2213 public void unmount(String volId) throws RemoteException; 2214 public void format(String volId) throws RemoteException; 2215 public long benchmark(String volId) throws RemoteException; 2216 2217 public void partitionPublic(String diskId) throws RemoteException; 2218 public void partitionPrivate(String diskId) throws RemoteException; 2219 public void partitionMixed(String diskId, int ratio) throws RemoteException; 2220 2221 public void setVolumeNickname(String fsUuid, String nickname) throws RemoteException; 2222 public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException; 2223 public void forgetVolume(String fsUuid) throws RemoteException; 2224 public void forgetAllVolumes() throws RemoteException; 2225 public void setDebugFlags(int flags, int mask) throws RemoteException; 2226 2227 public String getPrimaryStorageUuid() throws RemoteException; 2228 public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback) 2229 throws RemoteException; 2230 2231 public void remountUid(int uid) throws RemoteException; 2232 2233 /** 2234 * Creates the user data directory, possibly encrypted 2235 * @param userHandle Handle of the user whose directory we are creating 2236 * @param path Path at which to create the directory. 2237 */ 2238 public void createNewUserDir(int userHandle, String path) 2239 throws RemoteException; 2240 2241 /** 2242 * Securely delete the user's encryption key 2243 * @param userHandle Handle of the user whose key we are deleting 2244 */ 2245 public void deleteUserKey(int userHandle) 2246 throws RemoteException; 2247} 2248