ApplicationThreadNative.java revision 0c5001d776d56bae02a5cc2663286a125d99bc5e
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.Configuration;
27import android.os.Binder;
28import android.os.Bundle;
29import android.os.Debug;
30import android.os.Parcelable;
31import android.os.RemoteException;
32import android.os.IBinder;
33import android.os.Parcel;
34import android.os.ParcelFileDescriptor;
35
36import java.io.FileDescriptor;
37import java.io.IOException;
38import java.util.HashMap;
39import java.util.List;
40import java.util.Map;
41
42/** {@hide} */
43public abstract class ApplicationThreadNative extends Binder
44        implements IApplicationThread {
45    /**
46     * Cast a Binder object into an application thread interface, generating
47     * a proxy if needed.
48     */
49    static public IApplicationThread asInterface(IBinder obj) {
50        if (obj == null) {
51            return null;
52        }
53        IApplicationThread in =
54            (IApplicationThread)obj.queryLocalInterface(descriptor);
55        if (in != null) {
56            return in;
57        }
58
59        return new ApplicationThreadProxy(obj);
60    }
61
62    public ApplicationThreadNative() {
63        attachInterface(this, descriptor);
64    }
65
66    @Override
67    public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
68            throws RemoteException {
69        switch (code) {
70        case SCHEDULE_PAUSE_ACTIVITY_TRANSACTION:
71        {
72            data.enforceInterface(IApplicationThread.descriptor);
73            IBinder b = data.readStrongBinder();
74            boolean finished = data.readInt() != 0;
75            boolean userLeaving = data.readInt() != 0;
76            int configChanges = data.readInt();
77            schedulePauseActivity(b, finished, userLeaving, configChanges);
78            return true;
79        }
80
81        case SCHEDULE_STOP_ACTIVITY_TRANSACTION:
82        {
83            data.enforceInterface(IApplicationThread.descriptor);
84            IBinder b = data.readStrongBinder();
85            boolean show = data.readInt() != 0;
86            int configChanges = data.readInt();
87            scheduleStopActivity(b, show, configChanges);
88            return true;
89        }
90
91        case SCHEDULE_WINDOW_VISIBILITY_TRANSACTION:
92        {
93            data.enforceInterface(IApplicationThread.descriptor);
94            IBinder b = data.readStrongBinder();
95            boolean show = data.readInt() != 0;
96            scheduleWindowVisibility(b, show);
97            return true;
98        }
99
100        case SCHEDULE_SLEEPING_TRANSACTION:
101        {
102            data.enforceInterface(IApplicationThread.descriptor);
103            IBinder b = data.readStrongBinder();
104            boolean sleeping = data.readInt() != 0;
105            scheduleSleeping(b, sleeping);
106            return true;
107        }
108
109        case SCHEDULE_RESUME_ACTIVITY_TRANSACTION:
110        {
111            data.enforceInterface(IApplicationThread.descriptor);
112            IBinder b = data.readStrongBinder();
113            boolean isForward = data.readInt() != 0;
114            scheduleResumeActivity(b, isForward);
115            return true;
116        }
117
118        case SCHEDULE_SEND_RESULT_TRANSACTION:
119        {
120            data.enforceInterface(IApplicationThread.descriptor);
121            IBinder b = data.readStrongBinder();
122            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
123            scheduleSendResult(b, ri);
124            return true;
125        }
126
127        case SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION:
128        {
129            data.enforceInterface(IApplicationThread.descriptor);
130            Intent intent = Intent.CREATOR.createFromParcel(data);
131            IBinder b = data.readStrongBinder();
132            int ident = data.readInt();
133            ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
134            Bundle state = data.readBundle();
135            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
136            List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
137            boolean notResumed = data.readInt() != 0;
138            boolean isForward = data.readInt() != 0;
139            scheduleLaunchActivity(intent, b, ident, info, state, ri, pi,
140                    notResumed, isForward);
141            return true;
142        }
143
144        case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION:
145        {
146            data.enforceInterface(IApplicationThread.descriptor);
147            IBinder b = data.readStrongBinder();
148            List<ResultInfo> ri = data.createTypedArrayList(ResultInfo.CREATOR);
149            List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
150            int configChanges = data.readInt();
151            boolean notResumed = data.readInt() != 0;
152            Configuration config = null;
153            if (data.readInt() != 0) {
154                config = Configuration.CREATOR.createFromParcel(data);
155            }
156            scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config);
157            return true;
158        }
159
160        case SCHEDULE_NEW_INTENT_TRANSACTION:
161        {
162            data.enforceInterface(IApplicationThread.descriptor);
163            List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
164            IBinder b = data.readStrongBinder();
165            scheduleNewIntent(pi, b);
166            return true;
167        }
168
169        case SCHEDULE_FINISH_ACTIVITY_TRANSACTION:
170        {
171            data.enforceInterface(IApplicationThread.descriptor);
172            IBinder b = data.readStrongBinder();
173            boolean finishing = data.readInt() != 0;
174            int configChanges = data.readInt();
175            scheduleDestroyActivity(b, finishing, configChanges);
176            return true;
177        }
178
179        case SCHEDULE_RECEIVER_TRANSACTION:
180        {
181            data.enforceInterface(IApplicationThread.descriptor);
182            Intent intent = Intent.CREATOR.createFromParcel(data);
183            ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data);
184            int resultCode = data.readInt();
185            String resultData = data.readString();
186            Bundle resultExtras = data.readBundle();
187            boolean sync = data.readInt() != 0;
188            scheduleReceiver(intent, info, resultCode, resultData,
189                    resultExtras, sync);
190            return true;
191        }
192
193        case SCHEDULE_CREATE_SERVICE_TRANSACTION: {
194            data.enforceInterface(IApplicationThread.descriptor);
195            IBinder token = data.readStrongBinder();
196            ServiceInfo info = ServiceInfo.CREATOR.createFromParcel(data);
197            scheduleCreateService(token, info);
198            return true;
199        }
200
201        case SCHEDULE_BIND_SERVICE_TRANSACTION: {
202            data.enforceInterface(IApplicationThread.descriptor);
203            IBinder token = data.readStrongBinder();
204            Intent intent = Intent.CREATOR.createFromParcel(data);
205            boolean rebind = data.readInt() != 0;
206            scheduleBindService(token, intent, rebind);
207            return true;
208        }
209
210        case SCHEDULE_UNBIND_SERVICE_TRANSACTION: {
211            data.enforceInterface(IApplicationThread.descriptor);
212            IBinder token = data.readStrongBinder();
213            Intent intent = Intent.CREATOR.createFromParcel(data);
214            scheduleUnbindService(token, intent);
215            return true;
216        }
217
218        case SCHEDULE_SERVICE_ARGS_TRANSACTION:
219        {
220            data.enforceInterface(IApplicationThread.descriptor);
221            IBinder token = data.readStrongBinder();
222            boolean taskRemoved = data.readInt() != 0;
223            int startId = data.readInt();
224            int fl = data.readInt();
225            Intent args;
226            if (data.readInt() != 0) {
227                args = Intent.CREATOR.createFromParcel(data);
228            } else {
229                args = null;
230            }
231            scheduleServiceArgs(token, taskRemoved, startId, fl, args);
232            return true;
233        }
234
235        case SCHEDULE_STOP_SERVICE_TRANSACTION:
236        {
237            data.enforceInterface(IApplicationThread.descriptor);
238            IBinder token = data.readStrongBinder();
239            scheduleStopService(token);
240            return true;
241        }
242
243        case BIND_APPLICATION_TRANSACTION:
244        {
245            data.enforceInterface(IApplicationThread.descriptor);
246            String packageName = data.readString();
247            ApplicationInfo info =
248                ApplicationInfo.CREATOR.createFromParcel(data);
249            List<ProviderInfo> providers =
250                data.createTypedArrayList(ProviderInfo.CREATOR);
251            ComponentName testName = (data.readInt() != 0)
252                ? new ComponentName(data) : null;
253            String profileName = data.readString();
254            Bundle testArgs = data.readBundle();
255            IBinder binder = data.readStrongBinder();
256            IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
257            int testMode = data.readInt();
258            boolean restrictedBackupMode = (data.readInt() != 0);
259            Configuration config = Configuration.CREATOR.createFromParcel(data);
260            HashMap<String, IBinder> services = data.readHashMap(null);
261            Bundle coreSettings = data.readBundle();
262            bindApplication(packageName, info,
263                            providers, testName, profileName,
264                            testArgs, testWatcher, testMode, restrictedBackupMode,
265                            config, services, coreSettings);
266            return true;
267        }
268
269        case SCHEDULE_EXIT_TRANSACTION:
270        {
271            data.enforceInterface(IApplicationThread.descriptor);
272            scheduleExit();
273            return true;
274        }
275
276        case SCHEDULE_SUICIDE_TRANSACTION:
277        {
278            data.enforceInterface(IApplicationThread.descriptor);
279            scheduleSuicide();
280            return true;
281        }
282
283        case REQUEST_THUMBNAIL_TRANSACTION:
284        {
285            data.enforceInterface(IApplicationThread.descriptor);
286            IBinder b = data.readStrongBinder();
287            requestThumbnail(b);
288            return true;
289        }
290
291        case SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION:
292        {
293            data.enforceInterface(IApplicationThread.descriptor);
294            Configuration config = Configuration.CREATOR.createFromParcel(data);
295            scheduleConfigurationChanged(config);
296            return true;
297        }
298
299        case UPDATE_TIME_ZONE_TRANSACTION: {
300            data.enforceInterface(IApplicationThread.descriptor);
301            updateTimeZone();
302            return true;
303        }
304
305        case CLEAR_DNS_CACHE_TRANSACTION: {
306            data.enforceInterface(IApplicationThread.descriptor);
307            clearDnsCache();
308            return true;
309        }
310
311        case SET_HTTP_PROXY_TRANSACTION: {
312            data.enforceInterface(IApplicationThread.descriptor);
313            final String proxy = data.readString();
314            final String port = data.readString();
315            final String exclList = data.readString();
316            setHttpProxy(proxy, port, exclList);
317            return true;
318        }
319
320        case PROCESS_IN_BACKGROUND_TRANSACTION: {
321            data.enforceInterface(IApplicationThread.descriptor);
322            processInBackground();
323            return true;
324        }
325
326        case DUMP_SERVICE_TRANSACTION: {
327            data.enforceInterface(IApplicationThread.descriptor);
328            ParcelFileDescriptor fd = data.readFileDescriptor();
329            final IBinder service = data.readStrongBinder();
330            final String[] args = data.readStringArray();
331            if (fd != null) {
332                dumpService(fd.getFileDescriptor(), service, args);
333                try {
334                    fd.close();
335                } catch (IOException e) {
336                }
337            }
338            return true;
339        }
340
341        case SCHEDULE_REGISTERED_RECEIVER_TRANSACTION: {
342            data.enforceInterface(IApplicationThread.descriptor);
343            IIntentReceiver receiver = IIntentReceiver.Stub.asInterface(
344                    data.readStrongBinder());
345            Intent intent = Intent.CREATOR.createFromParcel(data);
346            int resultCode = data.readInt();
347            String dataStr = data.readString();
348            Bundle extras = data.readBundle();
349            boolean ordered = data.readInt() != 0;
350            boolean sticky = data.readInt() != 0;
351            scheduleRegisteredReceiver(receiver, intent,
352                    resultCode, dataStr, extras, ordered, sticky);
353            return true;
354        }
355
356        case SCHEDULE_LOW_MEMORY_TRANSACTION:
357        {
358            scheduleLowMemory();
359            return true;
360        }
361
362        case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION:
363        {
364            data.enforceInterface(IApplicationThread.descriptor);
365            IBinder b = data.readStrongBinder();
366            scheduleActivityConfigurationChanged(b);
367            return true;
368        }
369
370        case PROFILER_CONTROL_TRANSACTION:
371        {
372            data.enforceInterface(IApplicationThread.descriptor);
373            boolean start = data.readInt() != 0;
374            String path = data.readString();
375            ParcelFileDescriptor fd = data.readInt() != 0
376                    ? data.readFileDescriptor() : null;
377            profilerControl(start, path, fd);
378            return true;
379        }
380
381        case SET_SCHEDULING_GROUP_TRANSACTION:
382        {
383            data.enforceInterface(IApplicationThread.descriptor);
384            int group = data.readInt();
385            setSchedulingGroup(group);
386            return true;
387        }
388
389        case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION:
390        {
391            data.enforceInterface(IApplicationThread.descriptor);
392            ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
393            int backupMode = data.readInt();
394            scheduleCreateBackupAgent(appInfo, backupMode);
395            return true;
396        }
397
398        case SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION:
399        {
400            data.enforceInterface(IApplicationThread.descriptor);
401            ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
402            scheduleDestroyBackupAgent(appInfo);
403            return true;
404        }
405
406        case GET_MEMORY_INFO_TRANSACTION:
407        {
408            data.enforceInterface(IApplicationThread.descriptor);
409            Debug.MemoryInfo mi = new Debug.MemoryInfo();
410            getMemoryInfo(mi);
411            reply.writeNoException();
412            mi.writeToParcel(reply, 0);
413            return true;
414        }
415
416        case DISPATCH_PACKAGE_BROADCAST_TRANSACTION:
417        {
418            data.enforceInterface(IApplicationThread.descriptor);
419            int cmd = data.readInt();
420            String[] packages = data.readStringArray();
421            dispatchPackageBroadcast(cmd, packages);
422            return true;
423        }
424
425        case SCHEDULE_CRASH_TRANSACTION:
426        {
427            data.enforceInterface(IApplicationThread.descriptor);
428            String msg = data.readString();
429            scheduleCrash(msg);
430            return true;
431        }
432
433        case DUMP_HEAP_TRANSACTION:
434        {
435            data.enforceInterface(IApplicationThread.descriptor);
436            boolean managed = data.readInt() != 0;
437            String path = data.readString();
438            ParcelFileDescriptor fd = data.readInt() != 0
439                    ? data.readFileDescriptor() : null;
440            dumpHeap(managed, path, fd);
441            return true;
442        }
443
444        case DUMP_ACTIVITY_TRANSACTION: {
445            data.enforceInterface(IApplicationThread.descriptor);
446            ParcelFileDescriptor fd = data.readFileDescriptor();
447            final IBinder activity = data.readStrongBinder();
448            final String prefix = data.readString();
449            final String[] args = data.readStringArray();
450            if (fd != null) {
451                dumpActivity(fd.getFileDescriptor(), activity, prefix, args);
452                try {
453                    fd.close();
454                } catch (IOException e) {
455                }
456            }
457            return true;
458        }
459
460        case SET_CORE_SETTINGS: {
461            data.enforceInterface(IApplicationThread.descriptor);
462            Bundle settings = data.readBundle();
463            setCoreSettings(settings);
464            return true;
465        }
466        }
467
468        return super.onTransact(code, data, reply, flags);
469    }
470
471    public IBinder asBinder()
472    {
473        return this;
474    }
475}
476
477class ApplicationThreadProxy implements IApplicationThread {
478    private final IBinder mRemote;
479
480    public ApplicationThreadProxy(IBinder remote) {
481        mRemote = remote;
482    }
483
484    public final IBinder asBinder() {
485        return mRemote;
486    }
487
488    public final void schedulePauseActivity(IBinder token, boolean finished,
489            boolean userLeaving, int configChanges) throws RemoteException {
490        Parcel data = Parcel.obtain();
491        data.writeInterfaceToken(IApplicationThread.descriptor);
492        data.writeStrongBinder(token);
493        data.writeInt(finished ? 1 : 0);
494        data.writeInt(userLeaving ? 1 :0);
495        data.writeInt(configChanges);
496        mRemote.transact(SCHEDULE_PAUSE_ACTIVITY_TRANSACTION, data, null,
497                IBinder.FLAG_ONEWAY);
498        data.recycle();
499    }
500
501    public final void scheduleStopActivity(IBinder token, boolean showWindow,
502            int configChanges) throws RemoteException {
503        Parcel data = Parcel.obtain();
504        data.writeInterfaceToken(IApplicationThread.descriptor);
505        data.writeStrongBinder(token);
506        data.writeInt(showWindow ? 1 : 0);
507        data.writeInt(configChanges);
508        mRemote.transact(SCHEDULE_STOP_ACTIVITY_TRANSACTION, data, null,
509                IBinder.FLAG_ONEWAY);
510        data.recycle();
511    }
512
513    public final void scheduleWindowVisibility(IBinder token,
514            boolean showWindow) throws RemoteException {
515        Parcel data = Parcel.obtain();
516        data.writeInterfaceToken(IApplicationThread.descriptor);
517        data.writeStrongBinder(token);
518        data.writeInt(showWindow ? 1 : 0);
519        mRemote.transact(SCHEDULE_WINDOW_VISIBILITY_TRANSACTION, data, null,
520                IBinder.FLAG_ONEWAY);
521        data.recycle();
522    }
523
524    public final void scheduleSleeping(IBinder token,
525            boolean sleeping) throws RemoteException {
526        Parcel data = Parcel.obtain();
527        data.writeInterfaceToken(IApplicationThread.descriptor);
528        data.writeStrongBinder(token);
529        data.writeInt(sleeping ? 1 : 0);
530        mRemote.transact(SCHEDULE_SLEEPING_TRANSACTION, data, null,
531                IBinder.FLAG_ONEWAY);
532        data.recycle();
533    }
534
535    public final void scheduleResumeActivity(IBinder token, boolean isForward)
536            throws RemoteException {
537        Parcel data = Parcel.obtain();
538        data.writeInterfaceToken(IApplicationThread.descriptor);
539        data.writeStrongBinder(token);
540        data.writeInt(isForward ? 1 : 0);
541        mRemote.transact(SCHEDULE_RESUME_ACTIVITY_TRANSACTION, data, null,
542                IBinder.FLAG_ONEWAY);
543        data.recycle();
544    }
545
546    public final void scheduleSendResult(IBinder token, List<ResultInfo> results)
547    		throws RemoteException {
548        Parcel data = Parcel.obtain();
549        data.writeInterfaceToken(IApplicationThread.descriptor);
550        data.writeStrongBinder(token);
551        data.writeTypedList(results);
552        mRemote.transact(SCHEDULE_SEND_RESULT_TRANSACTION, data, null,
553                IBinder.FLAG_ONEWAY);
554        data.recycle();
555    }
556
557    public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
558            ActivityInfo info, Bundle state, List<ResultInfo> pendingResults,
559    		List<Intent> pendingNewIntents, boolean notResumed, boolean isForward)
560    		throws RemoteException {
561        Parcel data = Parcel.obtain();
562        data.writeInterfaceToken(IApplicationThread.descriptor);
563        intent.writeToParcel(data, 0);
564        data.writeStrongBinder(token);
565        data.writeInt(ident);
566        info.writeToParcel(data, 0);
567        data.writeBundle(state);
568        data.writeTypedList(pendingResults);
569        data.writeTypedList(pendingNewIntents);
570        data.writeInt(notResumed ? 1 : 0);
571        data.writeInt(isForward ? 1 : 0);
572        mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null,
573                IBinder.FLAG_ONEWAY);
574        data.recycle();
575    }
576
577    public final void scheduleRelaunchActivity(IBinder token,
578            List<ResultInfo> pendingResults, List<Intent> pendingNewIntents,
579            int configChanges, boolean notResumed, Configuration config)
580            throws RemoteException {
581        Parcel data = Parcel.obtain();
582        data.writeInterfaceToken(IApplicationThread.descriptor);
583        data.writeStrongBinder(token);
584        data.writeTypedList(pendingResults);
585        data.writeTypedList(pendingNewIntents);
586        data.writeInt(configChanges);
587        data.writeInt(notResumed ? 1 : 0);
588        if (config != null) {
589            data.writeInt(1);
590            config.writeToParcel(data, 0);
591        } else {
592            data.writeInt(0);
593        }
594        mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null,
595                IBinder.FLAG_ONEWAY);
596        data.recycle();
597    }
598
599    public void scheduleNewIntent(List<Intent> intents, IBinder token)
600            throws RemoteException {
601        Parcel data = Parcel.obtain();
602        data.writeInterfaceToken(IApplicationThread.descriptor);
603        data.writeTypedList(intents);
604        data.writeStrongBinder(token);
605        mRemote.transact(SCHEDULE_NEW_INTENT_TRANSACTION, data, null,
606                IBinder.FLAG_ONEWAY);
607        data.recycle();
608    }
609
610    public final void scheduleDestroyActivity(IBinder token, boolean finishing,
611            int configChanges) throws RemoteException {
612        Parcel data = Parcel.obtain();
613        data.writeInterfaceToken(IApplicationThread.descriptor);
614        data.writeStrongBinder(token);
615        data.writeInt(finishing ? 1 : 0);
616        data.writeInt(configChanges);
617        mRemote.transact(SCHEDULE_FINISH_ACTIVITY_TRANSACTION, data, null,
618                IBinder.FLAG_ONEWAY);
619        data.recycle();
620    }
621
622    public final void scheduleReceiver(Intent intent, ActivityInfo info,
623            int resultCode, String resultData,
624            Bundle map, boolean sync) throws RemoteException {
625        Parcel data = Parcel.obtain();
626        data.writeInterfaceToken(IApplicationThread.descriptor);
627        intent.writeToParcel(data, 0);
628        info.writeToParcel(data, 0);
629        data.writeInt(resultCode);
630        data.writeString(resultData);
631        data.writeBundle(map);
632        data.writeInt(sync ? 1 : 0);
633        mRemote.transact(SCHEDULE_RECEIVER_TRANSACTION, data, null,
634                IBinder.FLAG_ONEWAY);
635        data.recycle();
636    }
637
638    public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode)
639            throws RemoteException {
640        Parcel data = Parcel.obtain();
641        data.writeInterfaceToken(IApplicationThread.descriptor);
642        app.writeToParcel(data, 0);
643        data.writeInt(backupMode);
644        mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null,
645                IBinder.FLAG_ONEWAY);
646        data.recycle();
647    }
648
649    public final void scheduleDestroyBackupAgent(ApplicationInfo app) throws RemoteException {
650        Parcel data = Parcel.obtain();
651        data.writeInterfaceToken(IApplicationThread.descriptor);
652        app.writeToParcel(data, 0);
653        mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null,
654                IBinder.FLAG_ONEWAY);
655        data.recycle();
656    }
657
658    public final void scheduleCreateService(IBinder token, ServiceInfo info)
659            throws RemoteException {
660        Parcel data = Parcel.obtain();
661        data.writeInterfaceToken(IApplicationThread.descriptor);
662        data.writeStrongBinder(token);
663        info.writeToParcel(data, 0);
664        mRemote.transact(SCHEDULE_CREATE_SERVICE_TRANSACTION, data, null,
665                IBinder.FLAG_ONEWAY);
666        data.recycle();
667    }
668
669    public final void scheduleBindService(IBinder token, Intent intent, boolean rebind)
670            throws RemoteException {
671        Parcel data = Parcel.obtain();
672        data.writeInterfaceToken(IApplicationThread.descriptor);
673        data.writeStrongBinder(token);
674        intent.writeToParcel(data, 0);
675        data.writeInt(rebind ? 1 : 0);
676        mRemote.transact(SCHEDULE_BIND_SERVICE_TRANSACTION, data, null,
677                IBinder.FLAG_ONEWAY);
678        data.recycle();
679    }
680
681    public final void scheduleUnbindService(IBinder token, Intent intent)
682            throws RemoteException {
683        Parcel data = Parcel.obtain();
684        data.writeInterfaceToken(IApplicationThread.descriptor);
685        data.writeStrongBinder(token);
686        intent.writeToParcel(data, 0);
687        mRemote.transact(SCHEDULE_UNBIND_SERVICE_TRANSACTION, data, null,
688                IBinder.FLAG_ONEWAY);
689        data.recycle();
690    }
691
692    public final void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
693	    int flags, Intent args) throws RemoteException {
694        Parcel data = Parcel.obtain();
695        data.writeInterfaceToken(IApplicationThread.descriptor);
696        data.writeStrongBinder(token);
697        data.writeInt(taskRemoved ? 1 : 0);
698        data.writeInt(startId);
699        data.writeInt(flags);
700        if (args != null) {
701            data.writeInt(1);
702            args.writeToParcel(data, 0);
703        } else {
704            data.writeInt(0);
705        }
706        mRemote.transact(SCHEDULE_SERVICE_ARGS_TRANSACTION, data, null,
707                IBinder.FLAG_ONEWAY);
708        data.recycle();
709    }
710
711    public final void scheduleStopService(IBinder token)
712            throws RemoteException {
713        Parcel data = Parcel.obtain();
714        data.writeInterfaceToken(IApplicationThread.descriptor);
715        data.writeStrongBinder(token);
716        mRemote.transact(SCHEDULE_STOP_SERVICE_TRANSACTION, data, null,
717                IBinder.FLAG_ONEWAY);
718        data.recycle();
719    }
720
721    public final void bindApplication(String packageName, ApplicationInfo info,
722            List<ProviderInfo> providers, ComponentName testName,
723            String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode,
724            boolean restrictedBackupMode, Configuration config,
725            Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
726        Parcel data = Parcel.obtain();
727        data.writeInterfaceToken(IApplicationThread.descriptor);
728        data.writeString(packageName);
729        info.writeToParcel(data, 0);
730        data.writeTypedList(providers);
731        if (testName == null) {
732            data.writeInt(0);
733        } else {
734            data.writeInt(1);
735            testName.writeToParcel(data, 0);
736        }
737        data.writeString(profileName);
738        data.writeBundle(testArgs);
739        data.writeStrongInterface(testWatcher);
740        data.writeInt(debugMode);
741        data.writeInt(restrictedBackupMode ? 1 : 0);
742        config.writeToParcel(data, 0);
743        data.writeMap(services);
744        data.writeBundle(coreSettings);
745        mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,
746                IBinder.FLAG_ONEWAY);
747        data.recycle();
748    }
749
750    public final void scheduleExit() throws RemoteException {
751        Parcel data = Parcel.obtain();
752        data.writeInterfaceToken(IApplicationThread.descriptor);
753        mRemote.transact(SCHEDULE_EXIT_TRANSACTION, data, null,
754                IBinder.FLAG_ONEWAY);
755        data.recycle();
756    }
757
758    public final void scheduleSuicide() throws RemoteException {
759        Parcel data = Parcel.obtain();
760        data.writeInterfaceToken(IApplicationThread.descriptor);
761        mRemote.transact(SCHEDULE_SUICIDE_TRANSACTION, data, null,
762                IBinder.FLAG_ONEWAY);
763        data.recycle();
764    }
765
766    public final void requestThumbnail(IBinder token)
767            throws RemoteException {
768        Parcel data = Parcel.obtain();
769        data.writeInterfaceToken(IApplicationThread.descriptor);
770        data.writeStrongBinder(token);
771        mRemote.transact(REQUEST_THUMBNAIL_TRANSACTION, data, null,
772                IBinder.FLAG_ONEWAY);
773        data.recycle();
774    }
775
776    public final void scheduleConfigurationChanged(Configuration config)
777            throws RemoteException {
778        Parcel data = Parcel.obtain();
779        data.writeInterfaceToken(IApplicationThread.descriptor);
780        config.writeToParcel(data, 0);
781        mRemote.transact(SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION, data, null,
782                IBinder.FLAG_ONEWAY);
783        data.recycle();
784    }
785
786    public void updateTimeZone() throws RemoteException {
787        Parcel data = Parcel.obtain();
788        data.writeInterfaceToken(IApplicationThread.descriptor);
789        mRemote.transact(UPDATE_TIME_ZONE_TRANSACTION, data, null,
790                IBinder.FLAG_ONEWAY);
791        data.recycle();
792    }
793
794    public void clearDnsCache() throws RemoteException {
795        Parcel data = Parcel.obtain();
796        data.writeInterfaceToken(IApplicationThread.descriptor);
797        mRemote.transact(CLEAR_DNS_CACHE_TRANSACTION, data, null,
798                IBinder.FLAG_ONEWAY);
799        data.recycle();
800    }
801
802    public void setHttpProxy(String proxy, String port, String exclList) throws RemoteException {
803        Parcel data = Parcel.obtain();
804        data.writeInterfaceToken(IApplicationThread.descriptor);
805        data.writeString(proxy);
806        data.writeString(port);
807        data.writeString(exclList);
808        mRemote.transact(SET_HTTP_PROXY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
809        data.recycle();
810    }
811
812    public void processInBackground() throws RemoteException {
813        Parcel data = Parcel.obtain();
814        data.writeInterfaceToken(IApplicationThread.descriptor);
815        mRemote.transact(PROCESS_IN_BACKGROUND_TRANSACTION, data, null,
816                IBinder.FLAG_ONEWAY);
817        data.recycle();
818    }
819
820    public void dumpService(FileDescriptor fd, IBinder token, String[] args)
821            throws RemoteException {
822        Parcel data = Parcel.obtain();
823        data.writeInterfaceToken(IApplicationThread.descriptor);
824        data.writeFileDescriptor(fd);
825        data.writeStrongBinder(token);
826        data.writeStringArray(args);
827        mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
828        data.recycle();
829    }
830
831    public void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent,
832            int resultCode, String dataStr, Bundle extras, boolean ordered, boolean sticky)
833            throws RemoteException {
834        Parcel data = Parcel.obtain();
835        data.writeInterfaceToken(IApplicationThread.descriptor);
836        data.writeStrongBinder(receiver.asBinder());
837        intent.writeToParcel(data, 0);
838        data.writeInt(resultCode);
839        data.writeString(dataStr);
840        data.writeBundle(extras);
841        data.writeInt(ordered ? 1 : 0);
842        data.writeInt(sticky ? 1 : 0);
843        mRemote.transact(SCHEDULE_REGISTERED_RECEIVER_TRANSACTION, data, null,
844                IBinder.FLAG_ONEWAY);
845        data.recycle();
846    }
847
848    public final void scheduleLowMemory() throws RemoteException {
849        Parcel data = Parcel.obtain();
850        data.writeInterfaceToken(IApplicationThread.descriptor);
851        mRemote.transact(SCHEDULE_LOW_MEMORY_TRANSACTION, data, null,
852                IBinder.FLAG_ONEWAY);
853        data.recycle();
854    }
855
856    public final void scheduleActivityConfigurationChanged(
857            IBinder token) throws RemoteException {
858        Parcel data = Parcel.obtain();
859        data.writeInterfaceToken(IApplicationThread.descriptor);
860        data.writeStrongBinder(token);
861        mRemote.transact(SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION, data, null,
862                IBinder.FLAG_ONEWAY);
863        data.recycle();
864    }
865
866    public void profilerControl(boolean start, String path,
867            ParcelFileDescriptor fd) throws RemoteException {
868        Parcel data = Parcel.obtain();
869        data.writeInterfaceToken(IApplicationThread.descriptor);
870        data.writeInt(start ? 1 : 0);
871        data.writeString(path);
872        if (fd != null) {
873            data.writeInt(1);
874            fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
875        } else {
876            data.writeInt(0);
877        }
878        mRemote.transact(PROFILER_CONTROL_TRANSACTION, data, null,
879                IBinder.FLAG_ONEWAY);
880        data.recycle();
881    }
882
883    public void setSchedulingGroup(int group) throws RemoteException {
884        Parcel data = Parcel.obtain();
885        data.writeInterfaceToken(IApplicationThread.descriptor);
886        data.writeInt(group);
887        mRemote.transact(SET_SCHEDULING_GROUP_TRANSACTION, data, null,
888                IBinder.FLAG_ONEWAY);
889        data.recycle();
890    }
891
892    public void getMemoryInfo(Debug.MemoryInfo outInfo) throws RemoteException {
893        Parcel data = Parcel.obtain();
894        Parcel reply = Parcel.obtain();
895        data.writeInterfaceToken(IApplicationThread.descriptor);
896        mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
897        reply.readException();
898        outInfo.readFromParcel(reply);
899        data.recycle();
900        reply.recycle();
901    }
902
903    public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException {
904        Parcel data = Parcel.obtain();
905        data.writeInterfaceToken(IApplicationThread.descriptor);
906        data.writeInt(cmd);
907        data.writeStringArray(packages);
908        mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null,
909                IBinder.FLAG_ONEWAY);
910        data.recycle();
911
912    }
913
914    public void scheduleCrash(String msg) throws RemoteException {
915        Parcel data = Parcel.obtain();
916        data.writeInterfaceToken(IApplicationThread.descriptor);
917        data.writeString(msg);
918        mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null,
919                IBinder.FLAG_ONEWAY);
920        data.recycle();
921
922    }
923
924    public void dumpHeap(boolean managed, String path,
925            ParcelFileDescriptor fd) throws RemoteException {
926        Parcel data = Parcel.obtain();
927        data.writeInterfaceToken(IApplicationThread.descriptor);
928        data.writeInt(managed ? 1 : 0);
929        data.writeString(path);
930        if (fd != null) {
931            data.writeInt(1);
932            fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
933        } else {
934            data.writeInt(0);
935        }
936        mRemote.transact(DUMP_HEAP_TRANSACTION, data, null,
937                IBinder.FLAG_ONEWAY);
938        data.recycle();
939    }
940
941    public void dumpActivity(FileDescriptor fd, IBinder token, String prefix, String[] args)
942            throws RemoteException {
943        Parcel data = Parcel.obtain();
944        data.writeInterfaceToken(IApplicationThread.descriptor);
945        data.writeFileDescriptor(fd);
946        data.writeStrongBinder(token);
947        data.writeString(prefix);
948        data.writeStringArray(args);
949        mRemote.transact(DUMP_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY);
950        data.recycle();
951    }
952
953    public void setCoreSettings(Bundle coreSettings) throws RemoteException {
954        Parcel data = Parcel.obtain();
955        data.writeInterfaceToken(IApplicationThread.descriptor);
956        data.writeBundle(coreSettings);
957        mRemote.transact(SET_CORE_SETTINGS, data, null, IBinder.FLAG_ONEWAY);
958    }
959}
960