ApplicationThreadNative.java revision 0af6fa7015cd9da08bf52c1efb13641d30fd6bd7
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.net.Uri;
29import android.os.Binder;
30import android.os.Bundle;
31import android.os.Debug;
32import android.os.Parcelable;
33import android.os.PersistableBundle;
34import android.os.RemoteException;
35import android.os.IBinder;
36import android.os.Parcel;
37import android.os.ParcelFileDescriptor;
38import android.os.TransactionTooLargeException;
39import android.util.Log;
40
41import com.android.internal.app.IVoiceInteractor;
42import com.android.internal.content.ReferrerIntent;
43
44import java.io.FileDescriptor;
45import java.io.IOException;
46import java.util.HashMap;
47import java.util.List;
48import java.util.Map;
49
50/** {@hide} */
51public abstract class ApplicationThreadNative extends Binder
52        implements IApplicationThread {
53    /**
54     * Cast a Binder object into an application thread interface, generating
55     * a proxy if needed.
56     */
57    static public IApplicationThread asInterface(IBinder obj) {
58        if (obj == null) {
59            return null;
60        }
61        IApplicationThread in =
62            (IApplicationThread)obj.queryLocalInterface(descriptor);
63        if (in != null) {
64            return in;
65        }
66
67        return new ApplicationThreadProxy(obj);
68    }
69
70    public ApplicationThreadNative() {
71        attachInterface(this, descriptor);
72    }
73
74    @Override
75    public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
76            throws RemoteException {
77        switch (code) {
78        case SCHEDULE_PAUSE_ACTIVITY_TRANSACTION:
79        {
80            data.enforceInterface(IApplicationThread.descriptor);
81            IBinder b = data.readStrongBinder();
82            boolean finished = data.readInt() != 0;
83            boolean userLeaving = data.readInt() != 0;
84            int configChanges = data.readInt();
85            boolean dontReport = data.readInt() != 0;
86            schedulePauseActivity(b, finished, userLeaving, configChanges, dontReport);
87            return true;
88        }
89
90        case SCHEDULE_STOP_ACTIVITY_TRANSACTION:
91        {
92            data.enforceInterface(IApplicationThread.descriptor);
93            IBinder b = data.readStrongBinder();
94            boolean show = data.readInt() != 0;
95            int configChanges = data.readInt();
96            scheduleStopActivity(b, show, configChanges);
97            return true;
98        }
99
100        case SCHEDULE_WINDOW_VISIBILITY_TRANSACTION:
101        {
102            data.enforceInterface(IApplicationThread.descriptor);
103            IBinder b = data.readStrongBinder();
104            boolean show = data.readInt() != 0;
105            scheduleWindowVisibility(b, show);
106            return true;
107        }
108
109        case SCHEDULE_SLEEPING_TRANSACTION:
110        {
111            data.enforceInterface(IApplicationThread.descriptor);
112            IBinder b = data.readStrongBinder();
113            boolean sleeping = data.readInt() != 0;
114            scheduleSleeping(b, sleeping);
115            return true;
116        }
117
118        case SCHEDULE_RESUME_ACTIVITY_TRANSACTION:
119        {
120            data.enforceInterface(IApplicationThread.descriptor);
121            IBinder b = data.readStrongBinder();
122            int procState = data.readInt();
123            boolean isForward = data.readInt() != 0;
124            Bundle resumeArgs = data.readBundle();
125            scheduleResumeActivity(b, procState, isForward, resumeArgs);
126            return true;
127        }
128
129        case SCHEDULE_SEND_RESULT_TRANSACTION:
130        {
131            data.enforceInterface(IApplicationThread.descriptor);
132            IBinder b = data.readStrongBinder();
133            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
134            scheduleSendResult(b, ri);
135            return true;
136        }
137
138        case SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION:
139        {
140            data.enforceInterface(IApplicationThread.descriptor);
141            Intent intent = Intent.CREATOR.createFromParcel(data);
142            IBinder b = data.readStrongBinder();
143            int ident = data.readInt();
144            ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
145            Configuration curConfig = Configuration.CREATOR.createFromParcel(data);
146            Configuration overrideConfig = null;
147            if (data.readInt() != 0) {
148                overrideConfig = Configuration.CREATOR.createFromParcel(data);
149            }
150            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
151            String referrer = data.readString();
152            IVoiceInteractor voiceInteractor = IVoiceInteractor.Stub.asInterface(
153                    data.readStrongBinder());
154            int procState = data.readInt();
155            Bundle state = data.readBundle();
156            PersistableBundle persistentState = data.readPersistableBundle();
157            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
158            List<ReferrerIntent> pi = data.createTypedArrayList(ReferrerIntent.CREATOR);
159            boolean notResumed = data.readInt() != 0;
160            boolean isForward = data.readInt() != 0;
161            ProfilerInfo profilerInfo = data.readInt() != 0
162                    ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
163            scheduleLaunchActivity(intent, b, ident, info, curConfig, overrideConfig, compatInfo,
164                    referrer, voiceInteractor, procState, state, persistentState, ri, pi,
165                    notResumed, isForward, profilerInfo);
166            return true;
167        }
168
169        case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION:
170        {
171            data.enforceInterface(IApplicationThread.descriptor);
172            IBinder b = data.readStrongBinder();
173            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
174            List<ReferrerIntent> pi = data.createTypedArrayList(ReferrerIntent.CREATOR);
175            int configChanges = data.readInt();
176            boolean notResumed = data.readInt() != 0;
177            Configuration config = Configuration.CREATOR.createFromParcel(data);
178            Configuration overrideConfig = null;
179            if (data.readInt() != 0) {
180                overrideConfig = Configuration.CREATOR.createFromParcel(data);
181            }
182            boolean preserveWindows = data.readInt() == 1;
183            scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config, overrideConfig,
184                    preserveWindows);
185            return true;
186        }
187
188        case SCHEDULE_NEW_INTENT_TRANSACTION:
189        {
190            data.enforceInterface(IApplicationThread.descriptor);
191            List<ReferrerIntent> pi = data.createTypedArrayList(ReferrerIntent.CREATOR);
192            IBinder b = data.readStrongBinder();
193            scheduleNewIntent(pi, b);
194            return true;
195        }
196
197        case SCHEDULE_FINISH_ACTIVITY_TRANSACTION:
198        {
199            data.enforceInterface(IApplicationThread.descriptor);
200            IBinder b = data.readStrongBinder();
201            boolean finishing = data.readInt() != 0;
202            int configChanges = data.readInt();
203            scheduleDestroyActivity(b, finishing, configChanges);
204            return true;
205        }
206
207        case SCHEDULE_RECEIVER_TRANSACTION:
208        {
209            data.enforceInterface(IApplicationThread.descriptor);
210            Intent intent = Intent.CREATOR.createFromParcel(data);
211            ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
212            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
213            int resultCode = data.readInt();
214            String resultData = data.readString();
215            Bundle resultExtras = data.readBundle();
216            boolean sync = data.readInt() != 0;
217            int sendingUser = data.readInt();
218            int processState = data.readInt();
219            scheduleReceiver(intent, info, compatInfo, resultCode, resultData,
220                    resultExtras, sync, sendingUser, processState);
221            return true;
222        }
223
224        case SCHEDULE_CREATE_SERVICE_TRANSACTION: {
225            data.enforceInterface(IApplicationThread.descriptor);
226            IBinder token = data.readStrongBinder();
227            ServiceInfo info = ServiceInfo.CREATOR.createFromParcel(data);
228            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
229            int processState = data.readInt();
230            scheduleCreateService(token, info, compatInfo, processState);
231            return true;
232        }
233
234        case SCHEDULE_BIND_SERVICE_TRANSACTION: {
235            data.enforceInterface(IApplicationThread.descriptor);
236            IBinder token = data.readStrongBinder();
237            Intent intent = Intent.CREATOR.createFromParcel(data);
238            boolean rebind = data.readInt() != 0;
239            int processState = data.readInt();
240            scheduleBindService(token, intent, rebind, processState);
241            return true;
242        }
243
244        case SCHEDULE_UNBIND_SERVICE_TRANSACTION: {
245            data.enforceInterface(IApplicationThread.descriptor);
246            IBinder token = data.readStrongBinder();
247            Intent intent = Intent.CREATOR.createFromParcel(data);
248            scheduleUnbindService(token, intent);
249            return true;
250        }
251
252        case SCHEDULE_SERVICE_ARGS_TRANSACTION:
253        {
254            data.enforceInterface(IApplicationThread.descriptor);
255            IBinder token = data.readStrongBinder();
256            boolean taskRemoved = data.readInt() != 0;
257            int startId = data.readInt();
258            int fl = data.readInt();
259            Intent args;
260            if (data.readInt() != 0) {
261                args = Intent.CREATOR.createFromParcel(data);
262            } else {
263                args = null;
264            }
265            scheduleServiceArgs(token, taskRemoved, startId, fl, args);
266            return true;
267        }
268
269        case SCHEDULE_STOP_SERVICE_TRANSACTION:
270        {
271            data.enforceInterface(IApplicationThread.descriptor);
272            IBinder token = data.readStrongBinder();
273            scheduleStopService(token);
274            return true;
275        }
276
277        case BIND_APPLICATION_TRANSACTION:
278        {
279            data.enforceInterface(IApplicationThread.descriptor);
280            String packageName = data.readString();
281            ApplicationInfo info =
282                ApplicationInfo.CREATOR.createFromParcel(data);
283            List<ProviderInfo> providers =
284                data.createTypedArrayList(ProviderInfo.CREATOR);
285            ComponentName testName = (data.readInt() != 0)
286                ? new ComponentName(data) : null;
287            ProfilerInfo profilerInfo = data.readInt() != 0
288                    ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
289            Bundle testArgs = data.readBundle();
290            IBinder binder = data.readStrongBinder();
291            IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
292            binder = data.readStrongBinder();
293            IUiAutomationConnection uiAutomationConnection =
294                    IUiAutomationConnection.Stub.asInterface(binder);
295            int testMode = data.readInt();
296            boolean enableBinderTracking = data.readInt() != 0;
297            boolean trackAllocation = data.readInt() != 0;
298            boolean restrictedBackupMode = (data.readInt() != 0);
299            boolean persistent = (data.readInt() != 0);
300            Configuration config = Configuration.CREATOR.createFromParcel(data);
301            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
302            HashMap<String, IBinder> services = data.readHashMap(null);
303            Bundle coreSettings = data.readBundle();
304            bindApplication(packageName, info, providers, testName, profilerInfo, testArgs,
305                    testWatcher, uiAutomationConnection, testMode, enableBinderTracking,
306                    trackAllocation, restrictedBackupMode, persistent, config, compatInfo, services,
307                    coreSettings);
308            return true;
309        }
310
311        case SCHEDULE_EXIT_TRANSACTION:
312        {
313            data.enforceInterface(IApplicationThread.descriptor);
314            scheduleExit();
315            return true;
316        }
317
318        case SCHEDULE_SUICIDE_TRANSACTION:
319        {
320            data.enforceInterface(IApplicationThread.descriptor);
321            scheduleSuicide();
322            return true;
323        }
324
325        case SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION:
326        {
327            data.enforceInterface(IApplicationThread.descriptor);
328            Configuration config = Configuration.CREATOR.createFromParcel(data);
329            scheduleConfigurationChanged(config);
330            return true;
331        }
332
333        case UPDATE_TIME_ZONE_TRANSACTION: {
334            data.enforceInterface(IApplicationThread.descriptor);
335            updateTimeZone();
336            return true;
337        }
338
339        case CLEAR_DNS_CACHE_TRANSACTION: {
340            data.enforceInterface(IApplicationThread.descriptor);
341            clearDnsCache();
342            return true;
343        }
344
345        case SET_HTTP_PROXY_TRANSACTION: {
346            data.enforceInterface(IApplicationThread.descriptor);
347            final String proxy = data.readString();
348            final String port = data.readString();
349            final String exclList = data.readString();
350            final Uri pacFileUrl = Uri.CREATOR.createFromParcel(data);
351            setHttpProxy(proxy, port, exclList, pacFileUrl);
352            return true;
353        }
354
355        case PROCESS_IN_BACKGROUND_TRANSACTION: {
356            data.enforceInterface(IApplicationThread.descriptor);
357            processInBackground();
358            return true;
359        }
360
361        case DUMP_SERVICE_TRANSACTION: {
362            data.enforceInterface(IApplicationThread.descriptor);
363            ParcelFileDescriptor fd = data.readFileDescriptor();
364            final IBinder service = data.readStrongBinder();
365            final String[] args = data.readStringArray();
366            if (fd != null) {
367                dumpService(fd.getFileDescriptor(), service, args);
368                try {
369                    fd.close();
370                } catch (IOException e) {
371                }
372            }
373            return true;
374        }
375
376        case DUMP_PROVIDER_TRANSACTION: {
377            data.enforceInterface(IApplicationThread.descriptor);
378            ParcelFileDescriptor fd = data.readFileDescriptor();
379            final IBinder service = data.readStrongBinder();
380            final String[] args = data.readStringArray();
381            if (fd != null) {
382                dumpProvider(fd.getFileDescriptor(), service, args);
383                try {
384                    fd.close();
385                } catch (IOException e) {
386                }
387            }
388            return true;
389        }
390
391        case SCHEDULE_REGISTERED_RECEIVER_TRANSACTION: {
392            data.enforceInterface(IApplicationThread.descriptor);
393            IIntentReceiver receiver = IIntentReceiver.Stub.asInterface(
394                    data.readStrongBinder());
395            Intent intent = Intent.CREATOR.createFromParcel(data);
396            int resultCode = data.readInt();
397            String dataStr = data.readString();
398            Bundle extras = data.readBundle();
399            boolean ordered = data.readInt() != 0;
400            boolean sticky = data.readInt() != 0;
401            int sendingUser = data.readInt();
402            int processState = data.readInt();
403            scheduleRegisteredReceiver(receiver, intent,
404                    resultCode, dataStr, extras, ordered, sticky, sendingUser, processState);
405            return true;
406        }
407
408        case SCHEDULE_LOW_MEMORY_TRANSACTION:
409        {
410            data.enforceInterface(IApplicationThread.descriptor);
411            scheduleLowMemory();
412            return true;
413        }
414
415        case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION:
416        {
417            data.enforceInterface(IApplicationThread.descriptor);
418            IBinder b = data.readStrongBinder();
419            Configuration overrideConfig = null;
420            if (data.readInt() != 0) {
421                overrideConfig = Configuration.CREATOR.createFromParcel(data);
422            }
423            final boolean reportToActivity = data.readInt() == 1;
424            scheduleActivityConfigurationChanged(b, overrideConfig, reportToActivity);
425            return true;
426        }
427
428        case SCHEDULE_LOCAL_VOICE_INTERACTION_STARTED_TRANSACTION:
429        {
430            data.enforceInterface(IApplicationThread.descriptor);
431            IBinder token = data.readStrongBinder();
432            IVoiceInteractor voiceInteractor = IVoiceInteractor.Stub.asInterface(
433                    data.readStrongBinder());
434            scheduleLocalVoiceInteractionStarted(token, voiceInteractor);
435            return true;
436        }
437
438        case PROFILER_CONTROL_TRANSACTION:
439        {
440            data.enforceInterface(IApplicationThread.descriptor);
441            boolean start = data.readInt() != 0;
442            int profileType = data.readInt();
443            ProfilerInfo profilerInfo = data.readInt() != 0
444                    ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
445            profilerControl(start, profilerInfo, profileType);
446            return true;
447        }
448
449        case SET_SCHEDULING_GROUP_TRANSACTION:
450        {
451            data.enforceInterface(IApplicationThread.descriptor);
452            int group = data.readInt();
453            setSchedulingGroup(group);
454            return true;
455        }
456
457        case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION:
458        {
459            data.enforceInterface(IApplicationThread.descriptor);
460            ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
461            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
462            int backupMode = data.readInt();
463            scheduleCreateBackupAgent(appInfo, compatInfo, backupMode);
464            return true;
465        }
466
467        case SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION:
468        {
469            data.enforceInterface(IApplicationThread.descriptor);
470            ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
471            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
472            scheduleDestroyBackupAgent(appInfo, compatInfo);
473            return true;
474        }
475
476        case DISPATCH_PACKAGE_BROADCAST_TRANSACTION:
477        {
478            data.enforceInterface(IApplicationThread.descriptor);
479            int cmd = data.readInt();
480            String[] packages = data.readStringArray();
481            dispatchPackageBroadcast(cmd, packages);
482            return true;
483        }
484
485        case SCHEDULE_CRASH_TRANSACTION:
486        {
487            data.enforceInterface(IApplicationThread.descriptor);
488            String msg = data.readString();
489            scheduleCrash(msg);
490            return true;
491        }
492
493        case DUMP_HEAP_TRANSACTION:
494        {
495            data.enforceInterface(IApplicationThread.descriptor);
496            boolean managed = data.readInt() != 0;
497            String path = data.readString();
498            ParcelFileDescriptor fd = data.readInt() != 0
499                    ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
500            dumpHeap(managed, path, fd);
501            return true;
502        }
503
504        case DUMP_ACTIVITY_TRANSACTION: {
505            data.enforceInterface(IApplicationThread.descriptor);
506            ParcelFileDescriptor fd = data.readFileDescriptor();
507            final IBinder activity = data.readStrongBinder();
508            final String prefix = data.readString();
509            final String[] args = data.readStringArray();
510            if (fd != null) {
511                dumpActivity(fd.getFileDescriptor(), activity, prefix, args);
512                try {
513                    fd.close();
514                } catch (IOException e) {
515                }
516            }
517            return true;
518        }
519
520        case SET_CORE_SETTINGS_TRANSACTION: {
521            data.enforceInterface(IApplicationThread.descriptor);
522            Bundle settings = data.readBundle();
523            setCoreSettings(settings);
524            return true;
525        }
526
527        case UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION: {
528            data.enforceInterface(IApplicationThread.descriptor);
529            String pkg = data.readString();
530            CompatibilityInfo compat = CompatibilityInfo.CREATOR.createFromParcel(data);
531            updatePackageCompatibilityInfo(pkg, compat);
532            return true;
533        }
534
535        case SCHEDULE_TRIM_MEMORY_TRANSACTION: {
536            data.enforceInterface(IApplicationThread.descriptor);
537            int level = data.readInt();
538            scheduleTrimMemory(level);
539            return true;
540        }
541
542        case DUMP_MEM_INFO_TRANSACTION:
543        {
544            data.enforceInterface(IApplicationThread.descriptor);
545            ParcelFileDescriptor fd = data.readFileDescriptor();
546            Debug.MemoryInfo mi = Debug.MemoryInfo.CREATOR.createFromParcel(data);
547            boolean checkin = data.readInt() != 0;
548            boolean dumpInfo = data.readInt() != 0;
549            boolean dumpDalvik = data.readInt() != 0;
550            boolean dumpSummaryOnly = data.readInt() != 0;
551            String[] args = data.readStringArray();
552            if (fd != null) {
553                try {
554                    dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo,
555                            dumpDalvik, dumpSummaryOnly, args);
556                } finally {
557                    try {
558                        fd.close();
559                    } catch (IOException e) {
560                        // swallowed, not propagated back to the caller
561                    }
562                }
563            }
564            reply.writeNoException();
565            return true;
566        }
567
568        case DUMP_GFX_INFO_TRANSACTION:
569        {
570            data.enforceInterface(IApplicationThread.descriptor);
571            ParcelFileDescriptor fd = data.readFileDescriptor();
572            String[] args = data.readStringArray();
573            if (fd != null) {
574                try {
575                    dumpGfxInfo(fd.getFileDescriptor(), args);
576                } finally {
577                    try {
578                        fd.close();
579                    } catch (IOException e) {
580                        // swallowed, not propagated back to the caller
581                    }
582                }
583            }
584            reply.writeNoException();
585            return true;
586        }
587
588        case DUMP_DB_INFO_TRANSACTION:
589        {
590            data.enforceInterface(IApplicationThread.descriptor);
591            ParcelFileDescriptor fd = data.readFileDescriptor();
592            String[] args = data.readStringArray();
593            if (fd != null) {
594                try {
595                    dumpDbInfo(fd.getFileDescriptor(), args);
596                } finally {
597                    try {
598                        fd.close();
599                    } catch (IOException e) {
600                        // swallowed, not propagated back to the caller
601                    }
602                }
603            }
604            reply.writeNoException();
605            return true;
606        }
607
608        case UNSTABLE_PROVIDER_DIED_TRANSACTION:
609        {
610            data.enforceInterface(IApplicationThread.descriptor);
611            IBinder provider = data.readStrongBinder();
612            unstableProviderDied(provider);
613            reply.writeNoException();
614            return true;
615        }
616
617        case REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION:
618        {
619            data.enforceInterface(IApplicationThread.descriptor);
620            IBinder activityToken = data.readStrongBinder();
621            IBinder requestToken = data.readStrongBinder();
622            int requestType = data.readInt();
623            requestAssistContextExtras(activityToken, requestToken, requestType);
624            reply.writeNoException();
625            return true;
626        }
627
628        case SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION:
629        {
630            data.enforceInterface(IApplicationThread.descriptor);
631            IBinder token = data.readStrongBinder();
632            boolean timeout = data.readInt() == 1;
633            scheduleTranslucentConversionComplete(token, timeout);
634            reply.writeNoException();
635            return true;
636        }
637
638        case SCHEDULE_ON_NEW_ACTIVITY_OPTIONS_TRANSACTION:
639        {
640            data.enforceInterface(IApplicationThread.descriptor);
641            IBinder token = data.readStrongBinder();
642            ActivityOptions options = new ActivityOptions(data.readBundle());
643            scheduleOnNewActivityOptions(token, options);
644            reply.writeNoException();
645            return true;
646        }
647
648        case SET_PROCESS_STATE_TRANSACTION:
649        {
650            data.enforceInterface(IApplicationThread.descriptor);
651            int state = data.readInt();
652            setProcessState(state);
653            reply.writeNoException();
654            return true;
655        }
656
657        case SCHEDULE_INSTALL_PROVIDER_TRANSACTION:
658        {
659            data.enforceInterface(IApplicationThread.descriptor);
660            ProviderInfo provider = ProviderInfo.CREATOR.createFromParcel(data);
661            scheduleInstallProvider(provider);
662            reply.writeNoException();
663            return true;
664        }
665
666        case UPDATE_TIME_PREFS_TRANSACTION:
667        {
668            data.enforceInterface(IApplicationThread.descriptor);
669            byte is24Hour = data.readByte();
670            updateTimePrefs(is24Hour == (byte) 1);
671            reply.writeNoException();
672            return true;
673        }
674
675        case CANCEL_VISIBLE_BEHIND_TRANSACTION:
676        {
677            data.enforceInterface(IApplicationThread.descriptor);
678            IBinder token = data.readStrongBinder();
679            scheduleCancelVisibleBehind(token);
680            reply.writeNoException();
681            return true;
682        }
683
684        case BACKGROUND_VISIBLE_BEHIND_CHANGED_TRANSACTION:
685        {
686            data.enforceInterface(IApplicationThread.descriptor);
687            IBinder token = data.readStrongBinder();
688            boolean enabled = data.readInt() > 0;
689            scheduleBackgroundVisibleBehindChanged(token, enabled);
690            reply.writeNoException();
691            return true;
692        }
693
694        case ENTER_ANIMATION_COMPLETE_TRANSACTION:
695        {
696            data.enforceInterface(IApplicationThread.descriptor);
697            IBinder token = data.readStrongBinder();
698            scheduleEnterAnimationComplete(token);
699            reply.writeNoException();
700            return true;
701        }
702
703        case NOTIFY_CLEARTEXT_NETWORK_TRANSACTION:
704        {
705            data.enforceInterface(IApplicationThread.descriptor);
706            final byte[] firstPacket = data.createByteArray();
707            notifyCleartextNetwork(firstPacket);
708            reply.writeNoException();
709            return true;
710        }
711
712        case START_BINDER_TRACKING_TRANSACTION:
713        {
714            data.enforceInterface(IApplicationThread.descriptor);
715            startBinderTracking();
716            return true;
717        }
718
719        case STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION:
720        {
721            data.enforceInterface(IApplicationThread.descriptor);
722            ParcelFileDescriptor fd = data.readFileDescriptor();
723            if (fd != null) {
724                stopBinderTrackingAndDump(fd.getFileDescriptor());
725                try {
726                    fd.close();
727                } catch (IOException e) {
728                }
729            }
730            return true;
731        }
732
733        case SCHEDULE_MULTI_WINDOW_MODE_CHANGED_TRANSACTION:
734        {
735            data.enforceInterface(IApplicationThread.descriptor);
736            final IBinder b = data.readStrongBinder();
737            final boolean multiWindowMode = data.readInt() != 0;
738            scheduleMultiWindowModeChanged(b, multiWindowMode);
739            return true;
740        }
741
742        case SCHEDULE_PICTURE_IN_PICTURE_MODE_CHANGED_TRANSACTION:
743        {
744            data.enforceInterface(IApplicationThread.descriptor);
745            final IBinder b = data.readStrongBinder();
746            final boolean pipMode = data.readInt() != 0;
747            schedulePictureInPictureModeChanged(b, pipMode);
748            return true;
749        }
750
751        }
752
753        return super.onTransact(code, data, reply, flags);
754    }
755
756    public IBinder asBinder()
757    {
758        return this;
759    }
760}
761
762class ApplicationThreadProxy implements IApplicationThread {
763    private final IBinder mRemote;
764
765    public ApplicationThreadProxy(IBinder remote) {
766        mRemote = remote;
767    }
768
769    public final IBinder asBinder() {
770        return mRemote;
771    }
772
773    public final void schedulePauseActivity(IBinder token, boolean finished,
774            boolean userLeaving, int configChanges, boolean dontReport) throws RemoteException {
775        Parcel data = Parcel.obtain();
776        data.writeInterfaceToken(IApplicationThread.descriptor);
777        data.writeStrongBinder(token);
778        data.writeInt(finished ? 1 : 0);
779        data.writeInt(userLeaving ? 1 :0);
780        data.writeInt(configChanges);
781        data.writeInt(dontReport ? 1 : 0);
782        mRemote.transact(SCHEDULE_PAUSE_ACTIVITY_TRANSACTION, data, null,
783                IBinder.FLAG_ONEWAY);
784        data.recycle();
785    }
786
787    public final void scheduleStopActivity(IBinder token, boolean showWindow,
788            int configChanges) throws RemoteException {
789        Parcel data = Parcel.obtain();
790        data.writeInterfaceToken(IApplicationThread.descriptor);
791        data.writeStrongBinder(token);
792        data.writeInt(showWindow ? 1 : 0);
793        data.writeInt(configChanges);
794        mRemote.transact(SCHEDULE_STOP_ACTIVITY_TRANSACTION, data, null,
795                IBinder.FLAG_ONEWAY);
796        data.recycle();
797    }
798
799    public final void scheduleWindowVisibility(IBinder token,
800            boolean showWindow) throws RemoteException {
801        Parcel data = Parcel.obtain();
802        data.writeInterfaceToken(IApplicationThread.descriptor);
803        data.writeStrongBinder(token);
804        data.writeInt(showWindow ? 1 : 0);
805        mRemote.transact(SCHEDULE_WINDOW_VISIBILITY_TRANSACTION, data, null,
806                IBinder.FLAG_ONEWAY);
807        data.recycle();
808    }
809
810    public final void scheduleSleeping(IBinder token,
811            boolean sleeping) throws RemoteException {
812        Parcel data = Parcel.obtain();
813        data.writeInterfaceToken(IApplicationThread.descriptor);
814        data.writeStrongBinder(token);
815        data.writeInt(sleeping ? 1 : 0);
816        mRemote.transact(SCHEDULE_SLEEPING_TRANSACTION, data, null,
817                IBinder.FLAG_ONEWAY);
818        data.recycle();
819    }
820
821    public final void scheduleResumeActivity(IBinder token, int procState, boolean isForward,
822            Bundle resumeArgs)
823            throws RemoteException {
824        Parcel data = Parcel.obtain();
825        data.writeInterfaceToken(IApplicationThread.descriptor);
826        data.writeStrongBinder(token);
827        data.writeInt(procState);
828        data.writeInt(isForward ? 1 : 0);
829        data.writeBundle(resumeArgs);
830        mRemote.transact(SCHEDULE_RESUME_ACTIVITY_TRANSACTION, data, null,
831                IBinder.FLAG_ONEWAY);
832        data.recycle();
833    }
834
835    public final void scheduleSendResult(IBinder token, List<ResultInfo> results)
836            throws RemoteException {
837        Parcel data = Parcel.obtain();
838        data.writeInterfaceToken(IApplicationThread.descriptor);
839        data.writeStrongBinder(token);
840        data.writeTypedList(results);
841        mRemote.transact(SCHEDULE_SEND_RESULT_TRANSACTION, data, null,
842                IBinder.FLAG_ONEWAY);
843        data.recycle();
844    }
845
846    public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
847            ActivityInfo info, Configuration curConfig, Configuration overrideConfig,
848            CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor,
849            int procState, Bundle state, PersistableBundle persistentState,
850            List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
851            boolean notResumed, boolean isForward, ProfilerInfo profilerInfo) throws RemoteException {
852        Parcel data = Parcel.obtain();
853        data.writeInterfaceToken(IApplicationThread.descriptor);
854        intent.writeToParcel(data, 0);
855        data.writeStrongBinder(token);
856        data.writeInt(ident);
857        info.writeToParcel(data, 0);
858        curConfig.writeToParcel(data, 0);
859        if (overrideConfig != null) {
860            data.writeInt(1);
861            overrideConfig.writeToParcel(data, 0);
862        } else {
863            data.writeInt(0);
864        }
865        compatInfo.writeToParcel(data, 0);
866        data.writeString(referrer);
867        data.writeStrongBinder(voiceInteractor != null ? voiceInteractor.asBinder() : null);
868        data.writeInt(procState);
869        data.writeBundle(state);
870        data.writePersistableBundle(persistentState);
871        data.writeTypedList(pendingResults);
872        data.writeTypedList(pendingNewIntents);
873        data.writeInt(notResumed ? 1 : 0);
874        data.writeInt(isForward ? 1 : 0);
875        if (profilerInfo != null) {
876            data.writeInt(1);
877            profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
878        } else {
879            data.writeInt(0);
880        }
881        mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null,
882                IBinder.FLAG_ONEWAY);
883        data.recycle();
884    }
885
886    public final void scheduleRelaunchActivity(IBinder token,
887            List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
888            int configChanges, boolean notResumed, Configuration config,
889            Configuration overrideConfig, boolean preserveWindow) throws RemoteException {
890        Parcel data = Parcel.obtain();
891        data.writeInterfaceToken(IApplicationThread.descriptor);
892        data.writeStrongBinder(token);
893        data.writeTypedList(pendingResults);
894        data.writeTypedList(pendingNewIntents);
895        data.writeInt(configChanges);
896        data.writeInt(notResumed ? 1 : 0);
897        config.writeToParcel(data, 0);
898        if (overrideConfig != null) {
899            data.writeInt(1);
900            overrideConfig.writeToParcel(data, 0);
901        } else {
902            data.writeInt(0);
903        }
904        data.writeInt(preserveWindow ? 1 : 0);
905        mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null,
906                IBinder.FLAG_ONEWAY);
907        data.recycle();
908    }
909
910    public void scheduleNewIntent(List<ReferrerIntent> intents, IBinder token)
911            throws RemoteException {
912        Parcel data = Parcel.obtain();
913        data.writeInterfaceToken(IApplicationThread.descriptor);
914        data.writeTypedList(intents);
915        data.writeStrongBinder(token);
916        mRemote.transact(SCHEDULE_NEW_INTENT_TRANSACTION, data, null,
917                IBinder.FLAG_ONEWAY);
918        data.recycle();
919    }
920
921    public final void scheduleDestroyActivity(IBinder token, boolean finishing,
922            int configChanges) throws RemoteException {
923        Parcel data = Parcel.obtain();
924        data.writeInterfaceToken(IApplicationThread.descriptor);
925        data.writeStrongBinder(token);
926        data.writeInt(finishing ? 1 : 0);
927        data.writeInt(configChanges);
928        mRemote.transact(SCHEDULE_FINISH_ACTIVITY_TRANSACTION, data, null,
929                IBinder.FLAG_ONEWAY);
930        data.recycle();
931    }
932
933    public final void scheduleReceiver(Intent intent, ActivityInfo info,
934            CompatibilityInfo compatInfo, int resultCode, String resultData,
935            Bundle map, boolean sync, int sendingUser, int processState) throws RemoteException {
936        Parcel data = Parcel.obtain();
937        data.writeInterfaceToken(IApplicationThread.descriptor);
938        intent.writeToParcel(data, 0);
939        info.writeToParcel(data, 0);
940        compatInfo.writeToParcel(data, 0);
941        data.writeInt(resultCode);
942        data.writeString(resultData);
943        data.writeBundle(map);
944        data.writeInt(sync ? 1 : 0);
945        data.writeInt(sendingUser);
946        data.writeInt(processState);
947        mRemote.transact(SCHEDULE_RECEIVER_TRANSACTION, data, null,
948                IBinder.FLAG_ONEWAY);
949        data.recycle();
950    }
951
952    public final void scheduleCreateBackupAgent(ApplicationInfo app,
953            CompatibilityInfo compatInfo, int backupMode) throws RemoteException {
954        Parcel data = Parcel.obtain();
955        data.writeInterfaceToken(IApplicationThread.descriptor);
956        app.writeToParcel(data, 0);
957        compatInfo.writeToParcel(data, 0);
958        data.writeInt(backupMode);
959        mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null,
960                IBinder.FLAG_ONEWAY);
961        data.recycle();
962    }
963
964    public final void scheduleDestroyBackupAgent(ApplicationInfo app,
965            CompatibilityInfo compatInfo) throws RemoteException {
966        Parcel data = Parcel.obtain();
967        data.writeInterfaceToken(IApplicationThread.descriptor);
968        app.writeToParcel(data, 0);
969        compatInfo.writeToParcel(data, 0);
970        mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null,
971                IBinder.FLAG_ONEWAY);
972        data.recycle();
973    }
974
975    public final void scheduleCreateService(IBinder token, ServiceInfo info,
976            CompatibilityInfo compatInfo, int processState) throws RemoteException {
977        Parcel data = Parcel.obtain();
978        data.writeInterfaceToken(IApplicationThread.descriptor);
979        data.writeStrongBinder(token);
980        info.writeToParcel(data, 0);
981        compatInfo.writeToParcel(data, 0);
982        data.writeInt(processState);
983        try {
984            mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null,
985                    IBinder.FLAG_ONEWAY);
986        } catch (TransactionTooLargeException e) {
987            Log.e("CREATE_SERVICE", "Binder failure starting service; service=" + info);
988            throw e;
989        }
990        data.recycle();
991    }
992
993    public final void scheduleBindService(IBinder token, Intent intent, boolean rebind,
994            int processState) throws RemoteException {
995        Parcel data = Parcel.obtain();
996        data.writeInterfaceToken(IApplicationThread.descriptor);
997        data.writeStrongBinder(token);
998        intent.writeToParcel(data, 0);
999        data.writeInt(rebind ? 1 : 0);
1000        data.writeInt(processState);
1001        mRemote.transact(SCHEDULE_BIND_SERVICE_TRANSACTION, data, null,
1002                IBinder.FLAG_ONEWAY);
1003        data.recycle();
1004    }
1005
1006    public final void scheduleUnbindService(IBinder token, Intent intent)
1007            throws RemoteException {
1008        Parcel data = Parcel.obtain();
1009        data.writeInterfaceToken(IApplicationThread.descriptor);
1010        data.writeStrongBinder(token);
1011        intent.writeToParcel(data, 0);
1012        mRemote.transact(SCHEDULE_UNBIND_SERVICE_TRANSACTION, data, null,
1013                IBinder.FLAG_ONEWAY);
1014        data.recycle();
1015    }
1016
1017    public final void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
1018            int flags, Intent args) throws RemoteException {
1019        Parcel data = Parcel.obtain();
1020        data.writeInterfaceToken(IApplicationThread.descriptor);
1021        data.writeStrongBinder(token);
1022        data.writeInt(taskRemoved ? 1 : 0);
1023        data.writeInt(startId);
1024        data.writeInt(flags);
1025        if (args != null) {
1026            data.writeInt(1);
1027            args.writeToParcel(data, 0);
1028        } else {
1029            data.writeInt(0);
1030        }
1031        mRemote.transact(SCHEDULE_SERVICE_ARGS_TRANSACTION, data, null,
1032                IBinder.FLAG_ONEWAY);
1033        data.recycle();
1034    }
1035
1036    public final void scheduleStopService(IBinder token)
1037            throws RemoteException {
1038        Parcel data = Parcel.obtain();
1039        data.writeInterfaceToken(IApplicationThread.descriptor);
1040        data.writeStrongBinder(token);
1041        mRemote.transact(SCHEDULE_STOP_SERVICE_TRANSACTION, data, null,
1042                IBinder.FLAG_ONEWAY);
1043        data.recycle();
1044    }
1045
1046    @Override
1047    public final void bindApplication(String packageName, ApplicationInfo info,
1048            List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo,
1049            Bundle testArgs, IInstrumentationWatcher testWatcher,
1050            IUiAutomationConnection uiAutomationConnection, int debugMode,
1051            boolean enableBinderTracking, boolean trackAllocation, boolean restrictedBackupMode,
1052            boolean persistent, Configuration config, CompatibilityInfo compatInfo,
1053            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
1054        Parcel data = Parcel.obtain();
1055        data.writeInterfaceToken(IApplicationThread.descriptor);
1056        data.writeString(packageName);
1057        info.writeToParcel(data, 0);
1058        data.writeTypedList(providers);
1059        if (testName == null) {
1060            data.writeInt(0);
1061        } else {
1062            data.writeInt(1);
1063            testName.writeToParcel(data, 0);
1064        }
1065        if (profilerInfo != null) {
1066            data.writeInt(1);
1067            profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1068        } else {
1069            data.writeInt(0);
1070        }
1071        data.writeBundle(testArgs);
1072        data.writeStrongInterface(testWatcher);
1073        data.writeStrongInterface(uiAutomationConnection);
1074        data.writeInt(debugMode);
1075        data.writeInt(enableBinderTracking ? 1 : 0);
1076        data.writeInt(trackAllocation ? 1 : 0);
1077        data.writeInt(restrictedBackupMode ? 1 : 0);
1078        data.writeInt(persistent ? 1 : 0);
1079        config.writeToParcel(data, 0);
1080        compatInfo.writeToParcel(data, 0);
1081        data.writeMap(services);
1082        data.writeBundle(coreSettings);
1083        mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,
1084                IBinder.FLAG_ONEWAY);
1085        data.recycle();
1086    }
1087
1088    public final void scheduleExit() throws RemoteException {
1089        Parcel data = Parcel.obtain();
1090        data.writeInterfaceToken(IApplicationThread.descriptor);
1091        mRemote.transact(SCHEDULE_EXIT_TRANSACTION, data, null,
1092                IBinder.FLAG_ONEWAY);
1093        data.recycle();
1094    }
1095
1096    public final void scheduleSuicide() throws RemoteException {
1097        Parcel data = Parcel.obtain();
1098        data.writeInterfaceToken(IApplicationThread.descriptor);
1099        mRemote.transact(SCHEDULE_SUICIDE_TRANSACTION, data, null,
1100                IBinder.FLAG_ONEWAY);
1101        data.recycle();
1102    }
1103
1104    public final void scheduleConfigurationChanged(Configuration config)
1105            throws RemoteException {
1106        Parcel data = Parcel.obtain();
1107        data.writeInterfaceToken(IApplicationThread.descriptor);
1108        config.writeToParcel(data, 0);
1109        mRemote.transact(SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION, data, null,
1110                IBinder.FLAG_ONEWAY);
1111        data.recycle();
1112    }
1113
1114    public final void scheduleLocalVoiceInteractionStarted(IBinder token,
1115            IVoiceInteractor voiceInteractor) throws RemoteException {
1116        Parcel data = Parcel.obtain();
1117        data.writeInterfaceToken(IApplicationThread.descriptor);
1118        data.writeStrongBinder(token);
1119        data.writeStrongBinder(voiceInteractor != null ? voiceInteractor.asBinder() : null);
1120        mRemote.transact(SCHEDULE_LOCAL_VOICE_INTERACTION_STARTED_TRANSACTION, data, null,
1121                IBinder.FLAG_ONEWAY);
1122        data.recycle();
1123    }
1124
1125    public void updateTimeZone() throws RemoteException {
1126        Parcel data = Parcel.obtain();
1127        data.writeInterfaceToken(IApplicationThread.descriptor);
1128        mRemote.transact(UPDATE_TIME_ZONE_TRANSACTION, data, null,
1129                IBinder.FLAG_ONEWAY);
1130        data.recycle();
1131    }
1132
1133    public void clearDnsCache() throws RemoteException {
1134        Parcel data = Parcel.obtain();
1135        data.writeInterfaceToken(IApplicationThread.descriptor);
1136        mRemote.transact(CLEAR_DNS_CACHE_TRANSACTION, data, null,
1137                IBinder.FLAG_ONEWAY);
1138        data.recycle();
1139    }
1140
1141    public void setHttpProxy(String proxy, String port, String exclList,
1142            Uri pacFileUrl) throws RemoteException {
1143        Parcel data = Parcel.obtain();
1144        data.writeInterfaceToken(IApplicationThread.descriptor);
1145        data.writeString(proxy);
1146        data.writeString(port);
1147        data.writeString(exclList);
1148        pacFileUrl.writeToParcel(data, 0);
1149        mRemote.transact(SET_HTTP_PROXY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1150        data.recycle();
1151    }
1152
1153    public void processInBackground() throws RemoteException {
1154        Parcel data = Parcel.obtain();
1155        data.writeInterfaceToken(IApplicationThread.descriptor);
1156        mRemote.transact(PROCESS_IN_BACKGROUND_TRANSACTION, data, null,
1157                IBinder.FLAG_ONEWAY);
1158        data.recycle();
1159    }
1160
1161    public void dumpService(FileDescriptor fd, IBinder token, String[] args)
1162            throws RemoteException {
1163        Parcel data = Parcel.obtain();
1164        data.writeInterfaceToken(IApplicationThread.descriptor);
1165        data.writeFileDescriptor(fd);
1166        data.writeStrongBinder(token);
1167        data.writeStringArray(args);
1168        mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1169        data.recycle();
1170    }
1171
1172    public void dumpProvider(FileDescriptor fd, IBinder token, String[] args)
1173            throws RemoteException {
1174        Parcel data = Parcel.obtain();
1175        data.writeInterfaceToken(IApplicationThread.descriptor);
1176        data.writeFileDescriptor(fd);
1177        data.writeStrongBinder(token);
1178        data.writeStringArray(args);
1179        mRemote.transact(DUMP_PROVIDER_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1180        data.recycle();
1181    }
1182
1183    public void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent,
1184            int resultCode, String dataStr, Bundle extras, boolean ordered,
1185            boolean sticky, int sendingUser, int processState) throws RemoteException {
1186        Parcel data = Parcel.obtain();
1187        data.writeInterfaceToken(IApplicationThread.descriptor);
1188        data.writeStrongBinder(receiver.asBinder());
1189        intent.writeToParcel(data, 0);
1190        data.writeInt(resultCode);
1191        data.writeString(dataStr);
1192        data.writeBundle(extras);
1193        data.writeInt(ordered ? 1 : 0);
1194        data.writeInt(sticky ? 1 : 0);
1195        data.writeInt(sendingUser);
1196        data.writeInt(processState);
1197        mRemote.transact(SCHEDULE_REGISTERED_RECEIVER_TRANSACTION, data, null,
1198                IBinder.FLAG_ONEWAY);
1199        data.recycle();
1200    }
1201
1202    @Override
1203    public final void scheduleLowMemory() throws RemoteException {
1204        Parcel data = Parcel.obtain();
1205        data.writeInterfaceToken(IApplicationThread.descriptor);
1206        mRemote.transact(SCHEDULE_LOW_MEMORY_TRANSACTION, data, null,
1207                IBinder.FLAG_ONEWAY);
1208        data.recycle();
1209    }
1210
1211    @Override
1212    public final void scheduleActivityConfigurationChanged(IBinder token,
1213            Configuration overrideConfig, boolean reportToActivity) throws RemoteException {
1214        Parcel data = Parcel.obtain();
1215        data.writeInterfaceToken(IApplicationThread.descriptor);
1216        data.writeStrongBinder(token);
1217        if (overrideConfig != null) {
1218            data.writeInt(1);
1219            overrideConfig.writeToParcel(data, 0);
1220        } else {
1221            data.writeInt(0);
1222        }
1223        data.writeInt(reportToActivity ? 1 : 0);
1224        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
1225                IBinder.FLAG_ONEWAY);
1226        data.recycle();
1227    }
1228
1229    @Override
1230    public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
1231            throws RemoteException {
1232        Parcel data = Parcel.obtain();
1233        data.writeInterfaceToken(IApplicationThread.descriptor);
1234        data.writeInt(start ? 1 : 0);
1235        data.writeInt(profileType);
1236        if (profilerInfo != null) {
1237            data.writeInt(1);
1238            profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1239        } else {
1240            data.writeInt(0);
1241        }
1242        mRemote.transact(PROFILER_CONTROL_TRANSACTION, data, null,
1243                IBinder.FLAG_ONEWAY);
1244        data.recycle();
1245    }
1246
1247    public void setSchedulingGroup(int group) throws RemoteException {
1248        Parcel data = Parcel.obtain();
1249        data.writeInterfaceToken(IApplicationThread.descriptor);
1250        data.writeInt(group);
1251        mRemote.transact(SET_SCHEDULING_GROUP_TRANSACTION, data, null,
1252                IBinder.FLAG_ONEWAY);
1253        data.recycle();
1254    }
1255
1256    public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException {
1257        Parcel data = Parcel.obtain();
1258        data.writeInterfaceToken(IApplicationThread.descriptor);
1259        data.writeInt(cmd);
1260        data.writeStringArray(packages);
1261        mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null,
1262                IBinder.FLAG_ONEWAY);
1263        data.recycle();
1264    }
1265
1266    public void scheduleCrash(String msg) throws RemoteException {
1267        Parcel data = Parcel.obtain();
1268        data.writeInterfaceToken(IApplicationThread.descriptor);
1269        data.writeString(msg);
1270        mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null,
1271                IBinder.FLAG_ONEWAY);
1272        data.recycle();
1273    }
1274
1275    public void dumpHeap(boolean managed, String path,
1276            ParcelFileDescriptor fd) throws RemoteException {
1277        Parcel data = Parcel.obtain();
1278        data.writeInterfaceToken(IApplicationThread.descriptor);
1279        data.writeInt(managed ? 1 : 0);
1280        data.writeString(path);
1281        if (fd != null) {
1282            data.writeInt(1);
1283            fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1284        } else {
1285            data.writeInt(0);
1286        }
1287        mRemote.transact(DUMP_HEAP_TRANSACTION, data, null,
1288                IBinder.FLAG_ONEWAY);
1289        data.recycle();
1290    }
1291
1292    public void dumpActivity(FileDescriptor fd, IBinder token, String prefix, String[] args)
1293            throws RemoteException {
1294        Parcel data = Parcel.obtain();
1295        data.writeInterfaceToken(IApplicationThread.descriptor);
1296        data.writeFileDescriptor(fd);
1297        data.writeStrongBinder(token);
1298        data.writeString(prefix);
1299        data.writeStringArray(args);
1300        mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1301        data.recycle();
1302    }
1303
1304    public void setCoreSettings(Bundle coreSettings) throws RemoteException {
1305        Parcel data = Parcel.obtain();
1306        data.writeInterfaceToken(IApplicationThread.descriptor);
1307        data.writeBundle(coreSettings);
1308        mRemote.transact(SET_CORE_SETTINGS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1309    }
1310
1311    public void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info)
1312            throws RemoteException {
1313        Parcel data = Parcel.obtain();
1314        data.writeInterfaceToken(IApplicationThread.descriptor);
1315        data.writeString(pkg);
1316        info.writeToParcel(data, 0);
1317        mRemote.transact(UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION, data, null,
1318                IBinder.FLAG_ONEWAY);
1319    }
1320
1321    public void scheduleTrimMemory(int level) throws RemoteException {
1322        Parcel data = Parcel.obtain();
1323        data.writeInterfaceToken(IApplicationThread.descriptor);
1324        data.writeInt(level);
1325        mRemote.transact(SCHEDULE_TRIM_MEMORY_TRANSACTION, data, null,
1326                IBinder.FLAG_ONEWAY);
1327        data.recycle();
1328    }
1329
1330    public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin,
1331            boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly, String[] args) throws RemoteException {
1332        Parcel data = Parcel.obtain();
1333        Parcel reply = Parcel.obtain();
1334        data.writeInterfaceToken(IApplicationThread.descriptor);
1335        data.writeFileDescriptor(fd);
1336        mem.writeToParcel(data, 0);
1337        data.writeInt(checkin ? 1 : 0);
1338        data.writeInt(dumpInfo ? 1 : 0);
1339        data.writeInt(dumpDalvik ? 1 : 0);
1340        data.writeInt(dumpSummaryOnly ? 1 : 0);
1341        data.writeStringArray(args);
1342        mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0);
1343        reply.readException();
1344        data.recycle();
1345        reply.recycle();
1346    }
1347
1348    public void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException {
1349        Parcel data = Parcel.obtain();
1350        data.writeInterfaceToken(IApplicationThread.descriptor);
1351        data.writeFileDescriptor(fd);
1352        data.writeStringArray(args);
1353        mRemote.transact(DUMP_GFX_INFO_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1354        data.recycle();
1355    }
1356
1357    public void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException {
1358        Parcel data = Parcel.obtain();
1359        data.writeInterfaceToken(IApplicationThread.descriptor);
1360        data.writeFileDescriptor(fd);
1361        data.writeStringArray(args);
1362        mRemote.transact(DUMP_DB_INFO_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1363        data.recycle();
1364    }
1365
1366    @Override
1367    public void unstableProviderDied(IBinder provider) throws RemoteException {
1368        Parcel data = Parcel.obtain();
1369        data.writeInterfaceToken(IApplicationThread.descriptor);
1370        data.writeStrongBinder(provider);
1371        mRemote.transact(UNSTABLE_PROVIDER_DIED_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1372        data.recycle();
1373    }
1374
1375    @Override
1376    public void requestAssistContextExtras(IBinder activityToken, IBinder requestToken,
1377            int requestType) throws RemoteException {
1378        Parcel data = Parcel.obtain();
1379        data.writeInterfaceToken(IApplicationThread.descriptor);
1380        data.writeStrongBinder(activityToken);
1381        data.writeStrongBinder(requestToken);
1382        data.writeInt(requestType);
1383        mRemote.transact(REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION, data, null,
1384                IBinder.FLAG_ONEWAY);
1385        data.recycle();
1386    }
1387
1388    @Override
1389    public void scheduleTranslucentConversionComplete(IBinder token, boolean timeout)
1390            throws RemoteException {
1391        Parcel data = Parcel.obtain();
1392        data.writeInterfaceToken(IApplicationThread.descriptor);
1393        data.writeStrongBinder(token);
1394        data.writeInt(timeout ? 1 : 0);
1395        mRemote.transact(SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION, data, null,
1396                IBinder.FLAG_ONEWAY);
1397        data.recycle();
1398    }
1399
1400    @Override
1401    public void scheduleOnNewActivityOptions(IBinder token, ActivityOptions options)
1402            throws RemoteException {
1403        Parcel data = Parcel.obtain();
1404        data.writeInterfaceToken(IApplicationThread.descriptor);
1405        data.writeStrongBinder(token);
1406        data.writeBundle(options == null ? null : options.toBundle());
1407        mRemote.transact(SCHEDULE_ON_NEW_ACTIVITY_OPTIONS_TRANSACTION, data, null,
1408                IBinder.FLAG_ONEWAY);
1409        data.recycle();
1410    }
1411
1412    @Override
1413    public void setProcessState(int state) throws RemoteException {
1414        Parcel data = Parcel.obtain();
1415        data.writeInterfaceToken(IApplicationThread.descriptor);
1416        data.writeInt(state);
1417        mRemote.transact(SET_PROCESS_STATE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1418        data.recycle();
1419    }
1420
1421    @Override
1422    public void scheduleInstallProvider(ProviderInfo provider) throws RemoteException {
1423        Parcel data = Parcel.obtain();
1424        data.writeInterfaceToken(IApplicationThread.descriptor);
1425        provider.writeToParcel(data, 0);
1426        mRemote.transact(SCHEDULE_INSTALL_PROVIDER_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1427        data.recycle();
1428    }
1429
1430    @Override
1431    public void updateTimePrefs(boolean is24Hour) throws RemoteException {
1432        Parcel data = Parcel.obtain();
1433        data.writeInterfaceToken(IApplicationThread.descriptor);
1434        data.writeByte(is24Hour ? (byte) 1 : (byte) 0);
1435        mRemote.transact(UPDATE_TIME_PREFS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1436        data.recycle();
1437    }
1438
1439    @Override
1440    public void scheduleCancelVisibleBehind(IBinder token) throws RemoteException {
1441        Parcel data = Parcel.obtain();
1442        data.writeInterfaceToken(IApplicationThread.descriptor);
1443        data.writeStrongBinder(token);
1444        mRemote.transact(CANCEL_VISIBLE_BEHIND_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1445        data.recycle();
1446    }
1447
1448    @Override
1449    public void scheduleBackgroundVisibleBehindChanged(IBinder token, boolean enabled)
1450            throws RemoteException {
1451        Parcel data = Parcel.obtain();
1452        data.writeInterfaceToken(IApplicationThread.descriptor);
1453        data.writeStrongBinder(token);
1454        data.writeInt(enabled ? 1 : 0);
1455        mRemote.transact(BACKGROUND_VISIBLE_BEHIND_CHANGED_TRANSACTION, data, null,
1456                IBinder.FLAG_ONEWAY);
1457        data.recycle();
1458    }
1459
1460    @Override
1461    public void scheduleEnterAnimationComplete(IBinder token) throws RemoteException {
1462        Parcel data = Parcel.obtain();
1463        data.writeInterfaceToken(IApplicationThread.descriptor);
1464        data.writeStrongBinder(token);
1465        mRemote.transact(ENTER_ANIMATION_COMPLETE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1466        data.recycle();
1467    }
1468
1469    @Override
1470    public void notifyCleartextNetwork(byte[] firstPacket) throws RemoteException {
1471        Parcel data = Parcel.obtain();
1472        data.writeInterfaceToken(IApplicationThread.descriptor);
1473        data.writeByteArray(firstPacket);
1474        mRemote.transact(NOTIFY_CLEARTEXT_NETWORK_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1475        data.recycle();
1476    }
1477
1478    @Override
1479    public void startBinderTracking() throws RemoteException {
1480        Parcel data = Parcel.obtain();
1481        data.writeInterfaceToken(IApplicationThread.descriptor);
1482        mRemote.transact(START_BINDER_TRACKING_TRANSACTION, data, null,
1483                IBinder.FLAG_ONEWAY);
1484        data.recycle();
1485    }
1486
1487    @Override
1488    public void stopBinderTrackingAndDump(FileDescriptor fd) throws RemoteException {
1489        Parcel data = Parcel.obtain();
1490        data.writeInterfaceToken(IApplicationThread.descriptor);
1491        data.writeFileDescriptor(fd);
1492        mRemote.transact(STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION, data, null,
1493                IBinder.FLAG_ONEWAY);
1494        data.recycle();
1495    }
1496
1497    @Override
1498    public final void scheduleMultiWindowModeChanged(
1499            IBinder token, boolean multiWindowMode) throws RemoteException {
1500        Parcel data = Parcel.obtain();
1501        data.writeInterfaceToken(IApplicationThread.descriptor);
1502        data.writeStrongBinder(token);
1503        data.writeInt(multiWindowMode ? 1 : 0);
1504        mRemote.transact(SCHEDULE_MULTI_WINDOW_MODE_CHANGED_TRANSACTION, data, null,
1505                IBinder.FLAG_ONEWAY);
1506        data.recycle();
1507    }
1508
1509    @Override
1510    public final void schedulePictureInPictureModeChanged(IBinder token, boolean pipMode)
1511            throws RemoteException {
1512        Parcel data = Parcel.obtain();
1513        data.writeInterfaceToken(IApplicationThread.descriptor);
1514        data.writeStrongBinder(token);
1515        data.writeInt(pipMode ? 1 : 0);
1516        mRemote.transact(SCHEDULE_PICTURE_IN_PICTURE_MODE_CHANGED_TRANSACTION, data, null,
1517                IBinder.FLAG_ONEWAY);
1518        data.recycle();
1519    }
1520}
1521