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