ApplicationThreadNative.java revision 9a8c5cefcab3d5dec6ff63f0e99553e1aa9a4af8
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            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
136            Bundle state = data.readBundle();
137            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
138            List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
139            boolean notResumed = data.readInt() != 0;
140            boolean isForward = data.readInt() != 0;
141            scheduleLaunchActivity(intent, b, ident, info, compatInfo, state, ri, pi,
142                    notResumed, isForward);
143            return true;
144        }
145
146        case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION:
147        {
148            data.enforceInterface(IApplicationThread.descriptor);
149            IBinder b = data.readStrongBinder();
150            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
151            List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
152            int configChanges = data.readInt();
153            boolean notResumed = data.readInt() != 0;
154            Configuration config = null;
155            if (data.readInt() != 0) {
156                config = Configuration.CREATOR.createFromParcel(data);
157            }
158            scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config);
159            return true;
160        }
161
162        case SCHEDULE_NEW_INTENT_TRANSACTION:
163        {
164            data.enforceInterface(IApplicationThread.descriptor);
165            List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
166            IBinder b = data.readStrongBinder();
167            scheduleNewIntent(pi, b);
168            return true;
169        }
170
171        case SCHEDULE_FINISH_ACTIVITY_TRANSACTION:
172        {
173            data.enforceInterface(IApplicationThread.descriptor);
174            IBinder b = data.readStrongBinder();
175            boolean finishing = data.readInt() != 0;
176            int configChanges = data.readInt();
177            scheduleDestroyActivity(b, finishing, configChanges);
178            return true;
179        }
180
181        case SCHEDULE_RECEIVER_TRANSACTION:
182        {
183            data.enforceInterface(IApplicationThread.descriptor);
184            Intent intent = Intent.CREATOR.createFromParcel(data);
185            ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
186            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
187            int resultCode = data.readInt();
188            String resultData = data.readString();
189            Bundle resultExtras = data.readBundle();
190            boolean sync = data.readInt() != 0;
191            scheduleReceiver(intent, info, compatInfo, resultCode, resultData,
192                    resultExtras, sync);
193            return true;
194        }
195
196        case SCHEDULE_CREATE_SERVICE_TRANSACTION: {
197            data.enforceInterface(IApplicationThread.descriptor);
198            IBinder token = data.readStrongBinder();
199            ServiceInfo info = ServiceInfo.CREATOR.createFromParcel(data);
200            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
201            scheduleCreateService(token, info, compatInfo);
202            return true;
203        }
204
205        case SCHEDULE_BIND_SERVICE_TRANSACTION: {
206            data.enforceInterface(IApplicationThread.descriptor);
207            IBinder token = data.readStrongBinder();
208            Intent intent = Intent.CREATOR.createFromParcel(data);
209            boolean rebind = data.readInt() != 0;
210            scheduleBindService(token, intent, rebind);
211            return true;
212        }
213
214        case SCHEDULE_UNBIND_SERVICE_TRANSACTION: {
215            data.enforceInterface(IApplicationThread.descriptor);
216            IBinder token = data.readStrongBinder();
217            Intent intent = Intent.CREATOR.createFromParcel(data);
218            scheduleUnbindService(token, intent);
219            return true;
220        }
221
222        case SCHEDULE_SERVICE_ARGS_TRANSACTION:
223        {
224            data.enforceInterface(IApplicationThread.descriptor);
225            IBinder token = data.readStrongBinder();
226            boolean taskRemoved = data.readInt() != 0;
227            int startId = data.readInt();
228            int fl = data.readInt();
229            Intent args;
230            if (data.readInt() != 0) {
231                args = Intent.CREATOR.createFromParcel(data);
232            } else {
233                args = null;
234            }
235            scheduleServiceArgs(token, taskRemoved, startId, fl, args);
236            return true;
237        }
238
239        case SCHEDULE_STOP_SERVICE_TRANSACTION:
240        {
241            data.enforceInterface(IApplicationThread.descriptor);
242            IBinder token = data.readStrongBinder();
243            scheduleStopService(token);
244            return true;
245        }
246
247        case BIND_APPLICATION_TRANSACTION:
248        {
249            data.enforceInterface(IApplicationThread.descriptor);
250            String packageName = data.readString();
251            ApplicationInfo info =
252                ApplicationInfo.CREATOR.createFromParcel(data);
253            List<ProviderInfo> providers =
254                data.createTypedArrayList(ProviderInfo.CREATOR);
255            ComponentName testName = (data.readInt() != 0)
256                ? new ComponentName(data) : null;
257            String profileName = data.readString();
258            Bundle testArgs = data.readBundle();
259            IBinder binder = data.readStrongBinder();
260            IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
261            int testMode = data.readInt();
262            boolean restrictedBackupMode = (data.readInt() != 0);
263            Configuration config = Configuration.CREATOR.createFromParcel(data);
264            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
265            HashMap<String, IBinder> services = data.readHashMap(null);
266            Bundle coreSettings = data.readBundle();
267            bindApplication(packageName, info,
268                            providers, testName, profileName,
269                            testArgs, testWatcher, testMode, restrictedBackupMode,
270                            config, compatInfo, services, coreSettings);
271            return true;
272        }
273
274        case SCHEDULE_EXIT_TRANSACTION:
275        {
276            data.enforceInterface(IApplicationThread.descriptor);
277            scheduleExit();
278            return true;
279        }
280
281        case SCHEDULE_SUICIDE_TRANSACTION:
282        {
283            data.enforceInterface(IApplicationThread.descriptor);
284            scheduleSuicide();
285            return true;
286        }
287
288        case REQUEST_THUMBNAIL_TRANSACTION:
289        {
290            data.enforceInterface(IApplicationThread.descriptor);
291            IBinder b = data.readStrongBinder();
292            requestThumbnail(b);
293            return true;
294        }
295
296        case SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION:
297        {
298            data.enforceInterface(IApplicationThread.descriptor);
299            Configuration config = Configuration.CREATOR.createFromParcel(data);
300            scheduleConfigurationChanged(config);
301            return true;
302        }
303
304        case UPDATE_TIME_ZONE_TRANSACTION: {
305            data.enforceInterface(IApplicationThread.descriptor);
306            updateTimeZone();
307            return true;
308        }
309
310        case CLEAR_DNS_CACHE_TRANSACTION: {
311            data.enforceInterface(IApplicationThread.descriptor);
312            clearDnsCache();
313            return true;
314        }
315
316        case SET_HTTP_PROXY_TRANSACTION: {
317            data.enforceInterface(IApplicationThread.descriptor);
318            final String proxy = data.readString();
319            final String port = data.readString();
320            final String exclList = data.readString();
321            setHttpProxy(proxy, port, exclList);
322            return true;
323        }
324
325        case PROCESS_IN_BACKGROUND_TRANSACTION: {
326            data.enforceInterface(IApplicationThread.descriptor);
327            processInBackground();
328            return true;
329        }
330
331        case DUMP_SERVICE_TRANSACTION: {
332            data.enforceInterface(IApplicationThread.descriptor);
333            ParcelFileDescriptor fd = data.readFileDescriptor();
334            final IBinder service = data.readStrongBinder();
335            final String[] args = data.readStringArray();
336            if (fd != null) {
337                dumpService(fd.getFileDescriptor(), service, args);
338                try {
339                    fd.close();
340                } catch (IOException e) {
341                }
342            }
343            return true;
344        }
345
346        case SCHEDULE_REGISTERED_RECEIVER_TRANSACTION: {
347            data.enforceInterface(IApplicationThread.descriptor);
348            IIntentReceiver receiver = IIntentReceiver.Stub.asInterface(
349                    data.readStrongBinder());
350            Intent intent = Intent.CREATOR.createFromParcel(data);
351            int resultCode = data.readInt();
352            String dataStr = data.readString();
353            Bundle extras = data.readBundle();
354            boolean ordered = data.readInt() != 0;
355            boolean sticky = data.readInt() != 0;
356            scheduleRegisteredReceiver(receiver, intent,
357                    resultCode, dataStr, extras, ordered, sticky);
358            return true;
359        }
360
361        case SCHEDULE_LOW_MEMORY_TRANSACTION:
362        {
363            scheduleLowMemory();
364            return true;
365        }
366
367        case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION:
368        {
369            data.enforceInterface(IApplicationThread.descriptor);
370            IBinder b = data.readStrongBinder();
371            scheduleActivityConfigurationChanged(b);
372            return true;
373        }
374
375        case PROFILER_CONTROL_TRANSACTION:
376        {
377            data.enforceInterface(IApplicationThread.descriptor);
378            boolean start = data.readInt() != 0;
379            int profileType = data.readInt();
380            String path = data.readString();
381            ParcelFileDescriptor fd = data.readInt() != 0
382                    ? data.readFileDescriptor() : null;
383            profilerControl(start, path, fd, profileType);
384            return true;
385        }
386
387        case SET_SCHEDULING_GROUP_TRANSACTION:
388        {
389            data.enforceInterface(IApplicationThread.descriptor);
390            int group = data.readInt();
391            setSchedulingGroup(group);
392            return true;
393        }
394
395        case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION:
396        {
397            data.enforceInterface(IApplicationThread.descriptor);
398            ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
399            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
400            int backupMode = data.readInt();
401            scheduleCreateBackupAgent(appInfo, compatInfo, backupMode);
402            return true;
403        }
404
405        case SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION:
406        {
407            data.enforceInterface(IApplicationThread.descriptor);
408            ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
409            CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
410            scheduleDestroyBackupAgent(appInfo, compatInfo);
411            return true;
412        }
413
414        case GET_MEMORY_INFO_TRANSACTION:
415        {
416            data.enforceInterface(IApplicationThread.descriptor);
417            Debug.MemoryInfo mi = new Debug.MemoryInfo();
418            getMemoryInfo(mi);
419            reply.writeNoException();
420            mi.writeToParcel(reply, 0);
421            return true;
422        }
423
424        case DISPATCH_PACKAGE_BROADCAST_TRANSACTION:
425        {
426            data.enforceInterface(IApplicationThread.descriptor);
427            int cmd = data.readInt();
428            String[] packages = data.readStringArray();
429            dispatchPackageBroadcast(cmd, packages);
430            return true;
431        }
432
433        case SCHEDULE_CRASH_TRANSACTION:
434        {
435            data.enforceInterface(IApplicationThread.descriptor);
436            String msg = data.readString();
437            scheduleCrash(msg);
438            return true;
439        }
440
441        case DUMP_HEAP_TRANSACTION:
442        {
443            data.enforceInterface(IApplicationThread.descriptor);
444            boolean managed = data.readInt() != 0;
445            String path = data.readString();
446            ParcelFileDescriptor fd = data.readInt() != 0
447                    ? data.readFileDescriptor() : null;
448            dumpHeap(managed, path, fd);
449            return true;
450        }
451
452        case DUMP_ACTIVITY_TRANSACTION: {
453            data.enforceInterface(IApplicationThread.descriptor);
454            ParcelFileDescriptor fd = data.readFileDescriptor();
455            final IBinder activity = data.readStrongBinder();
456            final String prefix = data.readString();
457            final String[] args = data.readStringArray();
458            if (fd != null) {
459                dumpActivity(fd.getFileDescriptor(), activity, prefix, args);
460                try {
461                    fd.close();
462                } catch (IOException e) {
463                }
464            }
465            return true;
466        }
467
468        case SET_CORE_SETTINGS_TRANSACTION: {
469            data.enforceInterface(IApplicationThread.descriptor);
470            Bundle settings = data.readBundle();
471            setCoreSettings(settings);
472            return true;
473        }
474
475        case UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION: {
476            data.enforceInterface(IApplicationThread.descriptor);
477            String pkg = data.readString();
478            CompatibilityInfo compat = CompatibilityInfo.CREATOR.createFromParcel(data);
479            updatePackageCompatibilityInfo(pkg, compat);
480            return true;
481        }
482
483        case SCHEDULE_TRIM_MEMORY_TRANSACTION: {
484            data.enforceInterface(IApplicationThread.descriptor);
485            int level = data.readInt();
486            scheduleTrimMemory(level);
487            return true;
488        }
489
490        case DUMP_MEM_INFO_TRANSACTION:
491        {
492            data.enforceInterface(IApplicationThread.descriptor);
493            ParcelFileDescriptor fd = data.readFileDescriptor();
494            String[] args = data.readStringArray();
495            Debug.MemoryInfo mi = null;
496            if (fd != null) {
497                try {
498                    mi = dumpMemInfo(fd.getFileDescriptor(), args);
499                } finally {
500                    try {
501                        fd.close();
502                    } catch (IOException e) {
503                        // swallowed, not propagated back to the caller
504                    }
505                }
506            }
507            reply.writeNoException();
508            mi.writeToParcel(reply, 0);
509            return true;
510        }
511
512        case DUMP_GFX_INFO_TRANSACTION:
513        {
514            data.enforceInterface(IApplicationThread.descriptor);
515            ParcelFileDescriptor fd = data.readFileDescriptor();
516            String[] args = data.readStringArray();
517            if (fd != null) {
518                try {
519                    dumpGfxInfo(fd.getFileDescriptor(), args);
520                } finally {
521                    try {
522                        fd.close();
523                    } catch (IOException e) {
524                        // swallowed, not propagated back to the caller
525                    }
526                }
527            }
528            reply.writeNoException();
529            return true;
530        }
531        }
532
533        return super.onTransact(code, data, reply, flags);
534    }
535
536    public IBinder asBinder()
537    {
538        return this;
539    }
540}
541
542class ApplicationThreadProxy implements IApplicationThread {
543    private final IBinder mRemote;
544
545    public ApplicationThreadProxy(IBinder remote) {
546        mRemote = remote;
547    }
548
549    public final IBinder asBinder() {
550        return mRemote;
551    }
552
553    public final void schedulePauseActivity(IBinder token, boolean finished,
554            boolean userLeaving, int configChanges) throws RemoteException {
555        Parcel data = Parcel.obtain();
556        data.writeInterfaceToken(IApplicationThread.descriptor);
557        data.writeStrongBinder(token);
558        data.writeInt(finished ? 1 : 0);
559        data.writeInt(userLeaving ? 1 :0);
560        data.writeInt(configChanges);
561        mRemote.transact(SCHEDULE_PAUSE_ACTIVITY_TRANSACTION, data, null,
562                IBinder.FLAG_ONEWAY);
563        data.recycle();
564    }
565
566    public final void scheduleStopActivity(IBinder token, boolean showWindow,
567            int configChanges) throws RemoteException {
568        Parcel data = Parcel.obtain();
569        data.writeInterfaceToken(IApplicationThread.descriptor);
570        data.writeStrongBinder(token);
571        data.writeInt(showWindow ? 1 : 0);
572        data.writeInt(configChanges);
573        mRemote.transact(SCHEDULE_STOP_ACTIVITY_TRANSACTION, data, null,
574                IBinder.FLAG_ONEWAY);
575        data.recycle();
576    }
577
578    public final void scheduleWindowVisibility(IBinder token,
579            boolean showWindow) throws RemoteException {
580        Parcel data = Parcel.obtain();
581        data.writeInterfaceToken(IApplicationThread.descriptor);
582        data.writeStrongBinder(token);
583        data.writeInt(showWindow ? 1 : 0);
584        mRemote.transact(SCHEDULE_WINDOW_VISIBILITY_TRANSACTION, data, null,
585                IBinder.FLAG_ONEWAY);
586        data.recycle();
587    }
588
589    public final void scheduleSleeping(IBinder token,
590            boolean sleeping) throws RemoteException {
591        Parcel data = Parcel.obtain();
592        data.writeInterfaceToken(IApplicationThread.descriptor);
593        data.writeStrongBinder(token);
594        data.writeInt(sleeping ? 1 : 0);
595        mRemote.transact(SCHEDULE_SLEEPING_TRANSACTION, data, null,
596                IBinder.FLAG_ONEWAY);
597        data.recycle();
598    }
599
600    public final void scheduleResumeActivity(IBinder token, boolean isForward)
601            throws RemoteException {
602        Parcel data = Parcel.obtain();
603        data.writeInterfaceToken(IApplicationThread.descriptor);
604        data.writeStrongBinder(token);
605        data.writeInt(isForward ? 1 : 0);
606        mRemote.transact(SCHEDULE_RESUME_ACTIVITY_TRANSACTION, data, null,
607                IBinder.FLAG_ONEWAY);
608        data.recycle();
609    }
610
611    public final void scheduleSendResult(IBinder token, List<ResultInfo> results)
612    		throws RemoteException {
613        Parcel data = Parcel.obtain();
614        data.writeInterfaceToken(IApplicationThread.descriptor);
615        data.writeStrongBinder(token);
616        data.writeTypedList(results);
617        mRemote.transact(SCHEDULE_SEND_RESULT_TRANSACTION, data, null,
618                IBinder.FLAG_ONEWAY);
619        data.recycle();
620    }
621
622    public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
623            ActivityInfo info, CompatibilityInfo compatInfo, Bundle state,
624            List<ResultInfo> pendingResults,
625    		List<Intent> pendingNewIntents, boolean notResumed, boolean isForward)
626    		throws RemoteException {
627        Parcel data = Parcel.obtain();
628        data.writeInterfaceToken(IApplicationThread.descriptor);
629        intent.writeToParcel(data, 0);
630        data.writeStrongBinder(token);
631        data.writeInt(ident);
632        info.writeToParcel(data, 0);
633        compatInfo.writeToParcel(data, 0);
634        data.writeBundle(state);
635        data.writeTypedList(pendingResults);
636        data.writeTypedList(pendingNewIntents);
637        data.writeInt(notResumed ? 1 : 0);
638        data.writeInt(isForward ? 1 : 0);
639        mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null,
640                IBinder.FLAG_ONEWAY);
641        data.recycle();
642    }
643
644    public final void scheduleRelaunchActivity(IBinder token,
645            List<ResultInfo> pendingResults, List<Intent> pendingNewIntents,
646            int configChanges, boolean notResumed, Configuration config)
647            throws RemoteException {
648        Parcel data = Parcel.obtain();
649        data.writeInterfaceToken(IApplicationThread.descriptor);
650        data.writeStrongBinder(token);
651        data.writeTypedList(pendingResults);
652        data.writeTypedList(pendingNewIntents);
653        data.writeInt(configChanges);
654        data.writeInt(notResumed ? 1 : 0);
655        if (config != null) {
656            data.writeInt(1);
657            config.writeToParcel(data, 0);
658        } else {
659            data.writeInt(0);
660        }
661        mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null,
662                IBinder.FLAG_ONEWAY);
663        data.recycle();
664    }
665
666    public void scheduleNewIntent(List<Intent> intents, IBinder token)
667            throws RemoteException {
668        Parcel data = Parcel.obtain();
669        data.writeInterfaceToken(IApplicationThread.descriptor);
670        data.writeTypedList(intents);
671        data.writeStrongBinder(token);
672        mRemote.transact(SCHEDULE_NEW_INTENT_TRANSACTION, data, null,
673                IBinder.FLAG_ONEWAY);
674        data.recycle();
675    }
676
677    public final void scheduleDestroyActivity(IBinder token, boolean finishing,
678            int configChanges) throws RemoteException {
679        Parcel data = Parcel.obtain();
680        data.writeInterfaceToken(IApplicationThread.descriptor);
681        data.writeStrongBinder(token);
682        data.writeInt(finishing ? 1 : 0);
683        data.writeInt(configChanges);
684        mRemote.transact(SCHEDULE_FINISH_ACTIVITY_TRANSACTION, data, null,
685                IBinder.FLAG_ONEWAY);
686        data.recycle();
687    }
688
689    public final void scheduleReceiver(Intent intent, ActivityInfo info,
690            CompatibilityInfo compatInfo, int resultCode, String resultData,
691            Bundle map, boolean sync) throws RemoteException {
692        Parcel data = Parcel.obtain();
693        data.writeInterfaceToken(IApplicationThread.descriptor);
694        intent.writeToParcel(data, 0);
695        info.writeToParcel(data, 0);
696        compatInfo.writeToParcel(data, 0);
697        data.writeInt(resultCode);
698        data.writeString(resultData);
699        data.writeBundle(map);
700        data.writeInt(sync ? 1 : 0);
701        mRemote.transact(SCHEDULE_RECEIVER_TRANSACTION, data, null,
702                IBinder.FLAG_ONEWAY);
703        data.recycle();
704    }
705
706    public final void scheduleCreateBackupAgent(ApplicationInfo app,
707            CompatibilityInfo compatInfo, int backupMode) throws RemoteException {
708        Parcel data = Parcel.obtain();
709        data.writeInterfaceToken(IApplicationThread.descriptor);
710        app.writeToParcel(data, 0);
711        compatInfo.writeToParcel(data, 0);
712        data.writeInt(backupMode);
713        mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null,
714                IBinder.FLAG_ONEWAY);
715        data.recycle();
716    }
717
718    public final void scheduleDestroyBackupAgent(ApplicationInfo app,
719            CompatibilityInfo compatInfo) throws RemoteException {
720        Parcel data = Parcel.obtain();
721        data.writeInterfaceToken(IApplicationThread.descriptor);
722        app.writeToParcel(data, 0);
723        compatInfo.writeToParcel(data, 0);
724        mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null,
725                IBinder.FLAG_ONEWAY);
726        data.recycle();
727    }
728
729    public final void scheduleCreateService(IBinder token, ServiceInfo info,
730            CompatibilityInfo compatInfo) throws RemoteException {
731        Parcel data = Parcel.obtain();
732        data.writeInterfaceToken(IApplicationThread.descriptor);
733        data.writeStrongBinder(token);
734        info.writeToParcel(data, 0);
735        compatInfo.writeToParcel(data, 0);
736        mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null,
737                IBinder.FLAG_ONEWAY);
738        data.recycle();
739    }
740
741    public final void scheduleBindService(IBinder token, Intent intent, boolean rebind)
742            throws RemoteException {
743        Parcel data = Parcel.obtain();
744        data.writeInterfaceToken(IApplicationThread.descriptor);
745        data.writeStrongBinder(token);
746        intent.writeToParcel(data, 0);
747        data.writeInt(rebind ? 1 : 0);
748        mRemote.transact(SCHEDULE_BIND_SERVICE_TRANSACTION, data, null,
749                IBinder.FLAG_ONEWAY);
750        data.recycle();
751    }
752
753    public final void scheduleUnbindService(IBinder token, Intent intent)
754            throws RemoteException {
755        Parcel data = Parcel.obtain();
756        data.writeInterfaceToken(IApplicationThread.descriptor);
757        data.writeStrongBinder(token);
758        intent.writeToParcel(data, 0);
759        mRemote.transact(SCHEDULE_UNBIND_SERVICE_TRANSACTION, data, null,
760                IBinder.FLAG_ONEWAY);
761        data.recycle();
762    }
763
764    public final void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
765	    int flags, Intent args) throws RemoteException {
766        Parcel data = Parcel.obtain();
767        data.writeInterfaceToken(IApplicationThread.descriptor);
768        data.writeStrongBinder(token);
769        data.writeInt(taskRemoved ? 1 : 0);
770        data.writeInt(startId);
771        data.writeInt(flags);
772        if (args != null) {
773            data.writeInt(1);
774            args.writeToParcel(data, 0);
775        } else {
776            data.writeInt(0);
777        }
778        mRemote.transact(SCHEDULE_SERVICE_ARGS_TRANSACTION, data, null,
779                IBinder.FLAG_ONEWAY);
780        data.recycle();
781    }
782
783    public final void scheduleStopService(IBinder token)
784            throws RemoteException {
785        Parcel data = Parcel.obtain();
786        data.writeInterfaceToken(IApplicationThread.descriptor);
787        data.writeStrongBinder(token);
788        mRemote.transact(SCHEDULE_STOP_SERVICE_TRANSACTION, data, null,
789                IBinder.FLAG_ONEWAY);
790        data.recycle();
791    }
792
793    public final void bindApplication(String packageName, ApplicationInfo info,
794            List<ProviderInfo> providers, ComponentName testName,
795            String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode,
796            boolean restrictedBackupMode, Configuration config, CompatibilityInfo compatInfo,
797            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
798        Parcel data = Parcel.obtain();
799        data.writeInterfaceToken(IApplicationThread.descriptor);
800        data.writeString(packageName);
801        info.writeToParcel(data, 0);
802        data.writeTypedList(providers);
803        if (testName == null) {
804            data.writeInt(0);
805        } else {
806            data.writeInt(1);
807            testName.writeToParcel(data, 0);
808        }
809        data.writeString(profileName);
810        data.writeBundle(testArgs);
811        data.writeStrongInterface(testWatcher);
812        data.writeInt(debugMode);
813        data.writeInt(restrictedBackupMode ? 1 : 0);
814        config.writeToParcel(data, 0);
815        compatInfo.writeToParcel(data, 0);
816        data.writeMap(services);
817        data.writeBundle(coreSettings);
818        mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,
819                IBinder.FLAG_ONEWAY);
820        data.recycle();
821    }
822
823    public final void scheduleExit() throws RemoteException {
824        Parcel data = Parcel.obtain();
825        data.writeInterfaceToken(IApplicationThread.descriptor);
826        mRemote.transact(SCHEDULE_EXIT_TRANSACTION, data, null,
827                IBinder.FLAG_ONEWAY);
828        data.recycle();
829    }
830
831    public final void scheduleSuicide() throws RemoteException {
832        Parcel data = Parcel.obtain();
833        data.writeInterfaceToken(IApplicationThread.descriptor);
834        mRemote.transact(SCHEDULE_SUICIDE_TRANSACTION, data, null,
835                IBinder.FLAG_ONEWAY);
836        data.recycle();
837    }
838
839    public final void requestThumbnail(IBinder token)
840            throws RemoteException {
841        Parcel data = Parcel.obtain();
842        data.writeInterfaceToken(IApplicationThread.descriptor);
843        data.writeStrongBinder(token);
844        mRemote.transact(REQUEST_THUMBNAIL_TRANSACTION, data, null,
845                IBinder.FLAG_ONEWAY);
846        data.recycle();
847    }
848
849    public final void scheduleConfigurationChanged(Configuration config)
850            throws RemoteException {
851        Parcel data = Parcel.obtain();
852        data.writeInterfaceToken(IApplicationThread.descriptor);
853        config.writeToParcel(data, 0);
854        mRemote.transact(SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION, data, null,
855                IBinder.FLAG_ONEWAY);
856        data.recycle();
857    }
858
859    public void updateTimeZone() throws RemoteException {
860        Parcel data = Parcel.obtain();
861        data.writeInterfaceToken(IApplicationThread.descriptor);
862        mRemote.transact(UPDATE_TIME_ZONE_TRANSACTION, data, null,
863                IBinder.FLAG_ONEWAY);
864        data.recycle();
865    }
866
867    public void clearDnsCache() throws RemoteException {
868        Parcel data = Parcel.obtain();
869        data.writeInterfaceToken(IApplicationThread.descriptor);
870        mRemote.transact(CLEAR_DNS_CACHE_TRANSACTION, data, null,
871                IBinder.FLAG_ONEWAY);
872        data.recycle();
873    }
874
875    public void setHttpProxy(String proxy, String port, String exclList) throws RemoteException {
876        Parcel data = Parcel.obtain();
877        data.writeInterfaceToken(IApplicationThread.descriptor);
878        data.writeString(proxy);
879        data.writeString(port);
880        data.writeString(exclList);
881        mRemote.transact(SET_HTTP_PROXY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
882        data.recycle();
883    }
884
885    public void processInBackground() throws RemoteException {
886        Parcel data = Parcel.obtain();
887        data.writeInterfaceToken(IApplicationThread.descriptor);
888        mRemote.transact(PROCESS_IN_BACKGROUND_TRANSACTION, data, null,
889                IBinder.FLAG_ONEWAY);
890        data.recycle();
891    }
892
893    public void dumpService(FileDescriptor fd, IBinder token, String[] args)
894            throws RemoteException {
895        Parcel data = Parcel.obtain();
896        data.writeInterfaceToken(IApplicationThread.descriptor);
897        data.writeFileDescriptor(fd);
898        data.writeStrongBinder(token);
899        data.writeStringArray(args);
900        mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
901        data.recycle();
902    }
903
904    public void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent,
905            int resultCode, String dataStr, Bundle extras, boolean ordered, boolean sticky)
906            throws RemoteException {
907        Parcel data = Parcel.obtain();
908        data.writeInterfaceToken(IApplicationThread.descriptor);
909        data.writeStrongBinder(receiver.asBinder());
910        intent.writeToParcel(data, 0);
911        data.writeInt(resultCode);
912        data.writeString(dataStr);
913        data.writeBundle(extras);
914        data.writeInt(ordered ? 1 : 0);
915        data.writeInt(sticky ? 1 : 0);
916        mRemote.transact(SCHEDULE_REGISTERED_RECEIVER_TRANSACTION, data, null,
917                IBinder.FLAG_ONEWAY);
918        data.recycle();
919    }
920
921    public final void scheduleLowMemory() throws RemoteException {
922        Parcel data = Parcel.obtain();
923        data.writeInterfaceToken(IApplicationThread.descriptor);
924        mRemote.transact(SCHEDULE_LOW_MEMORY_TRANSACTION, data, null,
925                IBinder.FLAG_ONEWAY);
926        data.recycle();
927    }
928
929    public final void scheduleActivityConfigurationChanged(
930            IBinder token) throws RemoteException {
931        Parcel data = Parcel.obtain();
932        data.writeInterfaceToken(IApplicationThread.descriptor);
933        data.writeStrongBinder(token);
934        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
935                IBinder.FLAG_ONEWAY);
936        data.recycle();
937    }
938
939    public void profilerControl(boolean start, String path,
940            ParcelFileDescriptor fd, int profileType) throws RemoteException {
941        Parcel data = Parcel.obtain();
942        data.writeInterfaceToken(IApplicationThread.descriptor);
943        data.writeInt(start ? 1 : 0);
944        data.writeInt(profileType);
945        data.writeString(path);
946        if (fd != null) {
947            data.writeInt(1);
948            fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
949        } else {
950            data.writeInt(0);
951        }
952        mRemote.transact(PROFILER_CONTROL_TRANSACTION, data, null,
953                IBinder.FLAG_ONEWAY);
954        data.recycle();
955    }
956
957    public void setSchedulingGroup(int group) throws RemoteException {
958        Parcel data = Parcel.obtain();
959        data.writeInterfaceToken(IApplicationThread.descriptor);
960        data.writeInt(group);
961        mRemote.transact(SET_SCHEDULING_GROUP_TRANSACTION, data, null,
962                IBinder.FLAG_ONEWAY);
963        data.recycle();
964    }
965
966    public void getMemoryInfo(Debug.MemoryInfo outInfo) throws RemoteException {
967        Parcel data = Parcel.obtain();
968        Parcel reply = Parcel.obtain();
969        data.writeInterfaceToken(IApplicationThread.descriptor);
970        mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
971        reply.readException();
972        outInfo.readFromParcel(reply);
973        data.recycle();
974        reply.recycle();
975    }
976
977    public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException {
978        Parcel data = Parcel.obtain();
979        data.writeInterfaceToken(IApplicationThread.descriptor);
980        data.writeInt(cmd);
981        data.writeStringArray(packages);
982        mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null,
983                IBinder.FLAG_ONEWAY);
984        data.recycle();
985
986    }
987
988    public void scheduleCrash(String msg) throws RemoteException {
989        Parcel data = Parcel.obtain();
990        data.writeInterfaceToken(IApplicationThread.descriptor);
991        data.writeString(msg);
992        mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null,
993                IBinder.FLAG_ONEWAY);
994        data.recycle();
995
996    }
997
998    public void dumpHeap(boolean managed, String path,
999            ParcelFileDescriptor fd) throws RemoteException {
1000        Parcel data = Parcel.obtain();
1001        data.writeInterfaceToken(IApplicationThread.descriptor);
1002        data.writeInt(managed ? 1 : 0);
1003        data.writeString(path);
1004        if (fd != null) {
1005            data.writeInt(1);
1006            fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1007        } else {
1008            data.writeInt(0);
1009        }
1010        mRemote.transact(DUMP_HEAP_TRANSACTION, data, null,
1011                IBinder.FLAG_ONEWAY);
1012        data.recycle();
1013    }
1014
1015    public void dumpActivity(FileDescriptor fd, IBinder token, String prefix, String[] args)
1016            throws RemoteException {
1017        Parcel data = Parcel.obtain();
1018        data.writeInterfaceToken(IApplicationThread.descriptor);
1019        data.writeFileDescriptor(fd);
1020        data.writeStrongBinder(token);
1021        data.writeString(prefix);
1022        data.writeStringArray(args);
1023        mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1024        data.recycle();
1025    }
1026
1027    public void setCoreSettings(Bundle coreSettings) throws RemoteException {
1028        Parcel data = Parcel.obtain();
1029        data.writeInterfaceToken(IApplicationThread.descriptor);
1030        data.writeBundle(coreSettings);
1031        mRemote.transact(SET_CORE_SETTINGS_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1032    }
1033
1034    public void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info)
1035            throws RemoteException {
1036        Parcel data = Parcel.obtain();
1037        data.writeInterfaceToken(IApplicationThread.descriptor);
1038        data.writeString(pkg);
1039        info.writeToParcel(data, 0);
1040        mRemote.transact(UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION, data, null,
1041                IBinder.FLAG_ONEWAY);
1042    }
1043
1044    public void scheduleTrimMemory(int level) throws RemoteException {
1045        Parcel data = Parcel.obtain();
1046        data.writeInterfaceToken(IApplicationThread.descriptor);
1047        data.writeInt(level);
1048        mRemote.transact(SCHEDULE_TRIM_MEMORY_TRANSACTION, data, null,
1049                IBinder.FLAG_ONEWAY);
1050    }
1051
1052    public Debug.MemoryInfo dumpMemInfo(FileDescriptor fd, String[] args) throws RemoteException {
1053        Parcel data = Parcel.obtain();
1054        Parcel reply = Parcel.obtain();
1055        data.writeInterfaceToken(IApplicationThread.descriptor);
1056        data.writeFileDescriptor(fd);
1057        data.writeStringArray(args);
1058        mRemote.transact(DUMP_MEM_INFO_TRANSACTION, data, reply, 0);
1059        reply.readException();
1060        Debug.MemoryInfo info = new Debug.MemoryInfo();
1061        info.readFromParcel(reply);
1062        data.recycle();
1063        reply.recycle();
1064        return info;
1065    }
1066
1067    public void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException {
1068        Parcel data = Parcel.obtain();
1069        data.writeInterfaceToken(IApplicationThread.descriptor);
1070        data.writeFileDescriptor(fd);
1071        data.writeStringArray(args);
1072        mRemote.transact(DUMP_GFX_INFO_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
1073        data.recycle();
1074    }
1075}
1076