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