• 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.IIntentReceiver;
21 import android.content.IIntentSender;
22 import android.content.Intent;
23 import android.content.IntentFilter;
24 import android.content.IntentSender;
25 import android.content.pm.ApplicationInfo;
26 import android.content.pm.ConfigurationInfo;
27 import android.content.pm.IPackageDataObserver;
28 import android.content.pm.UserInfo;
29 import android.content.res.Configuration;
30 import android.graphics.Bitmap;
31 import android.net.Uri;
32 import android.os.Binder;
33 import android.os.Bundle;
34 import android.os.Debug;
35 import android.os.IBinder;
36 import android.os.Parcel;
37 import android.os.ParcelFileDescriptor;
38 import android.os.Parcelable;
39 import android.os.RemoteException;
40 import android.os.ServiceManager;
41 import android.os.StrictMode;
42 import android.os.UserHandle;
43 import android.text.TextUtils;
44 import android.util.Log;
45 import android.util.Singleton;
46 
47 import java.util.ArrayList;
48 import java.util.List;
49 
50 /** {@hide} */
51 public abstract class ActivityManagerNative extends Binder implements IActivityManager
52 {
53     /**
54      * Cast a Binder object into an activity manager interface, generating
55      * a proxy if needed.
56      */
asInterface(IBinder obj)57     static public IActivityManager asInterface(IBinder obj) {
58         if (obj == null) {
59             return null;
60         }
61         IActivityManager in =
62             (IActivityManager)obj.queryLocalInterface(descriptor);
63         if (in != null) {
64             return in;
65         }
66 
67         return new ActivityManagerProxy(obj);
68     }
69 
70     /**
71      * Retrieve the system's default/global activity manager.
72      */
getDefault()73     static public IActivityManager getDefault() {
74         return gDefault.get();
75     }
76 
77     /**
78      * Convenience for checking whether the system is ready.  For internal use only.
79      */
isSystemReady()80     static public boolean isSystemReady() {
81         if (!sSystemReady) {
82             sSystemReady = getDefault().testIsSystemReady();
83         }
84         return sSystemReady;
85     }
86     static boolean sSystemReady = false;
87 
88     /**
89      * Convenience for sending a sticky broadcast.  For internal use only.
90      * If you don't care about permission, use null.
91      */
broadcastStickyIntent(Intent intent, String permission, int userId)92     static public void broadcastStickyIntent(Intent intent, String permission, int userId) {
93         try {
94             getDefault().broadcastIntent(
95                 null, intent, null, null, Activity.RESULT_OK, null, null,
96                 null /*permission*/, false, true, userId);
97         } catch (RemoteException ex) {
98         }
99     }
100 
noteWakeupAlarm(PendingIntent ps)101     static public void noteWakeupAlarm(PendingIntent ps) {
102         try {
103             getDefault().noteWakeupAlarm(ps.getTarget());
104         } catch (RemoteException ex) {
105         }
106     }
107 
ActivityManagerNative()108     public ActivityManagerNative() {
109         attachInterface(this, descriptor);
110     }
111 
onTransact(int code, Parcel data, Parcel reply, int flags)112     public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
113             throws RemoteException {
114         switch (code) {
115         case START_ACTIVITY_TRANSACTION:
116         {
117             data.enforceInterface(IActivityManager.descriptor);
118             IBinder b = data.readStrongBinder();
119             IApplicationThread app = ApplicationThreadNative.asInterface(b);
120             Intent intent = Intent.CREATOR.createFromParcel(data);
121             String resolvedType = data.readString();
122             IBinder resultTo = data.readStrongBinder();
123             String resultWho = data.readString();
124             int requestCode = data.readInt();
125             int startFlags = data.readInt();
126             String profileFile = data.readString();
127             ParcelFileDescriptor profileFd = data.readInt() != 0
128                     ? data.readFileDescriptor() : null;
129             Bundle options = data.readInt() != 0
130                     ? Bundle.CREATOR.createFromParcel(data) : null;
131             int result = startActivity(app, intent, resolvedType,
132                     resultTo, resultWho, requestCode, startFlags,
133                     profileFile, profileFd, options);
134             reply.writeNoException();
135             reply.writeInt(result);
136             return true;
137         }
138 
139         case START_ACTIVITY_AS_USER_TRANSACTION:
140         {
141             data.enforceInterface(IActivityManager.descriptor);
142             IBinder b = data.readStrongBinder();
143             IApplicationThread app = ApplicationThreadNative.asInterface(b);
144             Intent intent = Intent.CREATOR.createFromParcel(data);
145             String resolvedType = data.readString();
146             IBinder resultTo = data.readStrongBinder();
147             String resultWho = data.readString();
148             int requestCode = data.readInt();
149             int startFlags = data.readInt();
150             String profileFile = data.readString();
151             ParcelFileDescriptor profileFd = data.readInt() != 0
152                     ? data.readFileDescriptor() : null;
153             Bundle options = data.readInt() != 0
154                     ? Bundle.CREATOR.createFromParcel(data) : null;
155             int userId = data.readInt();
156             int result = startActivityAsUser(app, intent, resolvedType,
157                     resultTo, resultWho, requestCode, startFlags,
158                     profileFile, profileFd, options, userId);
159             reply.writeNoException();
160             reply.writeInt(result);
161             return true;
162         }
163 
164         case START_ACTIVITY_AND_WAIT_TRANSACTION:
165         {
166             data.enforceInterface(IActivityManager.descriptor);
167             IBinder b = data.readStrongBinder();
168             IApplicationThread app = ApplicationThreadNative.asInterface(b);
169             Intent intent = Intent.CREATOR.createFromParcel(data);
170             String resolvedType = data.readString();
171             IBinder resultTo = data.readStrongBinder();
172             String resultWho = data.readString();
173             int requestCode = data.readInt();
174             int startFlags = data.readInt();
175             String profileFile = data.readString();
176             ParcelFileDescriptor profileFd = data.readInt() != 0
177                     ? data.readFileDescriptor() : null;
178             Bundle options = data.readInt() != 0
179                     ? Bundle.CREATOR.createFromParcel(data) : null;
180             int userId = data.readInt();
181             WaitResult result = startActivityAndWait(app, intent, resolvedType,
182                     resultTo, resultWho, requestCode, startFlags,
183                     profileFile, profileFd, options, userId);
184             reply.writeNoException();
185             result.writeToParcel(reply, 0);
186             return true;
187         }
188 
189         case START_ACTIVITY_WITH_CONFIG_TRANSACTION:
190         {
191             data.enforceInterface(IActivityManager.descriptor);
192             IBinder b = data.readStrongBinder();
193             IApplicationThread app = ApplicationThreadNative.asInterface(b);
194             Intent intent = Intent.CREATOR.createFromParcel(data);
195             String resolvedType = data.readString();
196             IBinder resultTo = data.readStrongBinder();
197             String resultWho = data.readString();
198             int requestCode = data.readInt();
199             int startFlags = data.readInt();
200             Configuration config = Configuration.CREATOR.createFromParcel(data);
201             Bundle options = data.readInt() != 0
202                     ? Bundle.CREATOR.createFromParcel(data) : null;
203             int userId = data.readInt();
204             int result = startActivityWithConfig(app, intent, resolvedType,
205                     resultTo, resultWho, requestCode, startFlags, config, options, userId);
206             reply.writeNoException();
207             reply.writeInt(result);
208             return true;
209         }
210 
211         case START_ACTIVITY_INTENT_SENDER_TRANSACTION:
212         {
213             data.enforceInterface(IActivityManager.descriptor);
214             IBinder b = data.readStrongBinder();
215             IApplicationThread app = ApplicationThreadNative.asInterface(b);
216             IntentSender intent = IntentSender.CREATOR.createFromParcel(data);
217             Intent fillInIntent = null;
218             if (data.readInt() != 0) {
219                 fillInIntent = Intent.CREATOR.createFromParcel(data);
220             }
221             String resolvedType = data.readString();
222             IBinder resultTo = data.readStrongBinder();
223             String resultWho = data.readString();
224             int requestCode = data.readInt();
225             int flagsMask = data.readInt();
226             int flagsValues = data.readInt();
227             Bundle options = data.readInt() != 0
228                     ? Bundle.CREATOR.createFromParcel(data) : null;
229             int result = startActivityIntentSender(app, intent,
230                     fillInIntent, resolvedType, resultTo, resultWho,
231                     requestCode, flagsMask, flagsValues, options);
232             reply.writeNoException();
233             reply.writeInt(result);
234             return true;
235         }
236 
237         case START_NEXT_MATCHING_ACTIVITY_TRANSACTION:
238         {
239             data.enforceInterface(IActivityManager.descriptor);
240             IBinder callingActivity = data.readStrongBinder();
241             Intent intent = Intent.CREATOR.createFromParcel(data);
242             Bundle options = data.readInt() != 0
243                     ? Bundle.CREATOR.createFromParcel(data) : null;
244             boolean result = startNextMatchingActivity(callingActivity, intent, options);
245             reply.writeNoException();
246             reply.writeInt(result ? 1 : 0);
247             return true;
248         }
249 
250         case FINISH_ACTIVITY_TRANSACTION: {
251             data.enforceInterface(IActivityManager.descriptor);
252             IBinder token = data.readStrongBinder();
253             Intent resultData = null;
254             int resultCode = data.readInt();
255             if (data.readInt() != 0) {
256                 resultData = Intent.CREATOR.createFromParcel(data);
257             }
258             boolean res = finishActivity(token, resultCode, resultData);
259             reply.writeNoException();
260             reply.writeInt(res ? 1 : 0);
261             return true;
262         }
263 
264         case FINISH_SUB_ACTIVITY_TRANSACTION: {
265             data.enforceInterface(IActivityManager.descriptor);
266             IBinder token = data.readStrongBinder();
267             String resultWho = data.readString();
268             int requestCode = data.readInt();
269             finishSubActivity(token, resultWho, requestCode);
270             reply.writeNoException();
271             return true;
272         }
273 
274         case FINISH_ACTIVITY_AFFINITY_TRANSACTION: {
275             data.enforceInterface(IActivityManager.descriptor);
276             IBinder token = data.readStrongBinder();
277             boolean res = finishActivityAffinity(token);
278             reply.writeNoException();
279             reply.writeInt(res ? 1 : 0);
280             return true;
281         }
282 
283         case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: {
284             data.enforceInterface(IActivityManager.descriptor);
285             IBinder token = data.readStrongBinder();
286             boolean res = willActivityBeVisible(token);
287             reply.writeNoException();
288             reply.writeInt(res ? 1 : 0);
289             return true;
290         }
291 
292         case REGISTER_RECEIVER_TRANSACTION:
293         {
294             data.enforceInterface(IActivityManager.descriptor);
295             IBinder b = data.readStrongBinder();
296             IApplicationThread app =
297                 b != null ? ApplicationThreadNative.asInterface(b) : null;
298             String packageName = data.readString();
299             b = data.readStrongBinder();
300             IIntentReceiver rec
301                 = b != null ? IIntentReceiver.Stub.asInterface(b) : null;
302             IntentFilter filter = IntentFilter.CREATOR.createFromParcel(data);
303             String perm = data.readString();
304             int userId = data.readInt();
305             Intent intent = registerReceiver(app, packageName, rec, filter, perm, userId);
306             reply.writeNoException();
307             if (intent != null) {
308                 reply.writeInt(1);
309                 intent.writeToParcel(reply, 0);
310             } else {
311                 reply.writeInt(0);
312             }
313             return true;
314         }
315 
316         case UNREGISTER_RECEIVER_TRANSACTION:
317         {
318             data.enforceInterface(IActivityManager.descriptor);
319             IBinder b = data.readStrongBinder();
320             if (b == null) {
321                 return true;
322             }
323             IIntentReceiver rec = IIntentReceiver.Stub.asInterface(b);
324             unregisterReceiver(rec);
325             reply.writeNoException();
326             return true;
327         }
328 
329         case BROADCAST_INTENT_TRANSACTION:
330         {
331             data.enforceInterface(IActivityManager.descriptor);
332             IBinder b = data.readStrongBinder();
333             IApplicationThread app =
334                 b != null ? ApplicationThreadNative.asInterface(b) : null;
335             Intent intent = Intent.CREATOR.createFromParcel(data);
336             String resolvedType = data.readString();
337             b = data.readStrongBinder();
338             IIntentReceiver resultTo =
339                 b != null ? IIntentReceiver.Stub.asInterface(b) : null;
340             int resultCode = data.readInt();
341             String resultData = data.readString();
342             Bundle resultExtras = data.readBundle();
343             String perm = data.readString();
344             boolean serialized = data.readInt() != 0;
345             boolean sticky = data.readInt() != 0;
346             int userId = data.readInt();
347             int res = broadcastIntent(app, intent, resolvedType, resultTo,
348                     resultCode, resultData, resultExtras, perm,
349                     serialized, sticky, userId);
350             reply.writeNoException();
351             reply.writeInt(res);
352             return true;
353         }
354 
355         case UNBROADCAST_INTENT_TRANSACTION:
356         {
357             data.enforceInterface(IActivityManager.descriptor);
358             IBinder b = data.readStrongBinder();
359             IApplicationThread app = b != null ? ApplicationThreadNative.asInterface(b) : null;
360             Intent intent = Intent.CREATOR.createFromParcel(data);
361             int userId = data.readInt();
362             unbroadcastIntent(app, intent, userId);
363             reply.writeNoException();
364             return true;
365         }
366 
367         case FINISH_RECEIVER_TRANSACTION: {
368             data.enforceInterface(IActivityManager.descriptor);
369             IBinder who = data.readStrongBinder();
370             int resultCode = data.readInt();
371             String resultData = data.readString();
372             Bundle resultExtras = data.readBundle();
373             boolean resultAbort = data.readInt() != 0;
374             if (who != null) {
375                 finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
376             }
377             reply.writeNoException();
378             return true;
379         }
380 
381         case ATTACH_APPLICATION_TRANSACTION: {
382             data.enforceInterface(IActivityManager.descriptor);
383             IApplicationThread app = ApplicationThreadNative.asInterface(
384                     data.readStrongBinder());
385             if (app != null) {
386                 attachApplication(app);
387             }
388             reply.writeNoException();
389             return true;
390         }
391 
392         case ACTIVITY_IDLE_TRANSACTION: {
393             data.enforceInterface(IActivityManager.descriptor);
394             IBinder token = data.readStrongBinder();
395             Configuration config = null;
396             if (data.readInt() != 0) {
397                 config = Configuration.CREATOR.createFromParcel(data);
398             }
399             boolean stopProfiling = data.readInt() != 0;
400             if (token != null) {
401                 activityIdle(token, config, stopProfiling);
402             }
403             reply.writeNoException();
404             return true;
405         }
406 
407         case ACTIVITY_RESUMED_TRANSACTION: {
408             data.enforceInterface(IActivityManager.descriptor);
409             IBinder token = data.readStrongBinder();
410             activityResumed(token);
411             reply.writeNoException();
412             return true;
413         }
414 
415         case ACTIVITY_PAUSED_TRANSACTION: {
416             data.enforceInterface(IActivityManager.descriptor);
417             IBinder token = data.readStrongBinder();
418             activityPaused(token);
419             reply.writeNoException();
420             return true;
421         }
422 
423         case ACTIVITY_STOPPED_TRANSACTION: {
424             data.enforceInterface(IActivityManager.descriptor);
425             IBinder token = data.readStrongBinder();
426             Bundle map = data.readBundle();
427             Bitmap thumbnail = data.readInt() != 0
428                 ? Bitmap.CREATOR.createFromParcel(data) : null;
429             CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
430             activityStopped(token, map, thumbnail, description);
431             reply.writeNoException();
432             return true;
433         }
434 
435         case ACTIVITY_SLEPT_TRANSACTION: {
436             data.enforceInterface(IActivityManager.descriptor);
437             IBinder token = data.readStrongBinder();
438             activitySlept(token);
439             reply.writeNoException();
440             return true;
441         }
442 
443         case ACTIVITY_DESTROYED_TRANSACTION: {
444             data.enforceInterface(IActivityManager.descriptor);
445             IBinder token = data.readStrongBinder();
446             activityDestroyed(token);
447             reply.writeNoException();
448             return true;
449         }
450 
451         case GET_CALLING_PACKAGE_TRANSACTION: {
452             data.enforceInterface(IActivityManager.descriptor);
453             IBinder token = data.readStrongBinder();
454             String res = token != null ? getCallingPackage(token) : null;
455             reply.writeNoException();
456             reply.writeString(res);
457             return true;
458         }
459 
460         case GET_CALLING_ACTIVITY_TRANSACTION: {
461             data.enforceInterface(IActivityManager.descriptor);
462             IBinder token = data.readStrongBinder();
463             ComponentName cn = getCallingActivity(token);
464             reply.writeNoException();
465             ComponentName.writeToParcel(cn, reply);
466             return true;
467         }
468 
469         case GET_TASKS_TRANSACTION: {
470             data.enforceInterface(IActivityManager.descriptor);
471             int maxNum = data.readInt();
472             int fl = data.readInt();
473             IBinder receiverBinder = data.readStrongBinder();
474             IThumbnailReceiver receiver = receiverBinder != null
475                 ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
476                 : null;
477             List list = getTasks(maxNum, fl, receiver);
478             reply.writeNoException();
479             int N = list != null ? list.size() : -1;
480             reply.writeInt(N);
481             int i;
482             for (i=0; i<N; i++) {
483                 ActivityManager.RunningTaskInfo info =
484                         (ActivityManager.RunningTaskInfo)list.get(i);
485                 info.writeToParcel(reply, 0);
486             }
487             return true;
488         }
489 
490         case GET_RECENT_TASKS_TRANSACTION: {
491             data.enforceInterface(IActivityManager.descriptor);
492             int maxNum = data.readInt();
493             int fl = data.readInt();
494             int userId = data.readInt();
495             List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
496                     fl, userId);
497             reply.writeNoException();
498             reply.writeTypedList(list);
499             return true;
500         }
501 
502         case GET_TASK_THUMBNAILS_TRANSACTION: {
503             data.enforceInterface(IActivityManager.descriptor);
504             int id = data.readInt();
505             ActivityManager.TaskThumbnails bm = getTaskThumbnails(id);
506             reply.writeNoException();
507             if (bm != null) {
508                 reply.writeInt(1);
509                 bm.writeToParcel(reply, 0);
510             } else {
511                 reply.writeInt(0);
512             }
513             return true;
514         }
515 
516         case GET_TASK_TOP_THUMBNAIL_TRANSACTION: {
517             data.enforceInterface(IActivityManager.descriptor);
518             int id = data.readInt();
519             Bitmap bm = getTaskTopThumbnail(id);
520             reply.writeNoException();
521             if (bm != null) {
522                 reply.writeInt(1);
523                 bm.writeToParcel(reply, 0);
524             } else {
525                 reply.writeInt(0);
526             }
527             return true;
528         }
529 
530         case GET_SERVICES_TRANSACTION: {
531             data.enforceInterface(IActivityManager.descriptor);
532             int maxNum = data.readInt();
533             int fl = data.readInt();
534             List list = getServices(maxNum, fl);
535             reply.writeNoException();
536             int N = list != null ? list.size() : -1;
537             reply.writeInt(N);
538             int i;
539             for (i=0; i<N; i++) {
540                 ActivityManager.RunningServiceInfo info =
541                         (ActivityManager.RunningServiceInfo)list.get(i);
542                 info.writeToParcel(reply, 0);
543             }
544             return true;
545         }
546 
547         case GET_PROCESSES_IN_ERROR_STATE_TRANSACTION: {
548             data.enforceInterface(IActivityManager.descriptor);
549             List<ActivityManager.ProcessErrorStateInfo> list = getProcessesInErrorState();
550             reply.writeNoException();
551             reply.writeTypedList(list);
552             return true;
553         }
554 
555         case GET_RUNNING_APP_PROCESSES_TRANSACTION: {
556             data.enforceInterface(IActivityManager.descriptor);
557             List<ActivityManager.RunningAppProcessInfo> list = getRunningAppProcesses();
558             reply.writeNoException();
559             reply.writeTypedList(list);
560             return true;
561         }
562 
563         case GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION: {
564             data.enforceInterface(IActivityManager.descriptor);
565             List<ApplicationInfo> list = getRunningExternalApplications();
566             reply.writeNoException();
567             reply.writeTypedList(list);
568             return true;
569         }
570 
571         case MOVE_TASK_TO_FRONT_TRANSACTION: {
572             data.enforceInterface(IActivityManager.descriptor);
573             int task = data.readInt();
574             int fl = data.readInt();
575             Bundle options = data.readInt() != 0
576                     ? Bundle.CREATOR.createFromParcel(data) : null;
577             moveTaskToFront(task, fl, options);
578             reply.writeNoException();
579             return true;
580         }
581 
582         case MOVE_TASK_TO_BACK_TRANSACTION: {
583             data.enforceInterface(IActivityManager.descriptor);
584             int task = data.readInt();
585             moveTaskToBack(task);
586             reply.writeNoException();
587             return true;
588         }
589 
590         case MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION: {
591             data.enforceInterface(IActivityManager.descriptor);
592             IBinder token = data.readStrongBinder();
593             boolean nonRoot = data.readInt() != 0;
594             boolean res = moveActivityTaskToBack(token, nonRoot);
595             reply.writeNoException();
596             reply.writeInt(res ? 1 : 0);
597             return true;
598         }
599 
600         case MOVE_TASK_BACKWARDS_TRANSACTION: {
601             data.enforceInterface(IActivityManager.descriptor);
602             int task = data.readInt();
603             moveTaskBackwards(task);
604             reply.writeNoException();
605             return true;
606         }
607 
608         case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
609             data.enforceInterface(IActivityManager.descriptor);
610             IBinder token = data.readStrongBinder();
611             boolean onlyRoot = data.readInt() != 0;
612             int res = token != null
613                 ? getTaskForActivity(token, onlyRoot) : -1;
614                 reply.writeNoException();
615             reply.writeInt(res);
616             return true;
617         }
618 
619         case REPORT_THUMBNAIL_TRANSACTION: {
620             data.enforceInterface(IActivityManager.descriptor);
621             IBinder token = data.readStrongBinder();
622             Bitmap thumbnail = data.readInt() != 0
623                 ? Bitmap.CREATOR.createFromParcel(data) : null;
624             CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
625             reportThumbnail(token, thumbnail, description);
626             reply.writeNoException();
627             return true;
628         }
629 
630         case GET_CONTENT_PROVIDER_TRANSACTION: {
631             data.enforceInterface(IActivityManager.descriptor);
632             IBinder b = data.readStrongBinder();
633             IApplicationThread app = ApplicationThreadNative.asInterface(b);
634             String name = data.readString();
635             int userId = data.readInt();
636             boolean stable = data.readInt() != 0;
637             ContentProviderHolder cph = getContentProvider(app, name, userId, stable);
638             reply.writeNoException();
639             if (cph != null) {
640                 reply.writeInt(1);
641                 cph.writeToParcel(reply, 0);
642             } else {
643                 reply.writeInt(0);
644             }
645             return true;
646         }
647 
648         case GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION: {
649             data.enforceInterface(IActivityManager.descriptor);
650             String name = data.readString();
651             int userId = data.readInt();
652             IBinder token = data.readStrongBinder();
653             ContentProviderHolder cph = getContentProviderExternal(name, userId, token);
654             reply.writeNoException();
655             if (cph != null) {
656                 reply.writeInt(1);
657                 cph.writeToParcel(reply, 0);
658             } else {
659                 reply.writeInt(0);
660             }
661             return true;
662         }
663 
664         case PUBLISH_CONTENT_PROVIDERS_TRANSACTION: {
665             data.enforceInterface(IActivityManager.descriptor);
666             IBinder b = data.readStrongBinder();
667             IApplicationThread app = ApplicationThreadNative.asInterface(b);
668             ArrayList<ContentProviderHolder> providers =
669                 data.createTypedArrayList(ContentProviderHolder.CREATOR);
670             publishContentProviders(app, providers);
671             reply.writeNoException();
672             return true;
673         }
674 
675         case REF_CONTENT_PROVIDER_TRANSACTION: {
676             data.enforceInterface(IActivityManager.descriptor);
677             IBinder b = data.readStrongBinder();
678             int stable = data.readInt();
679             int unstable = data.readInt();
680             boolean res = refContentProvider(b, stable, unstable);
681             reply.writeNoException();
682             reply.writeInt(res ? 1 : 0);
683             return true;
684         }
685 
686         case UNSTABLE_PROVIDER_DIED_TRANSACTION: {
687             data.enforceInterface(IActivityManager.descriptor);
688             IBinder b = data.readStrongBinder();
689             unstableProviderDied(b);
690             reply.writeNoException();
691             return true;
692         }
693 
694         case REMOVE_CONTENT_PROVIDER_TRANSACTION: {
695             data.enforceInterface(IActivityManager.descriptor);
696             IBinder b = data.readStrongBinder();
697             boolean stable = data.readInt() != 0;
698             removeContentProvider(b, stable);
699             reply.writeNoException();
700             return true;
701         }
702 
703         case REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION: {
704             data.enforceInterface(IActivityManager.descriptor);
705             String name = data.readString();
706             IBinder token = data.readStrongBinder();
707             removeContentProviderExternal(name, token);
708             reply.writeNoException();
709             return true;
710         }
711 
712         case GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION: {
713             data.enforceInterface(IActivityManager.descriptor);
714             ComponentName comp = ComponentName.CREATOR.createFromParcel(data);
715             PendingIntent pi = getRunningServiceControlPanel(comp);
716             reply.writeNoException();
717             PendingIntent.writePendingIntentOrNullToParcel(pi, reply);
718             return true;
719         }
720 
721         case START_SERVICE_TRANSACTION: {
722             data.enforceInterface(IActivityManager.descriptor);
723             IBinder b = data.readStrongBinder();
724             IApplicationThread app = ApplicationThreadNative.asInterface(b);
725             Intent service = Intent.CREATOR.createFromParcel(data);
726             String resolvedType = data.readString();
727             int userId = data.readInt();
728             ComponentName cn = startService(app, service, resolvedType, userId);
729             reply.writeNoException();
730             ComponentName.writeToParcel(cn, reply);
731             return true;
732         }
733 
734         case STOP_SERVICE_TRANSACTION: {
735             data.enforceInterface(IActivityManager.descriptor);
736             IBinder b = data.readStrongBinder();
737             IApplicationThread app = ApplicationThreadNative.asInterface(b);
738             Intent service = Intent.CREATOR.createFromParcel(data);
739             String resolvedType = data.readString();
740             int userId = data.readInt();
741             int res = stopService(app, service, resolvedType, userId);
742             reply.writeNoException();
743             reply.writeInt(res);
744             return true;
745         }
746 
747         case STOP_SERVICE_TOKEN_TRANSACTION: {
748             data.enforceInterface(IActivityManager.descriptor);
749             ComponentName className = ComponentName.readFromParcel(data);
750             IBinder token = data.readStrongBinder();
751             int startId = data.readInt();
752             boolean res = stopServiceToken(className, token, startId);
753             reply.writeNoException();
754             reply.writeInt(res ? 1 : 0);
755             return true;
756         }
757 
758         case SET_SERVICE_FOREGROUND_TRANSACTION: {
759             data.enforceInterface(IActivityManager.descriptor);
760             ComponentName className = ComponentName.readFromParcel(data);
761             IBinder token = data.readStrongBinder();
762             int id = data.readInt();
763             Notification notification = null;
764             if (data.readInt() != 0) {
765                 notification = Notification.CREATOR.createFromParcel(data);
766             }
767             boolean removeNotification = data.readInt() != 0;
768             setServiceForeground(className, token, id, notification, removeNotification);
769             reply.writeNoException();
770             return true;
771         }
772 
773         case BIND_SERVICE_TRANSACTION: {
774             data.enforceInterface(IActivityManager.descriptor);
775             IBinder b = data.readStrongBinder();
776             IApplicationThread app = ApplicationThreadNative.asInterface(b);
777             IBinder token = data.readStrongBinder();
778             Intent service = Intent.CREATOR.createFromParcel(data);
779             String resolvedType = data.readString();
780             b = data.readStrongBinder();
781             int fl = data.readInt();
782             int userId = data.readInt();
783             IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
784             int res = bindService(app, token, service, resolvedType, conn, fl, userId);
785             reply.writeNoException();
786             reply.writeInt(res);
787             return true;
788         }
789 
790         case UNBIND_SERVICE_TRANSACTION: {
791             data.enforceInterface(IActivityManager.descriptor);
792             IBinder b = data.readStrongBinder();
793             IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
794             boolean res = unbindService(conn);
795             reply.writeNoException();
796             reply.writeInt(res ? 1 : 0);
797             return true;
798         }
799 
800         case PUBLISH_SERVICE_TRANSACTION: {
801             data.enforceInterface(IActivityManager.descriptor);
802             IBinder token = data.readStrongBinder();
803             Intent intent = Intent.CREATOR.createFromParcel(data);
804             IBinder service = data.readStrongBinder();
805             publishService(token, intent, service);
806             reply.writeNoException();
807             return true;
808         }
809 
810         case UNBIND_FINISHED_TRANSACTION: {
811             data.enforceInterface(IActivityManager.descriptor);
812             IBinder token = data.readStrongBinder();
813             Intent intent = Intent.CREATOR.createFromParcel(data);
814             boolean doRebind = data.readInt() != 0;
815             unbindFinished(token, intent, doRebind);
816             reply.writeNoException();
817             return true;
818         }
819 
820         case SERVICE_DONE_EXECUTING_TRANSACTION: {
821             data.enforceInterface(IActivityManager.descriptor);
822             IBinder token = data.readStrongBinder();
823             int type = data.readInt();
824             int startId = data.readInt();
825             int res = data.readInt();
826             serviceDoneExecuting(token, type, startId, res);
827             reply.writeNoException();
828             return true;
829         }
830 
831         case START_INSTRUMENTATION_TRANSACTION: {
832             data.enforceInterface(IActivityManager.descriptor);
833             ComponentName className = ComponentName.readFromParcel(data);
834             String profileFile = data.readString();
835             int fl = data.readInt();
836             Bundle arguments = data.readBundle();
837             IBinder b = data.readStrongBinder();
838             IInstrumentationWatcher w = IInstrumentationWatcher.Stub.asInterface(b);
839             int userId = data.readInt();
840             boolean res = startInstrumentation(className, profileFile, fl, arguments, w, userId);
841             reply.writeNoException();
842             reply.writeInt(res ? 1 : 0);
843             return true;
844         }
845 
846 
847         case FINISH_INSTRUMENTATION_TRANSACTION: {
848             data.enforceInterface(IActivityManager.descriptor);
849             IBinder b = data.readStrongBinder();
850             IApplicationThread app = ApplicationThreadNative.asInterface(b);
851             int resultCode = data.readInt();
852             Bundle results = data.readBundle();
853             finishInstrumentation(app, resultCode, results);
854             reply.writeNoException();
855             return true;
856         }
857 
858         case GET_CONFIGURATION_TRANSACTION: {
859             data.enforceInterface(IActivityManager.descriptor);
860             Configuration config = getConfiguration();
861             reply.writeNoException();
862             config.writeToParcel(reply, 0);
863             return true;
864         }
865 
866         case UPDATE_CONFIGURATION_TRANSACTION: {
867             data.enforceInterface(IActivityManager.descriptor);
868             Configuration config = Configuration.CREATOR.createFromParcel(data);
869             updateConfiguration(config);
870             reply.writeNoException();
871             return true;
872         }
873 
874         case SET_REQUESTED_ORIENTATION_TRANSACTION: {
875             data.enforceInterface(IActivityManager.descriptor);
876             IBinder token = data.readStrongBinder();
877             int requestedOrientation = data.readInt();
878             setRequestedOrientation(token, requestedOrientation);
879             reply.writeNoException();
880             return true;
881         }
882 
883         case GET_REQUESTED_ORIENTATION_TRANSACTION: {
884             data.enforceInterface(IActivityManager.descriptor);
885             IBinder token = data.readStrongBinder();
886             int req = getRequestedOrientation(token);
887             reply.writeNoException();
888             reply.writeInt(req);
889             return true;
890         }
891 
892         case GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION: {
893             data.enforceInterface(IActivityManager.descriptor);
894             IBinder token = data.readStrongBinder();
895             ComponentName cn = getActivityClassForToken(token);
896             reply.writeNoException();
897             ComponentName.writeToParcel(cn, reply);
898             return true;
899         }
900 
901         case GET_PACKAGE_FOR_TOKEN_TRANSACTION: {
902             data.enforceInterface(IActivityManager.descriptor);
903             IBinder token = data.readStrongBinder();
904             reply.writeNoException();
905             reply.writeString(getPackageForToken(token));
906             return true;
907         }
908 
909         case GET_INTENT_SENDER_TRANSACTION: {
910             data.enforceInterface(IActivityManager.descriptor);
911             int type = data.readInt();
912             String packageName = data.readString();
913             IBinder token = data.readStrongBinder();
914             String resultWho = data.readString();
915             int requestCode = data.readInt();
916             Intent[] requestIntents;
917             String[] requestResolvedTypes;
918             if (data.readInt() != 0) {
919                 requestIntents = data.createTypedArray(Intent.CREATOR);
920                 requestResolvedTypes = data.createStringArray();
921             } else {
922                 requestIntents = null;
923                 requestResolvedTypes = null;
924             }
925             int fl = data.readInt();
926             Bundle options = data.readInt() != 0
927                     ? Bundle.CREATOR.createFromParcel(data) : null;
928             int userId = data.readInt();
929             IIntentSender res = getIntentSender(type, packageName, token,
930                     resultWho, requestCode, requestIntents,
931                     requestResolvedTypes, fl, options, userId);
932             reply.writeNoException();
933             reply.writeStrongBinder(res != null ? res.asBinder() : null);
934             return true;
935         }
936 
937         case CANCEL_INTENT_SENDER_TRANSACTION: {
938             data.enforceInterface(IActivityManager.descriptor);
939             IIntentSender r = IIntentSender.Stub.asInterface(
940                 data.readStrongBinder());
941             cancelIntentSender(r);
942             reply.writeNoException();
943             return true;
944         }
945 
946         case GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION: {
947             data.enforceInterface(IActivityManager.descriptor);
948             IIntentSender r = IIntentSender.Stub.asInterface(
949                 data.readStrongBinder());
950             String res = getPackageForIntentSender(r);
951             reply.writeNoException();
952             reply.writeString(res);
953             return true;
954         }
955 
956         case GET_UID_FOR_INTENT_SENDER_TRANSACTION: {
957             data.enforceInterface(IActivityManager.descriptor);
958             IIntentSender r = IIntentSender.Stub.asInterface(
959                 data.readStrongBinder());
960             int res = getUidForIntentSender(r);
961             reply.writeNoException();
962             reply.writeInt(res);
963             return true;
964         }
965 
966         case HANDLE_INCOMING_USER_TRANSACTION: {
967             data.enforceInterface(IActivityManager.descriptor);
968             int callingPid = data.readInt();
969             int callingUid = data.readInt();
970             int userId = data.readInt();
971             boolean allowAll = data.readInt() != 0 ;
972             boolean requireFull = data.readInt() != 0;
973             String name = data.readString();
974             String callerPackage = data.readString();
975             int res = handleIncomingUser(callingPid, callingUid, userId, allowAll,
976                     requireFull, name, callerPackage);
977             reply.writeNoException();
978             reply.writeInt(res);
979             return true;
980         }
981 
982         case SET_PROCESS_LIMIT_TRANSACTION: {
983             data.enforceInterface(IActivityManager.descriptor);
984             int max = data.readInt();
985             setProcessLimit(max);
986             reply.writeNoException();
987             return true;
988         }
989 
990         case GET_PROCESS_LIMIT_TRANSACTION: {
991             data.enforceInterface(IActivityManager.descriptor);
992             int limit = getProcessLimit();
993             reply.writeNoException();
994             reply.writeInt(limit);
995             return true;
996         }
997 
998         case SET_PROCESS_FOREGROUND_TRANSACTION: {
999             data.enforceInterface(IActivityManager.descriptor);
1000             IBinder token = data.readStrongBinder();
1001             int pid = data.readInt();
1002             boolean isForeground = data.readInt() != 0;
1003             setProcessForeground(token, pid, isForeground);
1004             reply.writeNoException();
1005             return true;
1006         }
1007 
1008         case CHECK_PERMISSION_TRANSACTION: {
1009             data.enforceInterface(IActivityManager.descriptor);
1010             String perm = data.readString();
1011             int pid = data.readInt();
1012             int uid = data.readInt();
1013             int res = checkPermission(perm, pid, uid);
1014             reply.writeNoException();
1015             reply.writeInt(res);
1016             return true;
1017         }
1018 
1019         case CHECK_URI_PERMISSION_TRANSACTION: {
1020             data.enforceInterface(IActivityManager.descriptor);
1021             Uri uri = Uri.CREATOR.createFromParcel(data);
1022             int pid = data.readInt();
1023             int uid = data.readInt();
1024             int mode = data.readInt();
1025             int res = checkUriPermission(uri, pid, uid, mode);
1026             reply.writeNoException();
1027             reply.writeInt(res);
1028             return true;
1029         }
1030 
1031         case CLEAR_APP_DATA_TRANSACTION: {
1032             data.enforceInterface(IActivityManager.descriptor);
1033             String packageName = data.readString();
1034             IPackageDataObserver observer = IPackageDataObserver.Stub.asInterface(
1035                     data.readStrongBinder());
1036             int userId = data.readInt();
1037             boolean res = clearApplicationUserData(packageName, observer, userId);
1038             reply.writeNoException();
1039             reply.writeInt(res ? 1 : 0);
1040             return true;
1041         }
1042 
1043         case GRANT_URI_PERMISSION_TRANSACTION: {
1044             data.enforceInterface(IActivityManager.descriptor);
1045             IBinder b = data.readStrongBinder();
1046             IApplicationThread app = ApplicationThreadNative.asInterface(b);
1047             String targetPkg = data.readString();
1048             Uri uri = Uri.CREATOR.createFromParcel(data);
1049             int mode = data.readInt();
1050             grantUriPermission(app, targetPkg, uri, mode);
1051             reply.writeNoException();
1052             return true;
1053         }
1054 
1055         case REVOKE_URI_PERMISSION_TRANSACTION: {
1056             data.enforceInterface(IActivityManager.descriptor);
1057             IBinder b = data.readStrongBinder();
1058             IApplicationThread app = ApplicationThreadNative.asInterface(b);
1059             Uri uri = Uri.CREATOR.createFromParcel(data);
1060             int mode = data.readInt();
1061             revokeUriPermission(app, uri, mode);
1062             reply.writeNoException();
1063             return true;
1064         }
1065 
1066         case SHOW_WAITING_FOR_DEBUGGER_TRANSACTION: {
1067             data.enforceInterface(IActivityManager.descriptor);
1068             IBinder b = data.readStrongBinder();
1069             IApplicationThread app = ApplicationThreadNative.asInterface(b);
1070             boolean waiting = data.readInt() != 0;
1071             showWaitingForDebugger(app, waiting);
1072             reply.writeNoException();
1073             return true;
1074         }
1075 
1076         case GET_MEMORY_INFO_TRANSACTION: {
1077             data.enforceInterface(IActivityManager.descriptor);
1078             ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
1079             getMemoryInfo(mi);
1080             reply.writeNoException();
1081             mi.writeToParcel(reply, 0);
1082             return true;
1083         }
1084 
1085         case UNHANDLED_BACK_TRANSACTION: {
1086             data.enforceInterface(IActivityManager.descriptor);
1087             unhandledBack();
1088             reply.writeNoException();
1089             return true;
1090         }
1091 
1092         case OPEN_CONTENT_URI_TRANSACTION: {
1093             data.enforceInterface(IActivityManager.descriptor);
1094             Uri uri = Uri.parse(data.readString());
1095             ParcelFileDescriptor pfd = openContentUri(uri);
1096             reply.writeNoException();
1097             if (pfd != null) {
1098                 reply.writeInt(1);
1099                 pfd.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1100             } else {
1101                 reply.writeInt(0);
1102             }
1103             return true;
1104         }
1105 
1106         case GOING_TO_SLEEP_TRANSACTION: {
1107             data.enforceInterface(IActivityManager.descriptor);
1108             goingToSleep();
1109             reply.writeNoException();
1110             return true;
1111         }
1112 
1113         case WAKING_UP_TRANSACTION: {
1114             data.enforceInterface(IActivityManager.descriptor);
1115             wakingUp();
1116             reply.writeNoException();
1117             return true;
1118         }
1119 
1120         case SET_LOCK_SCREEN_SHOWN_TRANSACTION: {
1121             data.enforceInterface(IActivityManager.descriptor);
1122             setLockScreenShown(data.readInt() != 0);
1123             reply.writeNoException();
1124             return true;
1125         }
1126 
1127         case SET_DEBUG_APP_TRANSACTION: {
1128             data.enforceInterface(IActivityManager.descriptor);
1129             String pn = data.readString();
1130             boolean wfd = data.readInt() != 0;
1131             boolean per = data.readInt() != 0;
1132             setDebugApp(pn, wfd, per);
1133             reply.writeNoException();
1134             return true;
1135         }
1136 
1137         case SET_ALWAYS_FINISH_TRANSACTION: {
1138             data.enforceInterface(IActivityManager.descriptor);
1139             boolean enabled = data.readInt() != 0;
1140             setAlwaysFinish(enabled);
1141             reply.writeNoException();
1142             return true;
1143         }
1144 
1145         case SET_ACTIVITY_CONTROLLER_TRANSACTION: {
1146             data.enforceInterface(IActivityManager.descriptor);
1147             IActivityController watcher = IActivityController.Stub.asInterface(
1148                     data.readStrongBinder());
1149             setActivityController(watcher);
1150             return true;
1151         }
1152 
1153         case ENTER_SAFE_MODE_TRANSACTION: {
1154             data.enforceInterface(IActivityManager.descriptor);
1155             enterSafeMode();
1156             reply.writeNoException();
1157             return true;
1158         }
1159 
1160         case NOTE_WAKEUP_ALARM_TRANSACTION: {
1161             data.enforceInterface(IActivityManager.descriptor);
1162             IIntentSender is = IIntentSender.Stub.asInterface(
1163                     data.readStrongBinder());
1164             noteWakeupAlarm(is);
1165             reply.writeNoException();
1166             return true;
1167         }
1168 
1169         case KILL_PIDS_TRANSACTION: {
1170             data.enforceInterface(IActivityManager.descriptor);
1171             int[] pids = data.createIntArray();
1172             String reason = data.readString();
1173             boolean secure = data.readInt() != 0;
1174             boolean res = killPids(pids, reason, secure);
1175             reply.writeNoException();
1176             reply.writeInt(res ? 1 : 0);
1177             return true;
1178         }
1179 
1180         case KILL_PROCESSES_BELOW_FOREGROUND_TRANSACTION: {
1181             data.enforceInterface(IActivityManager.descriptor);
1182             String reason = data.readString();
1183             boolean res = killProcessesBelowForeground(reason);
1184             reply.writeNoException();
1185             reply.writeInt(res ? 1 : 0);
1186             return true;
1187         }
1188 
1189         case START_RUNNING_TRANSACTION: {
1190             data.enforceInterface(IActivityManager.descriptor);
1191             String pkg = data.readString();
1192             String cls = data.readString();
1193             String action = data.readString();
1194             String indata = data.readString();
1195             startRunning(pkg, cls, action, indata);
1196             reply.writeNoException();
1197             return true;
1198         }
1199 
1200         case HANDLE_APPLICATION_CRASH_TRANSACTION: {
1201             data.enforceInterface(IActivityManager.descriptor);
1202             IBinder app = data.readStrongBinder();
1203             ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
1204             handleApplicationCrash(app, ci);
1205             reply.writeNoException();
1206             return true;
1207         }
1208 
1209         case HANDLE_APPLICATION_WTF_TRANSACTION: {
1210             data.enforceInterface(IActivityManager.descriptor);
1211             IBinder app = data.readStrongBinder();
1212             String tag = data.readString();
1213             ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
1214             boolean res = handleApplicationWtf(app, tag, ci);
1215             reply.writeNoException();
1216             reply.writeInt(res ? 1 : 0);
1217             return true;
1218         }
1219 
1220         case HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION: {
1221             data.enforceInterface(IActivityManager.descriptor);
1222             IBinder app = data.readStrongBinder();
1223             int violationMask = data.readInt();
1224             StrictMode.ViolationInfo info = new StrictMode.ViolationInfo(data);
1225             handleApplicationStrictModeViolation(app, violationMask, info);
1226             reply.writeNoException();
1227             return true;
1228         }
1229 
1230         case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
1231             data.enforceInterface(IActivityManager.descriptor);
1232             int sig = data.readInt();
1233             signalPersistentProcesses(sig);
1234             reply.writeNoException();
1235             return true;
1236         }
1237 
1238         case KILL_BACKGROUND_PROCESSES_TRANSACTION: {
1239             data.enforceInterface(IActivityManager.descriptor);
1240             String packageName = data.readString();
1241             int userId = data.readInt();
1242             killBackgroundProcesses(packageName, userId);
1243             reply.writeNoException();
1244             return true;
1245         }
1246 
1247         case KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION: {
1248             data.enforceInterface(IActivityManager.descriptor);
1249             killAllBackgroundProcesses();
1250             reply.writeNoException();
1251             return true;
1252         }
1253 
1254         case FORCE_STOP_PACKAGE_TRANSACTION: {
1255             data.enforceInterface(IActivityManager.descriptor);
1256             String packageName = data.readString();
1257             int userId = data.readInt();
1258             forceStopPackage(packageName, userId);
1259             reply.writeNoException();
1260             return true;
1261         }
1262 
1263         case GET_MY_MEMORY_STATE_TRANSACTION: {
1264             data.enforceInterface(IActivityManager.descriptor);
1265             ActivityManager.RunningAppProcessInfo info =
1266                     new ActivityManager.RunningAppProcessInfo();
1267             getMyMemoryState(info);
1268             reply.writeNoException();
1269             info.writeToParcel(reply, 0);
1270             return true;
1271         }
1272 
1273         case GET_DEVICE_CONFIGURATION_TRANSACTION: {
1274             data.enforceInterface(IActivityManager.descriptor);
1275             ConfigurationInfo config = getDeviceConfigurationInfo();
1276             reply.writeNoException();
1277             config.writeToParcel(reply, 0);
1278             return true;
1279         }
1280 
1281         case PROFILE_CONTROL_TRANSACTION: {
1282             data.enforceInterface(IActivityManager.descriptor);
1283             String process = data.readString();
1284             int userId = data.readInt();
1285             boolean start = data.readInt() != 0;
1286             int profileType = data.readInt();
1287             String path = data.readString();
1288             ParcelFileDescriptor fd = data.readInt() != 0
1289                     ? data.readFileDescriptor() : null;
1290             boolean res = profileControl(process, userId, start, path, fd, profileType);
1291             reply.writeNoException();
1292             reply.writeInt(res ? 1 : 0);
1293             return true;
1294         }
1295 
1296         case SHUTDOWN_TRANSACTION: {
1297             data.enforceInterface(IActivityManager.descriptor);
1298             boolean res = shutdown(data.readInt());
1299             reply.writeNoException();
1300             reply.writeInt(res ? 1 : 0);
1301             return true;
1302         }
1303 
1304         case STOP_APP_SWITCHES_TRANSACTION: {
1305             data.enforceInterface(IActivityManager.descriptor);
1306             stopAppSwitches();
1307             reply.writeNoException();
1308             return true;
1309         }
1310 
1311         case RESUME_APP_SWITCHES_TRANSACTION: {
1312             data.enforceInterface(IActivityManager.descriptor);
1313             resumeAppSwitches();
1314             reply.writeNoException();
1315             return true;
1316         }
1317 
1318         case PEEK_SERVICE_TRANSACTION: {
1319             data.enforceInterface(IActivityManager.descriptor);
1320             Intent service = Intent.CREATOR.createFromParcel(data);
1321             String resolvedType = data.readString();
1322             IBinder binder = peekService(service, resolvedType);
1323             reply.writeNoException();
1324             reply.writeStrongBinder(binder);
1325             return true;
1326         }
1327 
1328         case START_BACKUP_AGENT_TRANSACTION: {
1329             data.enforceInterface(IActivityManager.descriptor);
1330             ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1331             int backupRestoreMode = data.readInt();
1332             boolean success = bindBackupAgent(info, backupRestoreMode);
1333             reply.writeNoException();
1334             reply.writeInt(success ? 1 : 0);
1335             return true;
1336         }
1337 
1338         case BACKUP_AGENT_CREATED_TRANSACTION: {
1339             data.enforceInterface(IActivityManager.descriptor);
1340             String packageName = data.readString();
1341             IBinder agent = data.readStrongBinder();
1342             backupAgentCreated(packageName, agent);
1343             reply.writeNoException();
1344             return true;
1345         }
1346 
1347         case UNBIND_BACKUP_AGENT_TRANSACTION: {
1348             data.enforceInterface(IActivityManager.descriptor);
1349             ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1350             unbindBackupAgent(info);
1351             reply.writeNoException();
1352             return true;
1353         }
1354 
1355         case KILL_APPLICATION_WITH_APPID_TRANSACTION: {
1356             data.enforceInterface(IActivityManager.descriptor);
1357             String pkg = data.readString();
1358             int appid = data.readInt();
1359             killApplicationWithAppId(pkg, appid);
1360             reply.writeNoException();
1361             return true;
1362         }
1363 
1364         case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
1365             data.enforceInterface(IActivityManager.descriptor);
1366             String reason = data.readString();
1367             closeSystemDialogs(reason);
1368             reply.writeNoException();
1369             return true;
1370         }
1371 
1372         case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
1373             data.enforceInterface(IActivityManager.descriptor);
1374             int[] pids = data.createIntArray();
1375             Debug.MemoryInfo[] res =  getProcessMemoryInfo(pids);
1376             reply.writeNoException();
1377             reply.writeTypedArray(res, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1378             return true;
1379         }
1380 
1381         case KILL_APPLICATION_PROCESS_TRANSACTION: {
1382             data.enforceInterface(IActivityManager.descriptor);
1383             String processName = data.readString();
1384             int uid = data.readInt();
1385             killApplicationProcess(processName, uid);
1386             reply.writeNoException();
1387             return true;
1388         }
1389 
1390         case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
1391             data.enforceInterface(IActivityManager.descriptor);
1392             IBinder token = data.readStrongBinder();
1393             String packageName = data.readString();
1394             int enterAnim = data.readInt();
1395             int exitAnim = data.readInt();
1396             overridePendingTransition(token, packageName, enterAnim, exitAnim);
1397             reply.writeNoException();
1398             return true;
1399         }
1400 
1401         case IS_USER_A_MONKEY_TRANSACTION: {
1402             data.enforceInterface(IActivityManager.descriptor);
1403             boolean areThey = isUserAMonkey();
1404             reply.writeNoException();
1405             reply.writeInt(areThey ? 1 : 0);
1406             return true;
1407         }
1408 
1409         case FINISH_HEAVY_WEIGHT_APP_TRANSACTION: {
1410             data.enforceInterface(IActivityManager.descriptor);
1411             finishHeavyWeightApp();
1412             reply.writeNoException();
1413             return true;
1414         }
1415 
1416         case IS_IMMERSIVE_TRANSACTION: {
1417             data.enforceInterface(IActivityManager.descriptor);
1418             IBinder token = data.readStrongBinder();
1419             boolean isit = isImmersive(token);
1420             reply.writeNoException();
1421             reply.writeInt(isit ? 1 : 0);
1422             return true;
1423         }
1424 
1425         case SET_IMMERSIVE_TRANSACTION: {
1426             data.enforceInterface(IActivityManager.descriptor);
1427             IBinder token = data.readStrongBinder();
1428             boolean imm = data.readInt() == 1;
1429             setImmersive(token, imm);
1430             reply.writeNoException();
1431             return true;
1432         }
1433 
1434         case IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION: {
1435             data.enforceInterface(IActivityManager.descriptor);
1436             boolean isit = isTopActivityImmersive();
1437             reply.writeNoException();
1438             reply.writeInt(isit ? 1 : 0);
1439             return true;
1440         }
1441 
1442         case CRASH_APPLICATION_TRANSACTION: {
1443             data.enforceInterface(IActivityManager.descriptor);
1444             int uid = data.readInt();
1445             int initialPid = data.readInt();
1446             String packageName = data.readString();
1447             String message = data.readString();
1448             crashApplication(uid, initialPid, packageName, message);
1449             reply.writeNoException();
1450             return true;
1451         }
1452 
1453         case GET_PROVIDER_MIME_TYPE_TRANSACTION: {
1454             data.enforceInterface(IActivityManager.descriptor);
1455             Uri uri = Uri.CREATOR.createFromParcel(data);
1456             int userId = data.readInt();
1457             String type = getProviderMimeType(uri, userId);
1458             reply.writeNoException();
1459             reply.writeString(type);
1460             return true;
1461         }
1462 
1463         case NEW_URI_PERMISSION_OWNER_TRANSACTION: {
1464             data.enforceInterface(IActivityManager.descriptor);
1465             String name = data.readString();
1466             IBinder perm = newUriPermissionOwner(name);
1467             reply.writeNoException();
1468             reply.writeStrongBinder(perm);
1469             return true;
1470         }
1471 
1472         case GRANT_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1473             data.enforceInterface(IActivityManager.descriptor);
1474             IBinder owner = data.readStrongBinder();
1475             int fromUid = data.readInt();
1476             String targetPkg = data.readString();
1477             Uri uri = Uri.CREATOR.createFromParcel(data);
1478             int mode = data.readInt();
1479             grantUriPermissionFromOwner(owner, fromUid, targetPkg, uri, mode);
1480             reply.writeNoException();
1481             return true;
1482         }
1483 
1484         case REVOKE_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1485             data.enforceInterface(IActivityManager.descriptor);
1486             IBinder owner = data.readStrongBinder();
1487             Uri uri = null;
1488             if (data.readInt() != 0) {
1489                 Uri.CREATOR.createFromParcel(data);
1490             }
1491             int mode = data.readInt();
1492             revokeUriPermissionFromOwner(owner, uri, mode);
1493             reply.writeNoException();
1494             return true;
1495         }
1496 
1497         case CHECK_GRANT_URI_PERMISSION_TRANSACTION: {
1498             data.enforceInterface(IActivityManager.descriptor);
1499             int callingUid = data.readInt();
1500             String targetPkg = data.readString();
1501             Uri uri = Uri.CREATOR.createFromParcel(data);
1502             int modeFlags = data.readInt();
1503             int res = checkGrantUriPermission(callingUid, targetPkg, uri, modeFlags);
1504             reply.writeNoException();
1505             reply.writeInt(res);
1506             return true;
1507         }
1508 
1509         case DUMP_HEAP_TRANSACTION: {
1510             data.enforceInterface(IActivityManager.descriptor);
1511             String process = data.readString();
1512             int userId = data.readInt();
1513             boolean managed = data.readInt() != 0;
1514             String path = data.readString();
1515             ParcelFileDescriptor fd = data.readInt() != 0
1516                     ? data.readFileDescriptor() : null;
1517             boolean res = dumpHeap(process, userId, managed, path, fd);
1518             reply.writeNoException();
1519             reply.writeInt(res ? 1 : 0);
1520             return true;
1521         }
1522 
1523         case START_ACTIVITIES_TRANSACTION:
1524         {
1525             data.enforceInterface(IActivityManager.descriptor);
1526             IBinder b = data.readStrongBinder();
1527             IApplicationThread app = ApplicationThreadNative.asInterface(b);
1528             Intent[] intents = data.createTypedArray(Intent.CREATOR);
1529             String[] resolvedTypes = data.createStringArray();
1530             IBinder resultTo = data.readStrongBinder();
1531             Bundle options = data.readInt() != 0
1532                     ? Bundle.CREATOR.createFromParcel(data) : null;
1533             int userId = data.readInt();
1534             int result = startActivities(app, intents, resolvedTypes, resultTo,
1535                     options, userId);
1536             reply.writeNoException();
1537             reply.writeInt(result);
1538             return true;
1539         }
1540 
1541         case GET_FRONT_ACTIVITY_SCREEN_COMPAT_MODE_TRANSACTION:
1542         {
1543             data.enforceInterface(IActivityManager.descriptor);
1544             int mode = getFrontActivityScreenCompatMode();
1545             reply.writeNoException();
1546             reply.writeInt(mode);
1547             return true;
1548         }
1549 
1550         case SET_FRONT_ACTIVITY_SCREEN_COMPAT_MODE_TRANSACTION:
1551         {
1552             data.enforceInterface(IActivityManager.descriptor);
1553             int mode = data.readInt();
1554             setFrontActivityScreenCompatMode(mode);
1555             reply.writeNoException();
1556             reply.writeInt(mode);
1557             return true;
1558         }
1559 
1560         case GET_PACKAGE_SCREEN_COMPAT_MODE_TRANSACTION:
1561         {
1562             data.enforceInterface(IActivityManager.descriptor);
1563             String pkg = data.readString();
1564             int mode = getPackageScreenCompatMode(pkg);
1565             reply.writeNoException();
1566             reply.writeInt(mode);
1567             return true;
1568         }
1569 
1570         case SET_PACKAGE_SCREEN_COMPAT_MODE_TRANSACTION:
1571         {
1572             data.enforceInterface(IActivityManager.descriptor);
1573             String pkg = data.readString();
1574             int mode = data.readInt();
1575             setPackageScreenCompatMode(pkg, mode);
1576             reply.writeNoException();
1577             return true;
1578         }
1579 
1580         case SWITCH_USER_TRANSACTION: {
1581             data.enforceInterface(IActivityManager.descriptor);
1582             int userid = data.readInt();
1583             boolean result = switchUser(userid);
1584             reply.writeNoException();
1585             reply.writeInt(result ? 1 : 0);
1586             return true;
1587         }
1588 
1589         case STOP_USER_TRANSACTION: {
1590             data.enforceInterface(IActivityManager.descriptor);
1591             int userid = data.readInt();
1592             IStopUserCallback callback = IStopUserCallback.Stub.asInterface(
1593                     data.readStrongBinder());
1594             int result = stopUser(userid, callback);
1595             reply.writeNoException();
1596             reply.writeInt(result);
1597             return true;
1598         }
1599 
1600         case GET_CURRENT_USER_TRANSACTION: {
1601             data.enforceInterface(IActivityManager.descriptor);
1602             UserInfo userInfo = getCurrentUser();
1603             reply.writeNoException();
1604             userInfo.writeToParcel(reply, 0);
1605             return true;
1606         }
1607 
1608         case IS_USER_RUNNING_TRANSACTION: {
1609             data.enforceInterface(IActivityManager.descriptor);
1610             int userid = data.readInt();
1611             boolean orStopping = data.readInt() != 0;
1612             boolean result = isUserRunning(userid, orStopping);
1613             reply.writeNoException();
1614             reply.writeInt(result ? 1 : 0);
1615             return true;
1616         }
1617 
1618         case GET_RUNNING_USER_IDS_TRANSACTION: {
1619             data.enforceInterface(IActivityManager.descriptor);
1620             int[] result = getRunningUserIds();
1621             reply.writeNoException();
1622             reply.writeIntArray(result);
1623             return true;
1624         }
1625 
1626         case REMOVE_SUB_TASK_TRANSACTION:
1627         {
1628             data.enforceInterface(IActivityManager.descriptor);
1629             int taskId = data.readInt();
1630             int subTaskIndex = data.readInt();
1631             boolean result = removeSubTask(taskId, subTaskIndex);
1632             reply.writeNoException();
1633             reply.writeInt(result ? 1 : 0);
1634             return true;
1635         }
1636 
1637         case REMOVE_TASK_TRANSACTION:
1638         {
1639             data.enforceInterface(IActivityManager.descriptor);
1640             int taskId = data.readInt();
1641             int fl = data.readInt();
1642             boolean result = removeTask(taskId, fl);
1643             reply.writeNoException();
1644             reply.writeInt(result ? 1 : 0);
1645             return true;
1646         }
1647 
1648         case REGISTER_PROCESS_OBSERVER_TRANSACTION: {
1649             data.enforceInterface(IActivityManager.descriptor);
1650             IProcessObserver observer = IProcessObserver.Stub.asInterface(
1651                     data.readStrongBinder());
1652             registerProcessObserver(observer);
1653             return true;
1654         }
1655 
1656         case UNREGISTER_PROCESS_OBSERVER_TRANSACTION: {
1657             data.enforceInterface(IActivityManager.descriptor);
1658             IProcessObserver observer = IProcessObserver.Stub.asInterface(
1659                     data.readStrongBinder());
1660             unregisterProcessObserver(observer);
1661             return true;
1662         }
1663 
1664         case GET_PACKAGE_ASK_SCREEN_COMPAT_TRANSACTION:
1665         {
1666             data.enforceInterface(IActivityManager.descriptor);
1667             String pkg = data.readString();
1668             boolean ask = getPackageAskScreenCompat(pkg);
1669             reply.writeNoException();
1670             reply.writeInt(ask ? 1 : 0);
1671             return true;
1672         }
1673 
1674         case SET_PACKAGE_ASK_SCREEN_COMPAT_TRANSACTION:
1675         {
1676             data.enforceInterface(IActivityManager.descriptor);
1677             String pkg = data.readString();
1678             boolean ask = data.readInt() != 0;
1679             setPackageAskScreenCompat(pkg, ask);
1680             reply.writeNoException();
1681             return true;
1682         }
1683 
1684         case IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION: {
1685             data.enforceInterface(IActivityManager.descriptor);
1686             IIntentSender r = IIntentSender.Stub.asInterface(
1687                 data.readStrongBinder());
1688             boolean res = isIntentSenderTargetedToPackage(r);
1689             reply.writeNoException();
1690             reply.writeInt(res ? 1 : 0);
1691             return true;
1692         }
1693 
1694         case IS_INTENT_SENDER_AN_ACTIVITY_TRANSACTION: {
1695             data.enforceInterface(IActivityManager.descriptor);
1696             IIntentSender r = IIntentSender.Stub.asInterface(
1697                 data.readStrongBinder());
1698             boolean res = isIntentSenderAnActivity(r);
1699             reply.writeNoException();
1700             reply.writeInt(res ? 1 : 0);
1701             return true;
1702         }
1703 
1704         case GET_INTENT_FOR_INTENT_SENDER_TRANSACTION: {
1705             data.enforceInterface(IActivityManager.descriptor);
1706             IIntentSender r = IIntentSender.Stub.asInterface(
1707                 data.readStrongBinder());
1708             Intent intent = getIntentForIntentSender(r);
1709             reply.writeNoException();
1710             if (intent != null) {
1711                 reply.writeInt(1);
1712                 intent.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1713             } else {
1714                 reply.writeInt(0);
1715             }
1716             return true;
1717         }
1718 
1719         case UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION: {
1720             data.enforceInterface(IActivityManager.descriptor);
1721             Configuration config = Configuration.CREATOR.createFromParcel(data);
1722             updatePersistentConfiguration(config);
1723             reply.writeNoException();
1724             return true;
1725         }
1726 
1727         case GET_PROCESS_PSS_TRANSACTION: {
1728             data.enforceInterface(IActivityManager.descriptor);
1729             int[] pids = data.createIntArray();
1730             long[] pss = getProcessPss(pids);
1731             reply.writeNoException();
1732             reply.writeLongArray(pss);
1733             return true;
1734         }
1735 
1736         case SHOW_BOOT_MESSAGE_TRANSACTION: {
1737             data.enforceInterface(IActivityManager.descriptor);
1738             CharSequence msg = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
1739             boolean always = data.readInt() != 0;
1740             showBootMessage(msg, always);
1741             reply.writeNoException();
1742             return true;
1743         }
1744 
1745         case DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION: {
1746             data.enforceInterface(IActivityManager.descriptor);
1747             dismissKeyguardOnNextActivity();
1748             reply.writeNoException();
1749             return true;
1750         }
1751 
1752         case TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION: {
1753             data.enforceInterface(IActivityManager.descriptor);
1754             IBinder token = data.readStrongBinder();
1755             String destAffinity = data.readString();
1756             boolean res = targetTaskAffinityMatchesActivity(token, destAffinity);
1757             reply.writeNoException();
1758             reply.writeInt(res ? 1 : 0);
1759             return true;
1760         }
1761 
1762         case NAVIGATE_UP_TO_TRANSACTION: {
1763             data.enforceInterface(IActivityManager.descriptor);
1764             IBinder token = data.readStrongBinder();
1765             Intent target = Intent.CREATOR.createFromParcel(data);
1766             int resultCode = data.readInt();
1767             Intent resultData = null;
1768             if (data.readInt() != 0) {
1769                 resultData = Intent.CREATOR.createFromParcel(data);
1770             }
1771             boolean res = navigateUpTo(token, target, resultCode, resultData);
1772             reply.writeNoException();
1773             reply.writeInt(res ? 1 : 0);
1774             return true;
1775         }
1776 
1777         case GET_LAUNCHED_FROM_UID_TRANSACTION: {
1778             data.enforceInterface(IActivityManager.descriptor);
1779             IBinder token = data.readStrongBinder();
1780             int res = getLaunchedFromUid(token);
1781             reply.writeNoException();
1782             reply.writeInt(res);
1783             return true;
1784         }
1785 
1786         case REGISTER_USER_SWITCH_OBSERVER_TRANSACTION: {
1787             data.enforceInterface(IActivityManager.descriptor);
1788             IUserSwitchObserver observer = IUserSwitchObserver.Stub.asInterface(
1789                     data.readStrongBinder());
1790             registerUserSwitchObserver(observer);
1791             reply.writeNoException();
1792             return true;
1793         }
1794 
1795         case UNREGISTER_USER_SWITCH_OBSERVER_TRANSACTION: {
1796             data.enforceInterface(IActivityManager.descriptor);
1797             IUserSwitchObserver observer = IUserSwitchObserver.Stub.asInterface(
1798                     data.readStrongBinder());
1799             unregisterUserSwitchObserver(observer);
1800             reply.writeNoException();
1801             return true;
1802         }
1803 
1804         case REQUEST_BUG_REPORT_TRANSACTION: {
1805             data.enforceInterface(IActivityManager.descriptor);
1806             requestBugReport();
1807             reply.writeNoException();
1808             return true;
1809         }
1810 
1811         case INPUT_DISPATCHING_TIMED_OUT_TRANSACTION: {
1812             data.enforceInterface(IActivityManager.descriptor);
1813             int pid = data.readInt();
1814             boolean aboveSystem = data.readInt() != 0;
1815             long res = inputDispatchingTimedOut(pid, aboveSystem);
1816             reply.writeNoException();
1817             reply.writeLong(res);
1818             return true;
1819         }
1820 
1821         }
1822 
1823         return super.onTransact(code, data, reply, flags);
1824     }
1825 
asBinder()1826     public IBinder asBinder() {
1827         return this;
1828     }
1829 
1830     private static final Singleton<IActivityManager> gDefault = new Singleton<IActivityManager>() {
1831         protected IActivityManager create() {
1832             IBinder b = ServiceManager.getService("activity");
1833             if (false) {
1834                 Log.v("ActivityManager", "default service binder = " + b);
1835             }
1836             IActivityManager am = asInterface(b);
1837             if (false) {
1838                 Log.v("ActivityManager", "default service = " + am);
1839             }
1840             return am;
1841         }
1842     };
1843 }
1844 
1845 class ActivityManagerProxy implements IActivityManager
1846 {
ActivityManagerProxy(IBinder remote)1847     public ActivityManagerProxy(IBinder remote)
1848     {
1849         mRemote = remote;
1850     }
1851 
asBinder()1852     public IBinder asBinder()
1853     {
1854         return mRemote;
1855     }
1856 
startActivity(IApplicationThread caller, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, String profileFile, ParcelFileDescriptor profileFd, Bundle options)1857     public int startActivity(IApplicationThread caller, Intent intent,
1858             String resolvedType, IBinder resultTo, String resultWho, int requestCode,
1859             int startFlags, String profileFile,
1860             ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
1861         Parcel data = Parcel.obtain();
1862         Parcel reply = Parcel.obtain();
1863         data.writeInterfaceToken(IActivityManager.descriptor);
1864         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1865         intent.writeToParcel(data, 0);
1866         data.writeString(resolvedType);
1867         data.writeStrongBinder(resultTo);
1868         data.writeString(resultWho);
1869         data.writeInt(requestCode);
1870         data.writeInt(startFlags);
1871         data.writeString(profileFile);
1872         if (profileFd != null) {
1873             data.writeInt(1);
1874             profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1875         } else {
1876             data.writeInt(0);
1877         }
1878         if (options != null) {
1879             data.writeInt(1);
1880             options.writeToParcel(data, 0);
1881         } else {
1882             data.writeInt(0);
1883         }
1884         mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1885         reply.readException();
1886         int result = reply.readInt();
1887         reply.recycle();
1888         data.recycle();
1889         return result;
1890     }
1891 
startActivityAsUser(IApplicationThread caller, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId)1892     public int startActivityAsUser(IApplicationThread caller, Intent intent,
1893             String resolvedType, IBinder resultTo, String resultWho, int requestCode,
1894             int startFlags, String profileFile,
1895             ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException {
1896         Parcel data = Parcel.obtain();
1897         Parcel reply = Parcel.obtain();
1898         data.writeInterfaceToken(IActivityManager.descriptor);
1899         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1900         intent.writeToParcel(data, 0);
1901         data.writeString(resolvedType);
1902         data.writeStrongBinder(resultTo);
1903         data.writeString(resultWho);
1904         data.writeInt(requestCode);
1905         data.writeInt(startFlags);
1906         data.writeString(profileFile);
1907         if (profileFd != null) {
1908             data.writeInt(1);
1909             profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1910         } else {
1911             data.writeInt(0);
1912         }
1913         if (options != null) {
1914             data.writeInt(1);
1915             options.writeToParcel(data, 0);
1916         } else {
1917             data.writeInt(0);
1918         }
1919         data.writeInt(userId);
1920         mRemote.transact(START_ACTIVITY_AS_USER_TRANSACTION, data, reply, 0);
1921         reply.readException();
1922         int result = reply.readInt();
1923         reply.recycle();
1924         data.recycle();
1925         return result;
1926     }
startActivityAndWait(IApplicationThread caller, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId)1927     public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
1928             String resolvedType, IBinder resultTo, String resultWho,
1929             int requestCode, int startFlags, String profileFile,
1930             ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException {
1931         Parcel data = Parcel.obtain();
1932         Parcel reply = Parcel.obtain();
1933         data.writeInterfaceToken(IActivityManager.descriptor);
1934         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1935         intent.writeToParcel(data, 0);
1936         data.writeString(resolvedType);
1937         data.writeStrongBinder(resultTo);
1938         data.writeString(resultWho);
1939         data.writeInt(requestCode);
1940         data.writeInt(startFlags);
1941         data.writeString(profileFile);
1942         if (profileFd != null) {
1943             data.writeInt(1);
1944             profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
1945         } else {
1946             data.writeInt(0);
1947         }
1948         if (options != null) {
1949             data.writeInt(1);
1950             options.writeToParcel(data, 0);
1951         } else {
1952             data.writeInt(0);
1953         }
1954         data.writeInt(userId);
1955         mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
1956         reply.readException();
1957         WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
1958         reply.recycle();
1959         data.recycle();
1960         return result;
1961     }
startActivityWithConfig(IApplicationThread caller, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, Configuration config, Bundle options, int userId)1962     public int startActivityWithConfig(IApplicationThread caller, Intent intent,
1963             String resolvedType, IBinder resultTo, String resultWho,
1964             int requestCode, int startFlags, Configuration config,
1965             Bundle options, int userId) throws RemoteException {
1966         Parcel data = Parcel.obtain();
1967         Parcel reply = Parcel.obtain();
1968         data.writeInterfaceToken(IActivityManager.descriptor);
1969         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1970         intent.writeToParcel(data, 0);
1971         data.writeString(resolvedType);
1972         data.writeStrongBinder(resultTo);
1973         data.writeString(resultWho);
1974         data.writeInt(requestCode);
1975         data.writeInt(startFlags);
1976         config.writeToParcel(data, 0);
1977         if (options != null) {
1978             data.writeInt(1);
1979             options.writeToParcel(data, 0);
1980         } else {
1981             data.writeInt(0);
1982         }
1983         data.writeInt(userId);
1984         mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1985         reply.readException();
1986         int result = reply.readInt();
1987         reply.recycle();
1988         data.recycle();
1989         return result;
1990     }
startActivityIntentSender(IApplicationThread caller, IntentSender intent, Intent fillInIntent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle options)1991     public int startActivityIntentSender(IApplicationThread caller,
1992             IntentSender intent, Intent fillInIntent, String resolvedType,
1993             IBinder resultTo, String resultWho, int requestCode,
1994             int flagsMask, int flagsValues, Bundle options) throws RemoteException {
1995         Parcel data = Parcel.obtain();
1996         Parcel reply = Parcel.obtain();
1997         data.writeInterfaceToken(IActivityManager.descriptor);
1998         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1999         intent.writeToParcel(data, 0);
2000         if (fillInIntent != null) {
2001             data.writeInt(1);
2002             fillInIntent.writeToParcel(data, 0);
2003         } else {
2004             data.writeInt(0);
2005         }
2006         data.writeString(resolvedType);
2007         data.writeStrongBinder(resultTo);
2008         data.writeString(resultWho);
2009         data.writeInt(requestCode);
2010         data.writeInt(flagsMask);
2011         data.writeInt(flagsValues);
2012         if (options != null) {
2013             data.writeInt(1);
2014             options.writeToParcel(data, 0);
2015         } else {
2016             data.writeInt(0);
2017         }
2018         mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
2019         reply.readException();
2020         int result = reply.readInt();
2021         reply.recycle();
2022         data.recycle();
2023         return result;
2024     }
startNextMatchingActivity(IBinder callingActivity, Intent intent, Bundle options)2025     public boolean startNextMatchingActivity(IBinder callingActivity,
2026             Intent intent, Bundle options) throws RemoteException {
2027         Parcel data = Parcel.obtain();
2028         Parcel reply = Parcel.obtain();
2029         data.writeInterfaceToken(IActivityManager.descriptor);
2030         data.writeStrongBinder(callingActivity);
2031         intent.writeToParcel(data, 0);
2032         if (options != null) {
2033             data.writeInt(1);
2034             options.writeToParcel(data, 0);
2035         } else {
2036             data.writeInt(0);
2037         }
2038         mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
2039         reply.readException();
2040         int result = reply.readInt();
2041         reply.recycle();
2042         data.recycle();
2043         return result != 0;
2044     }
finishActivity(IBinder token, int resultCode, Intent resultData)2045     public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
2046             throws RemoteException {
2047         Parcel data = Parcel.obtain();
2048         Parcel reply = Parcel.obtain();
2049         data.writeInterfaceToken(IActivityManager.descriptor);
2050         data.writeStrongBinder(token);
2051         data.writeInt(resultCode);
2052         if (resultData != null) {
2053             data.writeInt(1);
2054             resultData.writeToParcel(data, 0);
2055         } else {
2056             data.writeInt(0);
2057         }
2058         mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
2059         reply.readException();
2060         boolean res = reply.readInt() != 0;
2061         data.recycle();
2062         reply.recycle();
2063         return res;
2064     }
finishSubActivity(IBinder token, String resultWho, int requestCode)2065     public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
2066     {
2067         Parcel data = Parcel.obtain();
2068         Parcel reply = Parcel.obtain();
2069         data.writeInterfaceToken(IActivityManager.descriptor);
2070         data.writeStrongBinder(token);
2071         data.writeString(resultWho);
2072         data.writeInt(requestCode);
2073         mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
2074         reply.readException();
2075         data.recycle();
2076         reply.recycle();
2077     }
finishActivityAffinity(IBinder token)2078     public boolean finishActivityAffinity(IBinder token) throws RemoteException {
2079         Parcel data = Parcel.obtain();
2080         Parcel reply = Parcel.obtain();
2081         data.writeInterfaceToken(IActivityManager.descriptor);
2082         data.writeStrongBinder(token);
2083         mRemote.transact(FINISH_ACTIVITY_AFFINITY_TRANSACTION, data, reply, 0);
2084         reply.readException();
2085         boolean res = reply.readInt() != 0;
2086         data.recycle();
2087         reply.recycle();
2088         return res;
2089     }
willActivityBeVisible(IBinder token)2090     public boolean willActivityBeVisible(IBinder token) throws RemoteException {
2091         Parcel data = Parcel.obtain();
2092         Parcel reply = Parcel.obtain();
2093         data.writeInterfaceToken(IActivityManager.descriptor);
2094         data.writeStrongBinder(token);
2095         mRemote.transact(WILL_ACTIVITY_BE_VISIBLE_TRANSACTION, data, reply, 0);
2096         reply.readException();
2097         boolean res = reply.readInt() != 0;
2098         data.recycle();
2099         reply.recycle();
2100         return res;
2101     }
registerReceiver(IApplicationThread caller, String packageName, IIntentReceiver receiver, IntentFilter filter, String perm, int userId)2102     public Intent registerReceiver(IApplicationThread caller, String packageName,
2103             IIntentReceiver receiver,
2104             IntentFilter filter, String perm, int userId) throws RemoteException
2105     {
2106         Parcel data = Parcel.obtain();
2107         Parcel reply = Parcel.obtain();
2108         data.writeInterfaceToken(IActivityManager.descriptor);
2109         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2110         data.writeString(packageName);
2111         data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
2112         filter.writeToParcel(data, 0);
2113         data.writeString(perm);
2114         data.writeInt(userId);
2115         mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
2116         reply.readException();
2117         Intent intent = null;
2118         int haveIntent = reply.readInt();
2119         if (haveIntent != 0) {
2120             intent = Intent.CREATOR.createFromParcel(reply);
2121         }
2122         reply.recycle();
2123         data.recycle();
2124         return intent;
2125     }
unregisterReceiver(IIntentReceiver receiver)2126     public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
2127     {
2128         Parcel data = Parcel.obtain();
2129         Parcel reply = Parcel.obtain();
2130         data.writeInterfaceToken(IActivityManager.descriptor);
2131         data.writeStrongBinder(receiver.asBinder());
2132         mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
2133         reply.readException();
2134         data.recycle();
2135         reply.recycle();
2136     }
broadcastIntent(IApplicationThread caller, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle map, String requiredPermission, boolean serialized, boolean sticky, int userId)2137     public int broadcastIntent(IApplicationThread caller,
2138             Intent intent, String resolvedType,  IIntentReceiver resultTo,
2139             int resultCode, String resultData, Bundle map,
2140             String requiredPermission, boolean serialized,
2141             boolean sticky, int userId) throws RemoteException
2142     {
2143         Parcel data = Parcel.obtain();
2144         Parcel reply = Parcel.obtain();
2145         data.writeInterfaceToken(IActivityManager.descriptor);
2146         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2147         intent.writeToParcel(data, 0);
2148         data.writeString(resolvedType);
2149         data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
2150         data.writeInt(resultCode);
2151         data.writeString(resultData);
2152         data.writeBundle(map);
2153         data.writeString(requiredPermission);
2154         data.writeInt(serialized ? 1 : 0);
2155         data.writeInt(sticky ? 1 : 0);
2156         data.writeInt(userId);
2157         mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
2158         reply.readException();
2159         int res = reply.readInt();
2160         reply.recycle();
2161         data.recycle();
2162         return res;
2163     }
unbroadcastIntent(IApplicationThread caller, Intent intent, int userId)2164     public void unbroadcastIntent(IApplicationThread caller, Intent intent, int userId)
2165             throws RemoteException
2166     {
2167         Parcel data = Parcel.obtain();
2168         Parcel reply = Parcel.obtain();
2169         data.writeInterfaceToken(IActivityManager.descriptor);
2170         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2171         intent.writeToParcel(data, 0);
2172         data.writeInt(userId);
2173         mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
2174         reply.readException();
2175         data.recycle();
2176         reply.recycle();
2177     }
finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast)2178     public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
2179     {
2180         Parcel data = Parcel.obtain();
2181         Parcel reply = Parcel.obtain();
2182         data.writeInterfaceToken(IActivityManager.descriptor);
2183         data.writeStrongBinder(who);
2184         data.writeInt(resultCode);
2185         data.writeString(resultData);
2186         data.writeBundle(map);
2187         data.writeInt(abortBroadcast ? 1 : 0);
2188         mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2189         reply.readException();
2190         data.recycle();
2191         reply.recycle();
2192     }
attachApplication(IApplicationThread app)2193     public void attachApplication(IApplicationThread app) throws RemoteException
2194     {
2195         Parcel data = Parcel.obtain();
2196         Parcel reply = Parcel.obtain();
2197         data.writeInterfaceToken(IActivityManager.descriptor);
2198         data.writeStrongBinder(app.asBinder());
2199         mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
2200         reply.readException();
2201         data.recycle();
2202         reply.recycle();
2203     }
activityIdle(IBinder token, Configuration config, boolean stopProfiling)2204     public void activityIdle(IBinder token, Configuration config, boolean stopProfiling)
2205             throws RemoteException
2206     {
2207         Parcel data = Parcel.obtain();
2208         Parcel reply = Parcel.obtain();
2209         data.writeInterfaceToken(IActivityManager.descriptor);
2210         data.writeStrongBinder(token);
2211         if (config != null) {
2212             data.writeInt(1);
2213             config.writeToParcel(data, 0);
2214         } else {
2215             data.writeInt(0);
2216         }
2217         data.writeInt(stopProfiling ? 1 : 0);
2218         mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2219         reply.readException();
2220         data.recycle();
2221         reply.recycle();
2222     }
activityResumed(IBinder token)2223     public void activityResumed(IBinder token) throws RemoteException
2224     {
2225         Parcel data = Parcel.obtain();
2226         Parcel reply = Parcel.obtain();
2227         data.writeInterfaceToken(IActivityManager.descriptor);
2228         data.writeStrongBinder(token);
2229         mRemote.transact(ACTIVITY_RESUMED_TRANSACTION, data, reply, 0);
2230         reply.readException();
2231         data.recycle();
2232         reply.recycle();
2233     }
activityPaused(IBinder token)2234     public void activityPaused(IBinder token) throws RemoteException
2235     {
2236         Parcel data = Parcel.obtain();
2237         Parcel reply = Parcel.obtain();
2238         data.writeInterfaceToken(IActivityManager.descriptor);
2239         data.writeStrongBinder(token);
2240         mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
2241         reply.readException();
2242         data.recycle();
2243         reply.recycle();
2244     }
activityStopped(IBinder token, Bundle state, Bitmap thumbnail, CharSequence description)2245     public void activityStopped(IBinder token, Bundle state,
2246             Bitmap thumbnail, CharSequence description) throws RemoteException
2247     {
2248         Parcel data = Parcel.obtain();
2249         Parcel reply = Parcel.obtain();
2250         data.writeInterfaceToken(IActivityManager.descriptor);
2251         data.writeStrongBinder(token);
2252         data.writeBundle(state);
2253         if (thumbnail != null) {
2254             data.writeInt(1);
2255             thumbnail.writeToParcel(data, 0);
2256         } else {
2257             data.writeInt(0);
2258         }
2259         TextUtils.writeToParcel(description, data, 0);
2260         mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2261         reply.readException();
2262         data.recycle();
2263         reply.recycle();
2264     }
activitySlept(IBinder token)2265     public void activitySlept(IBinder token) throws RemoteException
2266     {
2267         Parcel data = Parcel.obtain();
2268         Parcel reply = Parcel.obtain();
2269         data.writeInterfaceToken(IActivityManager.descriptor);
2270         data.writeStrongBinder(token);
2271         mRemote.transact(ACTIVITY_SLEPT_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2272         reply.readException();
2273         data.recycle();
2274         reply.recycle();
2275     }
activityDestroyed(IBinder token)2276     public void activityDestroyed(IBinder token) throws RemoteException
2277     {
2278         Parcel data = Parcel.obtain();
2279         Parcel reply = Parcel.obtain();
2280         data.writeInterfaceToken(IActivityManager.descriptor);
2281         data.writeStrongBinder(token);
2282         mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2283         reply.readException();
2284         data.recycle();
2285         reply.recycle();
2286     }
getCallingPackage(IBinder token)2287     public String getCallingPackage(IBinder token) throws RemoteException
2288     {
2289         Parcel data = Parcel.obtain();
2290         Parcel reply = Parcel.obtain();
2291         data.writeInterfaceToken(IActivityManager.descriptor);
2292         data.writeStrongBinder(token);
2293         mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
2294         reply.readException();
2295         String res = reply.readString();
2296         data.recycle();
2297         reply.recycle();
2298         return res;
2299     }
getCallingActivity(IBinder token)2300     public ComponentName getCallingActivity(IBinder token)
2301             throws RemoteException {
2302         Parcel data = Parcel.obtain();
2303         Parcel reply = Parcel.obtain();
2304         data.writeInterfaceToken(IActivityManager.descriptor);
2305         data.writeStrongBinder(token);
2306         mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
2307         reply.readException();
2308         ComponentName res = ComponentName.readFromParcel(reply);
2309         data.recycle();
2310         reply.recycle();
2311         return res;
2312     }
getTasks(int maxNum, int flags, IThumbnailReceiver receiver)2313     public List getTasks(int maxNum, int flags,
2314             IThumbnailReceiver receiver) throws RemoteException {
2315         Parcel data = Parcel.obtain();
2316         Parcel reply = Parcel.obtain();
2317         data.writeInterfaceToken(IActivityManager.descriptor);
2318         data.writeInt(maxNum);
2319         data.writeInt(flags);
2320         data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
2321         mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
2322         reply.readException();
2323         ArrayList list = null;
2324         int N = reply.readInt();
2325         if (N >= 0) {
2326             list = new ArrayList();
2327             while (N > 0) {
2328                 ActivityManager.RunningTaskInfo info =
2329                         ActivityManager.RunningTaskInfo.CREATOR
2330                         .createFromParcel(reply);
2331                 list.add(info);
2332                 N--;
2333             }
2334         }
2335         data.recycle();
2336         reply.recycle();
2337         return list;
2338     }
getRecentTasks(int maxNum, int flags, int userId)2339     public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
2340             int flags, int userId) throws RemoteException {
2341         Parcel data = Parcel.obtain();
2342         Parcel reply = Parcel.obtain();
2343         data.writeInterfaceToken(IActivityManager.descriptor);
2344         data.writeInt(maxNum);
2345         data.writeInt(flags);
2346         data.writeInt(userId);
2347         mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
2348         reply.readException();
2349         ArrayList<ActivityManager.RecentTaskInfo> list
2350             = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
2351         data.recycle();
2352         reply.recycle();
2353         return list;
2354     }
getTaskThumbnails(int id)2355     public ActivityManager.TaskThumbnails getTaskThumbnails(int id) throws RemoteException {
2356         Parcel data = Parcel.obtain();
2357         Parcel reply = Parcel.obtain();
2358         data.writeInterfaceToken(IActivityManager.descriptor);
2359         data.writeInt(id);
2360         mRemote.transact(GET_TASK_THUMBNAILS_TRANSACTION, data, reply, 0);
2361         reply.readException();
2362         ActivityManager.TaskThumbnails bm = null;
2363         if (reply.readInt() != 0) {
2364             bm = ActivityManager.TaskThumbnails.CREATOR.createFromParcel(reply);
2365         }
2366         data.recycle();
2367         reply.recycle();
2368         return bm;
2369     }
getTaskTopThumbnail(int id)2370     public Bitmap getTaskTopThumbnail(int id) throws RemoteException {
2371         Parcel data = Parcel.obtain();
2372         Parcel reply = Parcel.obtain();
2373         data.writeInterfaceToken(IActivityManager.descriptor);
2374         data.writeInt(id);
2375         mRemote.transact(GET_TASK_TOP_THUMBNAIL_TRANSACTION, data, reply, 0);
2376         reply.readException();
2377         Bitmap bm = null;
2378         if (reply.readInt() != 0) {
2379             bm = Bitmap.CREATOR.createFromParcel(reply);
2380         }
2381         data.recycle();
2382         reply.recycle();
2383         return bm;
2384     }
getServices(int maxNum, int flags)2385     public List getServices(int maxNum, int flags) throws RemoteException {
2386         Parcel data = Parcel.obtain();
2387         Parcel reply = Parcel.obtain();
2388         data.writeInterfaceToken(IActivityManager.descriptor);
2389         data.writeInt(maxNum);
2390         data.writeInt(flags);
2391         mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
2392         reply.readException();
2393         ArrayList list = null;
2394         int N = reply.readInt();
2395         if (N >= 0) {
2396             list = new ArrayList();
2397             while (N > 0) {
2398                 ActivityManager.RunningServiceInfo info =
2399                         ActivityManager.RunningServiceInfo.CREATOR
2400                         .createFromParcel(reply);
2401                 list.add(info);
2402                 N--;
2403             }
2404         }
2405         data.recycle();
2406         reply.recycle();
2407         return list;
2408     }
getProcessesInErrorState()2409     public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
2410             throws RemoteException {
2411         Parcel data = Parcel.obtain();
2412         Parcel reply = Parcel.obtain();
2413         data.writeInterfaceToken(IActivityManager.descriptor);
2414         mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
2415         reply.readException();
2416         ArrayList<ActivityManager.ProcessErrorStateInfo> list
2417             = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
2418         data.recycle();
2419         reply.recycle();
2420         return list;
2421     }
getRunningAppProcesses()2422     public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
2423             throws RemoteException {
2424         Parcel data = Parcel.obtain();
2425         Parcel reply = Parcel.obtain();
2426         data.writeInterfaceToken(IActivityManager.descriptor);
2427         mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
2428         reply.readException();
2429         ArrayList<ActivityManager.RunningAppProcessInfo> list
2430         = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
2431         data.recycle();
2432         reply.recycle();
2433         return list;
2434     }
getRunningExternalApplications()2435     public List<ApplicationInfo> getRunningExternalApplications()
2436             throws RemoteException {
2437         Parcel data = Parcel.obtain();
2438         Parcel reply = Parcel.obtain();
2439         data.writeInterfaceToken(IActivityManager.descriptor);
2440         mRemote.transact(GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION, data, reply, 0);
2441         reply.readException();
2442         ArrayList<ApplicationInfo> list
2443         = reply.createTypedArrayList(ApplicationInfo.CREATOR);
2444         data.recycle();
2445         reply.recycle();
2446         return list;
2447     }
moveTaskToFront(int task, int flags, Bundle options)2448     public void moveTaskToFront(int task, int flags, Bundle options) throws RemoteException
2449     {
2450         Parcel data = Parcel.obtain();
2451         Parcel reply = Parcel.obtain();
2452         data.writeInterfaceToken(IActivityManager.descriptor);
2453         data.writeInt(task);
2454         data.writeInt(flags);
2455         if (options != null) {
2456             data.writeInt(1);
2457             options.writeToParcel(data, 0);
2458         } else {
2459             data.writeInt(0);
2460         }
2461         mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
2462         reply.readException();
2463         data.recycle();
2464         reply.recycle();
2465     }
moveTaskToBack(int task)2466     public void moveTaskToBack(int task) throws RemoteException
2467     {
2468         Parcel data = Parcel.obtain();
2469         Parcel reply = Parcel.obtain();
2470         data.writeInterfaceToken(IActivityManager.descriptor);
2471         data.writeInt(task);
2472         mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
2473         reply.readException();
2474         data.recycle();
2475         reply.recycle();
2476     }
moveActivityTaskToBack(IBinder token, boolean nonRoot)2477     public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
2478             throws RemoteException {
2479         Parcel data = Parcel.obtain();
2480         Parcel reply = Parcel.obtain();
2481         data.writeInterfaceToken(IActivityManager.descriptor);
2482         data.writeStrongBinder(token);
2483         data.writeInt(nonRoot ? 1 : 0);
2484         mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
2485         reply.readException();
2486         boolean res = reply.readInt() != 0;
2487         data.recycle();
2488         reply.recycle();
2489         return res;
2490     }
moveTaskBackwards(int task)2491     public void moveTaskBackwards(int task) throws RemoteException
2492     {
2493         Parcel data = Parcel.obtain();
2494         Parcel reply = Parcel.obtain();
2495         data.writeInterfaceToken(IActivityManager.descriptor);
2496         data.writeInt(task);
2497         mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
2498         reply.readException();
2499         data.recycle();
2500         reply.recycle();
2501     }
getTaskForActivity(IBinder token, boolean onlyRoot)2502     public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
2503     {
2504         Parcel data = Parcel.obtain();
2505         Parcel reply = Parcel.obtain();
2506         data.writeInterfaceToken(IActivityManager.descriptor);
2507         data.writeStrongBinder(token);
2508         data.writeInt(onlyRoot ? 1 : 0);
2509         mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
2510         reply.readException();
2511         int res = reply.readInt();
2512         data.recycle();
2513         reply.recycle();
2514         return res;
2515     }
reportThumbnail(IBinder token, Bitmap thumbnail, CharSequence description)2516     public void reportThumbnail(IBinder token,
2517                                 Bitmap thumbnail, CharSequence description) throws RemoteException
2518     {
2519         Parcel data = Parcel.obtain();
2520         Parcel reply = Parcel.obtain();
2521         data.writeInterfaceToken(IActivityManager.descriptor);
2522         data.writeStrongBinder(token);
2523         if (thumbnail != null) {
2524             data.writeInt(1);
2525             thumbnail.writeToParcel(data, 0);
2526         } else {
2527             data.writeInt(0);
2528         }
2529         TextUtils.writeToParcel(description, data, 0);
2530         mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2531         reply.readException();
2532         data.recycle();
2533         reply.recycle();
2534     }
getContentProvider(IApplicationThread caller, String name, int userId, boolean stable)2535     public ContentProviderHolder getContentProvider(IApplicationThread caller,
2536             String name, int userId, boolean stable) throws RemoteException {
2537         Parcel data = Parcel.obtain();
2538         Parcel reply = Parcel.obtain();
2539         data.writeInterfaceToken(IActivityManager.descriptor);
2540         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2541         data.writeString(name);
2542         data.writeInt(userId);
2543         data.writeInt(stable ? 1 : 0);
2544         mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
2545         reply.readException();
2546         int res = reply.readInt();
2547         ContentProviderHolder cph = null;
2548         if (res != 0) {
2549             cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
2550         }
2551         data.recycle();
2552         reply.recycle();
2553         return cph;
2554     }
getContentProviderExternal(String name, int userId, IBinder token)2555     public ContentProviderHolder getContentProviderExternal(String name, int userId, IBinder token)
2556             throws RemoteException {
2557         Parcel data = Parcel.obtain();
2558         Parcel reply = Parcel.obtain();
2559         data.writeInterfaceToken(IActivityManager.descriptor);
2560         data.writeString(name);
2561         data.writeInt(userId);
2562         data.writeStrongBinder(token);
2563         mRemote.transact(GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION, data, reply, 0);
2564         reply.readException();
2565         int res = reply.readInt();
2566         ContentProviderHolder cph = null;
2567         if (res != 0) {
2568             cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
2569         }
2570         data.recycle();
2571         reply.recycle();
2572         return cph;
2573     }
publishContentProviders(IApplicationThread caller, List<ContentProviderHolder> providers)2574     public void publishContentProviders(IApplicationThread caller,
2575             List<ContentProviderHolder> providers) throws RemoteException
2576     {
2577         Parcel data = Parcel.obtain();
2578         Parcel reply = Parcel.obtain();
2579         data.writeInterfaceToken(IActivityManager.descriptor);
2580         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2581         data.writeTypedList(providers);
2582         mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
2583         reply.readException();
2584         data.recycle();
2585         reply.recycle();
2586     }
refContentProvider(IBinder connection, int stable, int unstable)2587     public boolean refContentProvider(IBinder connection, int stable, int unstable)
2588             throws RemoteException {
2589         Parcel data = Parcel.obtain();
2590         Parcel reply = Parcel.obtain();
2591         data.writeInterfaceToken(IActivityManager.descriptor);
2592         data.writeStrongBinder(connection);
2593         data.writeInt(stable);
2594         data.writeInt(unstable);
2595         mRemote.transact(REF_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
2596         reply.readException();
2597         boolean res = reply.readInt() != 0;
2598         data.recycle();
2599         reply.recycle();
2600         return res;
2601     }
unstableProviderDied(IBinder connection)2602     public void unstableProviderDied(IBinder connection) throws RemoteException {
2603         Parcel data = Parcel.obtain();
2604         Parcel reply = Parcel.obtain();
2605         data.writeInterfaceToken(IActivityManager.descriptor);
2606         data.writeStrongBinder(connection);
2607         mRemote.transact(UNSTABLE_PROVIDER_DIED_TRANSACTION, data, reply, 0);
2608         reply.readException();
2609         data.recycle();
2610         reply.recycle();
2611     }
2612 
removeContentProvider(IBinder connection, boolean stable)2613     public void removeContentProvider(IBinder connection, boolean stable) throws RemoteException {
2614         Parcel data = Parcel.obtain();
2615         Parcel reply = Parcel.obtain();
2616         data.writeInterfaceToken(IActivityManager.descriptor);
2617         data.writeStrongBinder(connection);
2618         data.writeInt(stable ? 1 : 0);
2619         mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
2620         reply.readException();
2621         data.recycle();
2622         reply.recycle();
2623     }
2624 
removeContentProviderExternal(String name, IBinder token)2625     public void removeContentProviderExternal(String name, IBinder token) throws RemoteException {
2626         Parcel data = Parcel.obtain();
2627         Parcel reply = Parcel.obtain();
2628         data.writeInterfaceToken(IActivityManager.descriptor);
2629         data.writeString(name);
2630         data.writeStrongBinder(token);
2631         mRemote.transact(REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION, data, reply, 0);
2632         reply.readException();
2633         data.recycle();
2634         reply.recycle();
2635     }
2636 
getRunningServiceControlPanel(ComponentName service)2637     public PendingIntent getRunningServiceControlPanel(ComponentName service)
2638             throws RemoteException
2639     {
2640         Parcel data = Parcel.obtain();
2641         Parcel reply = Parcel.obtain();
2642         data.writeInterfaceToken(IActivityManager.descriptor);
2643         service.writeToParcel(data, 0);
2644         mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
2645         reply.readException();
2646         PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
2647         data.recycle();
2648         reply.recycle();
2649         return res;
2650     }
2651 
startService(IApplicationThread caller, Intent service, String resolvedType, int userId)2652     public ComponentName startService(IApplicationThread caller, Intent service,
2653             String resolvedType, int userId) throws RemoteException
2654     {
2655         Parcel data = Parcel.obtain();
2656         Parcel reply = Parcel.obtain();
2657         data.writeInterfaceToken(IActivityManager.descriptor);
2658         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2659         service.writeToParcel(data, 0);
2660         data.writeString(resolvedType);
2661         data.writeInt(userId);
2662         mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
2663         reply.readException();
2664         ComponentName res = ComponentName.readFromParcel(reply);
2665         data.recycle();
2666         reply.recycle();
2667         return res;
2668     }
stopService(IApplicationThread caller, Intent service, String resolvedType, int userId)2669     public int stopService(IApplicationThread caller, Intent service,
2670             String resolvedType, int userId) throws RemoteException
2671     {
2672         Parcel data = Parcel.obtain();
2673         Parcel reply = Parcel.obtain();
2674         data.writeInterfaceToken(IActivityManager.descriptor);
2675         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2676         service.writeToParcel(data, 0);
2677         data.writeString(resolvedType);
2678         data.writeInt(userId);
2679         mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
2680         reply.readException();
2681         int res = reply.readInt();
2682         reply.recycle();
2683         data.recycle();
2684         return res;
2685     }
stopServiceToken(ComponentName className, IBinder token, int startId)2686     public boolean stopServiceToken(ComponentName className, IBinder token,
2687             int startId) throws RemoteException {
2688         Parcel data = Parcel.obtain();
2689         Parcel reply = Parcel.obtain();
2690         data.writeInterfaceToken(IActivityManager.descriptor);
2691         ComponentName.writeToParcel(className, data);
2692         data.writeStrongBinder(token);
2693         data.writeInt(startId);
2694         mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
2695         reply.readException();
2696         boolean res = reply.readInt() != 0;
2697         data.recycle();
2698         reply.recycle();
2699         return res;
2700     }
setServiceForeground(ComponentName className, IBinder token, int id, Notification notification, boolean removeNotification)2701     public void setServiceForeground(ComponentName className, IBinder token,
2702             int id, Notification notification, boolean removeNotification) throws RemoteException {
2703         Parcel data = Parcel.obtain();
2704         Parcel reply = Parcel.obtain();
2705         data.writeInterfaceToken(IActivityManager.descriptor);
2706         ComponentName.writeToParcel(className, data);
2707         data.writeStrongBinder(token);
2708         data.writeInt(id);
2709         if (notification != null) {
2710             data.writeInt(1);
2711             notification.writeToParcel(data, 0);
2712         } else {
2713             data.writeInt(0);
2714         }
2715         data.writeInt(removeNotification ? 1 : 0);
2716         mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
2717         reply.readException();
2718         data.recycle();
2719         reply.recycle();
2720     }
bindService(IApplicationThread caller, IBinder token, Intent service, String resolvedType, IServiceConnection connection, int flags, int userId)2721     public int bindService(IApplicationThread caller, IBinder token,
2722             Intent service, String resolvedType, IServiceConnection connection,
2723             int flags, int userId) throws RemoteException {
2724         Parcel data = Parcel.obtain();
2725         Parcel reply = Parcel.obtain();
2726         data.writeInterfaceToken(IActivityManager.descriptor);
2727         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2728         data.writeStrongBinder(token);
2729         service.writeToParcel(data, 0);
2730         data.writeString(resolvedType);
2731         data.writeStrongBinder(connection.asBinder());
2732         data.writeInt(flags);
2733         data.writeInt(userId);
2734         mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
2735         reply.readException();
2736         int res = reply.readInt();
2737         data.recycle();
2738         reply.recycle();
2739         return res;
2740     }
unbindService(IServiceConnection connection)2741     public boolean unbindService(IServiceConnection connection) throws RemoteException
2742     {
2743         Parcel data = Parcel.obtain();
2744         Parcel reply = Parcel.obtain();
2745         data.writeInterfaceToken(IActivityManager.descriptor);
2746         data.writeStrongBinder(connection.asBinder());
2747         mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
2748         reply.readException();
2749         boolean res = reply.readInt() != 0;
2750         data.recycle();
2751         reply.recycle();
2752         return res;
2753     }
2754 
publishService(IBinder token, Intent intent, IBinder service)2755     public void publishService(IBinder token,
2756             Intent intent, IBinder service) throws RemoteException {
2757         Parcel data = Parcel.obtain();
2758         Parcel reply = Parcel.obtain();
2759         data.writeInterfaceToken(IActivityManager.descriptor);
2760         data.writeStrongBinder(token);
2761         intent.writeToParcel(data, 0);
2762         data.writeStrongBinder(service);
2763         mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
2764         reply.readException();
2765         data.recycle();
2766         reply.recycle();
2767     }
2768 
unbindFinished(IBinder token, Intent intent, boolean doRebind)2769     public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
2770             throws RemoteException {
2771         Parcel data = Parcel.obtain();
2772         Parcel reply = Parcel.obtain();
2773         data.writeInterfaceToken(IActivityManager.descriptor);
2774         data.writeStrongBinder(token);
2775         intent.writeToParcel(data, 0);
2776         data.writeInt(doRebind ? 1 : 0);
2777         mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
2778         reply.readException();
2779         data.recycle();
2780         reply.recycle();
2781     }
2782 
serviceDoneExecuting(IBinder token, int type, int startId, int res)2783     public void serviceDoneExecuting(IBinder token, int type, int startId,
2784             int res) throws RemoteException {
2785         Parcel data = Parcel.obtain();
2786         Parcel reply = Parcel.obtain();
2787         data.writeInterfaceToken(IActivityManager.descriptor);
2788         data.writeStrongBinder(token);
2789         data.writeInt(type);
2790         data.writeInt(startId);
2791         data.writeInt(res);
2792         mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2793         reply.readException();
2794         data.recycle();
2795         reply.recycle();
2796     }
2797 
peekService(Intent service, String resolvedType)2798     public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
2799         Parcel data = Parcel.obtain();
2800         Parcel reply = Parcel.obtain();
2801         data.writeInterfaceToken(IActivityManager.descriptor);
2802         service.writeToParcel(data, 0);
2803         data.writeString(resolvedType);
2804         mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
2805         reply.readException();
2806         IBinder binder = reply.readStrongBinder();
2807         reply.recycle();
2808         data.recycle();
2809         return binder;
2810     }
2811 
bindBackupAgent(ApplicationInfo app, int backupRestoreMode)2812     public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
2813             throws RemoteException {
2814         Parcel data = Parcel.obtain();
2815         Parcel reply = Parcel.obtain();
2816         data.writeInterfaceToken(IActivityManager.descriptor);
2817         app.writeToParcel(data, 0);
2818         data.writeInt(backupRestoreMode);
2819         mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2820         reply.readException();
2821         boolean success = reply.readInt() != 0;
2822         reply.recycle();
2823         data.recycle();
2824         return success;
2825     }
2826 
clearPendingBackup()2827     public void clearPendingBackup() throws RemoteException {
2828         Parcel data = Parcel.obtain();
2829         Parcel reply = Parcel.obtain();
2830         data.writeInterfaceToken(IActivityManager.descriptor);
2831         mRemote.transact(CLEAR_PENDING_BACKUP_TRANSACTION, data, reply, 0);
2832         reply.recycle();
2833         data.recycle();
2834     }
2835 
backupAgentCreated(String packageName, IBinder agent)2836     public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
2837         Parcel data = Parcel.obtain();
2838         Parcel reply = Parcel.obtain();
2839         data.writeInterfaceToken(IActivityManager.descriptor);
2840         data.writeString(packageName);
2841         data.writeStrongBinder(agent);
2842         mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
2843         reply.recycle();
2844         data.recycle();
2845     }
2846 
unbindBackupAgent(ApplicationInfo app)2847     public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
2848         Parcel data = Parcel.obtain();
2849         Parcel reply = Parcel.obtain();
2850         data.writeInterfaceToken(IActivityManager.descriptor);
2851         app.writeToParcel(data, 0);
2852         mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2853         reply.readException();
2854         reply.recycle();
2855         data.recycle();
2856     }
2857 
startInstrumentation(ComponentName className, String profileFile, int flags, Bundle arguments, IInstrumentationWatcher watcher, int userId)2858     public boolean startInstrumentation(ComponentName className, String profileFile,
2859             int flags, Bundle arguments, IInstrumentationWatcher watcher, int userId)
2860             throws RemoteException {
2861         Parcel data = Parcel.obtain();
2862         Parcel reply = Parcel.obtain();
2863         data.writeInterfaceToken(IActivityManager.descriptor);
2864         ComponentName.writeToParcel(className, data);
2865         data.writeString(profileFile);
2866         data.writeInt(flags);
2867         data.writeBundle(arguments);
2868         data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2869         data.writeInt(userId);
2870         mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2871         reply.readException();
2872         boolean res = reply.readInt() != 0;
2873         reply.recycle();
2874         data.recycle();
2875         return res;
2876     }
2877 
finishInstrumentation(IApplicationThread target, int resultCode, Bundle results)2878     public void finishInstrumentation(IApplicationThread target,
2879             int resultCode, Bundle results) throws RemoteException {
2880         Parcel data = Parcel.obtain();
2881         Parcel reply = Parcel.obtain();
2882         data.writeInterfaceToken(IActivityManager.descriptor);
2883         data.writeStrongBinder(target != null ? target.asBinder() : null);
2884         data.writeInt(resultCode);
2885         data.writeBundle(results);
2886         mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2887         reply.readException();
2888         data.recycle();
2889         reply.recycle();
2890     }
getConfiguration()2891     public Configuration getConfiguration() throws RemoteException
2892     {
2893         Parcel data = Parcel.obtain();
2894         Parcel reply = Parcel.obtain();
2895         data.writeInterfaceToken(IActivityManager.descriptor);
2896         mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
2897         reply.readException();
2898         Configuration res = Configuration.CREATOR.createFromParcel(reply);
2899         reply.recycle();
2900         data.recycle();
2901         return res;
2902     }
updateConfiguration(Configuration values)2903     public void updateConfiguration(Configuration values) throws RemoteException
2904     {
2905         Parcel data = Parcel.obtain();
2906         Parcel reply = Parcel.obtain();
2907         data.writeInterfaceToken(IActivityManager.descriptor);
2908         values.writeToParcel(data, 0);
2909         mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
2910         reply.readException();
2911         data.recycle();
2912         reply.recycle();
2913     }
setRequestedOrientation(IBinder token, int requestedOrientation)2914     public void setRequestedOrientation(IBinder token, int requestedOrientation)
2915             throws RemoteException {
2916         Parcel data = Parcel.obtain();
2917         Parcel reply = Parcel.obtain();
2918         data.writeInterfaceToken(IActivityManager.descriptor);
2919         data.writeStrongBinder(token);
2920         data.writeInt(requestedOrientation);
2921         mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2922         reply.readException();
2923         data.recycle();
2924         reply.recycle();
2925     }
getRequestedOrientation(IBinder token)2926     public int getRequestedOrientation(IBinder token) throws RemoteException {
2927         Parcel data = Parcel.obtain();
2928         Parcel reply = Parcel.obtain();
2929         data.writeInterfaceToken(IActivityManager.descriptor);
2930         data.writeStrongBinder(token);
2931         mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2932         reply.readException();
2933         int res = reply.readInt();
2934         data.recycle();
2935         reply.recycle();
2936         return res;
2937     }
getActivityClassForToken(IBinder token)2938     public ComponentName getActivityClassForToken(IBinder token)
2939             throws RemoteException {
2940         Parcel data = Parcel.obtain();
2941         Parcel reply = Parcel.obtain();
2942         data.writeInterfaceToken(IActivityManager.descriptor);
2943         data.writeStrongBinder(token);
2944         mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2945         reply.readException();
2946         ComponentName res = ComponentName.readFromParcel(reply);
2947         data.recycle();
2948         reply.recycle();
2949         return res;
2950     }
getPackageForToken(IBinder token)2951     public String getPackageForToken(IBinder token) throws RemoteException
2952     {
2953         Parcel data = Parcel.obtain();
2954         Parcel reply = Parcel.obtain();
2955         data.writeInterfaceToken(IActivityManager.descriptor);
2956         data.writeStrongBinder(token);
2957         mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2958         reply.readException();
2959         String res = reply.readString();
2960         data.recycle();
2961         reply.recycle();
2962         return res;
2963     }
getIntentSender(int type, String packageName, IBinder token, String resultWho, int requestCode, Intent[] intents, String[] resolvedTypes, int flags, Bundle options, int userId)2964     public IIntentSender getIntentSender(int type,
2965             String packageName, IBinder token, String resultWho,
2966             int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
2967             Bundle options, int userId) throws RemoteException {
2968         Parcel data = Parcel.obtain();
2969         Parcel reply = Parcel.obtain();
2970         data.writeInterfaceToken(IActivityManager.descriptor);
2971         data.writeInt(type);
2972         data.writeString(packageName);
2973         data.writeStrongBinder(token);
2974         data.writeString(resultWho);
2975         data.writeInt(requestCode);
2976         if (intents != null) {
2977             data.writeInt(1);
2978             data.writeTypedArray(intents, 0);
2979             data.writeStringArray(resolvedTypes);
2980         } else {
2981             data.writeInt(0);
2982         }
2983         data.writeInt(flags);
2984         if (options != null) {
2985             data.writeInt(1);
2986             options.writeToParcel(data, 0);
2987         } else {
2988             data.writeInt(0);
2989         }
2990         data.writeInt(userId);
2991         mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2992         reply.readException();
2993         IIntentSender res = IIntentSender.Stub.asInterface(
2994             reply.readStrongBinder());
2995         data.recycle();
2996         reply.recycle();
2997         return res;
2998     }
cancelIntentSender(IIntentSender sender)2999     public void cancelIntentSender(IIntentSender sender) throws RemoteException {
3000         Parcel data = Parcel.obtain();
3001         Parcel reply = Parcel.obtain();
3002         data.writeInterfaceToken(IActivityManager.descriptor);
3003         data.writeStrongBinder(sender.asBinder());
3004         mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
3005         reply.readException();
3006         data.recycle();
3007         reply.recycle();
3008     }
getPackageForIntentSender(IIntentSender sender)3009     public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
3010         Parcel data = Parcel.obtain();
3011         Parcel reply = Parcel.obtain();
3012         data.writeInterfaceToken(IActivityManager.descriptor);
3013         data.writeStrongBinder(sender.asBinder());
3014         mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
3015         reply.readException();
3016         String res = reply.readString();
3017         data.recycle();
3018         reply.recycle();
3019         return res;
3020     }
getUidForIntentSender(IIntentSender sender)3021     public int getUidForIntentSender(IIntentSender sender) throws RemoteException {
3022         Parcel data = Parcel.obtain();
3023         Parcel reply = Parcel.obtain();
3024         data.writeInterfaceToken(IActivityManager.descriptor);
3025         data.writeStrongBinder(sender.asBinder());
3026         mRemote.transact(GET_UID_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
3027         reply.readException();
3028         int res = reply.readInt();
3029         data.recycle();
3030         reply.recycle();
3031         return res;
3032     }
handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, boolean requireFull, String name, String callerPackage)3033     public int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
3034             boolean requireFull, String name, String callerPackage) throws RemoteException {
3035         Parcel data = Parcel.obtain();
3036         Parcel reply = Parcel.obtain();
3037         data.writeInterfaceToken(IActivityManager.descriptor);
3038         data.writeInt(callingPid);
3039         data.writeInt(callingUid);
3040         data.writeInt(userId);
3041         data.writeInt(allowAll ? 1 : 0);
3042         data.writeInt(requireFull ? 1 : 0);
3043         data.writeString(name);
3044         data.writeString(callerPackage);
3045         mRemote.transact(HANDLE_INCOMING_USER_TRANSACTION, data, reply, 0);
3046         reply.readException();
3047         int res = reply.readInt();
3048         data.recycle();
3049         reply.recycle();
3050         return res;
3051     }
setProcessLimit(int max)3052     public void setProcessLimit(int max) throws RemoteException
3053     {
3054         Parcel data = Parcel.obtain();
3055         Parcel reply = Parcel.obtain();
3056         data.writeInterfaceToken(IActivityManager.descriptor);
3057         data.writeInt(max);
3058         mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
3059         reply.readException();
3060         data.recycle();
3061         reply.recycle();
3062     }
getProcessLimit()3063     public int getProcessLimit() throws RemoteException
3064     {
3065         Parcel data = Parcel.obtain();
3066         Parcel reply = Parcel.obtain();
3067         data.writeInterfaceToken(IActivityManager.descriptor);
3068         mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
3069         reply.readException();
3070         int res = reply.readInt();
3071         data.recycle();
3072         reply.recycle();
3073         return res;
3074     }
setProcessForeground(IBinder token, int pid, boolean isForeground)3075     public void setProcessForeground(IBinder token, int pid,
3076             boolean isForeground) throws RemoteException {
3077         Parcel data = Parcel.obtain();
3078         Parcel reply = Parcel.obtain();
3079         data.writeInterfaceToken(IActivityManager.descriptor);
3080         data.writeStrongBinder(token);
3081         data.writeInt(pid);
3082         data.writeInt(isForeground ? 1 : 0);
3083         mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
3084         reply.readException();
3085         data.recycle();
3086         reply.recycle();
3087     }
checkPermission(String permission, int pid, int uid)3088     public int checkPermission(String permission, int pid, int uid)
3089             throws RemoteException {
3090         Parcel data = Parcel.obtain();
3091         Parcel reply = Parcel.obtain();
3092         data.writeInterfaceToken(IActivityManager.descriptor);
3093         data.writeString(permission);
3094         data.writeInt(pid);
3095         data.writeInt(uid);
3096         mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
3097         reply.readException();
3098         int res = reply.readInt();
3099         data.recycle();
3100         reply.recycle();
3101         return res;
3102     }
clearApplicationUserData(final String packageName, final IPackageDataObserver observer, final int userId)3103     public boolean clearApplicationUserData(final String packageName,
3104             final IPackageDataObserver observer, final int userId) throws RemoteException {
3105         Parcel data = Parcel.obtain();
3106         Parcel reply = Parcel.obtain();
3107         data.writeInterfaceToken(IActivityManager.descriptor);
3108         data.writeString(packageName);
3109         data.writeStrongBinder(observer.asBinder());
3110         data.writeInt(userId);
3111         mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
3112         reply.readException();
3113         boolean res = reply.readInt() != 0;
3114         data.recycle();
3115         reply.recycle();
3116         return res;
3117     }
checkUriPermission(Uri uri, int pid, int uid, int mode)3118     public int checkUriPermission(Uri uri, int pid, int uid, int mode)
3119             throws RemoteException {
3120         Parcel data = Parcel.obtain();
3121         Parcel reply = Parcel.obtain();
3122         data.writeInterfaceToken(IActivityManager.descriptor);
3123         uri.writeToParcel(data, 0);
3124         data.writeInt(pid);
3125         data.writeInt(uid);
3126         data.writeInt(mode);
3127         mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
3128         reply.readException();
3129         int res = reply.readInt();
3130         data.recycle();
3131         reply.recycle();
3132         return res;
3133     }
grantUriPermission(IApplicationThread caller, String targetPkg, Uri uri, int mode)3134     public void grantUriPermission(IApplicationThread caller, String targetPkg,
3135             Uri uri, int mode) throws RemoteException {
3136         Parcel data = Parcel.obtain();
3137         Parcel reply = Parcel.obtain();
3138         data.writeInterfaceToken(IActivityManager.descriptor);
3139         data.writeStrongBinder(caller.asBinder());
3140         data.writeString(targetPkg);
3141         uri.writeToParcel(data, 0);
3142         data.writeInt(mode);
3143         mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
3144         reply.readException();
3145         data.recycle();
3146         reply.recycle();
3147     }
revokeUriPermission(IApplicationThread caller, Uri uri, int mode)3148     public void revokeUriPermission(IApplicationThread caller, Uri uri,
3149             int mode) throws RemoteException {
3150         Parcel data = Parcel.obtain();
3151         Parcel reply = Parcel.obtain();
3152         data.writeInterfaceToken(IActivityManager.descriptor);
3153         data.writeStrongBinder(caller.asBinder());
3154         uri.writeToParcel(data, 0);
3155         data.writeInt(mode);
3156         mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
3157         reply.readException();
3158         data.recycle();
3159         reply.recycle();
3160     }
showWaitingForDebugger(IApplicationThread who, boolean waiting)3161     public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
3162             throws RemoteException {
3163         Parcel data = Parcel.obtain();
3164         Parcel reply = Parcel.obtain();
3165         data.writeInterfaceToken(IActivityManager.descriptor);
3166         data.writeStrongBinder(who.asBinder());
3167         data.writeInt(waiting ? 1 : 0);
3168         mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
3169         reply.readException();
3170         data.recycle();
3171         reply.recycle();
3172     }
getMemoryInfo(ActivityManager.MemoryInfo outInfo)3173     public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
3174         Parcel data = Parcel.obtain();
3175         Parcel reply = Parcel.obtain();
3176         data.writeInterfaceToken(IActivityManager.descriptor);
3177         mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
3178         reply.readException();
3179         outInfo.readFromParcel(reply);
3180         data.recycle();
3181         reply.recycle();
3182     }
unhandledBack()3183     public void unhandledBack() throws RemoteException
3184     {
3185         Parcel data = Parcel.obtain();
3186         Parcel reply = Parcel.obtain();
3187         data.writeInterfaceToken(IActivityManager.descriptor);
3188         mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
3189         reply.readException();
3190         data.recycle();
3191         reply.recycle();
3192     }
openContentUri(Uri uri)3193     public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
3194     {
3195         Parcel data = Parcel.obtain();
3196         Parcel reply = Parcel.obtain();
3197         data.writeInterfaceToken(IActivityManager.descriptor);
3198         mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
3199         reply.readException();
3200         ParcelFileDescriptor pfd = null;
3201         if (reply.readInt() != 0) {
3202             pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
3203         }
3204         data.recycle();
3205         reply.recycle();
3206         return pfd;
3207     }
goingToSleep()3208     public void goingToSleep() throws RemoteException
3209     {
3210         Parcel data = Parcel.obtain();
3211         Parcel reply = Parcel.obtain();
3212         data.writeInterfaceToken(IActivityManager.descriptor);
3213         mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
3214         reply.readException();
3215         data.recycle();
3216         reply.recycle();
3217     }
wakingUp()3218     public void wakingUp() throws RemoteException
3219     {
3220         Parcel data = Parcel.obtain();
3221         Parcel reply = Parcel.obtain();
3222         data.writeInterfaceToken(IActivityManager.descriptor);
3223         mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
3224         reply.readException();
3225         data.recycle();
3226         reply.recycle();
3227     }
setLockScreenShown(boolean shown)3228     public void setLockScreenShown(boolean shown) throws RemoteException
3229     {
3230         Parcel data = Parcel.obtain();
3231         Parcel reply = Parcel.obtain();
3232         data.writeInterfaceToken(IActivityManager.descriptor);
3233         data.writeInt(shown ? 1 : 0);
3234         mRemote.transact(SET_LOCK_SCREEN_SHOWN_TRANSACTION, data, reply, 0);
3235         reply.readException();
3236         data.recycle();
3237         reply.recycle();
3238     }
setDebugApp( String packageName, boolean waitForDebugger, boolean persistent)3239     public void setDebugApp(
3240         String packageName, boolean waitForDebugger, boolean persistent)
3241         throws RemoteException
3242     {
3243         Parcel data = Parcel.obtain();
3244         Parcel reply = Parcel.obtain();
3245         data.writeInterfaceToken(IActivityManager.descriptor);
3246         data.writeString(packageName);
3247         data.writeInt(waitForDebugger ? 1 : 0);
3248         data.writeInt(persistent ? 1 : 0);
3249         mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
3250         reply.readException();
3251         data.recycle();
3252         reply.recycle();
3253     }
setAlwaysFinish(boolean enabled)3254     public void setAlwaysFinish(boolean enabled) throws RemoteException
3255     {
3256         Parcel data = Parcel.obtain();
3257         Parcel reply = Parcel.obtain();
3258         data.writeInterfaceToken(IActivityManager.descriptor);
3259         data.writeInt(enabled ? 1 : 0);
3260         mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
3261         reply.readException();
3262         data.recycle();
3263         reply.recycle();
3264     }
setActivityController(IActivityController watcher)3265     public void setActivityController(IActivityController watcher) throws RemoteException
3266     {
3267         Parcel data = Parcel.obtain();
3268         Parcel reply = Parcel.obtain();
3269         data.writeInterfaceToken(IActivityManager.descriptor);
3270         data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
3271         mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
3272         reply.readException();
3273         data.recycle();
3274         reply.recycle();
3275     }
enterSafeMode()3276     public void enterSafeMode() throws RemoteException {
3277         Parcel data = Parcel.obtain();
3278         data.writeInterfaceToken(IActivityManager.descriptor);
3279         mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
3280         data.recycle();
3281     }
noteWakeupAlarm(IIntentSender sender)3282     public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
3283         Parcel data = Parcel.obtain();
3284         data.writeStrongBinder(sender.asBinder());
3285         data.writeInterfaceToken(IActivityManager.descriptor);
3286         mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
3287         data.recycle();
3288     }
killPids(int[] pids, String reason, boolean secure)3289     public boolean killPids(int[] pids, String reason, boolean secure) throws RemoteException {
3290         Parcel data = Parcel.obtain();
3291         Parcel reply = Parcel.obtain();
3292         data.writeInterfaceToken(IActivityManager.descriptor);
3293         data.writeIntArray(pids);
3294         data.writeString(reason);
3295         data.writeInt(secure ? 1 : 0);
3296         mRemote.transact(KILL_PIDS_TRANSACTION, data, reply, 0);
3297         boolean res = reply.readInt() != 0;
3298         data.recycle();
3299         reply.recycle();
3300         return res;
3301     }
3302     @Override
killProcessesBelowForeground(String reason)3303     public boolean killProcessesBelowForeground(String reason) throws RemoteException {
3304         Parcel data = Parcel.obtain();
3305         Parcel reply = Parcel.obtain();
3306         data.writeInterfaceToken(IActivityManager.descriptor);
3307         data.writeString(reason);
3308         mRemote.transact(KILL_PROCESSES_BELOW_FOREGROUND_TRANSACTION, data, reply, 0);
3309         boolean res = reply.readInt() != 0;
3310         data.recycle();
3311         reply.recycle();
3312         return res;
3313     }
startRunning(String pkg, String cls, String action, String indata)3314     public void startRunning(String pkg, String cls, String action,
3315             String indata) throws RemoteException {
3316         Parcel data = Parcel.obtain();
3317         Parcel reply = Parcel.obtain();
3318         data.writeInterfaceToken(IActivityManager.descriptor);
3319         data.writeString(pkg);
3320         data.writeString(cls);
3321         data.writeString(action);
3322         data.writeString(indata);
3323         mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
3324         reply.readException();
3325         data.recycle();
3326         reply.recycle();
3327     }
testIsSystemReady()3328     public boolean testIsSystemReady()
3329     {
3330         /* this base class version is never called */
3331         return true;
3332     }
handleApplicationCrash(IBinder app, ApplicationErrorReport.CrashInfo crashInfo)3333     public void handleApplicationCrash(IBinder app,
3334             ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
3335     {
3336         Parcel data = Parcel.obtain();
3337         Parcel reply = Parcel.obtain();
3338         data.writeInterfaceToken(IActivityManager.descriptor);
3339         data.writeStrongBinder(app);
3340         crashInfo.writeToParcel(data, 0);
3341         mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
3342         reply.readException();
3343         reply.recycle();
3344         data.recycle();
3345     }
3346 
handleApplicationWtf(IBinder app, String tag, ApplicationErrorReport.CrashInfo crashInfo)3347     public boolean handleApplicationWtf(IBinder app, String tag,
3348             ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
3349     {
3350         Parcel data = Parcel.obtain();
3351         Parcel reply = Parcel.obtain();
3352         data.writeInterfaceToken(IActivityManager.descriptor);
3353         data.writeStrongBinder(app);
3354         data.writeString(tag);
3355         crashInfo.writeToParcel(data, 0);
3356         mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
3357         reply.readException();
3358         boolean res = reply.readInt() != 0;
3359         reply.recycle();
3360         data.recycle();
3361         return res;
3362     }
3363 
handleApplicationStrictModeViolation(IBinder app, int violationMask, StrictMode.ViolationInfo info)3364     public void handleApplicationStrictModeViolation(IBinder app,
3365             int violationMask,
3366             StrictMode.ViolationInfo info) throws RemoteException
3367     {
3368         Parcel data = Parcel.obtain();
3369         Parcel reply = Parcel.obtain();
3370         data.writeInterfaceToken(IActivityManager.descriptor);
3371         data.writeStrongBinder(app);
3372         data.writeInt(violationMask);
3373         info.writeToParcel(data, 0);
3374         mRemote.transact(HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION, data, reply, 0);
3375         reply.readException();
3376         reply.recycle();
3377         data.recycle();
3378     }
3379 
signalPersistentProcesses(int sig)3380     public void signalPersistentProcesses(int sig) throws RemoteException {
3381         Parcel data = Parcel.obtain();
3382         Parcel reply = Parcel.obtain();
3383         data.writeInterfaceToken(IActivityManager.descriptor);
3384         data.writeInt(sig);
3385         mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
3386         reply.readException();
3387         data.recycle();
3388         reply.recycle();
3389     }
3390 
killBackgroundProcesses(String packageName, int userId)3391     public void killBackgroundProcesses(String packageName, int userId) throws RemoteException {
3392         Parcel data = Parcel.obtain();
3393         Parcel reply = Parcel.obtain();
3394         data.writeInterfaceToken(IActivityManager.descriptor);
3395         data.writeString(packageName);
3396         data.writeInt(userId);
3397         mRemote.transact(KILL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
3398         reply.readException();
3399         data.recycle();
3400         reply.recycle();
3401     }
3402 
killAllBackgroundProcesses()3403     public void killAllBackgroundProcesses() throws RemoteException {
3404         Parcel data = Parcel.obtain();
3405         Parcel reply = Parcel.obtain();
3406         data.writeInterfaceToken(IActivityManager.descriptor);
3407         mRemote.transact(KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
3408         reply.readException();
3409         data.recycle();
3410         reply.recycle();
3411     }
3412 
forceStopPackage(String packageName, int userId)3413     public void forceStopPackage(String packageName, int userId) throws RemoteException {
3414         Parcel data = Parcel.obtain();
3415         Parcel reply = Parcel.obtain();
3416         data.writeInterfaceToken(IActivityManager.descriptor);
3417         data.writeString(packageName);
3418         data.writeInt(userId);
3419         mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
3420         reply.readException();
3421         data.recycle();
3422         reply.recycle();
3423     }
3424 
getMyMemoryState(ActivityManager.RunningAppProcessInfo outInfo)3425     public void getMyMemoryState(ActivityManager.RunningAppProcessInfo outInfo)
3426             throws RemoteException
3427     {
3428         Parcel data = Parcel.obtain();
3429         Parcel reply = Parcel.obtain();
3430         data.writeInterfaceToken(IActivityManager.descriptor);
3431         mRemote.transact(GET_MY_MEMORY_STATE_TRANSACTION, data, reply, 0);
3432         reply.readException();
3433         outInfo.readFromParcel(reply);
3434         reply.recycle();
3435         data.recycle();
3436     }
3437 
getDeviceConfigurationInfo()3438     public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
3439     {
3440         Parcel data = Parcel.obtain();
3441         Parcel reply = Parcel.obtain();
3442         data.writeInterfaceToken(IActivityManager.descriptor);
3443         mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
3444         reply.readException();
3445         ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
3446         reply.recycle();
3447         data.recycle();
3448         return res;
3449     }
3450 
profileControl(String process, int userId, boolean start, String path, ParcelFileDescriptor fd, int profileType)3451     public boolean profileControl(String process, int userId, boolean start,
3452             String path, ParcelFileDescriptor fd, int profileType) throws RemoteException
3453     {
3454         Parcel data = Parcel.obtain();
3455         Parcel reply = Parcel.obtain();
3456         data.writeInterfaceToken(IActivityManager.descriptor);
3457         data.writeString(process);
3458         data.writeInt(userId);
3459         data.writeInt(start ? 1 : 0);
3460         data.writeInt(profileType);
3461         data.writeString(path);
3462         if (fd != null) {
3463             data.writeInt(1);
3464             fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
3465         } else {
3466             data.writeInt(0);
3467         }
3468         mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
3469         reply.readException();
3470         boolean res = reply.readInt() != 0;
3471         reply.recycle();
3472         data.recycle();
3473         return res;
3474     }
3475 
shutdown(int timeout)3476     public boolean shutdown(int timeout) throws RemoteException
3477     {
3478         Parcel data = Parcel.obtain();
3479         Parcel reply = Parcel.obtain();
3480         data.writeInterfaceToken(IActivityManager.descriptor);
3481         data.writeInt(timeout);
3482         mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
3483         reply.readException();
3484         boolean res = reply.readInt() != 0;
3485         reply.recycle();
3486         data.recycle();
3487         return res;
3488     }
3489 
stopAppSwitches()3490     public void stopAppSwitches() throws RemoteException {
3491         Parcel data = Parcel.obtain();
3492         Parcel reply = Parcel.obtain();
3493         data.writeInterfaceToken(IActivityManager.descriptor);
3494         mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
3495         reply.readException();
3496         reply.recycle();
3497         data.recycle();
3498     }
3499 
resumeAppSwitches()3500     public void resumeAppSwitches() throws RemoteException {
3501         Parcel data = Parcel.obtain();
3502         Parcel reply = Parcel.obtain();
3503         data.writeInterfaceToken(IActivityManager.descriptor);
3504         mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
3505         reply.readException();
3506         reply.recycle();
3507         data.recycle();
3508     }
3509 
killApplicationWithAppId(String pkg, int appid)3510     public void killApplicationWithAppId(String pkg, int appid) throws RemoteException {
3511         Parcel data = Parcel.obtain();
3512         Parcel reply = Parcel.obtain();
3513         data.writeInterfaceToken(IActivityManager.descriptor);
3514         data.writeString(pkg);
3515         data.writeInt(appid);
3516         mRemote.transact(KILL_APPLICATION_WITH_APPID_TRANSACTION, data, reply, 0);
3517         reply.readException();
3518         data.recycle();
3519         reply.recycle();
3520     }
3521 
closeSystemDialogs(String reason)3522     public void closeSystemDialogs(String reason) throws RemoteException {
3523         Parcel data = Parcel.obtain();
3524         Parcel reply = Parcel.obtain();
3525         data.writeInterfaceToken(IActivityManager.descriptor);
3526         data.writeString(reason);
3527         mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
3528         reply.readException();
3529         data.recycle();
3530         reply.recycle();
3531     }
3532 
getProcessMemoryInfo(int[] pids)3533     public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
3534             throws RemoteException {
3535         Parcel data = Parcel.obtain();
3536         Parcel reply = Parcel.obtain();
3537         data.writeInterfaceToken(IActivityManager.descriptor);
3538         data.writeIntArray(pids);
3539         mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
3540         reply.readException();
3541         Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
3542         data.recycle();
3543         reply.recycle();
3544         return res;
3545     }
3546 
killApplicationProcess(String processName, int uid)3547     public void killApplicationProcess(String processName, int uid) throws RemoteException {
3548         Parcel data = Parcel.obtain();
3549         Parcel reply = Parcel.obtain();
3550         data.writeInterfaceToken(IActivityManager.descriptor);
3551         data.writeString(processName);
3552         data.writeInt(uid);
3553         mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
3554         reply.readException();
3555         data.recycle();
3556         reply.recycle();
3557     }
3558 
overridePendingTransition(IBinder token, String packageName, int enterAnim, int exitAnim)3559     public void overridePendingTransition(IBinder token, String packageName,
3560             int enterAnim, int exitAnim) throws RemoteException {
3561         Parcel data = Parcel.obtain();
3562         Parcel reply = Parcel.obtain();
3563         data.writeInterfaceToken(IActivityManager.descriptor);
3564         data.writeStrongBinder(token);
3565         data.writeString(packageName);
3566         data.writeInt(enterAnim);
3567         data.writeInt(exitAnim);
3568         mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
3569         reply.readException();
3570         data.recycle();
3571         reply.recycle();
3572     }
3573 
isUserAMonkey()3574     public boolean isUserAMonkey() throws RemoteException {
3575         Parcel data = Parcel.obtain();
3576         Parcel reply = Parcel.obtain();
3577         data.writeInterfaceToken(IActivityManager.descriptor);
3578         mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0);
3579         reply.readException();
3580         boolean res = reply.readInt() != 0;
3581         data.recycle();
3582         reply.recycle();
3583         return res;
3584     }
3585 
finishHeavyWeightApp()3586     public void finishHeavyWeightApp() throws RemoteException {
3587         Parcel data = Parcel.obtain();
3588         Parcel reply = Parcel.obtain();
3589         data.writeInterfaceToken(IActivityManager.descriptor);
3590         mRemote.transact(FINISH_HEAVY_WEIGHT_APP_TRANSACTION, data, reply, 0);
3591         reply.readException();
3592         data.recycle();
3593         reply.recycle();
3594     }
3595 
setImmersive(IBinder token, boolean immersive)3596     public void setImmersive(IBinder token, boolean immersive)
3597             throws RemoteException {
3598         Parcel data = Parcel.obtain();
3599         Parcel reply = Parcel.obtain();
3600         data.writeInterfaceToken(IActivityManager.descriptor);
3601         data.writeStrongBinder(token);
3602         data.writeInt(immersive ? 1 : 0);
3603         mRemote.transact(SET_IMMERSIVE_TRANSACTION, data, reply, 0);
3604         reply.readException();
3605         data.recycle();
3606         reply.recycle();
3607     }
3608 
isImmersive(IBinder token)3609     public boolean isImmersive(IBinder token)
3610             throws RemoteException {
3611         Parcel data = Parcel.obtain();
3612         Parcel reply = Parcel.obtain();
3613         data.writeInterfaceToken(IActivityManager.descriptor);
3614         data.writeStrongBinder(token);
3615         mRemote.transact(IS_IMMERSIVE_TRANSACTION, data, reply, 0);
3616         reply.readException();
3617         boolean res = reply.readInt() == 1;
3618         data.recycle();
3619         reply.recycle();
3620         return res;
3621     }
3622 
isTopActivityImmersive()3623     public boolean isTopActivityImmersive()
3624             throws RemoteException {
3625         Parcel data = Parcel.obtain();
3626         Parcel reply = Parcel.obtain();
3627         data.writeInterfaceToken(IActivityManager.descriptor);
3628         mRemote.transact(IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION, data, reply, 0);
3629         reply.readException();
3630         boolean res = reply.readInt() == 1;
3631         data.recycle();
3632         reply.recycle();
3633         return res;
3634     }
3635 
crashApplication(int uid, int initialPid, String packageName, String message)3636     public void crashApplication(int uid, int initialPid, String packageName,
3637             String message) throws RemoteException {
3638         Parcel data = Parcel.obtain();
3639         Parcel reply = Parcel.obtain();
3640         data.writeInterfaceToken(IActivityManager.descriptor);
3641         data.writeInt(uid);
3642         data.writeInt(initialPid);
3643         data.writeString(packageName);
3644         data.writeString(message);
3645         mRemote.transact(CRASH_APPLICATION_TRANSACTION, data, reply, 0);
3646         reply.readException();
3647         data.recycle();
3648         reply.recycle();
3649     }
3650 
getProviderMimeType(Uri uri, int userId)3651     public String getProviderMimeType(Uri uri, int userId) throws RemoteException {
3652         Parcel data = Parcel.obtain();
3653         Parcel reply = Parcel.obtain();
3654         data.writeInterfaceToken(IActivityManager.descriptor);
3655         uri.writeToParcel(data, 0);
3656         data.writeInt(userId);
3657         mRemote.transact(GET_PROVIDER_MIME_TYPE_TRANSACTION, data, reply, 0);
3658         reply.readException();
3659         String res = reply.readString();
3660         data.recycle();
3661         reply.recycle();
3662         return res;
3663     }
3664 
newUriPermissionOwner(String name)3665     public IBinder newUriPermissionOwner(String name)
3666             throws RemoteException {
3667         Parcel data = Parcel.obtain();
3668         Parcel reply = Parcel.obtain();
3669         data.writeInterfaceToken(IActivityManager.descriptor);
3670         data.writeString(name);
3671         mRemote.transact(NEW_URI_PERMISSION_OWNER_TRANSACTION, data, reply, 0);
3672         reply.readException();
3673         IBinder res = reply.readStrongBinder();
3674         data.recycle();
3675         reply.recycle();
3676         return res;
3677     }
3678 
grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg, Uri uri, int mode)3679     public void grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg,
3680             Uri uri, int mode) throws RemoteException {
3681         Parcel data = Parcel.obtain();
3682         Parcel reply = Parcel.obtain();
3683         data.writeInterfaceToken(IActivityManager.descriptor);
3684         data.writeStrongBinder(owner);
3685         data.writeInt(fromUid);
3686         data.writeString(targetPkg);
3687         uri.writeToParcel(data, 0);
3688         data.writeInt(mode);
3689         mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
3690         reply.readException();
3691         data.recycle();
3692         reply.recycle();
3693     }
3694 
revokeUriPermissionFromOwner(IBinder owner, Uri uri, int mode)3695     public void revokeUriPermissionFromOwner(IBinder owner, Uri uri,
3696             int mode) throws RemoteException {
3697         Parcel data = Parcel.obtain();
3698         Parcel reply = Parcel.obtain();
3699         data.writeInterfaceToken(IActivityManager.descriptor);
3700         data.writeStrongBinder(owner);
3701         if (uri != null) {
3702             data.writeInt(1);
3703             uri.writeToParcel(data, 0);
3704         } else {
3705             data.writeInt(0);
3706         }
3707         data.writeInt(mode);
3708         mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
3709         reply.readException();
3710         data.recycle();
3711         reply.recycle();
3712     }
3713 
checkGrantUriPermission(int callingUid, String targetPkg, Uri uri, int modeFlags)3714     public int checkGrantUriPermission(int callingUid, String targetPkg,
3715             Uri uri, int modeFlags) throws RemoteException {
3716         Parcel data = Parcel.obtain();
3717         Parcel reply = Parcel.obtain();
3718         data.writeInterfaceToken(IActivityManager.descriptor);
3719         data.writeInt(callingUid);
3720         data.writeString(targetPkg);
3721         uri.writeToParcel(data, 0);
3722         data.writeInt(modeFlags);
3723         mRemote.transact(CHECK_GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
3724         reply.readException();
3725         int res = reply.readInt();
3726         data.recycle();
3727         reply.recycle();
3728         return res;
3729     }
3730 
dumpHeap(String process, int userId, boolean managed, String path, ParcelFileDescriptor fd)3731     public boolean dumpHeap(String process, int userId, boolean managed,
3732             String path, ParcelFileDescriptor fd) throws RemoteException {
3733         Parcel data = Parcel.obtain();
3734         Parcel reply = Parcel.obtain();
3735         data.writeInterfaceToken(IActivityManager.descriptor);
3736         data.writeString(process);
3737         data.writeInt(userId);
3738         data.writeInt(managed ? 1 : 0);
3739         data.writeString(path);
3740         if (fd != null) {
3741             data.writeInt(1);
3742             fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
3743         } else {
3744             data.writeInt(0);
3745         }
3746         mRemote.transact(DUMP_HEAP_TRANSACTION, data, reply, 0);
3747         reply.readException();
3748         boolean res = reply.readInt() != 0;
3749         reply.recycle();
3750         data.recycle();
3751         return res;
3752     }
3753 
startActivities(IApplicationThread caller, Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options, int userId)3754     public int startActivities(IApplicationThread caller,
3755             Intent[] intents, String[] resolvedTypes, IBinder resultTo,
3756             Bundle options, int userId) throws RemoteException {
3757         Parcel data = Parcel.obtain();
3758         Parcel reply = Parcel.obtain();
3759         data.writeInterfaceToken(IActivityManager.descriptor);
3760         data.writeStrongBinder(caller != null ? caller.asBinder() : null);
3761         data.writeTypedArray(intents, 0);
3762         data.writeStringArray(resolvedTypes);
3763         data.writeStrongBinder(resultTo);
3764         if (options != null) {
3765             data.writeInt(1);
3766             options.writeToParcel(data, 0);
3767         } else {
3768             data.writeInt(0);
3769         }
3770         data.writeInt(userId);
3771         mRemote.transact(START_ACTIVITIES_TRANSACTION, data, reply, 0);
3772         reply.readException();
3773         int result = reply.readInt();
3774         reply.recycle();
3775         data.recycle();
3776         return result;
3777     }
3778 
getFrontActivityScreenCompatMode()3779     public int getFrontActivityScreenCompatMode() throws RemoteException {
3780         Parcel data = Parcel.obtain();
3781         Parcel reply = Parcel.obtain();
3782         data.writeInterfaceToken(IActivityManager.descriptor);
3783         mRemote.transact(GET_FRONT_ACTIVITY_SCREEN_COMPAT_MODE_TRANSACTION, data, reply, 0);
3784         reply.readException();
3785         int mode = reply.readInt();
3786         reply.recycle();
3787         data.recycle();
3788         return mode;
3789     }
3790 
setFrontActivityScreenCompatMode(int mode)3791     public void setFrontActivityScreenCompatMode(int mode) throws RemoteException {
3792         Parcel data = Parcel.obtain();
3793         Parcel reply = Parcel.obtain();
3794         data.writeInterfaceToken(IActivityManager.descriptor);
3795         data.writeInt(mode);
3796         mRemote.transact(SET_FRONT_ACTIVITY_SCREEN_COMPAT_MODE_TRANSACTION, data, reply, 0);
3797         reply.readException();
3798         reply.recycle();
3799         data.recycle();
3800     }
3801 
getPackageScreenCompatMode(String packageName)3802     public int getPackageScreenCompatMode(String packageName) throws RemoteException {
3803         Parcel data = Parcel.obtain();
3804         Parcel reply = Parcel.obtain();
3805         data.writeInterfaceToken(IActivityManager.descriptor);
3806         data.writeString(packageName);
3807         mRemote.transact(GET_PACKAGE_SCREEN_COMPAT_MODE_TRANSACTION, data, reply, 0);
3808         reply.readException();
3809         int mode = reply.readInt();
3810         reply.recycle();
3811         data.recycle();
3812         return mode;
3813     }
3814 
setPackageScreenCompatMode(String packageName, int mode)3815     public void setPackageScreenCompatMode(String packageName, int mode)
3816             throws RemoteException {
3817         Parcel data = Parcel.obtain();
3818         Parcel reply = Parcel.obtain();
3819         data.writeInterfaceToken(IActivityManager.descriptor);
3820         data.writeString(packageName);
3821         data.writeInt(mode);
3822         mRemote.transact(SET_PACKAGE_SCREEN_COMPAT_MODE_TRANSACTION, data, reply, 0);
3823         reply.readException();
3824         reply.recycle();
3825         data.recycle();
3826     }
3827 
getPackageAskScreenCompat(String packageName)3828     public boolean getPackageAskScreenCompat(String packageName) throws RemoteException {
3829         Parcel data = Parcel.obtain();
3830         Parcel reply = Parcel.obtain();
3831         data.writeInterfaceToken(IActivityManager.descriptor);
3832         data.writeString(packageName);
3833         mRemote.transact(GET_PACKAGE_ASK_SCREEN_COMPAT_TRANSACTION, data, reply, 0);
3834         reply.readException();
3835         boolean ask = reply.readInt() != 0;
3836         reply.recycle();
3837         data.recycle();
3838         return ask;
3839     }
3840 
setPackageAskScreenCompat(String packageName, boolean ask)3841     public void setPackageAskScreenCompat(String packageName, boolean ask)
3842             throws RemoteException {
3843         Parcel data = Parcel.obtain();
3844         Parcel reply = Parcel.obtain();
3845         data.writeInterfaceToken(IActivityManager.descriptor);
3846         data.writeString(packageName);
3847         data.writeInt(ask ? 1 : 0);
3848         mRemote.transact(SET_PACKAGE_ASK_SCREEN_COMPAT_TRANSACTION, data, reply, 0);
3849         reply.readException();
3850         reply.recycle();
3851         data.recycle();
3852     }
3853 
switchUser(int userid)3854     public boolean switchUser(int userid) throws RemoteException {
3855         Parcel data = Parcel.obtain();
3856         Parcel reply = Parcel.obtain();
3857         data.writeInterfaceToken(IActivityManager.descriptor);
3858         data.writeInt(userid);
3859         mRemote.transact(SWITCH_USER_TRANSACTION, data, reply, 0);
3860         reply.readException();
3861         boolean result = reply.readInt() != 0;
3862         reply.recycle();
3863         data.recycle();
3864         return result;
3865     }
3866 
stopUser(int userid, IStopUserCallback callback)3867     public int stopUser(int userid, IStopUserCallback callback) throws RemoteException {
3868         Parcel data = Parcel.obtain();
3869         Parcel reply = Parcel.obtain();
3870         data.writeInterfaceToken(IActivityManager.descriptor);
3871         data.writeInt(userid);
3872         data.writeStrongInterface(callback);
3873         mRemote.transact(STOP_USER_TRANSACTION, data, reply, 0);
3874         reply.readException();
3875         int result = reply.readInt();
3876         reply.recycle();
3877         data.recycle();
3878         return result;
3879     }
3880 
getCurrentUser()3881     public UserInfo getCurrentUser() throws RemoteException {
3882         Parcel data = Parcel.obtain();
3883         Parcel reply = Parcel.obtain();
3884         data.writeInterfaceToken(IActivityManager.descriptor);
3885         mRemote.transact(GET_CURRENT_USER_TRANSACTION, data, reply, 0);
3886         reply.readException();
3887         UserInfo userInfo = UserInfo.CREATOR.createFromParcel(reply);
3888         reply.recycle();
3889         data.recycle();
3890         return userInfo;
3891     }
3892 
isUserRunning(int userid, boolean orStopping)3893     public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException {
3894         Parcel data = Parcel.obtain();
3895         Parcel reply = Parcel.obtain();
3896         data.writeInterfaceToken(IActivityManager.descriptor);
3897         data.writeInt(userid);
3898         data.writeInt(orStopping ? 1 : 0);
3899         mRemote.transact(IS_USER_RUNNING_TRANSACTION, data, reply, 0);
3900         reply.readException();
3901         boolean result = reply.readInt() != 0;
3902         reply.recycle();
3903         data.recycle();
3904         return result;
3905     }
3906 
getRunningUserIds()3907     public int[] getRunningUserIds() throws RemoteException {
3908         Parcel data = Parcel.obtain();
3909         Parcel reply = Parcel.obtain();
3910         data.writeInterfaceToken(IActivityManager.descriptor);
3911         mRemote.transact(GET_RUNNING_USER_IDS_TRANSACTION, data, reply, 0);
3912         reply.readException();
3913         int[] result = reply.createIntArray();
3914         reply.recycle();
3915         data.recycle();
3916         return result;
3917     }
3918 
removeSubTask(int taskId, int subTaskIndex)3919     public boolean removeSubTask(int taskId, int subTaskIndex) throws RemoteException {
3920         Parcel data = Parcel.obtain();
3921         Parcel reply = Parcel.obtain();
3922         data.writeInterfaceToken(IActivityManager.descriptor);
3923         data.writeInt(taskId);
3924         data.writeInt(subTaskIndex);
3925         mRemote.transact(REMOVE_SUB_TASK_TRANSACTION, data, reply, 0);
3926         reply.readException();
3927         boolean result = reply.readInt() != 0;
3928         reply.recycle();
3929         data.recycle();
3930         return result;
3931     }
3932 
removeTask(int taskId, int flags)3933     public boolean removeTask(int taskId, int flags) throws RemoteException {
3934         Parcel data = Parcel.obtain();
3935         Parcel reply = Parcel.obtain();
3936         data.writeInterfaceToken(IActivityManager.descriptor);
3937         data.writeInt(taskId);
3938         data.writeInt(flags);
3939         mRemote.transact(REMOVE_TASK_TRANSACTION, data, reply, 0);
3940         reply.readException();
3941         boolean result = reply.readInt() != 0;
3942         reply.recycle();
3943         data.recycle();
3944         return result;
3945     }
3946 
registerProcessObserver(IProcessObserver observer)3947     public void registerProcessObserver(IProcessObserver observer) throws RemoteException {
3948         Parcel data = Parcel.obtain();
3949         Parcel reply = Parcel.obtain();
3950         data.writeInterfaceToken(IActivityManager.descriptor);
3951         data.writeStrongBinder(observer != null ? observer.asBinder() : null);
3952         mRemote.transact(REGISTER_PROCESS_OBSERVER_TRANSACTION, data, reply, 0);
3953         reply.readException();
3954         data.recycle();
3955         reply.recycle();
3956     }
3957 
unregisterProcessObserver(IProcessObserver observer)3958     public void unregisterProcessObserver(IProcessObserver observer) throws RemoteException {
3959         Parcel data = Parcel.obtain();
3960         Parcel reply = Parcel.obtain();
3961         data.writeInterfaceToken(IActivityManager.descriptor);
3962         data.writeStrongBinder(observer != null ? observer.asBinder() : null);
3963         mRemote.transact(UNREGISTER_PROCESS_OBSERVER_TRANSACTION, data, reply, 0);
3964         reply.readException();
3965         data.recycle();
3966         reply.recycle();
3967     }
3968 
isIntentSenderTargetedToPackage(IIntentSender sender)3969     public boolean isIntentSenderTargetedToPackage(IIntentSender sender) throws RemoteException {
3970         Parcel data = Parcel.obtain();
3971         Parcel reply = Parcel.obtain();
3972         data.writeInterfaceToken(IActivityManager.descriptor);
3973         data.writeStrongBinder(sender.asBinder());
3974         mRemote.transact(IS_INTENT_SENDER_TARGETED_TO_PACKAGE_TRANSACTION, data, reply, 0);
3975         reply.readException();
3976         boolean res = reply.readInt() != 0;
3977         data.recycle();
3978         reply.recycle();
3979         return res;
3980     }
3981 
isIntentSenderAnActivity(IIntentSender sender)3982     public boolean isIntentSenderAnActivity(IIntentSender sender) throws RemoteException {
3983         Parcel data = Parcel.obtain();
3984         Parcel reply = Parcel.obtain();
3985         data.writeInterfaceToken(IActivityManager.descriptor);
3986         data.writeStrongBinder(sender.asBinder());
3987         mRemote.transact(IS_INTENT_SENDER_AN_ACTIVITY_TRANSACTION, data, reply, 0);
3988         reply.readException();
3989         boolean res = reply.readInt() != 0;
3990         data.recycle();
3991         reply.recycle();
3992         return res;
3993     }
3994 
getIntentForIntentSender(IIntentSender sender)3995     public Intent getIntentForIntentSender(IIntentSender sender) throws RemoteException {
3996         Parcel data = Parcel.obtain();
3997         Parcel reply = Parcel.obtain();
3998         data.writeInterfaceToken(IActivityManager.descriptor);
3999         data.writeStrongBinder(sender.asBinder());
4000         mRemote.transact(GET_INTENT_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
4001         reply.readException();
4002         Intent res = reply.readInt() != 0
4003                 ? Intent.CREATOR.createFromParcel(reply) : null;
4004         data.recycle();
4005         reply.recycle();
4006         return res;
4007     }
4008 
updatePersistentConfiguration(Configuration values)4009     public void updatePersistentConfiguration(Configuration values) throws RemoteException
4010     {
4011         Parcel data = Parcel.obtain();
4012         Parcel reply = Parcel.obtain();
4013         data.writeInterfaceToken(IActivityManager.descriptor);
4014         values.writeToParcel(data, 0);
4015         mRemote.transact(UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION, data, reply, 0);
4016         reply.readException();
4017         data.recycle();
4018         reply.recycle();
4019     }
4020 
getProcessPss(int[] pids)4021     public long[] getProcessPss(int[] pids) throws RemoteException {
4022         Parcel data = Parcel.obtain();
4023         Parcel reply = Parcel.obtain();
4024         data.writeInterfaceToken(IActivityManager.descriptor);
4025         data.writeIntArray(pids);
4026         mRemote.transact(GET_PROCESS_PSS_TRANSACTION, data, reply, 0);
4027         reply.readException();
4028         long[] res = reply.createLongArray();
4029         data.recycle();
4030         reply.recycle();
4031         return res;
4032     }
4033 
showBootMessage(CharSequence msg, boolean always)4034     public void showBootMessage(CharSequence msg, boolean always) throws RemoteException {
4035         Parcel data = Parcel.obtain();
4036         Parcel reply = Parcel.obtain();
4037         data.writeInterfaceToken(IActivityManager.descriptor);
4038         TextUtils.writeToParcel(msg, data, 0);
4039         data.writeInt(always ? 1 : 0);
4040         mRemote.transact(SHOW_BOOT_MESSAGE_TRANSACTION, data, reply, 0);
4041         reply.readException();
4042         data.recycle();
4043         reply.recycle();
4044     }
4045 
dismissKeyguardOnNextActivity()4046     public void dismissKeyguardOnNextActivity() throws RemoteException {
4047         Parcel data = Parcel.obtain();
4048         Parcel reply = Parcel.obtain();
4049         data.writeInterfaceToken(IActivityManager.descriptor);
4050         mRemote.transact(DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION, data, reply, 0);
4051         reply.readException();
4052         data.recycle();
4053         reply.recycle();
4054     }
4055 
targetTaskAffinityMatchesActivity(IBinder token, String destAffinity)4056     public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity)
4057             throws RemoteException {
4058         Parcel data = Parcel.obtain();
4059         Parcel reply = Parcel.obtain();
4060         data.writeInterfaceToken(IActivityManager.descriptor);
4061         data.writeStrongBinder(token);
4062         data.writeString(destAffinity);
4063         mRemote.transact(TARGET_TASK_AFFINITY_MATCHES_ACTIVITY_TRANSACTION, data, reply, 0);
4064         reply.readException();
4065         boolean result = reply.readInt() != 0;
4066         data.recycle();
4067         reply.recycle();
4068         return result;
4069     }
4070 
navigateUpTo(IBinder token, Intent target, int resultCode, Intent resultData)4071     public boolean navigateUpTo(IBinder token, Intent target, int resultCode, Intent resultData)
4072             throws RemoteException {
4073         Parcel data = Parcel.obtain();
4074         Parcel reply = Parcel.obtain();
4075         data.writeInterfaceToken(IActivityManager.descriptor);
4076         data.writeStrongBinder(token);
4077         target.writeToParcel(data, 0);
4078         data.writeInt(resultCode);
4079         if (resultData != null) {
4080             data.writeInt(1);
4081             resultData.writeToParcel(data, 0);
4082         } else {
4083             data.writeInt(0);
4084         }
4085         mRemote.transact(NAVIGATE_UP_TO_TRANSACTION, data, reply, 0);
4086         reply.readException();
4087         boolean result = reply.readInt() != 0;
4088         data.recycle();
4089         reply.recycle();
4090         return result;
4091     }
4092 
getLaunchedFromUid(IBinder activityToken)4093     public int getLaunchedFromUid(IBinder activityToken) throws RemoteException {
4094         Parcel data = Parcel.obtain();
4095         Parcel reply = Parcel.obtain();
4096         data.writeInterfaceToken(IActivityManager.descriptor);
4097         data.writeStrongBinder(activityToken);
4098         mRemote.transact(GET_LAUNCHED_FROM_UID_TRANSACTION, data, reply, 0);
4099         reply.readException();
4100         int result = reply.readInt();
4101         data.recycle();
4102         reply.recycle();
4103         return result;
4104     }
4105 
registerUserSwitchObserver(IUserSwitchObserver observer)4106     public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException {
4107         Parcel data = Parcel.obtain();
4108         Parcel reply = Parcel.obtain();
4109         data.writeInterfaceToken(IActivityManager.descriptor);
4110         data.writeStrongBinder(observer != null ? observer.asBinder() : null);
4111         mRemote.transact(REGISTER_USER_SWITCH_OBSERVER_TRANSACTION, data, reply, 0);
4112         reply.readException();
4113         data.recycle();
4114         reply.recycle();
4115     }
4116 
unregisterUserSwitchObserver(IUserSwitchObserver observer)4117     public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException {
4118         Parcel data = Parcel.obtain();
4119         Parcel reply = Parcel.obtain();
4120         data.writeInterfaceToken(IActivityManager.descriptor);
4121         data.writeStrongBinder(observer != null ? observer.asBinder() : null);
4122         mRemote.transact(UNREGISTER_USER_SWITCH_OBSERVER_TRANSACTION, data, reply, 0);
4123         reply.readException();
4124         data.recycle();
4125         reply.recycle();
4126     }
4127 
requestBugReport()4128     public void requestBugReport() throws RemoteException {
4129         Parcel data = Parcel.obtain();
4130         Parcel reply = Parcel.obtain();
4131         data.writeInterfaceToken(IActivityManager.descriptor);
4132         mRemote.transact(REQUEST_BUG_REPORT_TRANSACTION, data, reply, 0);
4133         reply.readException();
4134         data.recycle();
4135         reply.recycle();
4136     }
4137 
inputDispatchingTimedOut(int pid, boolean aboveSystem)4138     public long inputDispatchingTimedOut(int pid, boolean aboveSystem) throws RemoteException {
4139         Parcel data = Parcel.obtain();
4140         Parcel reply = Parcel.obtain();
4141         data.writeInterfaceToken(IActivityManager.descriptor);
4142         data.writeInt(pid);
4143         data.writeInt(aboveSystem ? 1 : 0);
4144         mRemote.transact(INPUT_DISPATCHING_TIMED_OUT_TRANSACTION, data, reply, 0);
4145         reply.readException();
4146         long res = reply.readInt();
4147         data.recycle();
4148         reply.recycle();
4149         return res;
4150     }
4151 
4152     private IBinder mRemote;
4153 }
4154