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