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