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