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