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