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            boolean dumpUnreachable = data.readInt() != 0;
552            String[] args = data.readStringArray();
553            if (fd != null) {
554                try {
555                    dumpMemInfo(fd.getFileDescriptor(), mi, checkin, dumpInfo,
556                            dumpDalvik, dumpSummaryOnly, dumpUnreachable, args);
557                } finally {
558                    try {
559                        fd.close();
560                    } catch (IOException e) {
561                        // swallowed, not propagated back to the caller
562                    }
563                }
564            }
565            reply.writeNoException();
566            return true;
567        }
568
569        case DUMP_GFX_INFO_TRANSACTION:
570        {
571            data.enforceInterface(IApplicationThread.descriptor);
572            ParcelFileDescriptor fd = data.readFileDescriptor();
573            String[] args = data.readStringArray();
574            if (fd != null) {
575                try {
576                    dumpGfxInfo(fd.getFileDescriptor(), args);
577                } finally {
578                    try {
579                        fd.close();
580                    } catch (IOException e) {
581                        // swallowed, not propagated back to the caller
582                    }
583                }
584            }
585            reply.writeNoException();
586            return true;
587        }
588
589        case DUMP_DB_INFO_TRANSACTION:
590        {
591            data.enforceInterface(IApplicationThread.descriptor);
592            ParcelFileDescriptor fd = data.readFileDescriptor();
593            String[] args = data.readStringArray();
594            if (fd != null) {
595                try {
596                    dumpDbInfo(fd.getFileDescriptor(), args);
597                } finally {
598                    try {
599                        fd.close();
600                    } catch (IOException e) {
601                        // swallowed, not propagated back to the caller
602                    }
603                }
604            }
605            reply.writeNoException();
606            return true;
607        }
608
609        case UNSTABLE_PROVIDER_DIED_TRANSACTION:
610        {
611            data.enforceInterface(IApplicationThread.descriptor);
612            IBinder provider = data.readStrongBinder();
613            unstableProviderDied(provider);
614            reply.writeNoException();
615            return true;
616        }
617
618        case REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION:
619        {
620            data.enforceInterface(IApplicationThread.descriptor);
621            IBinder activityToken = data.readStrongBinder();
622            IBinder requestToken = data.readStrongBinder();
623            int requestType = data.readInt();
624            int sessionId = data.readInt();
625            requestAssistContextExtras(activityToken, requestToken, requestType, sessionId);
626            reply.writeNoException();
627            return true;
628        }
629
630        case SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION:
631        {
632            data.enforceInterface(IApplicationThread.descriptor);
633            IBinder token = data.readStrongBinder();
634            boolean timeout = data.readInt() == 1;
635            scheduleTranslucentConversionComplete(token, timeout);
636            reply.writeNoException();
637            return true;
638        }
639
640        case SCHEDULE_ON_NEW_ACTIVITY_OPTIONS_TRANSACTION:
641        {
642            data.enforceInterface(IApplicationThread.descriptor);
643            IBinder token = data.readStrongBinder();
644            ActivityOptions options = new ActivityOptions(data.readBundle());
645            scheduleOnNewActivityOptions(token, options);
646            reply.writeNoException();
647            return true;
648        }
649
650        case SET_PROCESS_STATE_TRANSACTION:
651        {
652            data.enforceInterface(IApplicationThread.descriptor);
653            int state = data.readInt();
654            setProcessState(state);
655            reply.writeNoException();
656            return true;
657        }
658
659        case SCHEDULE_INSTALL_PROVIDER_TRANSACTION:
660        {
661            data.enforceInterface(IApplicationThread.descriptor);
662            ProviderInfo provider = ProviderInfo.CREATOR.createFromParcel(data);
663            scheduleInstallProvider(provider);
664            reply.writeNoException();
665            return true;
666        }
667
668        case UPDATE_TIME_PREFS_TRANSACTION:
669        {
670            data.enforceInterface(IApplicationThread.descriptor);
671            byte is24Hour = data.readByte();
672            updateTimePrefs(is24Hour == (byte) 1);
673            reply.writeNoException();
674            return true;
675        }
676
677        case CANCEL_VISIBLE_BEHIND_TRANSACTION:
678        {
679            data.enforceInterface(IApplicationThread.descriptor);
680            IBinder token = data.readStrongBinder();
681            scheduleCancelVisibleBehind(token);
682            reply.writeNoException();
683            return true;
684        }
685
686        case BACKGROUND_VISIBLE_BEHIND_CHANGED_TRANSACTION:
687        {
688            data.enforceInterface(IApplicationThread.descriptor);
689            IBinder token = data.readStrongBinder();
690            boolean enabled = data.readInt() > 0;
691            scheduleBackgroundVisibleBehindChanged(token, enabled);
692            reply.writeNoException();
693            return true;
694        }
695
696        case ENTER_ANIMATION_COMPLETE_TRANSACTION:
697        {
698            data.enforceInterface(IApplicationThread.descriptor);
699            IBinder token = data.readStrongBinder();
700            scheduleEnterAnimationComplete(token);
701            reply.writeNoException();
702            return true;
703        }
704
705        case NOTIFY_CLEARTEXT_NETWORK_TRANSACTION:
706        {
707            data.enforceInterface(IApplicationThread.descriptor);
708            final byte[] firstPacket = data.createByteArray();
709            notifyCleartextNetwork(firstPacket);
710            reply.writeNoException();
711            return true;
712        }
713
714        case START_BINDER_TRACKING_TRANSACTION:
715        {
716            data.enforceInterface(IApplicationThread.descriptor);
717            startBinderTracking();
718            return true;
719        }
720
721        case STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION:
722        {
723            data.enforceInterface(IApplicationThread.descriptor);
724            ParcelFileDescriptor fd = data.readFileDescriptor();
725            if (fd != null) {
726                stopBinderTrackingAndDump(fd.getFileDescriptor());
727                try {
728                    fd.close();
729                } catch (IOException e) {
730                }
731            }
732            return true;
733        }
734
735        case SCHEDULE_MULTI_WINDOW_CHANGED_TRANSACTION:
736        {
737            data.enforceInterface(IApplicationThread.descriptor);
738            final IBinder b = data.readStrongBinder();
739            final boolean inMultiWindow = data.readInt() != 0;
740            scheduleMultiWindowModeChanged(b, inMultiWindow);
741            return true;
742        }
743
744        case SCHEDULE_PICTURE_IN_PICTURE_CHANGED_TRANSACTION:
745        {
746            data.enforceInterface(IApplicationThread.descriptor);
747            final IBinder b = data.readStrongBinder();
748            final boolean inPip = data.readInt() != 0;
749            schedulePictureInPictureModeChanged(b, inPip);
750            return true;
751        }
752
753        }
754
755        return super.onTransact(code, data, reply, flags);
756    }
757
758    public IBinder asBinder()
759    {
760        return this;
761    }
762}
763
764class ApplicationThreadProxy implements IApplicationThread {
765    private final IBinder mRemote;
766
767    public ApplicationThreadProxy(IBinder remote) {
768        mRemote = remote;
769    }
770
771    public final IBinder asBinder() {
772        return mRemote;
773    }
774
775    public final void schedulePauseActivity(IBinder token, boolean finished,
776            boolean userLeaving, int configChanges, boolean dontReport) throws RemoteException {
777        Parcel data = Parcel.obtain();
778        data.writeInterfaceToken(IApplicationThread.descriptor);
779        data.writeStrongBinder(token);
780        data.writeInt(finished ? 1 : 0);
781        data.writeInt(userLeaving ? 1 :0);
782        data.writeInt(configChanges);
783        data.writeInt(dontReport ? 1 : 0);
784        mRemote.transact(SCHEDULE_PAUSE_ACTIVITY_TRANSACTION, data, null,
785                IBinder.FLAG_ONEWAY);
786        data.recycle();
787    }
788
789    public final void scheduleStopActivity(IBinder token, boolean showWindow,
790            int configChanges) throws RemoteException {
791        Parcel data = Parcel.obtain();
792        data.writeInterfaceToken(IApplicationThread.descriptor);
793        data.writeStrongBinder(token);
794        data.writeInt(showWindow ? 1 : 0);
795        data.writeInt(configChanges);
796        mRemote.transact(SCHEDULE_STOP_ACTIVITY_TRANSACTION, data, null,
797                IBinder.FLAG_ONEWAY);
798        data.recycle();
799    }
800
801    public final void scheduleWindowVisibility(IBinder token,
802            boolean showWindow) throws RemoteException {
803        Parcel data = Parcel.obtain();
804        data.writeInterfaceToken(IApplicationThread.descriptor);
805        data.writeStrongBinder(token);
806        data.writeInt(showWindow ? 1 : 0);
807        mRemote.transact(SCHEDULE_WINDOW_VISIBILITY_TRANSACTION, data, null,
808                IBinder.FLAG_ONEWAY);
809        data.recycle();
810    }
811
812    public final void scheduleSleeping(IBinder token,
813            boolean sleeping) throws RemoteException {
814        Parcel data = Parcel.obtain();
815        data.writeInterfaceToken(IApplicationThread.descriptor);
816        data.writeStrongBinder(token);
817        data.writeInt(sleeping ? 1 : 0);
818        mRemote.transact(SCHEDULE_SLEEPING_TRANSACTION, data, null,
819                IBinder.FLAG_ONEWAY);
820        data.recycle();
821    }
822
823    public final void scheduleResumeActivity(IBinder token, int procState, boolean isForward,
824            Bundle resumeArgs)
825            throws RemoteException {
826        Parcel data = Parcel.obtain();
827        data.writeInterfaceToken(IApplicationThread.descriptor);
828        data.writeStrongBinder(token);
829        data.writeInt(procState);
830        data.writeInt(isForward ? 1 : 0);
831        data.writeBundle(resumeArgs);
832        mRemote.transact(SCHEDULE_RESUME_ACTIVITY_TRANSACTION, data, null,
833                IBinder.FLAG_ONEWAY);
834        data.recycle();
835    }
836
837    public final void scheduleSendResult(IBinder token, List<ResultInfo> results)
838            throws RemoteException {
839        Parcel data = Parcel.obtain();
840        data.writeInterfaceToken(IApplicationThread.descriptor);
841        data.writeStrongBinder(token);
842        data.writeTypedList(results);
843        mRemote.transact(SCHEDULE_SEND_RESULT_TRANSACTION, data, null,
844                IBinder.FLAG_ONEWAY);
845        data.recycle();
846    }
847
848    public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
849            ActivityInfo info, Configuration curConfig, Configuration overrideConfig,
850            CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor,
851            int procState, Bundle state, PersistableBundle persistentState,
852            List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
853            boolean notResumed, boolean isForward, ProfilerInfo profilerInfo) throws RemoteException {
854        Parcel data = Parcel.obtain();
855        data.writeInterfaceToken(IApplicationThread.descriptor);
856        intent.writeToParcel(data, 0);
857        data.writeStrongBinder(token);
858        data.writeInt(ident);
859        info.writeToParcel(data, 0);
860        curConfig.writeToParcel(data, 0);
861        if (overrideConfig != null) {
862            data.writeInt(1);
863            overrideConfig.writeToParcel(data, 0);
864        } else {
865            data.writeInt(0);
866        }
867        compatInfo.writeToParcel(data, 0);
868        data.writeString(referrer);
869        data.writeStrongBinder(voiceInteractor != null ? voiceInteractor.asBinder() : null);
870        data.writeInt(procState);
871        data.writeBundle(state);
872        data.writePersistableBundle(persistentState);
873        data.writeTypedList(pendingResults);
874        data.writeTypedList(pendingNewIntents);
875        data.writeInt(notResumed ? 1 : 0);
876        data.writeInt(isForward ? 1 : 0);
877        if (profilerInfo != null) {
878            data.writeInt(1);
879            profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
880        } else {
881            data.writeInt(0);
882        }
883        mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null,
884                IBinder.FLAG_ONEWAY);
885        data.recycle();
886    }
887
888    public final void scheduleRelaunchActivity(IBinder token,
889            List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
890            int configChanges, boolean notResumed, Configuration config,
891            Configuration overrideConfig, boolean preserveWindow) throws RemoteException {
892        Parcel data = Parcel.obtain();
893        data.writeInterfaceToken(IApplicationThread.descriptor);
894        data.writeStrongBinder(token);
895        data.writeTypedList(pendingResults);
896        data.writeTypedList(pendingNewIntents);
897        data.writeInt(configChanges);
898        data.writeInt(notResumed ? 1 : 0);
899        config.writeToParcel(data, 0);
900        if (overrideConfig != null) {
901            data.writeInt(1);
902            overrideConfig.writeToParcel(data, 0);
903        } else {
904            data.writeInt(0);
905        }
906        data.writeInt(preserveWindow ? 1 : 0);
907        mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null,
908                IBinder.FLAG_ONEWAY);
909        data.recycle();
910    }
911
912    public void scheduleNewIntent(List<ReferrerIntent> intents, IBinder token)
913            throws RemoteException {
914        Parcel data = Parcel.obtain();
915        data.writeInterfaceToken(IApplicationThread.descriptor);
916        data.writeTypedList(intents);
917        data.writeStrongBinder(token);
918        mRemote.transact(SCHEDULE_NEW_INTENT_TRANSACTION, data, null,
919                IBinder.FLAG_ONEWAY);
920        data.recycle();
921    }
922
923    public final void scheduleDestroyActivity(IBinder token, boolean finishing,
924            int configChanges) throws RemoteException {
925        Parcel data = Parcel.obtain();
926        data.writeInterfaceToken(IApplicationThread.descriptor);
927        data.writeStrongBinder(token);
928        data.writeInt(finishing ? 1 : 0);
929        data.writeInt(configChanges);
930        mRemote.transact(SCHEDULE_FINISH_ACTIVITY_TRANSACTION, data, null,
931                IBinder.FLAG_ONEWAY);
932        data.recycle();
933    }
934
935    public final void scheduleReceiver(Intent intent, ActivityInfo info,
936            CompatibilityInfo compatInfo, int resultCode, String resultData,
937            Bundle map, boolean sync, int sendingUser, int processState) throws RemoteException {
938        Parcel data = Parcel.obtain();
939        data.writeInterfaceToken(IApplicationThread.descriptor);
940        intent.writeToParcel(data, 0);
941        info.writeToParcel(data, 0);
942        compatInfo.writeToParcel(data, 0);
943        data.writeInt(resultCode);
944        data.writeString(resultData);
945        data.writeBundle(map);
946        data.writeInt(sync ? 1 : 0);
947        data.writeInt(sendingUser);
948        data.writeInt(processState);
949        mRemote.transact(SCHEDULE_RECEIVER_TRANSACTION, data, null,
950                IBinder.FLAG_ONEWAY);
951        data.recycle();
952    }
953
954    public final void scheduleCreateBackupAgent(ApplicationInfo app,
955            CompatibilityInfo compatInfo, int backupMode) throws RemoteException {
956        Parcel data = Parcel.obtain();
957        data.writeInterfaceToken(IApplicationThread.descriptor);
958        app.writeToParcel(data, 0);
959        compatInfo.writeToParcel(data, 0);
960        data.writeInt(backupMode);
961        mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null,
962                IBinder.FLAG_ONEWAY);
963        data.recycle();
964    }
965
966    public final void scheduleDestroyBackupAgent(ApplicationInfo app,
967            CompatibilityInfo compatInfo) throws RemoteException {
968        Parcel data = Parcel.obtain();
969        data.writeInterfaceToken(IApplicationThread.descriptor);
970        app.writeToParcel(data, 0);
971        compatInfo.writeToParcel(data, 0);
972        mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null,
973                IBinder.FLAG_ONEWAY);
974        data.recycle();
975    }
976
977    public final void scheduleCreateService(IBinder token, ServiceInfo info,
978            CompatibilityInfo compatInfo, int processState) throws RemoteException {
979        Parcel data = Parcel.obtain();
980        data.writeInterfaceToken(IApplicationThread.descriptor);
981        data.writeStrongBinder(token);
982        info.writeToParcel(data, 0);
983        compatInfo.writeToParcel(data, 0);
984        data.writeInt(processState);
985        try {
986            mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null,
987                    IBinder.FLAG_ONEWAY);
988        } catch (TransactionTooLargeException e) {
989            Log.e("CREATE_SERVICE", "Binder failure starting service; service=" + info);
990            throw e;
991        }
992        data.recycle();
993    }
994
995    public final void scheduleBindService(IBinder token, Intent intent, boolean rebind,
996            int processState) throws RemoteException {
997        Parcel data = Parcel.obtain();
998        data.writeInterfaceToken(IApplicationThread.descriptor);
999        data.writeStrongBinder(token);
1000        intent.writeToParcel(data, 0);
1001        data.writeInt(rebind ? 1 : 0);
1002        data.writeInt(processState);
1003        mRemote.transact(SCHEDULE_BIND_SERVICE_TRANSACTION, data, null,
1004                IBinder.FLAG_ONEWAY);
1005        data.recycle();
1006    }
1007
1008    public final void scheduleUnbindService(IBinder token, Intent intent)
1009            throws RemoteException {
1010        Parcel data = Parcel.obtain();
1011        data.writeInterfaceToken(IApplicationThread.descriptor);
1012        data.writeStrongBinder(token);
1013        intent.writeToParcel(data, 0);
1014        mRemote.transact(SCHEDULE_UNBIND_SERVICE_TRANSACTION, data, null,
1015                IBinder.FLAG_ONEWAY);
1016        data.recycle();
1017    }
1018
1019    public final void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
1020            int flags, Intent args) throws RemoteException {
1021        Parcel data = Parcel.obtain();
1022        data.writeInterfaceToken(IApplicationThread.descriptor);
1023        data.writeStrongBinder(token);
1024        data.writeInt(taskRemoved ? 1 : 0);
1025        data.writeInt(startId);
1026        data.writeInt(flags);
1027        if (args != null) {
1028            data.writeInt(1);
1029            args.writeToParcel(data, 0);
1030        } else {
1031            data.writeInt(0);
1032        }
1033        mRemote.transact(SCHEDULE_SERVICE_ARGS_TRANSACTION, data, null,
1034                IBinder.FLAG_ONEWAY);
1035        data.recycle();
1036    }
1037
1038    public final void scheduleStopService(IBinder token)
1039            throws RemoteException {
1040        Parcel data = Parcel.obtain();
1041        data.writeInterfaceToken(IApplicationThread.descriptor);
1042        data.writeStrongBinder(token);
1043        mRemote.transact(SCHEDULE_STOP_SERVICE_TRANSACTION, data, null,
1044                IBinder.FLAG_ONEWAY);
1045        data.recycle();
1046    }
1047
1048    @Override
1049    public final void bindApplication(String packageName, ApplicationInfo info,
1050            List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo,
1051            Bundle testArgs, IInstrumentationWatcher testWatcher,
1052            IUiAutomationConnection uiAutomationConnection, int debugMode,
1053            boolean enableBinderTracking, boolean trackAllocation, boolean restrictedBackupMode,
1054            boolean persistent, Configuration config, CompatibilityInfo compatInfo,
1055            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
1056        Parcel data = Parcel.obtain();
1057        data.writeInterfaceToken(IApplicationThread.descriptor);
1058        data.writeString(packageName);
1059        info.writeToParcel(data, 0);
1060        data.writeTypedList(providers);
1061        if (testName == null) {
1062            data.writeInt(0);
1063        } else {
1064            data.writeInt(1);
1065            testName.writeToParcel(data, 0);
1066        }
1067        if (profilerInfo != null) {
1068            data.writeInt(1);
1069            profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1070        } else {
1071            data.writeInt(0);
1072        }
1073        data.writeBundle(testArgs);
1074        data.writeStrongInterface(testWatcher);
1075        data.writeStrongInterface(uiAutomationConnection);
1076        data.writeInt(debugMode);
1077        data.writeInt(enableBinderTracking ? 1 : 0);
1078        data.writeInt(trackAllocation ? 1 : 0);
1079        data.writeInt(restrictedBackupMode ? 1 : 0);
1080        data.writeInt(persistent ? 1 : 0);
1081        config.writeToParcel(data, 0);
1082        compatInfo.writeToParcel(data, 0);
1083        data.writeMap(services);
1084        data.writeBundle(coreSettings);
1085        mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,
1086                IBinder.FLAG_ONEWAY);
1087        data.recycle();
1088    }
1089
1090    public final void scheduleExit() throws RemoteException {
1091        Parcel data = Parcel.obtain();
1092        data.writeInterfaceToken(IApplicationThread.descriptor);
1093        mRemote.transact(SCHEDULE_EXIT_TRANSACTION, data, null,
1094                IBinder.FLAG_ONEWAY);
1095        data.recycle();
1096    }
1097
1098    public final void scheduleSuicide() throws RemoteException {
1099        Parcel data = Parcel.obtain();
1100        data.writeInterfaceToken(IApplicationThread.descriptor);
1101        mRemote.transact(SCHEDULE_SUICIDE_TRANSACTION, data, null,
1102                IBinder.FLAG_ONEWAY);
1103        data.recycle();
1104    }
1105
1106    public final void scheduleConfigurationChanged(Configuration config)
1107            throws RemoteException {
1108        Parcel data = Parcel.obtain();
1109        data.writeInterfaceToken(IApplicationThread.descriptor);
1110        config.writeToParcel(data, 0);
1111        mRemote.transact(SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION, data, null,
1112                IBinder.FLAG_ONEWAY);
1113        data.recycle();
1114    }
1115
1116    public final void scheduleLocalVoiceInteractionStarted(IBinder token,
1117            IVoiceInteractor voiceInteractor) throws RemoteException {
1118        Parcel data = Parcel.obtain();
1119        data.writeInterfaceToken(IApplicationThread.descriptor);
1120        data.writeStrongBinder(token);
1121        data.writeStrongBinder(voiceInteractor != null ? voiceInteractor.asBinder() : null);
1122        mRemote.transact(SCHEDULE_LOCAL_VOICE_INTERACTION_STARTED_TRANSACTION, data, null,
1123                IBinder.FLAG_ONEWAY);
1124        data.recycle();
1125    }
1126
1127    public void updateTimeZone() throws RemoteException {
1128        Parcel data = Parcel.obtain();
1129        data.writeInterfaceToken(IApplicationThread.descriptor);
1130        mRemote.transact(UPDATE_TIME_ZONE_TRANSACTION, data, null,
1131                IBinder.FLAG_ONEWAY);
1132        data.recycle();
1133    }
1134
1135    public void clearDnsCache() throws RemoteException {
1136        Parcel data = Parcel.obtain();
1137        data.writeInterfaceToken(IApplicationThread.descriptor);
1138        mRemote.transact(CLEAR_DNS_CACHE_TRANSACTION, data, null,
1139                IBinder.FLAG_ONEWAY);
1140        data.recycle();
1141    }
1142
1143    public void setHttpProxy(String proxy, String port, String exclList,
1144            Uri pacFileUrl) throws RemoteException {
1145        Parcel data = Parcel.obtain();
1146        data.writeInterfaceToken(IApplicationThread.descriptor);
1147        data.writeString(proxy);
1148        data.writeString(port);
1149        data.writeString(exclList);
1150        pacFileUrl.writeToParcel(data, 0);
1151        mRemote.transact(SET_HTTP_PROXY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1152        data.recycle();
1153    }
1154
1155    public void processInBackground() throws RemoteException {
1156        Parcel data = Parcel.obtain();
1157        data.writeInterfaceToken(IApplicationThread.descriptor);
1158        mRemote.transact(PROCESS_IN_BACKGROUND_TRANSACTION, data, null,
1159                IBinder.FLAG_ONEWAY);
1160        data.recycle();
1161    }
1162
1163    public void dumpService(FileDescriptor fd, IBinder token, String[] args)
1164            throws RemoteException {
1165        Parcel data = Parcel.obtain();
1166        data.writeInterfaceToken(IApplicationThread.descriptor);
1167        data.writeFileDescriptor(fd);
1168        data.writeStrongBinder(token);
1169        data.writeStringArray(args);
1170        mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1171        data.recycle();
1172    }
1173
1174    public void dumpProvider(FileDescriptor fd, IBinder token, String[] args)
1175            throws RemoteException {
1176        Parcel data = Parcel.obtain();
1177        data.writeInterfaceToken(IApplicationThread.descriptor);
1178        data.writeFileDescriptor(fd);
1179        data.writeStrongBinder(token);
1180        data.writeStringArray(args);
1181        mRemote.transact(DUMP_PROVIDER_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1182        data.recycle();
1183    }
1184
1185    public void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent,
1186            int resultCode, String dataStr, Bundle extras, boolean ordered,
1187            boolean sticky, int sendingUser, int processState) throws RemoteException {
1188        Parcel data = Parcel.obtain();
1189        data.writeInterfaceToken(IApplicationThread.descriptor);
1190        data.writeStrongBinder(receiver.asBinder());
1191        intent.writeToParcel(data, 0);
1192        data.writeInt(resultCode);
1193        data.writeString(dataStr);
1194        data.writeBundle(extras);
1195        data.writeInt(ordered ? 1 : 0);
1196        data.writeInt(sticky ? 1 : 0);
1197        data.writeInt(sendingUser);
1198        data.writeInt(processState);
1199        mRemote.transact(SCHEDULE_REGISTERED_RECEIVER_TRANSACTION, data, null,
1200                IBinder.FLAG_ONEWAY);
1201        data.recycle();
1202    }
1203
1204    @Override
1205    public final void scheduleLowMemory() throws RemoteException {
1206        Parcel data = Parcel.obtain();
1207        data.writeInterfaceToken(IApplicationThread.descriptor);
1208        mRemote.transact(SCHEDULE_LOW_MEMORY_TRANSACTION, data, null,
1209                IBinder.FLAG_ONEWAY);
1210        data.recycle();
1211    }
1212
1213    @Override
1214    public final void scheduleActivityConfigurationChanged(IBinder token,
1215            Configuration overrideConfig, boolean reportToActivity) throws RemoteException {
1216        Parcel data = Parcel.obtain();
1217        data.writeInterfaceToken(IApplicationThread.descriptor);
1218        data.writeStrongBinder(token);
1219        if (overrideConfig != null) {
1220            data.writeInt(1);
1221            overrideConfig.writeToParcel(data, 0);
1222        } else {
1223            data.writeInt(0);
1224        }
1225        data.writeInt(reportToActivity ? 1 : 0);
1226        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
1227                IBinder.FLAG_ONEWAY);
1228        data.recycle();
1229    }
1230
1231    @Override
1232    public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
1233            throws RemoteException {
1234        Parcel data = Parcel.obtain();
1235        data.writeInterfaceToken(IApplicationThread.descriptor);
1236        data.writeInt(start ? 1 : 0);
1237        data.writeInt(profileType);
1238        if (profilerInfo != null) {
1239            data.writeInt(1);
1240            profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1241        } else {
1242            data.writeInt(0);
1243        }
1244        mRemote.transact(PROFILER_CONTROL_TRANSACTION, data, null,
1245                IBinder.FLAG_ONEWAY);
1246        data.recycle();
1247    }
1248
1249    public void setSchedulingGroup(int group) throws RemoteException {
1250        Parcel data = Parcel.obtain();
1251        data.writeInterfaceToken(IApplicationThread.descriptor);
1252        data.writeInt(group);
1253        mRemote.transact(SET_SCHEDULING_GROUP_TRANSACTION, data, null,
1254                IBinder.FLAG_ONEWAY);
1255        data.recycle();
1256    }
1257
1258    public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException {
1259        Parcel data = Parcel.obtain();
1260        data.writeInterfaceToken(IApplicationThread.descriptor);
1261        data.writeInt(cmd);
1262        data.writeStringArray(packages);
1263        mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null,
1264                IBinder.FLAG_ONEWAY);
1265        data.recycle();
1266    }
1267
1268    public void scheduleCrash(String msg) throws RemoteException {
1269        Parcel data = Parcel.obtain();
1270        data.writeInterfaceToken(IApplicationThread.descriptor);
1271        data.writeString(msg);
1272        mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null,
1273                IBinder.FLAG_ONEWAY);
1274        data.recycle();
1275    }
1276
1277    public void dumpHeap(boolean managed, String path,
1278            ParcelFileDescriptor fd) throws RemoteException {
1279        Parcel data = Parcel.obtain();
1280        data.writeInterfaceToken(IApplicationThread.descriptor);
1281        data.writeInt(managed ? 1 : 0);
1282        data.writeString(path);
1283        if (fd != null) {
1284            data.writeInt(1);
1285            fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1286        } else {
1287            data.writeInt(0);
1288        }
1289        mRemote.transact(DUMP_HEAP_TRANSACTION, data, null,
1290                IBinder.FLAG_ONEWAY);
1291        data.recycle();
1292    }
1293
1294    public void dumpActivity(FileDescriptor fd, IBinder token, String prefix, String[] args)
1295            throws RemoteException {
1296        Parcel data = Parcel.obtain();
1297        data.writeInterfaceToken(IApplicationThread.descriptor);
1298        data.writeFileDescriptor(fd);
1299        data.writeStrongBinder(token);
1300        data.writeString(prefix);
1301        data.writeStringArray(args);
1302        mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1303        data.recycle();
1304    }
1305
1306    public void setCoreSettings(Bundle coreSettings) throws RemoteException {
1307        Parcel data = Parcel.obtain();
1308        data.writeInterfaceToken(IApplicationThread.descriptor);
1309        data.writeBundle(coreSettings);
1310        mRemote.transact(SET_CORE_SETTINGS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1311    }
1312
1313    public void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info)
1314            throws RemoteException {
1315        Parcel data = Parcel.obtain();
1316        data.writeInterfaceToken(IApplicationThread.descriptor);
1317        data.writeString(pkg);
1318        info.writeToParcel(data, 0);
1319        mRemote.transact(UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION, data, null,
1320                IBinder.FLAG_ONEWAY);
1321    }
1322
1323    public void scheduleTrimMemory(int level) throws RemoteException {
1324        Parcel data = Parcel.obtain();
1325        data.writeInterfaceToken(IApplicationThread.descriptor);
1326        data.writeInt(level);
1327        mRemote.transact(SCHEDULE_TRIM_MEMORY_TRANSACTION, data, null,
1328                IBinder.FLAG_ONEWAY);
1329        data.recycle();
1330    }
1331
1332    public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin,
1333            boolean dumpInfo, boolean dumpDalvik, boolean dumpSummaryOnly,
1334            boolean dumpUnreachable, String[] args) throws RemoteException {
1335        Parcel data = Parcel.obtain();
1336        Parcel reply = Parcel.obtain();
1337        data.writeInterfaceToken(IApplicationThread.descriptor);
1338        data.writeFileDescriptor(fd);
1339        mem.writeToParcel(data, 0);
1340        data.writeInt(checkin ? 1 : 0);
1341        data.writeInt(dumpInfo ? 1 : 0);
1342        data.writeInt(dumpDalvik ? 1 : 0);
1343        data.writeInt(dumpSummaryOnly ? 1 : 0);
1344        data.writeInt(dumpUnreachable ? 1 : 0);
1345        data.writeStringArray(args);
1346        mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0);
1347        reply.readException();
1348        data.recycle();
1349        reply.recycle();
1350    }
1351
1352    public void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException {
1353        Parcel data = Parcel.obtain();
1354        data.writeInterfaceToken(IApplicationThread.descriptor);
1355        data.writeFileDescriptor(fd);
1356        data.writeStringArray(args);
1357        mRemote.transact(DUMP_GFX_INFO_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1358        data.recycle();
1359    }
1360
1361    public void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException {
1362        Parcel data = Parcel.obtain();
1363        data.writeInterfaceToken(IApplicationThread.descriptor);
1364        data.writeFileDescriptor(fd);
1365        data.writeStringArray(args);
1366        mRemote.transact(DUMP_DB_INFO_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1367        data.recycle();
1368    }
1369
1370    @Override
1371    public void unstableProviderDied(IBinder provider) throws RemoteException {
1372        Parcel data = Parcel.obtain();
1373        data.writeInterfaceToken(IApplicationThread.descriptor);
1374        data.writeStrongBinder(provider);
1375        mRemote.transact(UNSTABLE_PROVIDER_DIED_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1376        data.recycle();
1377    }
1378
1379    @Override
1380    public void requestAssistContextExtras(IBinder activityToken, IBinder requestToken,
1381            int requestType, int sessionId) throws RemoteException {
1382        Parcel data = Parcel.obtain();
1383        data.writeInterfaceToken(IApplicationThread.descriptor);
1384        data.writeStrongBinder(activityToken);
1385        data.writeStrongBinder(requestToken);
1386        data.writeInt(requestType);
1387        data.writeInt(sessionId);
1388        mRemote.transact(REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION, data, null,
1389                IBinder.FLAG_ONEWAY);
1390        data.recycle();
1391    }
1392
1393    @Override
1394    public void scheduleTranslucentConversionComplete(IBinder token, boolean timeout)
1395            throws RemoteException {
1396        Parcel data = Parcel.obtain();
1397        data.writeInterfaceToken(IApplicationThread.descriptor);
1398        data.writeStrongBinder(token);
1399        data.writeInt(timeout ? 1 : 0);
1400        mRemote.transact(SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION, data, null,
1401                IBinder.FLAG_ONEWAY);
1402        data.recycle();
1403    }
1404
1405    @Override
1406    public void scheduleOnNewActivityOptions(IBinder token, ActivityOptions options)
1407            throws RemoteException {
1408        Parcel data = Parcel.obtain();
1409        data.writeInterfaceToken(IApplicationThread.descriptor);
1410        data.writeStrongBinder(token);
1411        data.writeBundle(options == null ? null : options.toBundle());
1412        mRemote.transact(SCHEDULE_ON_NEW_ACTIVITY_OPTIONS_TRANSACTION, data, null,
1413                IBinder.FLAG_ONEWAY);
1414        data.recycle();
1415    }
1416
1417    @Override
1418    public void setProcessState(int state) throws RemoteException {
1419        Parcel data = Parcel.obtain();
1420        data.writeInterfaceToken(IApplicationThread.descriptor);
1421        data.writeInt(state);
1422        mRemote.transact(SET_PROCESS_STATE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1423        data.recycle();
1424    }
1425
1426    @Override
1427    public void scheduleInstallProvider(ProviderInfo provider) throws RemoteException {
1428        Parcel data = Parcel.obtain();
1429        data.writeInterfaceToken(IApplicationThread.descriptor);
1430        provider.writeToParcel(data, 0);
1431        mRemote.transact(SCHEDULE_INSTALL_PROVIDER_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1432        data.recycle();
1433    }
1434
1435    @Override
1436    public void updateTimePrefs(boolean is24Hour) throws RemoteException {
1437        Parcel data = Parcel.obtain();
1438        data.writeInterfaceToken(IApplicationThread.descriptor);
1439        data.writeByte(is24Hour ? (byte) 1 : (byte) 0);
1440        mRemote.transact(UPDATE_TIME_PREFS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1441        data.recycle();
1442    }
1443
1444    @Override
1445    public void scheduleCancelVisibleBehind(IBinder token) throws RemoteException {
1446        Parcel data = Parcel.obtain();
1447        data.writeInterfaceToken(IApplicationThread.descriptor);
1448        data.writeStrongBinder(token);
1449        mRemote.transact(CANCEL_VISIBLE_BEHIND_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1450        data.recycle();
1451    }
1452
1453    @Override
1454    public void scheduleBackgroundVisibleBehindChanged(IBinder token, boolean enabled)
1455            throws RemoteException {
1456        Parcel data = Parcel.obtain();
1457        data.writeInterfaceToken(IApplicationThread.descriptor);
1458        data.writeStrongBinder(token);
1459        data.writeInt(enabled ? 1 : 0);
1460        mRemote.transact(BACKGROUND_VISIBLE_BEHIND_CHANGED_TRANSACTION, data, null,
1461                IBinder.FLAG_ONEWAY);
1462        data.recycle();
1463    }
1464
1465    @Override
1466    public void scheduleEnterAnimationComplete(IBinder token) throws RemoteException {
1467        Parcel data = Parcel.obtain();
1468        data.writeInterfaceToken(IApplicationThread.descriptor);
1469        data.writeStrongBinder(token);
1470        mRemote.transact(ENTER_ANIMATION_COMPLETE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1471        data.recycle();
1472    }
1473
1474    @Override
1475    public void notifyCleartextNetwork(byte[] firstPacket) throws RemoteException {
1476        Parcel data = Parcel.obtain();
1477        data.writeInterfaceToken(IApplicationThread.descriptor);
1478        data.writeByteArray(firstPacket);
1479        mRemote.transact(NOTIFY_CLEARTEXT_NETWORK_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1480        data.recycle();
1481    }
1482
1483    @Override
1484    public void startBinderTracking() throws RemoteException {
1485        Parcel data = Parcel.obtain();
1486        data.writeInterfaceToken(IApplicationThread.descriptor);
1487        mRemote.transact(START_BINDER_TRACKING_TRANSACTION, data, null,
1488                IBinder.FLAG_ONEWAY);
1489        data.recycle();
1490    }
1491
1492    @Override
1493    public void stopBinderTrackingAndDump(FileDescriptor fd) throws RemoteException {
1494        Parcel data = Parcel.obtain();
1495        data.writeInterfaceToken(IApplicationThread.descriptor);
1496        data.writeFileDescriptor(fd);
1497        mRemote.transact(STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION, data, null,
1498                IBinder.FLAG_ONEWAY);
1499        data.recycle();
1500    }
1501
1502    @Override
1503    public final void scheduleMultiWindowModeChanged(
1504            IBinder token, boolean isInMultiWindowMode) throws RemoteException {
1505        Parcel data = Parcel.obtain();
1506        data.writeInterfaceToken(IApplicationThread.descriptor);
1507        data.writeStrongBinder(token);
1508        data.writeInt(isInMultiWindowMode ? 1 : 0);
1509        mRemote.transact(SCHEDULE_MULTI_WINDOW_CHANGED_TRANSACTION, data, null,
1510                IBinder.FLAG_ONEWAY);
1511        data.recycle();
1512    }
1513
1514    @Override
1515    public final void schedulePictureInPictureModeChanged(IBinder token, boolean isInPipMode)
1516            throws RemoteException {
1517        Parcel data = Parcel.obtain();
1518        data.writeInterfaceToken(IApplicationThread.descriptor);
1519        data.writeStrongBinder(token);
1520        data.writeInt(isInPipMode ? 1 : 0);
1521        mRemote.transact(SCHEDULE_PICTURE_IN_PICTURE_CHANGED_TRANSACTION, data, null,
1522                IBinder.FLAG_ONEWAY);
1523        data.recycle();
1524    }
1525}
1526