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