1 /*
2  * Copyright (C) 2016 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.app.ActivityManager;
20 import android.app.ActivityManager.PendingIntentInfo;
21 import android.app.ActivityTaskManager;
22 import android.app.ApplicationStartInfo;
23 import android.app.ApplicationErrorReport;
24 import android.app.ApplicationExitInfo;
25 import android.app.ContentProviderHolder;
26 import android.app.GrantedUriPermission;
27 import android.app.IApplicationStartInfoCompleteListener;
28 import android.app.IApplicationThread;
29 import android.app.IActivityController;
30 import android.app.IAppTask;
31 import android.app.IForegroundServiceObserver;
32 import android.app.IInstrumentationWatcher;
33 import android.app.IProcessObserver;
34 import android.app.IServiceConnection;
35 import android.app.IStopUserCallback;
36 import android.app.ITaskStackListener;
37 import android.app.IUiAutomationConnection;
38 import android.app.IUidFrozenStateChangedCallback;
39 import android.app.IUidObserver;
40 import android.app.IUserSwitchObserver;
41 import android.app.Notification;
42 import android.app.PendingIntent;
43 import android.app.PictureInPictureParams;
44 import android.app.ProfilerInfo;
45 import android.app.WaitResult;
46 import android.app.assist.AssistContent;
47 import android.app.assist.AssistStructure;
48 import android.content.ComponentName;
49 import android.content.IIntentReceiver;
50 import android.content.IIntentSender;
51 import android.content.Intent;
52 import android.content.IntentFilter;
53 import android.content.IntentSender;
54 import android.content.pm.ApplicationInfo;
55 import android.content.pm.ConfigurationInfo;
56 import android.content.pm.IPackageDataObserver;
57 import android.content.pm.ParceledListSlice;
58 import android.content.pm.ProviderInfo;
59 import android.content.pm.ResolveInfo;
60 import android.content.pm.UserInfo;
61 import android.content.res.Configuration;
62 import android.content.LocusId;
63 import android.graphics.Bitmap;
64 import android.graphics.GraphicBuffer;
65 import android.graphics.Point;
66 import android.graphics.Rect;
67 import android.net.Uri;
68 import android.os.Bundle;
69 import android.os.Debug;
70 import android.os.IBinder;
71 import android.os.IProgressListener;
72 import android.os.ParcelFileDescriptor;
73 import android.os.PersistableBundle;
74 import android.os.RemoteCallback;
75 import android.os.StrictMode;
76 import android.os.WorkSource;
77 import android.service.voice.IVoiceInteractionSession;
78 import android.view.RemoteAnimationDefinition;
79 import android.view.RemoteAnimationAdapter;
80 import com.android.internal.app.IVoiceInteractor;
81 import com.android.internal.os.IResultReceiver;
82 import com.android.internal.policy.IKeyguardDismissCallback;
83 
84 import java.util.List;
85 
86 /**
87  * System private API for talking with the activity manager service.  This
88  * provides calls from the application back to the activity manager.
89  *
90  * {@hide}
91  */
92 interface IActivityManager {
93     // WARNING: when these transactions are updated, check if they are any callers on the native
94     // side. If so, make sure they are using the correct transaction ids and arguments.
95     // If a transaction which will also be used on the native side is being inserted, add it to
96     // below block of transactions.
97 
98     // Since these transactions are also called from native code, these must be kept in sync with
99     // the ones in frameworks/native/libs/binder/include_activitymanager/binder/ActivityManager.h
100     // =============== Beginning of transactions used on native side as well ======================
openContentUri(in String uriString)101     ParcelFileDescriptor openContentUri(in String uriString);
registerUidObserver(in IUidObserver observer, int which, int cutpoint, String callingPackage)102     void registerUidObserver(in IUidObserver observer, int which, int cutpoint,
103             String callingPackage);
unregisterUidObserver(in IUidObserver observer)104     void unregisterUidObserver(in IUidObserver observer);
105 
106     /**
107      * Registers a UidObserver with a uid filter.
108      *
109      * @param observer The UidObserver implementation to register.
110      * @param which    A bitmask of events to observe. See ActivityManager.UID_OBSERVER_*.
111      * @param cutpoint The cutpoint for onUidStateChanged events. When the state crosses this
112      *                 threshold in either direction, onUidStateChanged will be called.
113      * @param callingPackage The name of the calling package.
114      * @param uids     A list of uids to watch. If all uids are to be watched, use
115      *                 registerUidObserver instead.
116      * @throws RemoteException
117      * @return Returns A binder token identifying the UidObserver registration.
118      */
registerUidObserverForUids(in IUidObserver observer, int which, int cutpoint, String callingPackage, in int[] uids)119     IBinder registerUidObserverForUids(in IUidObserver observer, int which, int cutpoint,
120             String callingPackage, in int[] uids);
121 
122     /**
123      * Adds a uid to the list of uids that a UidObserver will receive updates about.
124      *
125      * @param observerToken  The binder token identifying the UidObserver registration.
126      * @param callingPackage The name of the calling package.
127      * @param uid            The uid to watch.
128      * @throws RemoteException
129      */
addUidToObserver(in IBinder observerToken, String callingPackage, int uid)130     void addUidToObserver(in IBinder observerToken, String callingPackage, int uid);
131 
132     /**
133      * Removes a uid from the list of uids that a UidObserver will receive updates about.
134      *
135      * @param observerToken  The binder token identifying the UidObserver registration.
136      * @param callingPackage The name of the calling package.
137      * @param uid            The uid to stop watching.
138      * @throws RemoteException
139      */
removeUidFromObserver(in IBinder observerToken, String callingPackage, int uid)140     void removeUidFromObserver(in IBinder observerToken, String callingPackage, int uid);
141 
isUidActive(int uid, String callingPackage)142     boolean isUidActive(int uid, String callingPackage);
143     @JavaPassthrough(annotation=
144             "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)")
getUidProcessState(int uid, in String callingPackage)145     int getUidProcessState(int uid, in String callingPackage);
146     @UnsupportedAppUsage
checkPermission(in String permission, int pid, int uid)147     int checkPermission(in String permission, int pid, int uid);
148 
149     /** Logs start of an API call to associate with an FGS, used for FGS Type Metrics */
logFgsApiBegin(int apiType, int appUid, int appPid)150     oneway void logFgsApiBegin(int apiType, int appUid, int appPid);
151 
152     /** Logs stop of an API call to associate with an FGS, used for FGS Type Metrics */
logFgsApiEnd(int apiType, int appUid, int appPid)153     oneway void logFgsApiEnd(int apiType, int appUid, int appPid);
154 
155     /** Logs API state change to associate with an FGS, used for FGS Type Metrics */
logFgsApiStateChanged(int apiType, int state, int appUid, int appPid)156     oneway void logFgsApiStateChanged(int apiType, int state, int appUid, int appPid);
157     // =============== End of transactions used on native side as well ============================
158 
159     // Special low-level communication with activity manager.
handleApplicationCrash(in IBinder app, in ApplicationErrorReport.ParcelableCrashInfo crashInfo)160     void handleApplicationCrash(in IBinder app,
161             in ApplicationErrorReport.ParcelableCrashInfo crashInfo);
162     /** @deprecated Use {@link #startActivityWithFeature} instead */
163     @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link android.content.Context#startActivity(android.content.Intent)} instead")
startActivity(in IApplicationThread caller, in String callingPackage, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options)164     int startActivity(in IApplicationThread caller, in String callingPackage, in Intent intent,
165             in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
166             int flags, in ProfilerInfo profilerInfo, in Bundle options);
startActivityWithFeature(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options)167     int startActivityWithFeature(in IApplicationThread caller, in String callingPackage,
168             in String callingFeatureId, in Intent intent, in String resolvedType,
169             in IBinder resultTo, in String resultWho, int requestCode, int flags,
170             in ProfilerInfo profilerInfo, in Bundle options);
171     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
unhandledBack()172     void unhandledBack();
173     @UnsupportedAppUsage
finishActivity(in IBinder token, int code, in Intent data, int finishTask)174     boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);
175     @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)} instead")
registerReceiver(in IApplicationThread caller, in String callerPackage, in IIntentReceiver receiver, in IntentFilter filter, in String requiredPermission, int userId, int flags)176     Intent registerReceiver(in IApplicationThread caller, in String callerPackage,
177             in IIntentReceiver receiver, in IntentFilter filter,
178             in String requiredPermission, int userId, int flags);
registerReceiverWithFeature(in IApplicationThread caller, in String callerPackage, in String callingFeatureId, in String receiverId, in IIntentReceiver receiver, in IntentFilter filter, in String requiredPermission, int userId, int flags)179     Intent registerReceiverWithFeature(in IApplicationThread caller, in String callerPackage,
180             in String callingFeatureId, in String receiverId, in IIntentReceiver receiver,
181             in IntentFilter filter, in String requiredPermission, int userId, int flags);
182     @UnsupportedAppUsage
unregisterReceiver(in IIntentReceiver receiver)183     void unregisterReceiver(in IIntentReceiver receiver);
184     /** @deprecated Use {@link #broadcastIntentWithFeature} instead */
185     @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link android.content.Context#sendBroadcast(android.content.Intent)} instead")
broadcastIntent(in IApplicationThread caller, in Intent intent, in String resolvedType, in IIntentReceiver resultTo, int resultCode, in String resultData, in Bundle map, in String[] requiredPermissions, int appOp, in Bundle options, boolean serialized, boolean sticky, int userId)186     int broadcastIntent(in IApplicationThread caller, in Intent intent,
187             in String resolvedType, in IIntentReceiver resultTo, int resultCode,
188             in String resultData, in Bundle map, in String[] requiredPermissions,
189             int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
broadcastIntentWithFeature(in IApplicationThread caller, in String callingFeatureId, in Intent intent, in String resolvedType, in IIntentReceiver resultTo, int resultCode, in String resultData, in Bundle map, in String[] requiredPermissions, in String[] excludePermissions, in String[] excludePackages, int appOp, in Bundle options, boolean serialized, boolean sticky, int userId)190     int broadcastIntentWithFeature(in IApplicationThread caller, in String callingFeatureId,
191             in Intent intent, in String resolvedType, in IIntentReceiver resultTo, int resultCode,
192             in String resultData, in Bundle map, in String[] requiredPermissions, in String[] excludePermissions,
193             in String[] excludePackages, int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId)194     void unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId);
195     @UnsupportedAppUsage
finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map, boolean abortBroadcast, int flags)196     oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
197             boolean abortBroadcast, int flags);
attachApplication(in IApplicationThread app, long startSeq)198     void attachApplication(in IApplicationThread app, long startSeq);
finishAttachApplication(long startSeq)199     void finishAttachApplication(long startSeq);
getTasks(int maxNum)200     List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
201     @UnsupportedAppUsage
moveTaskToFront(in IApplicationThread caller, in String callingPackage, int task, int flags, in Bundle options)202     void moveTaskToFront(in IApplicationThread caller, in String callingPackage, int task,
203             int flags, in Bundle options);
204     @UnsupportedAppUsage
getTaskForActivity(in IBinder token, in boolean onlyRoot)205     int getTaskForActivity(in IBinder token, in boolean onlyRoot);
getContentProvider(in IApplicationThread caller, in String callingPackage, in String name, int userId, boolean stable)206     ContentProviderHolder getContentProvider(in IApplicationThread caller, in String callingPackage,
207             in String name, int userId, boolean stable);
208     @UnsupportedAppUsage
publishContentProviders(in IApplicationThread caller, in List<ContentProviderHolder> providers)209     void publishContentProviders(in IApplicationThread caller,
210             in List<ContentProviderHolder> providers);
refContentProvider(in IBinder connection, int stableDelta, int unstableDelta)211     boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta);
getRunningServiceControlPanel(in ComponentName service)212     PendingIntent getRunningServiceControlPanel(in ComponentName service);
startService(in IApplicationThread caller, in Intent service, in String resolvedType, boolean requireForeground, in String callingPackage, in String callingFeatureId, int userId)213     ComponentName startService(in IApplicationThread caller, in Intent service,
214             in String resolvedType, boolean requireForeground, in String callingPackage,
215             in String callingFeatureId, int userId);
216     @UnsupportedAppUsage
stopService(in IApplicationThread caller, in Intent service, in String resolvedType, int userId)217     int stopService(in IApplicationThread caller, in Intent service,
218             in String resolvedType, int userId);
219     // Currently keeping old bindService because it is on the greylist
220     @UnsupportedAppUsage
bindService(in IApplicationThread caller, in IBinder token, in Intent service, in String resolvedType, in IServiceConnection connection, long flags, in String callingPackage, int userId)221     int bindService(in IApplicationThread caller, in IBinder token, in Intent service,
222             in String resolvedType, in IServiceConnection connection, long flags,
223             in String callingPackage, int userId);
bindServiceInstance(in IApplicationThread caller, in IBinder token, in Intent service, in String resolvedType, in IServiceConnection connection, long flags, in String instanceName, in String callingPackage, int userId)224     int bindServiceInstance(in IApplicationThread caller, in IBinder token, in Intent service,
225             in String resolvedType, in IServiceConnection connection, long flags,
226             in String instanceName, in String callingPackage, int userId);
updateServiceGroup(in IServiceConnection connection, int group, int importance)227     void updateServiceGroup(in IServiceConnection connection, int group, int importance);
228     @UnsupportedAppUsage
unbindService(in IServiceConnection connection)229     boolean unbindService(in IServiceConnection connection);
publishService(in IBinder token, in Intent intent, in IBinder service)230     void publishService(in IBinder token, in Intent intent, in IBinder service);
231     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setDebugApp(in String packageName, boolean waitForDebugger, boolean persistent)232     void setDebugApp(in String packageName, boolean waitForDebugger, boolean persistent);
setAgentApp(in String packageName, @nullable String agent)233     void setAgentApp(in String packageName, @nullable String agent);
234     @UnsupportedAppUsage
setAlwaysFinish(boolean enabled)235     void setAlwaysFinish(boolean enabled);
236     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
startInstrumentation(in ComponentName className, in String profileFile, int flags, in Bundle arguments, in IInstrumentationWatcher watcher, in IUiAutomationConnection connection, int userId, in String abiOverride)237     boolean startInstrumentation(in ComponentName className, in String profileFile,
238             int flags, in Bundle arguments, in IInstrumentationWatcher watcher,
239             in IUiAutomationConnection connection, int userId,
240             in String abiOverride);
addInstrumentationResults(in IApplicationThread target, in Bundle results)241     void addInstrumentationResults(in IApplicationThread target, in Bundle results);
finishInstrumentation(in IApplicationThread target, int resultCode, in Bundle results)242     void finishInstrumentation(in IApplicationThread target, int resultCode,
243             in Bundle results);
244     /**
245      * @return A copy of global {@link Configuration}, contains general settings for the entire
246      *         system. Corresponds to the configuration of the default display.
247      * @throws RemoteException
248      */
249     @UnsupportedAppUsage
getConfiguration()250     Configuration getConfiguration();
251     /**
252      * Updates global configuration and applies changes to the entire system.
253      * @param values Update values for global configuration. If null is passed it will request the
254      *               Window Manager to compute new config for the default display.
255      * @throws RemoteException
256      * @return Returns true if the configuration was updated.
257      */
258     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
updateConfiguration(in Configuration values)259     boolean updateConfiguration(in Configuration values);
260     /**
261      * Updates mcc mnc configuration and applies changes to the entire system.
262      *
263      * @param mcc mcc configuration to update.
264      * @param mnc mnc configuration to update.
265      * @throws RemoteException; IllegalArgumentException if mcc or mnc is null.
266      * @return Returns {@code true} if the configuration was updated;
267      *         {@code false} otherwise.
268      */
updateMccMncConfiguration(in String mcc, in String mnc)269     boolean updateMccMncConfiguration(in String mcc, in String mnc);
stopServiceToken(in ComponentName className, in IBinder token, int startId)270     boolean stopServiceToken(in ComponentName className, in IBinder token, int startId);
271     @UnsupportedAppUsage
setProcessLimit(int max)272     void setProcessLimit(int max);
273     @UnsupportedAppUsage
getProcessLimit()274     int getProcessLimit();
checkUriPermission(in Uri uri, int pid, int uid, int mode, int userId, in IBinder callerToken)275     int checkUriPermission(in Uri uri, int pid, int uid, int mode, int userId,
276             in IBinder callerToken);
checkUriPermissions(in List<Uri> uris, int pid, int uid, int mode, int userId, in IBinder callerToken)277     int[] checkUriPermissions(in List<Uri> uris, int pid, int uid, int mode, int userId,
278                 in IBinder callerToken);
grantUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri, int mode, int userId)279     void grantUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri,
280             int mode, int userId);
revokeUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri, int mode, int userId)281     void revokeUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri,
282             int mode, int userId);
283     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setActivityController(in IActivityController watcher, boolean imAMonkey)284     void setActivityController(in IActivityController watcher, boolean imAMonkey);
showWaitingForDebugger(in IApplicationThread who, boolean waiting)285     void showWaitingForDebugger(in IApplicationThread who, boolean waiting);
286     /*
287      * This will deliver the specified signal to all the persistent processes. Currently only
288      * SIGUSR1 is delivered. All others are ignored.
289      */
signalPersistentProcesses(int signal)290     void signalPersistentProcesses(int signal);
291 
292     @UnsupportedAppUsage
getRecentTasks(int maxNum, int flags, int userId)293     ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
294     @UnsupportedAppUsage
serviceDoneExecuting(in IBinder token, int type, int startId, int res)295     oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res);
296     /** @deprecated  Use {@link #getIntentSenderWithFeature} instead */
297     @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@link PendingIntent#getIntentSender()} instead")
getIntentSender(int type, in String packageName, in IBinder token, in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes, int flags, in Bundle options, int userId)298     IIntentSender getIntentSender(int type, in String packageName, in IBinder token,
299             in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes,
300             int flags, in Bundle options, int userId);
getIntentSenderWithFeature(int type, in String packageName, in String featureId, in IBinder token, in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes, int flags, in Bundle options, int userId)301     IIntentSender getIntentSenderWithFeature(int type, in String packageName, in String featureId,
302             in IBinder token, in String resultWho, int requestCode, in Intent[] intents,
303             in String[] resolvedTypes, int flags, in Bundle options, int userId);
cancelIntentSender(in IIntentSender sender)304     void cancelIntentSender(in IIntentSender sender);
getInfoForIntentSender(in IIntentSender sender)305     ActivityManager.PendingIntentInfo getInfoForIntentSender(in IIntentSender sender);
306     /**
307       This method used to be called registerIntentSenderCancelListener(), was void, and
308       would call `receiver` if the PI has already been canceled.
309       Now it returns false if the PI is cancelled, without calling `receiver`.
310       The method was renamed to catch calls to the original method.
311      */
registerIntentSenderCancelListenerEx(in IIntentSender sender, in IResultReceiver receiver)312     boolean registerIntentSenderCancelListenerEx(in IIntentSender sender,
313         in IResultReceiver receiver);
unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver)314     void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
enterSafeMode()315     void enterSafeMode();
noteWakeupAlarm(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String sourcePkg, in String tag)316     void noteWakeupAlarm(in IIntentSender sender, in WorkSource workSource, int sourceUid,
317             in String sourcePkg, in String tag);
removeContentProvider(in IBinder connection, boolean stable)318     oneway void removeContentProvider(in IBinder connection, boolean stable);
319     @UnsupportedAppUsage
setRequestedOrientation(in IBinder token, int requestedOrientation)320     void setRequestedOrientation(in IBinder token, int requestedOrientation);
unbindFinished(in IBinder token, in Intent service, boolean doRebind)321     void unbindFinished(in IBinder token, in Intent service, boolean doRebind);
322     @UnsupportedAppUsage
setProcessImportant(in IBinder token, int pid, boolean isForeground, String reason)323     void setProcessImportant(in IBinder token, int pid, boolean isForeground, String reason);
setServiceForeground(in ComponentName className, in IBinder token, int id, in Notification notification, int flags, int foregroundServiceType)324     void setServiceForeground(in ComponentName className, in IBinder token,
325             int id, in Notification notification, int flags, int foregroundServiceType);
getForegroundServiceType(in ComponentName className, in IBinder token)326     int getForegroundServiceType(in ComponentName className, in IBinder token);
327     @UnsupportedAppUsage
moveActivityTaskToBack(in IBinder token, boolean nonRoot)328     boolean moveActivityTaskToBack(in IBinder token, boolean nonRoot);
329     @UnsupportedAppUsage
getMemoryInfo(out ActivityManager.MemoryInfo outInfo)330     void getMemoryInfo(out ActivityManager.MemoryInfo outInfo);
getProcessesInErrorState()331     List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState();
clearApplicationUserData(in String packageName, boolean keepState, in IPackageDataObserver observer, int userId)332     boolean clearApplicationUserData(in String packageName, boolean keepState,
333             in IPackageDataObserver observer, int userId);
stopAppForUser(in String packageName, int userId)334     void stopAppForUser(in String packageName, int userId);
335     /** Returns {@code false} if the callback could not be registered, {@true} otherwise. */
registerForegroundServiceObserver(in IForegroundServiceObserver callback)336     boolean registerForegroundServiceObserver(in IForegroundServiceObserver callback);
337     @UnsupportedAppUsage
forceStopPackage(in String packageName, int userId)338     void forceStopPackage(in String packageName, int userId);
forceStopPackageEvenWhenStopping(in String packageName, int userId)339     void forceStopPackageEvenWhenStopping(in String packageName, int userId);
killPids(in int[] pids, in String reason, boolean secure)340     boolean killPids(in int[] pids, in String reason, boolean secure);
341     @UnsupportedAppUsage
getServices(int maxNum, int flags)342     List<ActivityManager.RunningServiceInfo> getServices(int maxNum, int flags);
343     // Retrieve running application processes in the system
344     @UnsupportedAppUsage
getRunningAppProcesses()345     List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses();
peekService(in Intent service, in String resolvedType, in String callingPackage)346     IBinder peekService(in Intent service, in String resolvedType, in String callingPackage);
347     // Turn on/off profiling in a particular process.
348     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
profileControl(in String process, int userId, boolean start, in ProfilerInfo profilerInfo, int profileType)349     boolean profileControl(in String process, int userId, boolean start,
350             in ProfilerInfo profilerInfo, int profileType);
351     @UnsupportedAppUsage
shutdown(int timeout)352     boolean shutdown(int timeout);
353     @UnsupportedAppUsage
stopAppSwitches()354     void stopAppSwitches();
355     @UnsupportedAppUsage
resumeAppSwitches()356     void resumeAppSwitches();
bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId, int backupDestination)357     boolean bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId,
358             int backupDestination);
backupAgentCreated(in String packageName, in IBinder agent, int userId)359     void backupAgentCreated(in String packageName, in IBinder agent, int userId);
unbindBackupAgent(in ApplicationInfo appInfo)360     void unbindBackupAgent(in ApplicationInfo appInfo);
handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, boolean requireFull, in String name, in String callerPackage)361     int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
362             boolean requireFull, in String name, in String callerPackage);
addPackageDependency(in String packageName)363     void addPackageDependency(in String packageName);
killApplication(in String pkg, int appId, int userId, in String reason, int exitInfoReason)364     void killApplication(in String pkg, int appId, int userId, in String reason,
365             int exitInfoReason);
366     @UnsupportedAppUsage
closeSystemDialogs(in String reason)367     void closeSystemDialogs(in String reason);
368     @UnsupportedAppUsage
getProcessMemoryInfo(in int[] pids)369     Debug.MemoryInfo[] getProcessMemoryInfo(in int[] pids);
killApplicationProcess(in String processName, int uid)370     void killApplicationProcess(in String processName, int uid);
371     // Special low-level communication with activity manager.
handleApplicationWtf(in IBinder app, in String tag, boolean system, in ApplicationErrorReport.ParcelableCrashInfo crashInfo, int immediateCallerPid)372     boolean handleApplicationWtf(in IBinder app, in String tag, boolean system,
373             in ApplicationErrorReport.ParcelableCrashInfo crashInfo, int immediateCallerPid);
374     @UnsupportedAppUsage
killBackgroundProcesses(in String packageName, int userId)375     void killBackgroundProcesses(in String packageName, int userId);
isUserAMonkey()376     boolean isUserAMonkey();
377     // Retrieve info of applications installed on external media that are currently
378     // running.
getRunningExternalApplications()379     List<ApplicationInfo> getRunningExternalApplications();
380     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
finishHeavyWeightApp()381     void finishHeavyWeightApp();
382     // A StrictMode violation to be handled.
383     @UnsupportedAppUsage
handleApplicationStrictModeViolation(in IBinder app, int penaltyMask, in StrictMode.ViolationInfo crashInfo)384     void handleApplicationStrictModeViolation(in IBinder app, int penaltyMask,
385             in StrictMode.ViolationInfo crashInfo);
registerStrictModeCallback(in IBinder binder)386     void registerStrictModeCallback(in IBinder binder);
isTopActivityImmersive()387     boolean isTopActivityImmersive();
crashApplicationWithType(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId)388     void crashApplicationWithType(int uid, int initialPid, in String packageName, int userId,
389             in String message, boolean force, int exceptionTypeId);
crashApplicationWithTypeWithExtras(int uid, int initialPid, in String packageName, int userId, in String message, boolean force, int exceptionTypeId, in Bundle extras)390     void crashApplicationWithTypeWithExtras(int uid, int initialPid, in String packageName,
391             int userId, in String message, boolean force, int exceptionTypeId, in Bundle extras);
getMimeTypeFilterAsync(in Uri uri, int userId, in RemoteCallback resultCallback)392     oneway void getMimeTypeFilterAsync(in Uri uri, int userId, in RemoteCallback resultCallback);
393     // Cause the specified process to dump the specified heap.
dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo, boolean runGc, in String path, in ParcelFileDescriptor fd, in RemoteCallback finishCallback)394     boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo,
395             boolean runGc, in String path, in ParcelFileDescriptor fd,
396             in RemoteCallback finishCallback);
397     @UnsupportedAppUsage
isUserRunning(int userid, int flags)398     boolean isUserRunning(int userid, int flags);
399     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setPackageScreenCompatMode(in String packageName, int mode)400     void setPackageScreenCompatMode(in String packageName, int mode);
401     @UnsupportedAppUsage
switchUser(int userid)402     boolean switchUser(int userid);
getSwitchingFromUserMessage()403     String getSwitchingFromUserMessage();
getSwitchingToUserMessage()404     String getSwitchingToUserMessage();
405     @UnsupportedAppUsage
setStopUserOnSwitch(int value)406     void setStopUserOnSwitch(int value);
removeTask(int taskId)407     boolean removeTask(int taskId);
408     @UnsupportedAppUsage
registerProcessObserver(in IProcessObserver observer)409     void registerProcessObserver(in IProcessObserver observer);
410     @UnsupportedAppUsage
unregisterProcessObserver(in IProcessObserver observer)411     void unregisterProcessObserver(in IProcessObserver observer);
isIntentSenderTargetedToPackage(in IIntentSender sender)412     boolean isIntentSenderTargetedToPackage(in IIntentSender sender);
413     @UnsupportedAppUsage
updatePersistentConfiguration(in Configuration values)414     void updatePersistentConfiguration(in Configuration values);
updatePersistentConfigurationWithAttribution(in Configuration values, String callingPackageName, String callingAttributionTag)415     void updatePersistentConfigurationWithAttribution(in Configuration values,
416             String callingPackageName, String callingAttributionTag);
417     @UnsupportedAppUsage
getProcessPss(in int[] pids)418     long[] getProcessPss(in int[] pids);
showBootMessage(in CharSequence msg, boolean always)419     void showBootMessage(in CharSequence msg, boolean always);
420     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
killAllBackgroundProcesses()421     void killAllBackgroundProcesses();
getContentProviderExternal(in String name, int userId, in IBinder token, String tag)422     ContentProviderHolder getContentProviderExternal(in String name, int userId,
423             in IBinder token, String tag);
424     /** @deprecated - Use {@link #removeContentProviderExternalAsUser} which takes a user ID. */
425     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
removeContentProviderExternal(in String name, in IBinder token)426     void removeContentProviderExternal(in String name, in IBinder token);
removeContentProviderExternalAsUser(in String name, in IBinder token, int userId)427     void removeContentProviderExternalAsUser(in String name, in IBinder token, int userId);
428     // Get memory information about the calling process.
getMyMemoryState(out ActivityManager.RunningAppProcessInfo outInfo)429     void getMyMemoryState(out ActivityManager.RunningAppProcessInfo outInfo);
killProcessesBelowForeground(in String reason)430     boolean killProcessesBelowForeground(in String reason);
431     @UnsupportedAppUsage
getCurrentUser()432     UserInfo getCurrentUser();
getCurrentUserId()433     int getCurrentUserId();
434     // This is not public because you need to be very careful in how you
435     // manage your activity to make sure it is always the uid you expect.
436     @UnsupportedAppUsage
getLaunchedFromUid(in IBinder activityToken)437     int getLaunchedFromUid(in IBinder activityToken);
438     @UnsupportedAppUsage
unstableProviderDied(in IBinder connection)439     void unstableProviderDied(in IBinder connection);
440     @UnsupportedAppUsage
isIntentSenderAnActivity(in IIntentSender sender)441     boolean isIntentSenderAnActivity(in IIntentSender sender);
442     /** @deprecated Use {@link startActivityAsUserWithFeature} instead */
443     @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead")
startActivityAsUser(in IApplicationThread caller, in String callingPackage, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, int userId)444     int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
445             in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
446             int requestCode, int flags, in ProfilerInfo profilerInfo,
447             in Bundle options, int userId);
startActivityAsUserWithFeature(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, int userId)448     int startActivityAsUserWithFeature(in IApplicationThread caller, in String callingPackage,
449             in String callingFeatureId, in Intent intent, in String resolvedType,
450             in IBinder resultTo, in String resultWho, int requestCode, int flags,
451             in ProfilerInfo profilerInfo, in Bundle options, int userId);
452     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
stopUser(int userid, boolean force, in IStopUserCallback callback)453     int stopUser(int userid, boolean force, in IStopUserCallback callback);
454     /**
455      * Check {@link com.android.server.am.ActivityManagerService#stopUserWithDelayedLocking(int, boolean, IStopUserCallback)}
456      * for details.
457      */
stopUserWithDelayedLocking(int userid, boolean force, in IStopUserCallback callback)458     int stopUserWithDelayedLocking(int userid, boolean force, in IStopUserCallback callback);
459 
460     @UnsupportedAppUsage
registerUserSwitchObserver(in IUserSwitchObserver observer, in String name)461     void registerUserSwitchObserver(in IUserSwitchObserver observer, in String name);
unregisterUserSwitchObserver(in IUserSwitchObserver observer)462     void unregisterUserSwitchObserver(in IUserSwitchObserver observer);
getRunningUserIds()463     int[] getRunningUserIds();
464 
465     // Request a heap dump for the system server.
requestSystemServerHeapDump()466     void requestSystemServerHeapDump();
467 
requestBugReport(int bugreportType)468     void requestBugReport(int bugreportType);
requestBugReportWithDescription(in @ullable String shareTitle, in @nullable String shareDescription, int bugreportType)469     void requestBugReportWithDescription(in @nullable String shareTitle,
470                 in @nullable String shareDescription, int bugreportType);
471 
472     /**
473      *  Takes a telephony bug report and notifies the user with the title and description
474      *  that are passed to this API as parameters
475      *
476      *  @param shareTitle should be a valid legible string less than 50 chars long
477      *  @param shareDescription should be less than 150 chars long
478      *
479      *  @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the
480      *          paremeters cannot be encoding to an UTF-8 charset.
481      */
requestTelephonyBugReport(in String shareTitle, in String shareDescription)482     void requestTelephonyBugReport(in String shareTitle, in String shareDescription);
483 
484     /**
485      *  This method is only used by Wifi.
486      *
487      *  Takes a minimal bugreport of Wifi-related state.
488      *
489      *  @param shareTitle should be a valid legible string less than 50 chars long
490      *  @param shareDescription should be less than 150 chars long
491      *
492      *  @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the
493      *          parameters cannot be encoding to an UTF-8 charset.
494      */
requestWifiBugReport(in String shareTitle, in String shareDescription)495     void requestWifiBugReport(in String shareTitle, in String shareDescription);
requestInteractiveBugReportWithDescription(in String shareTitle, in String shareDescription)496     void requestInteractiveBugReportWithDescription(in String shareTitle,
497             in String shareDescription);
498 
requestInteractiveBugReport()499     void requestInteractiveBugReport();
requestFullBugReport()500     void requestFullBugReport();
requestRemoteBugReport(long nonce)501     void requestRemoteBugReport(long nonce);
launchBugReportHandlerApp()502     boolean launchBugReportHandlerApp();
getBugreportWhitelistedPackages()503     List<String> getBugreportWhitelistedPackages();
504 
505     @UnsupportedAppUsage
getIntentForIntentSender(in IIntentSender sender)506     Intent getIntentForIntentSender(in IIntentSender sender);
507     // This is not public because you need to be very careful in how you
508     // manage your activity to make sure it is always the uid you expect.
509     @UnsupportedAppUsage
getLaunchedFromPackage(in IBinder activityToken)510     String getLaunchedFromPackage(in IBinder activityToken);
killUid(int appId, int userId, in String reason)511     void killUid(int appId, int userId, in String reason);
setUserIsMonkey(boolean monkey)512     void setUserIsMonkey(boolean monkey);
513     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
hang(in IBinder who, boolean allowRestart)514     void hang(in IBinder who, boolean allowRestart);
515 
getAllRootTaskInfos()516     List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfos();
moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop)517     void moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop);
setFocusedRootTask(int taskId)518     void setFocusedRootTask(int taskId);
getFocusedRootTaskInfo()519     ActivityTaskManager.RootTaskInfo getFocusedRootTaskInfo();
520     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
restart()521     void restart();
performIdleMaintenance()522     void performIdleMaintenance();
appNotRespondingViaProvider(in IBinder connection)523     void appNotRespondingViaProvider(in IBinder connection);
524     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getTaskBounds(int taskId)525     Rect getTaskBounds(int taskId);
526     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setProcessMemoryTrimLevel(in String process, int userId, int level)527     boolean setProcessMemoryTrimLevel(in String process, int userId, int level);
528 
529 
530     // Start of L transactions
getTagForIntentSender(in IIntentSender sender, in String prefix)531     String getTagForIntentSender(in IIntentSender sender, in String prefix);
532 
533     /**
534       * Starts a user in the background (i.e., while another user is running in the foreground).
535       *
536       * Notice that a background user is "invisible" and cannot launch activities. Starting on
537       * Android U, all users started with this method are invisible, even profiles (prior to Android
538       * U, profiles started with this method would be visible if its parent was the current user) -
539       * if you want to start a profile visible, you should call {@code startProfile()} instead.
540       */
541     @UnsupportedAppUsage
startUserInBackground(int userid)542     boolean startUserInBackground(int userid);
543 
544     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
isInLockTaskMode()545     boolean isInLockTaskMode();
546     @UnsupportedAppUsage
startActivityFromRecents(int taskId, in Bundle options)547     int startActivityFromRecents(int taskId, in Bundle options);
548     @UnsupportedAppUsage
startSystemLockTaskMode(int taskId)549     void startSystemLockTaskMode(int taskId);
550     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
isTopOfTask(in IBinder token)551     boolean isTopOfTask(in IBinder token);
bootAnimationComplete()552     void bootAnimationComplete();
553 
554     /**
555      * Used by {@link com.android.systemui.theme.ThemeOverlayController} to notify when color
556      * palette is ready.
557      *
558      * @param userId The ID of the user where ThemeOverlayController is ready.
559      *
560      * @throws RemoteException
561      */
setThemeOverlayReady(int userId)562     void setThemeOverlayReady(int userId);
563 
564     @UnsupportedAppUsage
registerTaskStackListener(in ITaskStackListener listener)565     void registerTaskStackListener(in ITaskStackListener listener);
unregisterTaskStackListener(in ITaskStackListener listener)566     void unregisterTaskStackListener(in ITaskStackListener listener);
notifyCleartextNetwork(int uid, in byte[] firstPacket)567     void notifyCleartextNetwork(int uid, in byte[] firstPacket);
568     @UnsupportedAppUsage
setTaskResizeable(int taskId, int resizeableMode)569     void setTaskResizeable(int taskId, int resizeableMode);
570     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
resizeTask(int taskId, in Rect bounds, int resizeMode)571     void resizeTask(int taskId, in Rect bounds, int resizeMode);
572     @UnsupportedAppUsage
getLockTaskModeState()573     int getLockTaskModeState();
574     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize, in String reportPackage)575     void setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize,
576             in String reportPackage);
dumpHeapFinished(in String path)577     void dumpHeapFinished(in String path);
updateLockTaskPackages(int userId, in String[] packages)578     void updateLockTaskPackages(int userId, in String[] packages);
noteAlarmStart(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag)579     void noteAlarmStart(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag)580     void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
581     @UnsupportedAppUsage
getPackageProcessState(in String packageName, in String callingPackage)582     int getPackageProcessState(in String packageName, in String callingPackage);
583 
584     // Start of N transactions
585     // Start Binder transaction tracking for all applications.
586     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
startBinderTracking()587     boolean startBinderTracking();
588     // Stop Binder transaction tracking for all applications and dump trace data to the given file
589     // descriptor.
590     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
stopBinderTrackingAndDump(in ParcelFileDescriptor fd)591     boolean stopBinderTrackingAndDump(in ParcelFileDescriptor fd);
592 
593     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
suppressResizeConfigChanges(boolean suppress)594     void suppressResizeConfigChanges(boolean suppress);
595 
596     /**
597      * @deprecated Use {@link #unlockUser2(int, IProgressListener)} instead, since the token and
598      * secret arguments no longer do anything.  This method still exists only because it is marked
599      * with {@code @UnsupportedAppUsage}, so it might not be safe to remove it or change its
600      * signature.
601      */
602     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
unlockUser(int userid, in byte[] token, in byte[] secret, in IProgressListener listener)603     boolean unlockUser(int userid, in byte[] token, in byte[] secret,
604             in IProgressListener listener);
605 
606     /**
607      * Tries to unlock the given user.
608      * <p>
609      * This will succeed only if the user's CE storage key is already unlocked or if the user
610      * doesn't have a lockscreen credential set.
611      *
612      * @param userId The ID of the user to unlock.
613      * @param listener An optional progress listener.
614      *
615      * @return true if the user was successfully unlocked, otherwise false.
616      */
unlockUser2(int userId, in IProgressListener listener)617     boolean unlockUser2(int userId, in IProgressListener listener);
618 
killPackageDependents(in String packageName, int userId)619     void killPackageDependents(in String packageName, int userId);
makePackageIdle(String packageName, int userId)620     void makePackageIdle(String packageName, int userId);
setDeterministicUidIdle(boolean deterministic)621     void setDeterministicUidIdle(boolean deterministic);
getMemoryTrimLevel()622     int getMemoryTrimLevel();
isVrModePackageEnabled(in ComponentName packageName)623     boolean isVrModePackageEnabled(in ComponentName packageName);
notifyLockedProfile(int userId)624     void notifyLockedProfile(int userId);
startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options)625     void startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options);
626     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
sendIdleJobTrigger()627     void sendIdleJobTrigger();
sendIntentSender(in IApplicationThread caller, in IIntentSender target, in IBinder whitelistToken, int code, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in String requiredPermission, in Bundle options)628     int sendIntentSender(in IApplicationThread caller, in IIntentSender target,
629             in IBinder whitelistToken, int code,
630             in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver,
631             in String requiredPermission, in Bundle options);
isBackgroundRestricted(in String packageName)632     boolean isBackgroundRestricted(in String packageName);
633 
634     // Start of N MR1 transactions
setRenderThread(int tid)635     void setRenderThread(int tid);
636     /**
637      * Lets activity manager know whether the calling process is currently showing "top-level" UI
638      * that is not an activity, i.e. windows on the screen the user is currently interacting with.
639      *
640      * <p>This flag can only be set for persistent processes.
641      *
642      * @param hasTopUi Whether the calling process has "top-level" UI.
643      */
setHasTopUi(boolean hasTopUi)644     void setHasTopUi(boolean hasTopUi);
645 
646     // Start of O transactions
647     /** Cancels the window transitions for the given task. */
648     @UnsupportedAppUsage
cancelTaskWindowTransition(int taskId)649     void cancelTaskWindowTransition(int taskId);
scheduleApplicationInfoChanged(in List<String> packageNames, int userId)650     void scheduleApplicationInfoChanged(in List<String> packageNames, int userId);
setPersistentVrThread(int tid)651     void setPersistentVrThread(int tid);
652 
waitForNetworkStateUpdate(long procStateSeq)653     void waitForNetworkStateUpdate(long procStateSeq);
654     /**
655      * Add a bare uid to the background restrictions whitelist.  Only the system uid may call this.
656      */
backgroundAllowlistUid(int uid)657     void backgroundAllowlistUid(int uid);
658 
659     // Start of P transactions
660     /**
661      *  Similar to {@link #startUserInBackground(int userId), but with a listener to report
662      *  user unlock progress.
663      */
startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener)664     boolean startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener);
665 
666     /**
667      * Method for the shell UID to start deletating its permission identity to an
668      * active instrumenation. The shell can delegate permissions only to one active
669      * instrumentation at a time. An active instrumentation is one running and
670      * started from the shell.
671      */
startDelegateShellPermissionIdentity(int uid, in String[] permissions)672     void startDelegateShellPermissionIdentity(int uid, in String[] permissions);
673 
674     /**
675      * Method for the shell UID to stop deletating its permission identity to an
676      * active instrumenation. An active instrumentation is one running and
677      * started from the shell.
678      */
stopDelegateShellPermissionIdentity()679     void stopDelegateShellPermissionIdentity();
680 
681     /**
682      * Method for the shell UID to get currently adopted permissions for an active instrumentation.
683      * An active instrumentation is one running and started from the shell.
684      */
getDelegatedShellPermissions()685     List<String> getDelegatedShellPermissions();
686 
687     /** Returns a file descriptor that'll be closed when the system server process dies. */
getLifeMonitor()688     ParcelFileDescriptor getLifeMonitor();
689 
690     /**
691      * Start user, if it us not already running, and bring it to foreground.
692      * unlockProgressListener can be null if monitoring progress is not necessary.
693      */
startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener)694     boolean startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener);
695 
696     /**
697      * Method for the app to tell system that it's wedged and would like to trigger an ANR.
698      */
appNotResponding(String reason)699     void appNotResponding(String reason);
700 
701     /**
702      * Return a list of {@link ApplicationStartInfo} records.
703      *
704      * <p class="note"> Note: System stores historical information in a ring buffer, older
705      * records would be overwritten by newer records. </p>
706      *
707      * @param packageName Optional, an empty value means match all packages belonging to the
708      *                    caller's UID. If this package belongs to another UID, you must hold
709      *                    {@link android.Manifest.permission#DUMP} in order to retrieve it.
710      * @param maxNum      Optional, the maximum number of results should be returned; A value of 0
711      *                    means to ignore this parameter and return all matching records
712      * @param userId      The userId in the multi-user environment.
713      *
714      * @return a list of {@link ApplicationStartInfo} records with the matching criteria, sorted in
715      *         the order from most recent to least recent.
716      */
getHistoricalProcessStartReasons(String packageName, int maxNum, int userId)717     ParceledListSlice<ApplicationStartInfo> getHistoricalProcessStartReasons(String packageName,
718             int maxNum, int userId);
719 
720 
721     /**
722      * Sets a callback for {@link ApplicationStartInfo} upon completion of collecting startup data.
723      *
724      * <p class="note"> Note: completion of startup is no guaranteed and as such this callback may not occur.</p>
725      *
726      * @param listener    A listener to for the callback upon completion of startup data collection.
727      * @param userId      The userId in the multi-user environment.
728      */
setApplicationStartInfoCompleteListener(IApplicationStartInfoCompleteListener listener, int userId)729     void setApplicationStartInfoCompleteListener(IApplicationStartInfoCompleteListener listener,
730             int userId);
731 
732 
733     /**
734      * Removes callback for {@link ApplicationStartInfo} upon completion of collecting startup data.
735      *
736      * @param userId      The userId in the multi-user environment.
737      */
removeApplicationStartInfoCompleteListener(int userId)738     void removeApplicationStartInfoCompleteListener(int userId);
739 
740     /**
741      * Return a list of {@link ApplicationExitInfo} records.
742      *
743      * <p class="note"> Note: System stores these historical information in a ring buffer, older
744      * records would be overwritten by newer records. </p>
745      *
746      * <p class="note"> Note: In the case that this application bound to an external service with
747      * flag {@link android.content.Context#BIND_EXTERNAL_SERVICE}, the process of that external
748      * service will be included in this package's exit info. </p>
749      *
750      * @param packageName Optional, an empty value means match all packages belonging to the
751      *                    caller's UID. If this package belongs to another UID, you must hold
752      *                    {@link android.Manifest.permission#DUMP} in order to retrieve it.
753      * @param pid         Optional, it could be a process ID that used to belong to this package but
754      *                    died later; A value of 0 means to ignore this parameter and return all
755      *                    matching records.
756      * @param maxNum      Optional, the maximum number of results should be returned; A value of 0
757      *                    means to ignore this parameter and return all matching records
758      * @param userId      The userId in the multi-user environment.
759      *
760      * @return a list of {@link ApplicationExitInfo} records with the matching criteria, sorted in
761      *         the order from most recent to least recent.
762      */
getHistoricalProcessExitReasons(String packageName, int pid, int maxNum, int userId)763     ParceledListSlice<ApplicationExitInfo> getHistoricalProcessExitReasons(String packageName,
764             int pid, int maxNum, int userId);
765 
766     /*
767      * Kill the given PIDs, but the killing will be delayed until the device is idle
768      * and the given process is imperceptible.
769      */
killProcessesWhenImperceptible(in int[] pids, String reason)770     void killProcessesWhenImperceptible(in int[] pids, String reason);
771 
772     /**
773      * Set locus context for a given activity.
774      * @param activity
775      * @param locusId a unique, stable id that identifies this activity instance from others.
776      * @param appToken ActivityRecord's appToken.
777      */
setActivityLocusContext(in ComponentName activity, in LocusId locusId, in IBinder appToken)778     void setActivityLocusContext(in ComponentName activity, in LocusId locusId,
779             in IBinder appToken);
780 
781     /**
782      * Set custom state data for this process. It will be included in the record of
783      * {@link ApplicationExitInfo} on the death of the current calling process; the new process
784      * of the app can retrieve this state data by calling
785      * {@link ApplicationExitInfo#getProcessStateSummary} on the record returned by
786      * {@link #getHistoricalProcessExitReasons}.
787      *
788      * <p> This would be useful for the calling app to save its stateful data: if it's
789      * killed later for any reason, the new process of the app can know what the
790      * previous process of the app was doing. For instance, you could use this to encode
791      * the current level in a game, or a set of features/experiments that were enabled. Later you
792      * could analyze under what circumstances the app tends to crash or use too much memory.
793      * However, it's not suggested to rely on this to restore the applications previous UI state
794      * or so, it's only meant for analyzing application healthy status.</p>
795      *
796      * <p> System might decide to throttle the calls to this API; so call this API in a reasonable
797      * manner, excessive calls to this API could result a {@link java.lang.RuntimeException}.
798      * </p>
799      *
800      * @param state The customized state data
801      */
setProcessStateSummary(in byte[] state)802     void setProcessStateSummary(in byte[] state);
803 
804     /**
805      * Return whether the app freezer is supported (true) or not (false) by this system.
806      */
isAppFreezerSupported()807     boolean isAppFreezerSupported();
808 
809     /**
810      * Return whether the app freezer is enabled (true) or not (false) by this system.
811      */
isAppFreezerEnabled()812     boolean isAppFreezerEnabled();
813 
814     /**
815      * Kills uid with the reason of permission change.
816      */
killUidForPermissionChange(int appId, int userId, String reason)817     void killUidForPermissionChange(int appId, int userId, String reason);
818 
819     /**
820      * Resets the state of the {@link com.android.server.am.AppErrors} instance.
821      * This is intended for testing within the CTS only and is protected by
822      * android.permission.RESET_APP_ERRORS.
823      */
resetAppErrors()824     void resetAppErrors();
825 
826     /**
827      * Control the app freezer state. Returns true in case of success, false if the operation
828      * didn't succeed (for example, when the app freezer isn't supported).
829      * Handling the freezer state via this method is reentrant, that is it can be
830      * disabled and re-enabled multiple times in parallel. As long as there's a 1:1 disable to
831      * enable match, the freezer is re-enabled at last enable only.
832      * @param enable set it to true to enable the app freezer, false to disable it.
833      */
enableAppFreezer(in boolean enable)834     boolean enableAppFreezer(in boolean enable);
835 
836     /**
837      * Suppress or reenable the rate limit on foreground service notification deferral.
838      * This is for use within CTS and is protected by android.permission.WRITE_DEVICE_CONFIG.
839      *
840      * @param enable false to suppress rate-limit policy; true to reenable it.
841      */
enableFgsNotificationRateLimit(in boolean enable)842     boolean enableFgsNotificationRateLimit(in boolean enable);
843 
844     /**
845      * Holds the AM lock for the specified amount of milliseconds.
846      * This is intended for use by the tests that need to imitate lock contention.
847      * The token should be obtained by
848      * {@link android.content.pm.PackageManager#getHoldLockToken()}.
849      */
holdLock(in IBinder token, in int durationMs)850     void holdLock(in IBinder token, in int durationMs);
851 
852     /**
853      * Starts a profile.
854      * @param userId the user id of the profile.
855      * @return true if the profile has been successfully started or if the profile is already
856      * running, false if profile failed to start.
857      * @throws IllegalArgumentException if the user is not a profile.
858      */
startProfile(int userId)859     boolean startProfile(int userId);
860 
861     /**
862      * Stops a profile.
863      * @param userId the user id of the profile.
864      * @return true if the profile has been successfully stopped or is already stopped. Otherwise
865      * the exceptions listed below are thrown.
866      * @throws IllegalArgumentException if the user is not a profile.
867      */
stopProfile(int userId)868     boolean stopProfile(int userId);
869 
870     /** Called by PendingIntent.queryIntentComponents() */
queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags)871     ParceledListSlice queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags);
872 
873     @JavaPassthrough(annotation=
874             "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)")
getUidProcessCapabilities(int uid, in String callingPackage)875     int getUidProcessCapabilities(int uid, in String callingPackage);
876 
877     /** Blocks until all broadcast queues become idle. */
waitForBroadcastIdle()878     void waitForBroadcastIdle();
waitForBroadcastBarrier()879     void waitForBroadcastBarrier();
880 
881     /** Delays delivering broadcasts to the specified package. */
882     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
forceDelayBroadcastDelivery(in String targetPackage, long delayedDurationMs)883     void forceDelayBroadcastDelivery(in String targetPackage, long delayedDurationMs);
884 
885     /** Checks if the modern broadcast queue is enabled. */
886     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
isModernBroadcastQueueEnabled()887     boolean isModernBroadcastQueueEnabled();
888 
889     /** Checks if the process represented by the given pid is frozen. */
890     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
isProcessFrozen(int pid)891     boolean isProcessFrozen(int pid);
892 
893     /**
894      * @return The reason code of whether or not the given UID should be exempted from background
895      * restrictions here.
896      *
897      * <p>
898      * Note: Call it with caution as it'll try to acquire locks in other services.
899      * </p>
900      */
getBackgroundRestrictionExemptionReason(int uid)901     int getBackgroundRestrictionExemptionReason(int uid);
902 
903     // Start (?) of T transactions
904     /**
905      * Similar to {@link #startUserInBackgroundWithListener(int userId, IProgressListener unlockProgressListener)},
906      * but setting the user as the visible user of that display (i.e., allowing the user and its
907      * running profiles to launch activities on that display).
908      *
909      * <p>Typically used only by automotive builds when the vehicle has multiple displays.
910      */
911     @JavaPassthrough(annotation=
912             "@android.annotation.RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}, conditional = true)")
startUserInBackgroundVisibleOnDisplay(int userid, int displayId, IProgressListener unlockProgressListener)913     boolean startUserInBackgroundVisibleOnDisplay(int userid, int displayId, IProgressListener unlockProgressListener);
914 
915     /**
916      * Similar to {@link #startProfile(int userId)}, but with a listener to report user unlock
917      * progress.
918      */
startProfileWithListener(int userid, IProgressListener unlockProgressListener)919     boolean startProfileWithListener(int userid, IProgressListener unlockProgressListener);
920 
restartUserInBackground(int userId, int userStartMode)921     int restartUserInBackground(int userId, int userStartMode);
922 
923     /**
924      * Gets the ids of displays that can be used on {@link #startUserInBackgroundVisibleOnDisplay(int userId, int displayId)}.
925      *
926      * <p>Typically used only by automotive builds when the vehicle has multiple displays.
927      */
getDisplayIdsForStartingVisibleBackgroundUsers()928     @nullable int[] getDisplayIdsForStartingVisibleBackgroundUsers();
929 
930     /** Returns if the service is a short-service is still "alive" and past the timeout. */
shouldServiceTimeOut(in ComponentName className, in IBinder token)931     boolean shouldServiceTimeOut(in ComponentName className, in IBinder token);
932 
registerUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback)933     void registerUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback);
934     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)")
unregisterUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback)935     void unregisterUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback);
936     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)")
getUidFrozenState(in int[] uids)937     int[] getUidFrozenState(in int[] uids);
938 
939     /**
940      * Notify AMS about binder transactions to frozen apps.
941      *
942      * @param debugPid The binder transaction sender
943      * @param code The binder transaction code
944      * @param flags The binder transaction flags
945      * @param err The binder transaction error
946      */
frozenBinderTransactionDetected(int debugPid, int code, int flags, int err)947     oneway void frozenBinderTransactionDetected(int debugPid, int code, int flags, int err);
948 }
949