ApplicationThreadNative.java revision 434203a277cd2f237a71508a3d5a7d1602126cd5
1/* 2 * Copyright (C) 2006 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.app; 18 19import android.content.ComponentName; 20import android.content.Intent; 21import android.content.IIntentReceiver; 22import android.content.pm.ActivityInfo; 23import android.content.pm.ApplicationInfo; 24import android.content.pm.ProviderInfo; 25import android.content.pm.ServiceInfo; 26import android.content.res.Configuration; 27import android.os.Binder; 28import android.os.Bundle; 29import android.os.Debug; 30import android.os.Parcelable; 31import android.os.RemoteException; 32import android.os.IBinder; 33import android.os.Parcel; 34import android.os.ParcelFileDescriptor; 35 36import java.io.FileDescriptor; 37import java.io.IOException; 38import java.util.HashMap; 39import java.util.List; 40import java.util.Map; 41 42/** {@hide} */ 43public abstract class ApplicationThreadNative extends Binder 44 implements IApplicationThread { 45 /** 46 * Cast a Binder object into an application thread interface, generating 47 * a proxy if needed. 48 */ 49 static public IApplicationThread asInterface(IBinder obj) { 50 if (obj == null) { 51 return null; 52 } 53 IApplicationThread in = 54 (IApplicationThread)obj.queryLocalInterface(descriptor); 55 if (in != null) { 56 return in; 57 } 58 59 return new ApplicationThreadProxy(obj); 60 } 61 62 public ApplicationThreadNative() { 63 attachInterface(this, descriptor); 64 } 65 66 @Override 67 public boolean onTransact(int code, Parcel data, Parcel reply, int flags) 68 throws RemoteException { 69 switch (code) { 70 case SCHEDULE_PAUSE_ACTIVITY_TRANSACTION: 71 { 72 data.enforceInterface(IApplicationThread.descriptor); 73 IBinder b = data.readStrongBinder(); 74 boolean finished = data.readInt() != 0; 75 boolean userLeaving = data.readInt() != 0; 76 int configChanges = data.readInt(); 77 schedulePauseActivity(b, finished, userLeaving, configChanges); 78 return true; 79 } 80 81 case SCHEDULE_STOP_ACTIVITY_TRANSACTION: 82 { 83 data.enforceInterface(IApplicationThread.descriptor); 84 IBinder b = data.readStrongBinder(); 85 boolean show = data.readInt() != 0; 86 int configChanges = data.readInt(); 87 scheduleStopActivity(b, show, configChanges); 88 return true; 89 } 90 91 case SCHEDULE_WINDOW_VISIBILITY_TRANSACTION: 92 { 93 data.enforceInterface(IApplicationThread.descriptor); 94 IBinder b = data.readStrongBinder(); 95 boolean show = data.readInt() != 0; 96 scheduleWindowVisibility(b, show); 97 return true; 98 } 99 100 case SCHEDULE_RESUME_ACTIVITY_TRANSACTION: 101 { 102 data.enforceInterface(IApplicationThread.descriptor); 103 IBinder b = data.readStrongBinder(); 104 boolean isForward = data.readInt() != 0; 105 scheduleResumeActivity(b, isForward); 106 return true; 107 } 108 109 case SCHEDULE_SEND_RESULT_TRANSACTION: 110 { 111 data.enforceInterface(IApplicationThread.descriptor); 112 IBinder b = data.readStrongBinder(); 113 List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR); 114 scheduleSendResult(b, ri); 115 return true; 116 } 117 118 case SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION: 119 { 120 data.enforceInterface(IApplicationThread.descriptor); 121 Intent intent = Intent.CREATOR.createFromParcel(data); 122 IBinder b = data.readStrongBinder(); 123 int ident = data.readInt(); 124 ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data); 125 Bundle state = data.readBundle(); 126 List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR); 127 List<Intent> pi = data.createTypedArrayList(Intent.CREATOR); 128 boolean notResumed = data.readInt() != 0; 129 boolean isForward = data.readInt() != 0; 130 scheduleLaunchActivity(intent, b, ident, info, state, ri, pi, 131 notResumed, isForward); 132 return true; 133 } 134 135 case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION: 136 { 137 data.enforceInterface(IApplicationThread.descriptor); 138 IBinder b = data.readStrongBinder(); 139 List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR); 140 List<Intent> pi = data.createTypedArrayList(Intent.CREATOR); 141 int configChanges = data.readInt(); 142 boolean notResumed = data.readInt() != 0; 143 Configuration config = null; 144 if (data.readInt() != 0) { 145 config = Configuration.CREATOR.createFromParcel(data); 146 } 147 scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config); 148 return true; 149 } 150 151 case SCHEDULE_NEW_INTENT_TRANSACTION: 152 { 153 data.enforceInterface(IApplicationThread.descriptor); 154 List<Intent> pi = data.createTypedArrayList(Intent.CREATOR); 155 IBinder b = data.readStrongBinder(); 156 scheduleNewIntent(pi, b); 157 return true; 158 } 159 160 case SCHEDULE_FINISH_ACTIVITY_TRANSACTION: 161 { 162 data.enforceInterface(IApplicationThread.descriptor); 163 IBinder b = data.readStrongBinder(); 164 boolean finishing = data.readInt() != 0; 165 int configChanges = data.readInt(); 166 scheduleDestroyActivity(b, finishing, configChanges); 167 return true; 168 } 169 170 case SCHEDULE_RECEIVER_TRANSACTION: 171 { 172 data.enforceInterface(IApplicationThread.descriptor); 173 Intent intent = Intent.CREATOR.createFromParcel(data); 174 ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data); 175 int resultCode = data.readInt(); 176 String resultData = data.readString(); 177 Bundle resultExtras = data.readBundle(); 178 boolean sync = data.readInt() != 0; 179 scheduleReceiver(intent, info, resultCode, resultData, 180 resultExtras, sync); 181 return true; 182 } 183 184 case SCHEDULE_CREATE_SERVICE_TRANSACTION: { 185 data.enforceInterface(IApplicationThread.descriptor); 186 IBinder token = data.readStrongBinder(); 187 ServiceInfo info = ServiceInfo.CREATOR.createFromParcel(data); 188 scheduleCreateService(token, info); 189 return true; 190 } 191 192 case SCHEDULE_BIND_SERVICE_TRANSACTION: { 193 data.enforceInterface(IApplicationThread.descriptor); 194 IBinder token = data.readStrongBinder(); 195 Intent intent = Intent.CREATOR.createFromParcel(data); 196 boolean rebind = data.readInt() != 0; 197 scheduleBindService(token, intent, rebind); 198 return true; 199 } 200 201 case SCHEDULE_UNBIND_SERVICE_TRANSACTION: { 202 data.enforceInterface(IApplicationThread.descriptor); 203 IBinder token = data.readStrongBinder(); 204 Intent intent = Intent.CREATOR.createFromParcel(data); 205 scheduleUnbindService(token, intent); 206 return true; 207 } 208 209 case SCHEDULE_SERVICE_ARGS_TRANSACTION: 210 { 211 data.enforceInterface(IApplicationThread.descriptor); 212 IBinder token = data.readStrongBinder(); 213 int startId = data.readInt(); 214 int fl = data.readInt(); 215 Intent args; 216 if (data.readInt() != 0) { 217 args = Intent.CREATOR.createFromParcel(data); 218 } else { 219 args = null; 220 } 221 scheduleServiceArgs(token, startId, fl, args); 222 return true; 223 } 224 225 case SCHEDULE_STOP_SERVICE_TRANSACTION: 226 { 227 data.enforceInterface(IApplicationThread.descriptor); 228 IBinder token = data.readStrongBinder(); 229 scheduleStopService(token); 230 return true; 231 } 232 233 case BIND_APPLICATION_TRANSACTION: 234 { 235 data.enforceInterface(IApplicationThread.descriptor); 236 String packageName = data.readString(); 237 ApplicationInfo info = 238 ApplicationInfo.CREATOR.createFromParcel(data); 239 List<ProviderInfo> providers = 240 data.createTypedArrayList(ProviderInfo.CREATOR); 241 ComponentName testName = (data.readInt() != 0) 242 ? new ComponentName(data) : null; 243 String profileName = data.readString(); 244 Bundle testArgs = data.readBundle(); 245 IBinder binder = data.readStrongBinder(); 246 IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder); 247 int testMode = data.readInt(); 248 boolean restrictedBackupMode = (data.readInt() != 0); 249 Configuration config = Configuration.CREATOR.createFromParcel(data); 250 HashMap<String, IBinder> services = data.readHashMap(null); 251 bindApplication(packageName, info, 252 providers, testName, profileName, 253 testArgs, testWatcher, testMode, restrictedBackupMode, 254 config, services); 255 return true; 256 } 257 258 case SCHEDULE_EXIT_TRANSACTION: 259 { 260 data.enforceInterface(IApplicationThread.descriptor); 261 scheduleExit(); 262 return true; 263 } 264 265 case SCHEDULE_SUICIDE_TRANSACTION: 266 { 267 data.enforceInterface(IApplicationThread.descriptor); 268 scheduleSuicide(); 269 return true; 270 } 271 272 case REQUEST_THUMBNAIL_TRANSACTION: 273 { 274 data.enforceInterface(IApplicationThread.descriptor); 275 IBinder b = data.readStrongBinder(); 276 requestThumbnail(b); 277 return true; 278 } 279 280 case SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION: 281 { 282 data.enforceInterface(IApplicationThread.descriptor); 283 Configuration config = Configuration.CREATOR.createFromParcel(data); 284 scheduleConfigurationChanged(config); 285 return true; 286 } 287 288 case UPDATE_TIME_ZONE_TRANSACTION: { 289 data.enforceInterface(IApplicationThread.descriptor); 290 updateTimeZone(); 291 return true; 292 } 293 294 case CLEAR_DNS_CACHE_TRANSACTION: { 295 data.enforceInterface(IApplicationThread.descriptor); 296 clearDnsCache(); 297 return true; 298 } 299 300 case SET_HTTP_PROXY_TRANSACTION: { 301 data.enforceInterface(IApplicationThread.descriptor); 302 final String proxy = data.readString(); 303 final String port = data.readString(); 304 final String exclList = data.readString(); 305 setHttpProxy(proxy, port, exclList); 306 return true; 307 } 308 309 case PROCESS_IN_BACKGROUND_TRANSACTION: { 310 data.enforceInterface(IApplicationThread.descriptor); 311 processInBackground(); 312 return true; 313 } 314 315 case DUMP_SERVICE_TRANSACTION: { 316 data.enforceInterface(IApplicationThread.descriptor); 317 ParcelFileDescriptor fd = data.readFileDescriptor(); 318 final IBinder service = data.readStrongBinder(); 319 final String[] args = data.readStringArray(); 320 if (fd != null) { 321 dumpService(fd.getFileDescriptor(), service, args); 322 try { 323 fd.close(); 324 } catch (IOException e) { 325 } 326 } 327 return true; 328 } 329 330 case SCHEDULE_REGISTERED_RECEIVER_TRANSACTION: { 331 data.enforceInterface(IApplicationThread.descriptor); 332 IIntentReceiver receiver = IIntentReceiver.Stub.asInterface( 333 data.readStrongBinder()); 334 Intent intent = Intent.CREATOR.createFromParcel(data); 335 int resultCode = data.readInt(); 336 String dataStr = data.readString(); 337 Bundle extras = data.readBundle(); 338 boolean ordered = data.readInt() != 0; 339 boolean sticky = data.readInt() != 0; 340 scheduleRegisteredReceiver(receiver, intent, 341 resultCode, dataStr, extras, ordered, sticky); 342 return true; 343 } 344 345 case SCHEDULE_LOW_MEMORY_TRANSACTION: 346 { 347 scheduleLowMemory(); 348 return true; 349 } 350 351 case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION: 352 { 353 data.enforceInterface(IApplicationThread.descriptor); 354 IBinder b = data.readStrongBinder(); 355 scheduleActivityConfigurationChanged(b); 356 return true; 357 } 358 359 case PROFILER_CONTROL_TRANSACTION: 360 { 361 data.enforceInterface(IApplicationThread.descriptor); 362 boolean start = data.readInt() != 0; 363 String path = data.readString(); 364 ParcelFileDescriptor fd = data.readInt() != 0 365 ? data.readFileDescriptor() : null; 366 profilerControl(start, path, fd); 367 return true; 368 } 369 370 case SET_SCHEDULING_GROUP_TRANSACTION: 371 { 372 data.enforceInterface(IApplicationThread.descriptor); 373 int group = data.readInt(); 374 setSchedulingGroup(group); 375 return true; 376 } 377 378 case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION: 379 { 380 data.enforceInterface(IApplicationThread.descriptor); 381 ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data); 382 int backupMode = data.readInt(); 383 scheduleCreateBackupAgent(appInfo, backupMode); 384 return true; 385 } 386 387 case SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION: 388 { 389 data.enforceInterface(IApplicationThread.descriptor); 390 ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data); 391 scheduleDestroyBackupAgent(appInfo); 392 return true; 393 } 394 395 case GET_MEMORY_INFO_TRANSACTION: 396 { 397 data.enforceInterface(IApplicationThread.descriptor); 398 Debug.MemoryInfo mi = new Debug.MemoryInfo(); 399 getMemoryInfo(mi); 400 reply.writeNoException(); 401 mi.writeToParcel(reply, 0); 402 return true; 403 } 404 405 case DISPATCH_PACKAGE_BROADCAST_TRANSACTION: 406 { 407 data.enforceInterface(IApplicationThread.descriptor); 408 int cmd = data.readInt(); 409 String[] packages = data.readStringArray(); 410 dispatchPackageBroadcast(cmd, packages); 411 return true; 412 } 413 414 case SCHEDULE_CRASH_TRANSACTION: 415 { 416 data.enforceInterface(IApplicationThread.descriptor); 417 String msg = data.readString(); 418 scheduleCrash(msg); 419 return true; 420 } 421 422 case DUMP_HEAP_TRANSACTION: 423 { 424 data.enforceInterface(IApplicationThread.descriptor); 425 boolean managed = data.readInt() != 0; 426 String path = data.readString(); 427 ParcelFileDescriptor fd = data.readInt() != 0 428 ? data.readFileDescriptor() : null; 429 dumpHeap(managed, path, fd); 430 return true; 431 } 432 433 case DUMP_ACTIVITY_TRANSACTION: { 434 data.enforceInterface(IApplicationThread.descriptor); 435 ParcelFileDescriptor fd = data.readFileDescriptor(); 436 final IBinder activity = data.readStrongBinder(); 437 final String[] args = data.readStringArray(); 438 if (fd != null) { 439 dumpActivity(fd.getFileDescriptor(), activity, args); 440 try { 441 fd.close(); 442 } catch (IOException e) { 443 } 444 } 445 return true; 446 } 447 } 448 449 return super.onTransact(code, data, reply, flags); 450 } 451 452 public IBinder asBinder() 453 { 454 return this; 455 } 456} 457 458class ApplicationThreadProxy implements IApplicationThread { 459 private final IBinder mRemote; 460 461 public ApplicationThreadProxy(IBinder remote) { 462 mRemote = remote; 463 } 464 465 public final IBinder asBinder() { 466 return mRemote; 467 } 468 469 public final void schedulePauseActivity(IBinder token, boolean finished, 470 boolean userLeaving, int configChanges) throws RemoteException { 471 Parcel data = Parcel.obtain(); 472 data.writeInterfaceToken(IApplicationThread.descriptor); 473 data.writeStrongBinder(token); 474 data.writeInt(finished ? 1 : 0); 475 data.writeInt(userLeaving ? 1 :0); 476 data.writeInt(configChanges); 477 mRemote.transact(SCHEDULE_PAUSE_ACTIVITY_TRANSACTION, data, null, 478 IBinder.FLAG_ONEWAY); 479 data.recycle(); 480 } 481 482 public final void scheduleStopActivity(IBinder token, boolean showWindow, 483 int configChanges) throws RemoteException { 484 Parcel data = Parcel.obtain(); 485 data.writeInterfaceToken(IApplicationThread.descriptor); 486 data.writeStrongBinder(token); 487 data.writeInt(showWindow ? 1 : 0); 488 data.writeInt(configChanges); 489 mRemote.transact(SCHEDULE_STOP_ACTIVITY_TRANSACTION, data, null, 490 IBinder.FLAG_ONEWAY); 491 data.recycle(); 492 } 493 494 public final void scheduleWindowVisibility(IBinder token, 495 boolean showWindow) throws RemoteException { 496 Parcel data = Parcel.obtain(); 497 data.writeInterfaceToken(IApplicationThread.descriptor); 498 data.writeStrongBinder(token); 499 data.writeInt(showWindow ? 1 : 0); 500 mRemote.transact(SCHEDULE_WINDOW_VISIBILITY_TRANSACTION, data, null, 501 IBinder.FLAG_ONEWAY); 502 data.recycle(); 503 } 504 505 public final void scheduleResumeActivity(IBinder token, boolean isForward) 506 throws RemoteException { 507 Parcel data = Parcel.obtain(); 508 data.writeInterfaceToken(IApplicationThread.descriptor); 509 data.writeStrongBinder(token); 510 data.writeInt(isForward ? 1 : 0); 511 mRemote.transact(SCHEDULE_RESUME_ACTIVITY_TRANSACTION, data, null, 512 IBinder.FLAG_ONEWAY); 513 data.recycle(); 514 } 515 516 public final void scheduleSendResult(IBinder token, List<ResultInfo> results) 517 throws RemoteException { 518 Parcel data = Parcel.obtain(); 519 data.writeInterfaceToken(IApplicationThread.descriptor); 520 data.writeStrongBinder(token); 521 data.writeTypedList(results); 522 mRemote.transact(SCHEDULE_SEND_RESULT_TRANSACTION, data, null, 523 IBinder.FLAG_ONEWAY); 524 data.recycle(); 525 } 526 527 public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, 528 ActivityInfo info, Bundle state, List<ResultInfo> pendingResults, 529 List<Intent> pendingNewIntents, boolean notResumed, boolean isForward) 530 throws RemoteException { 531 Parcel data = Parcel.obtain(); 532 data.writeInterfaceToken(IApplicationThread.descriptor); 533 intent.writeToParcel(data, 0); 534 data.writeStrongBinder(token); 535 data.writeInt(ident); 536 info.writeToParcel(data, 0); 537 data.writeBundle(state); 538 data.writeTypedList(pendingResults); 539 data.writeTypedList(pendingNewIntents); 540 data.writeInt(notResumed ? 1 : 0); 541 data.writeInt(isForward ? 1 : 0); 542 mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null, 543 IBinder.FLAG_ONEWAY); 544 data.recycle(); 545 } 546 547 public final void scheduleRelaunchActivity(IBinder token, 548 List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, 549 int configChanges, boolean notResumed, Configuration config) 550 throws RemoteException { 551 Parcel data = Parcel.obtain(); 552 data.writeInterfaceToken(IApplicationThread.descriptor); 553 data.writeStrongBinder(token); 554 data.writeTypedList(pendingResults); 555 data.writeTypedList(pendingNewIntents); 556 data.writeInt(configChanges); 557 data.writeInt(notResumed ? 1 : 0); 558 if (config != null) { 559 data.writeInt(1); 560 config.writeToParcel(data, 0); 561 } else { 562 data.writeInt(0); 563 } 564 mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null, 565 IBinder.FLAG_ONEWAY); 566 data.recycle(); 567 } 568 569 public void scheduleNewIntent(List<Intent> intents, IBinder token) 570 throws RemoteException { 571 Parcel data = Parcel.obtain(); 572 data.writeInterfaceToken(IApplicationThread.descriptor); 573 data.writeTypedList(intents); 574 data.writeStrongBinder(token); 575 mRemote.transact(SCHEDULE_NEW_INTENT_TRANSACTION, data, null, 576 IBinder.FLAG_ONEWAY); 577 data.recycle(); 578 } 579 580 public final void scheduleDestroyActivity(IBinder token, boolean finishing, 581 int configChanges) throws RemoteException { 582 Parcel data = Parcel.obtain(); 583 data.writeInterfaceToken(IApplicationThread.descriptor); 584 data.writeStrongBinder(token); 585 data.writeInt(finishing ? 1 : 0); 586 data.writeInt(configChanges); 587 mRemote.transact(SCHEDULE_FINISH_ACTIVITY_TRANSACTION, data, null, 588 IBinder.FLAG_ONEWAY); 589 data.recycle(); 590 } 591 592 public final void scheduleReceiver(Intent intent, ActivityInfo info, 593 int resultCode, String resultData, 594 Bundle map, boolean sync) throws RemoteException { 595 Parcel data = Parcel.obtain(); 596 data.writeInterfaceToken(IApplicationThread.descriptor); 597 intent.writeToParcel(data, 0); 598 info.writeToParcel(data, 0); 599 data.writeInt(resultCode); 600 data.writeString(resultData); 601 data.writeBundle(map); 602 data.writeInt(sync ? 1 : 0); 603 mRemote.transact(SCHEDULE_RECEIVER_TRANSACTION, data, null, 604 IBinder.FLAG_ONEWAY); 605 data.recycle(); 606 } 607 608 public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode) 609 throws RemoteException { 610 Parcel data = Parcel.obtain(); 611 data.writeInterfaceToken(IApplicationThread.descriptor); 612 app.writeToParcel(data, 0); 613 data.writeInt(backupMode); 614 mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null, 615 IBinder.FLAG_ONEWAY); 616 data.recycle(); 617 } 618 619 public final void scheduleDestroyBackupAgent(ApplicationInfo app) throws RemoteException { 620 Parcel data = Parcel.obtain(); 621 data.writeInterfaceToken(IApplicationThread.descriptor); 622 app.writeToParcel(data, 0); 623 mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null, 624 IBinder.FLAG_ONEWAY); 625 data.recycle(); 626 } 627 628 public final void scheduleCreateService(IBinder token, ServiceInfo info) 629 throws RemoteException { 630 Parcel data = Parcel.obtain(); 631 data.writeInterfaceToken(IApplicationThread.descriptor); 632 data.writeStrongBinder(token); 633 info.writeToParcel(data, 0); 634 mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null, 635 IBinder.FLAG_ONEWAY); 636 data.recycle(); 637 } 638 639 public final void scheduleBindService(IBinder token, Intent intent, boolean rebind) 640 throws RemoteException { 641 Parcel data = Parcel.obtain(); 642 data.writeInterfaceToken(IApplicationThread.descriptor); 643 data.writeStrongBinder(token); 644 intent.writeToParcel(data, 0); 645 data.writeInt(rebind ? 1 : 0); 646 mRemote.transact(SCHEDULE_BIND_SERVICE_TRANSACTION, data, null, 647 IBinder.FLAG_ONEWAY); 648 data.recycle(); 649 } 650 651 public final void scheduleUnbindService(IBinder token, Intent intent) 652 throws RemoteException { 653 Parcel data = Parcel.obtain(); 654 data.writeInterfaceToken(IApplicationThread.descriptor); 655 data.writeStrongBinder(token); 656 intent.writeToParcel(data, 0); 657 mRemote.transact(SCHEDULE_UNBIND_SERVICE_TRANSACTION, data, null, 658 IBinder.FLAG_ONEWAY); 659 data.recycle(); 660 } 661 662 public final void scheduleServiceArgs(IBinder token, int startId, 663 int flags, Intent args) throws RemoteException { 664 Parcel data = Parcel.obtain(); 665 data.writeInterfaceToken(IApplicationThread.descriptor); 666 data.writeStrongBinder(token); 667 data.writeInt(startId); 668 data.writeInt(flags); 669 if (args != null) { 670 data.writeInt(1); 671 args.writeToParcel(data, 0); 672 } else { 673 data.writeInt(0); 674 } 675 mRemote.transact(SCHEDULE_SERVICE_ARGS_TRANSACTION, data, null, 676 IBinder.FLAG_ONEWAY); 677 data.recycle(); 678 } 679 680 public final void scheduleStopService(IBinder token) 681 throws RemoteException { 682 Parcel data = Parcel.obtain(); 683 data.writeInterfaceToken(IApplicationThread.descriptor); 684 data.writeStrongBinder(token); 685 mRemote.transact(SCHEDULE_STOP_SERVICE_TRANSACTION, data, null, 686 IBinder.FLAG_ONEWAY); 687 data.recycle(); 688 } 689 690 public final void bindApplication(String packageName, ApplicationInfo info, 691 List<ProviderInfo> providers, ComponentName testName, 692 String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode, 693 boolean restrictedBackupMode, Configuration config, 694 Map<String, IBinder> services) throws RemoteException { 695 Parcel data = Parcel.obtain(); 696 data.writeInterfaceToken(IApplicationThread.descriptor); 697 data.writeString(packageName); 698 info.writeToParcel(data, 0); 699 data.writeTypedList(providers); 700 if (testName == null) { 701 data.writeInt(0); 702 } else { 703 data.writeInt(1); 704 testName.writeToParcel(data, 0); 705 } 706 data.writeString(profileName); 707 data.writeBundle(testArgs); 708 data.writeStrongInterface(testWatcher); 709 data.writeInt(debugMode); 710 data.writeInt(restrictedBackupMode ? 1 : 0); 711 config.writeToParcel(data, 0); 712 data.writeMap(services); 713 mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null, 714 IBinder.FLAG_ONEWAY); 715 data.recycle(); 716 } 717 718 public final void scheduleExit() throws RemoteException { 719 Parcel data = Parcel.obtain(); 720 data.writeInterfaceToken(IApplicationThread.descriptor); 721 mRemote.transact(SCHEDULE_EXIT_TRANSACTION, data, null, 722 IBinder.FLAG_ONEWAY); 723 data.recycle(); 724 } 725 726 public final void scheduleSuicide() throws RemoteException { 727 Parcel data = Parcel.obtain(); 728 data.writeInterfaceToken(IApplicationThread.descriptor); 729 mRemote.transact(SCHEDULE_SUICIDE_TRANSACTION, data, null, 730 IBinder.FLAG_ONEWAY); 731 data.recycle(); 732 } 733 734 public final void requestThumbnail(IBinder token) 735 throws RemoteException { 736 Parcel data = Parcel.obtain(); 737 data.writeInterfaceToken(IApplicationThread.descriptor); 738 data.writeStrongBinder(token); 739 mRemote.transact(REQUEST_THUMBNAIL_TRANSACTION, data, null, 740 IBinder.FLAG_ONEWAY); 741 data.recycle(); 742 } 743 744 public final void scheduleConfigurationChanged(Configuration config) 745 throws RemoteException { 746 Parcel data = Parcel.obtain(); 747 data.writeInterfaceToken(IApplicationThread.descriptor); 748 config.writeToParcel(data, 0); 749 mRemote.transact(SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION, data, null, 750 IBinder.FLAG_ONEWAY); 751 data.recycle(); 752 } 753 754 public void updateTimeZone() throws RemoteException { 755 Parcel data = Parcel.obtain(); 756 data.writeInterfaceToken(IApplicationThread.descriptor); 757 mRemote.transact(UPDATE_TIME_ZONE_TRANSACTION, data, null, 758 IBinder.FLAG_ONEWAY); 759 data.recycle(); 760 } 761 762 public void clearDnsCache() throws RemoteException { 763 Parcel data = Parcel.obtain(); 764 data.writeInterfaceToken(IApplicationThread.descriptor); 765 mRemote.transact(CLEAR_DNS_CACHE_TRANSACTION, data, null, 766 IBinder.FLAG_ONEWAY); 767 data.recycle(); 768 } 769 770 public void setHttpProxy(String proxy, String port, String exclList) throws RemoteException { 771 Parcel data = Parcel.obtain(); 772 data.writeInterfaceToken(IApplicationThread.descriptor); 773 data.writeString(proxy); 774 data.writeString(port); 775 data.writeString(exclList); 776 mRemote.transact(SET_HTTP_PROXY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); 777 data.recycle(); 778 } 779 780 public void processInBackground() throws RemoteException { 781 Parcel data = Parcel.obtain(); 782 data.writeInterfaceToken(IApplicationThread.descriptor); 783 mRemote.transact(PROCESS_IN_BACKGROUND_TRANSACTION, data, null, 784 IBinder.FLAG_ONEWAY); 785 data.recycle(); 786 } 787 788 public void dumpService(FileDescriptor fd, IBinder token, String[] args) 789 throws RemoteException { 790 Parcel data = Parcel.obtain(); 791 data.writeInterfaceToken(IApplicationThread.descriptor); 792 data.writeFileDescriptor(fd); 793 data.writeStrongBinder(token); 794 data.writeStringArray(args); 795 mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, 0); 796 data.recycle(); 797 } 798 799 public void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent, 800 int resultCode, String dataStr, Bundle extras, boolean ordered, boolean sticky) 801 throws RemoteException { 802 Parcel data = Parcel.obtain(); 803 data.writeInterfaceToken(IApplicationThread.descriptor); 804 data.writeStrongBinder(receiver.asBinder()); 805 intent.writeToParcel(data, 0); 806 data.writeInt(resultCode); 807 data.writeString(dataStr); 808 data.writeBundle(extras); 809 data.writeInt(ordered ? 1 : 0); 810 data.writeInt(sticky ? 1 : 0); 811 mRemote.transact(SCHEDULE_REGISTERED_RECEIVER_TRANSACTION, data, null, 812 IBinder.FLAG_ONEWAY); 813 data.recycle(); 814 } 815 816 public final void scheduleLowMemory() throws RemoteException { 817 Parcel data = Parcel.obtain(); 818 data.writeInterfaceToken(IApplicationThread.descriptor); 819 mRemote.transact(SCHEDULE_LOW_MEMORY_TRANSACTION, data, null, 820 IBinder.FLAG_ONEWAY); 821 data.recycle(); 822 } 823 824 public final void scheduleActivityConfigurationChanged( 825 IBinder token) throws RemoteException { 826 Parcel data = Parcel.obtain(); 827 data.writeInterfaceToken(IApplicationThread.descriptor); 828 data.writeStrongBinder(token); 829 mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null, 830 IBinder.FLAG_ONEWAY); 831 data.recycle(); 832 } 833 834 public void profilerControl(boolean start, String path, 835 ParcelFileDescriptor fd) throws RemoteException { 836 Parcel data = Parcel.obtain(); 837 data.writeInterfaceToken(IApplicationThread.descriptor); 838 data.writeInt(start ? 1 : 0); 839 data.writeString(path); 840 if (fd != null) { 841 data.writeInt(1); 842 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 843 } else { 844 data.writeInt(0); 845 } 846 mRemote.transact(PROFILER_CONTROL_TRANSACTION, data, null, 847 IBinder.FLAG_ONEWAY); 848 data.recycle(); 849 } 850 851 public void setSchedulingGroup(int group) throws RemoteException { 852 Parcel data = Parcel.obtain(); 853 data.writeInterfaceToken(IApplicationThread.descriptor); 854 data.writeInt(group); 855 mRemote.transact(SET_SCHEDULING_GROUP_TRANSACTION, data, null, 856 IBinder.FLAG_ONEWAY); 857 data.recycle(); 858 } 859 860 public void getMemoryInfo(Debug.MemoryInfo outInfo) throws RemoteException { 861 Parcel data = Parcel.obtain(); 862 Parcel reply = Parcel.obtain(); 863 data.writeInterfaceToken(IApplicationThread.descriptor); 864 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0); 865 reply.readException(); 866 outInfo.readFromParcel(reply); 867 data.recycle(); 868 reply.recycle(); 869 } 870 871 public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException { 872 Parcel data = Parcel.obtain(); 873 data.writeInterfaceToken(IApplicationThread.descriptor); 874 data.writeInt(cmd); 875 data.writeStringArray(packages); 876 mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null, 877 IBinder.FLAG_ONEWAY); 878 data.recycle(); 879 880 } 881 882 public void scheduleCrash(String msg) throws RemoteException { 883 Parcel data = Parcel.obtain(); 884 data.writeInterfaceToken(IApplicationThread.descriptor); 885 data.writeString(msg); 886 mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null, 887 IBinder.FLAG_ONEWAY); 888 data.recycle(); 889 890 } 891 892 public void dumpHeap(boolean managed, String path, 893 ParcelFileDescriptor fd) throws RemoteException { 894 Parcel data = Parcel.obtain(); 895 data.writeInterfaceToken(IApplicationThread.descriptor); 896 data.writeInt(managed ? 1 : 0); 897 data.writeString(path); 898 if (fd != null) { 899 data.writeInt(1); 900 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 901 } else { 902 data.writeInt(0); 903 } 904 mRemote.transact(DUMP_HEAP_TRANSACTION, data, null, 905 IBinder.FLAG_ONEWAY); 906 data.recycle(); 907 } 908 909 public void dumpActivity(FileDescriptor fd, IBinder token, String[] args) 910 throws RemoteException { 911 Parcel data = Parcel.obtain(); 912 data.writeInterfaceToken(IApplicationThread.descriptor); 913 data.writeFileDescriptor(fd); 914 data.writeStrongBinder(token); 915 data.writeStringArray(args); 916 mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, 0); 917 data.recycle(); 918 } 919} 920