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