ApplicationThreadNative.java revision 4416c3d6e4becd9ed39b89a03db0239c8225a135
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 PROCESS_IN_BACKGROUND_TRANSACTION: { 295 data.enforceInterface(IApplicationThread.descriptor); 296 processInBackground(); 297 return true; 298 } 299 300 case DUMP_SERVICE_TRANSACTION: { 301 data.enforceInterface(IApplicationThread.descriptor); 302 ParcelFileDescriptor fd = data.readFileDescriptor(); 303 final IBinder service = data.readStrongBinder(); 304 final String[] args = data.readStringArray(); 305 if (fd != null) { 306 dumpService(fd.getFileDescriptor(), service, args); 307 try { 308 fd.close(); 309 } catch (IOException e) { 310 } 311 } 312 return true; 313 } 314 315 case SCHEDULE_REGISTERED_RECEIVER_TRANSACTION: { 316 data.enforceInterface(IApplicationThread.descriptor); 317 IIntentReceiver receiver = IIntentReceiver.Stub.asInterface( 318 data.readStrongBinder()); 319 Intent intent = Intent.CREATOR.createFromParcel(data); 320 int resultCode = data.readInt(); 321 String dataStr = data.readString(); 322 Bundle extras = data.readBundle(); 323 boolean ordered = data.readInt() != 0; 324 boolean sticky = data.readInt() != 0; 325 scheduleRegisteredReceiver(receiver, intent, 326 resultCode, dataStr, extras, ordered, sticky); 327 return true; 328 } 329 330 case SCHEDULE_LOW_MEMORY_TRANSACTION: 331 { 332 scheduleLowMemory(); 333 return true; 334 } 335 336 case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION: 337 { 338 data.enforceInterface(IApplicationThread.descriptor); 339 IBinder b = data.readStrongBinder(); 340 scheduleActivityConfigurationChanged(b); 341 return true; 342 } 343 344 case REQUEST_PSS_TRANSACTION: 345 { 346 data.enforceInterface(IApplicationThread.descriptor); 347 requestPss(); 348 return true; 349 } 350 351 case PROFILER_CONTROL_TRANSACTION: 352 { 353 data.enforceInterface(IApplicationThread.descriptor); 354 boolean start = data.readInt() != 0; 355 String path = data.readString(); 356 ParcelFileDescriptor fd = data.readInt() != 0 357 ? data.readFileDescriptor() : null; 358 profilerControl(start, path, fd); 359 return true; 360 } 361 362 case SET_SCHEDULING_GROUP_TRANSACTION: 363 { 364 data.enforceInterface(IApplicationThread.descriptor); 365 int group = data.readInt(); 366 setSchedulingGroup(group); 367 return true; 368 } 369 370 case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION: 371 { 372 data.enforceInterface(IApplicationThread.descriptor); 373 ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data); 374 int backupMode = data.readInt(); 375 scheduleCreateBackupAgent(appInfo, backupMode); 376 return true; 377 } 378 379 case SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION: 380 { 381 data.enforceInterface(IApplicationThread.descriptor); 382 ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data); 383 scheduleDestroyBackupAgent(appInfo); 384 return true; 385 } 386 387 case GET_MEMORY_INFO_TRANSACTION: 388 { 389 data.enforceInterface(IApplicationThread.descriptor); 390 Debug.MemoryInfo mi = new Debug.MemoryInfo(); 391 getMemoryInfo(mi); 392 reply.writeNoException(); 393 mi.writeToParcel(reply, 0); 394 return true; 395 } 396 397 case DISPATCH_PACKAGE_BROADCAST_TRANSACTION: 398 { 399 data.enforceInterface(IApplicationThread.descriptor); 400 int cmd = data.readInt(); 401 String[] packages = data.readStringArray(); 402 dispatchPackageBroadcast(cmd, packages); 403 return true; 404 } 405 } 406 407 return super.onTransact(code, data, reply, flags); 408 } 409 410 public IBinder asBinder() 411 { 412 return this; 413 } 414} 415 416class ApplicationThreadProxy implements IApplicationThread { 417 private final IBinder mRemote; 418 419 public ApplicationThreadProxy(IBinder remote) { 420 mRemote = remote; 421 } 422 423 public final IBinder asBinder() { 424 return mRemote; 425 } 426 427 public final void schedulePauseActivity(IBinder token, boolean finished, 428 boolean userLeaving, int configChanges) throws RemoteException { 429 Parcel data = Parcel.obtain(); 430 data.writeInterfaceToken(IApplicationThread.descriptor); 431 data.writeStrongBinder(token); 432 data.writeInt(finished ? 1 : 0); 433 data.writeInt(userLeaving ? 1 :0); 434 data.writeInt(configChanges); 435 mRemote.transact(SCHEDULE_PAUSE_ACTIVITY_TRANSACTION, data, null, 436 IBinder.FLAG_ONEWAY); 437 data.recycle(); 438 } 439 440 public final void scheduleStopActivity(IBinder token, boolean showWindow, 441 int configChanges) throws RemoteException { 442 Parcel data = Parcel.obtain(); 443 data.writeInterfaceToken(IApplicationThread.descriptor); 444 data.writeStrongBinder(token); 445 data.writeInt(showWindow ? 1 : 0); 446 data.writeInt(configChanges); 447 mRemote.transact(SCHEDULE_STOP_ACTIVITY_TRANSACTION, data, null, 448 IBinder.FLAG_ONEWAY); 449 data.recycle(); 450 } 451 452 public final void scheduleWindowVisibility(IBinder token, 453 boolean showWindow) throws RemoteException { 454 Parcel data = Parcel.obtain(); 455 data.writeInterfaceToken(IApplicationThread.descriptor); 456 data.writeStrongBinder(token); 457 data.writeInt(showWindow ? 1 : 0); 458 mRemote.transact(SCHEDULE_WINDOW_VISIBILITY_TRANSACTION, data, null, 459 IBinder.FLAG_ONEWAY); 460 data.recycle(); 461 } 462 463 public final void scheduleResumeActivity(IBinder token, boolean isForward) 464 throws RemoteException { 465 Parcel data = Parcel.obtain(); 466 data.writeInterfaceToken(IApplicationThread.descriptor); 467 data.writeStrongBinder(token); 468 data.writeInt(isForward ? 1 : 0); 469 mRemote.transact(SCHEDULE_RESUME_ACTIVITY_TRANSACTION, data, null, 470 IBinder.FLAG_ONEWAY); 471 data.recycle(); 472 } 473 474 public final void scheduleSendResult(IBinder token, List<ResultInfo> results) 475 throws RemoteException { 476 Parcel data = Parcel.obtain(); 477 data.writeInterfaceToken(IApplicationThread.descriptor); 478 data.writeStrongBinder(token); 479 data.writeTypedList(results); 480 mRemote.transact(SCHEDULE_SEND_RESULT_TRANSACTION, data, null, 481 IBinder.FLAG_ONEWAY); 482 data.recycle(); 483 } 484 485 public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, 486 ActivityInfo info, Bundle state, List<ResultInfo> pendingResults, 487 List<Intent> pendingNewIntents, boolean notResumed, boolean isForward) 488 throws RemoteException { 489 Parcel data = Parcel.obtain(); 490 data.writeInterfaceToken(IApplicationThread.descriptor); 491 intent.writeToParcel(data, 0); 492 data.writeStrongBinder(token); 493 data.writeInt(ident); 494 info.writeToParcel(data, 0); 495 data.writeBundle(state); 496 data.writeTypedList(pendingResults); 497 data.writeTypedList(pendingNewIntents); 498 data.writeInt(notResumed ? 1 : 0); 499 data.writeInt(isForward ? 1 : 0); 500 mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null, 501 IBinder.FLAG_ONEWAY); 502 data.recycle(); 503 } 504 505 public final void scheduleRelaunchActivity(IBinder token, 506 List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, 507 int configChanges, boolean notResumed, Configuration config) 508 throws RemoteException { 509 Parcel data = Parcel.obtain(); 510 data.writeInterfaceToken(IApplicationThread.descriptor); 511 data.writeStrongBinder(token); 512 data.writeTypedList(pendingResults); 513 data.writeTypedList(pendingNewIntents); 514 data.writeInt(configChanges); 515 data.writeInt(notResumed ? 1 : 0); 516 if (config != null) { 517 data.writeInt(1); 518 config.writeToParcel(data, 0); 519 } else { 520 data.writeInt(0); 521 } 522 mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null, 523 IBinder.FLAG_ONEWAY); 524 data.recycle(); 525 } 526 527 public void scheduleNewIntent(List<Intent> intents, IBinder token) 528 throws RemoteException { 529 Parcel data = Parcel.obtain(); 530 data.writeInterfaceToken(IApplicationThread.descriptor); 531 data.writeTypedList(intents); 532 data.writeStrongBinder(token); 533 mRemote.transact(SCHEDULE_NEW_INTENT_TRANSACTION, data, null, 534 IBinder.FLAG_ONEWAY); 535 data.recycle(); 536 } 537 538 public final void scheduleDestroyActivity(IBinder token, boolean finishing, 539 int configChanges) throws RemoteException { 540 Parcel data = Parcel.obtain(); 541 data.writeInterfaceToken(IApplicationThread.descriptor); 542 data.writeStrongBinder(token); 543 data.writeInt(finishing ? 1 : 0); 544 data.writeInt(configChanges); 545 mRemote.transact(SCHEDULE_FINISH_ACTIVITY_TRANSACTION, data, null, 546 IBinder.FLAG_ONEWAY); 547 data.recycle(); 548 } 549 550 public final void scheduleReceiver(Intent intent, ActivityInfo info, 551 int resultCode, String resultData, 552 Bundle map, boolean sync) throws RemoteException { 553 Parcel data = Parcel.obtain(); 554 data.writeInterfaceToken(IApplicationThread.descriptor); 555 intent.writeToParcel(data, 0); 556 info.writeToParcel(data, 0); 557 data.writeInt(resultCode); 558 data.writeString(resultData); 559 data.writeBundle(map); 560 data.writeInt(sync ? 1 : 0); 561 mRemote.transact(SCHEDULE_RECEIVER_TRANSACTION, data, null, 562 IBinder.FLAG_ONEWAY); 563 data.recycle(); 564 } 565 566 public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode) 567 throws RemoteException { 568 Parcel data = Parcel.obtain(); 569 data.writeInterfaceToken(IApplicationThread.descriptor); 570 app.writeToParcel(data, 0); 571 data.writeInt(backupMode); 572 mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null, 573 IBinder.FLAG_ONEWAY); 574 data.recycle(); 575 } 576 577 public final void scheduleDestroyBackupAgent(ApplicationInfo app) throws RemoteException { 578 Parcel data = Parcel.obtain(); 579 data.writeInterfaceToken(IApplicationThread.descriptor); 580 app.writeToParcel(data, 0); 581 mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null, 582 IBinder.FLAG_ONEWAY); 583 data.recycle(); 584 } 585 586 public final void scheduleCreateService(IBinder token, ServiceInfo info) 587 throws RemoteException { 588 Parcel data = Parcel.obtain(); 589 data.writeInterfaceToken(IApplicationThread.descriptor); 590 data.writeStrongBinder(token); 591 info.writeToParcel(data, 0); 592 mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null, 593 IBinder.FLAG_ONEWAY); 594 data.recycle(); 595 } 596 597 public final void scheduleBindService(IBinder token, Intent intent, boolean rebind) 598 throws RemoteException { 599 Parcel data = Parcel.obtain(); 600 data.writeInterfaceToken(IApplicationThread.descriptor); 601 data.writeStrongBinder(token); 602 intent.writeToParcel(data, 0); 603 data.writeInt(rebind ? 1 : 0); 604 mRemote.transact(SCHEDULE_BIND_SERVICE_TRANSACTION, data, null, 605 IBinder.FLAG_ONEWAY); 606 data.recycle(); 607 } 608 609 public final void scheduleUnbindService(IBinder token, Intent intent) 610 throws RemoteException { 611 Parcel data = Parcel.obtain(); 612 data.writeInterfaceToken(IApplicationThread.descriptor); 613 data.writeStrongBinder(token); 614 intent.writeToParcel(data, 0); 615 mRemote.transact(SCHEDULE_UNBIND_SERVICE_TRANSACTION, data, null, 616 IBinder.FLAG_ONEWAY); 617 data.recycle(); 618 } 619 620 public final void scheduleServiceArgs(IBinder token, int startId, 621 int flags, Intent args) throws RemoteException { 622 Parcel data = Parcel.obtain(); 623 data.writeInterfaceToken(IApplicationThread.descriptor); 624 data.writeStrongBinder(token); 625 data.writeInt(startId); 626 data.writeInt(flags); 627 if (args != null) { 628 data.writeInt(1); 629 args.writeToParcel(data, 0); 630 } else { 631 data.writeInt(0); 632 } 633 mRemote.transact(SCHEDULE_SERVICE_ARGS_TRANSACTION, data, null, 634 IBinder.FLAG_ONEWAY); 635 data.recycle(); 636 } 637 638 public final void scheduleStopService(IBinder token) 639 throws RemoteException { 640 Parcel data = Parcel.obtain(); 641 data.writeInterfaceToken(IApplicationThread.descriptor); 642 data.writeStrongBinder(token); 643 mRemote.transact(SCHEDULE_STOP_SERVICE_TRANSACTION, data, null, 644 IBinder.FLAG_ONEWAY); 645 data.recycle(); 646 } 647 648 public final void bindApplication(String packageName, ApplicationInfo info, 649 List<ProviderInfo> providers, ComponentName testName, 650 String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode, 651 boolean restrictedBackupMode, Configuration config, 652 Map<String, IBinder> services) throws RemoteException { 653 Parcel data = Parcel.obtain(); 654 data.writeInterfaceToken(IApplicationThread.descriptor); 655 data.writeString(packageName); 656 info.writeToParcel(data, 0); 657 data.writeTypedList(providers); 658 if (testName == null) { 659 data.writeInt(0); 660 } else { 661 data.writeInt(1); 662 testName.writeToParcel(data, 0); 663 } 664 data.writeString(profileName); 665 data.writeBundle(testArgs); 666 data.writeStrongInterface(testWatcher); 667 data.writeInt(debugMode); 668 data.writeInt(restrictedBackupMode ? 1 : 0); 669 config.writeToParcel(data, 0); 670 data.writeMap(services); 671 mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null, 672 IBinder.FLAG_ONEWAY); 673 data.recycle(); 674 } 675 676 public final void scheduleExit() throws RemoteException { 677 Parcel data = Parcel.obtain(); 678 data.writeInterfaceToken(IApplicationThread.descriptor); 679 mRemote.transact(SCHEDULE_EXIT_TRANSACTION, data, null, 680 IBinder.FLAG_ONEWAY); 681 data.recycle(); 682 } 683 684 public final void scheduleSuicide() throws RemoteException { 685 Parcel data = Parcel.obtain(); 686 data.writeInterfaceToken(IApplicationThread.descriptor); 687 mRemote.transact(SCHEDULE_SUICIDE_TRANSACTION, data, null, 688 IBinder.FLAG_ONEWAY); 689 data.recycle(); 690 } 691 692 public final void requestThumbnail(IBinder token) 693 throws RemoteException { 694 Parcel data = Parcel.obtain(); 695 data.writeInterfaceToken(IApplicationThread.descriptor); 696 data.writeStrongBinder(token); 697 mRemote.transact(REQUEST_THUMBNAIL_TRANSACTION, data, null, 698 IBinder.FLAG_ONEWAY); 699 data.recycle(); 700 } 701 702 public final void scheduleConfigurationChanged(Configuration config) 703 throws RemoteException { 704 Parcel data = Parcel.obtain(); 705 data.writeInterfaceToken(IApplicationThread.descriptor); 706 config.writeToParcel(data, 0); 707 mRemote.transact(SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION, data, null, 708 IBinder.FLAG_ONEWAY); 709 data.recycle(); 710 } 711 712 public void updateTimeZone() throws RemoteException { 713 Parcel data = Parcel.obtain(); 714 data.writeInterfaceToken(IApplicationThread.descriptor); 715 mRemote.transact(UPDATE_TIME_ZONE_TRANSACTION, data, null, 716 IBinder.FLAG_ONEWAY); 717 data.recycle(); 718 } 719 720 public void processInBackground() throws RemoteException { 721 Parcel data = Parcel.obtain(); 722 data.writeInterfaceToken(IApplicationThread.descriptor); 723 mRemote.transact(PROCESS_IN_BACKGROUND_TRANSACTION, data, null, 724 IBinder.FLAG_ONEWAY); 725 data.recycle(); 726 } 727 728 public void dumpService(FileDescriptor fd, IBinder token, String[] args) 729 throws RemoteException { 730 Parcel data = Parcel.obtain(); 731 data.writeInterfaceToken(IApplicationThread.descriptor); 732 data.writeFileDescriptor(fd); 733 data.writeStrongBinder(token); 734 data.writeStringArray(args); 735 mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, 0); 736 data.recycle(); 737 } 738 739 public void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent, 740 int resultCode, String dataStr, Bundle extras, boolean ordered, boolean sticky) 741 throws RemoteException { 742 Parcel data = Parcel.obtain(); 743 data.writeInterfaceToken(IApplicationThread.descriptor); 744 data.writeStrongBinder(receiver.asBinder()); 745 intent.writeToParcel(data, 0); 746 data.writeInt(resultCode); 747 data.writeString(dataStr); 748 data.writeBundle(extras); 749 data.writeInt(ordered ? 1 : 0); 750 data.writeInt(sticky ? 1 : 0); 751 mRemote.transact(SCHEDULE_REGISTERED_RECEIVER_TRANSACTION, data, null, 752 IBinder.FLAG_ONEWAY); 753 data.recycle(); 754 } 755 756 public final void scheduleLowMemory() throws RemoteException { 757 Parcel data = Parcel.obtain(); 758 data.writeInterfaceToken(IApplicationThread.descriptor); 759 mRemote.transact(SCHEDULE_LOW_MEMORY_TRANSACTION, data, null, 760 IBinder.FLAG_ONEWAY); 761 data.recycle(); 762 } 763 764 public final void scheduleActivityConfigurationChanged( 765 IBinder token) throws RemoteException { 766 Parcel data = Parcel.obtain(); 767 data.writeInterfaceToken(IApplicationThread.descriptor); 768 data.writeStrongBinder(token); 769 mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null, 770 IBinder.FLAG_ONEWAY); 771 data.recycle(); 772 } 773 774 public final void requestPss() throws RemoteException { 775 Parcel data = Parcel.obtain(); 776 data.writeInterfaceToken(IApplicationThread.descriptor); 777 mRemote.transact(REQUEST_PSS_TRANSACTION, data, null, 778 IBinder.FLAG_ONEWAY); 779 data.recycle(); 780 } 781 782 public void profilerControl(boolean start, String path, 783 ParcelFileDescriptor fd) throws RemoteException { 784 Parcel data = Parcel.obtain(); 785 data.writeInterfaceToken(IApplicationThread.descriptor); 786 data.writeInt(start ? 1 : 0); 787 data.writeString(path); 788 if (fd != null) { 789 data.writeInt(1); 790 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); 791 } else { 792 data.writeInt(0); 793 } 794 mRemote.transact(PROFILER_CONTROL_TRANSACTION, data, null, 795 IBinder.FLAG_ONEWAY); 796 data.recycle(); 797 } 798 799 public void setSchedulingGroup(int group) throws RemoteException { 800 Parcel data = Parcel.obtain(); 801 data.writeInterfaceToken(IApplicationThread.descriptor); 802 data.writeInt(group); 803 mRemote.transact(SET_SCHEDULING_GROUP_TRANSACTION, data, null, 804 IBinder.FLAG_ONEWAY); 805 data.recycle(); 806 } 807 808 public void getMemoryInfo(Debug.MemoryInfo outInfo) throws RemoteException { 809 Parcel data = Parcel.obtain(); 810 Parcel reply = Parcel.obtain(); 811 data.writeInterfaceToken(IApplicationThread.descriptor); 812 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0); 813 reply.readException(); 814 outInfo.readFromParcel(reply); 815 data.recycle(); 816 reply.recycle(); 817 } 818 819 public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException { 820 Parcel data = Parcel.obtain(); 821 data.writeInterfaceToken(IApplicationThread.descriptor); 822 data.writeInt(cmd); 823 data.writeStringArray(packages); 824 mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null, 825 IBinder.FLAG_ONEWAY); 826 data.recycle(); 827 828 } 829} 830 831