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