• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     @UnsupportedAppUsage
registerTaskStackListener(in ITaskStackListener listener)554     void registerTaskStackListener(in ITaskStackListener listener);
unregisterTaskStackListener(in ITaskStackListener listener)555     void unregisterTaskStackListener(in ITaskStackListener listener);
notifyCleartextNetwork(int uid, in byte[] firstPacket)556     void notifyCleartextNetwork(int uid, in byte[] firstPacket);
557     @UnsupportedAppUsage
setTaskResizeable(int taskId, int resizeableMode)558     void setTaskResizeable(int taskId, int resizeableMode);
559     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
resizeTask(int taskId, in Rect bounds, int resizeMode)560     void resizeTask(int taskId, in Rect bounds, int resizeMode);
561     @UnsupportedAppUsage
getLockTaskModeState()562     int getLockTaskModeState();
563     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize, in String reportPackage)564     void setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize,
565             in String reportPackage);
dumpHeapFinished(in String path)566     void dumpHeapFinished(in String path);
updateLockTaskPackages(int userId, in String[] packages)567     void updateLockTaskPackages(int userId, in String[] packages);
noteAlarmStart(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag)568     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)569     void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
570     @UnsupportedAppUsage
getPackageProcessState(in String packageName, in String callingPackage)571     int getPackageProcessState(in String packageName, in String callingPackage);
572 
573     // Start of N transactions
574     // Start Binder transaction tracking for all applications.
575     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
startBinderTracking()576     boolean startBinderTracking();
577     // Stop Binder transaction tracking for all applications and dump trace data to the given file
578     // descriptor.
579     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
stopBinderTrackingAndDump(in ParcelFileDescriptor fd)580     boolean stopBinderTrackingAndDump(in ParcelFileDescriptor fd);
581 
582     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
suppressResizeConfigChanges(boolean suppress)583     void suppressResizeConfigChanges(boolean suppress);
584 
585     /**
586      * @deprecated Use {@link #unlockUser2(int, IProgressListener)} instead, since the token and
587      * secret arguments no longer do anything.  This method still exists only because it is marked
588      * with {@code @UnsupportedAppUsage}, so it might not be safe to remove it or change its
589      * signature.
590      */
591     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
unlockUser(int userid, in byte[] token, in byte[] secret, in IProgressListener listener)592     boolean unlockUser(int userid, in byte[] token, in byte[] secret,
593             in IProgressListener listener);
594 
595     /**
596      * Tries to unlock the given user.
597      * <p>
598      * This will succeed only if the user's CE storage key is already unlocked or if the user
599      * doesn't have a lockscreen credential set.
600      *
601      * @param userId The ID of the user to unlock.
602      * @param listener An optional progress listener.
603      *
604      * @return true if the user was successfully unlocked, otherwise false.
605      */
unlockUser2(int userId, in IProgressListener listener)606     boolean unlockUser2(int userId, in IProgressListener listener);
607 
killPackageDependents(in String packageName, int userId)608     void killPackageDependents(in String packageName, int userId);
makePackageIdle(String packageName, int userId)609     void makePackageIdle(String packageName, int userId);
setDeterministicUidIdle(boolean deterministic)610     void setDeterministicUidIdle(boolean deterministic);
getMemoryTrimLevel()611     int getMemoryTrimLevel();
isVrModePackageEnabled(in ComponentName packageName)612     boolean isVrModePackageEnabled(in ComponentName packageName);
notifyLockedProfile(int userId)613     void notifyLockedProfile(int userId);
startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options)614     void startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options);
615     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
sendIdleJobTrigger()616     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)617     int sendIntentSender(in IApplicationThread caller, in IIntentSender target,
618             in IBinder whitelistToken, int code,
619             in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver,
620             in String requiredPermission, in Bundle options);
isBackgroundRestricted(in String packageName)621     boolean isBackgroundRestricted(in String packageName);
622 
623     // Start of N MR1 transactions
setRenderThread(int tid)624     void setRenderThread(int tid);
625     /**
626      * Lets activity manager know whether the calling process is currently showing "top-level" UI
627      * that is not an activity, i.e. windows on the screen the user is currently interacting with.
628      *
629      * <p>This flag can only be set for persistent processes.
630      *
631      * @param hasTopUi Whether the calling process has "top-level" UI.
632      */
setHasTopUi(boolean hasTopUi)633     void setHasTopUi(boolean hasTopUi);
634 
635     // Start of O transactions
636     /** Cancels the window transitions for the given task. */
637     @UnsupportedAppUsage
cancelTaskWindowTransition(int taskId)638     void cancelTaskWindowTransition(int taskId);
scheduleApplicationInfoChanged(in List<String> packageNames, int userId)639     void scheduleApplicationInfoChanged(in List<String> packageNames, int userId);
setPersistentVrThread(int tid)640     void setPersistentVrThread(int tid);
641 
waitForNetworkStateUpdate(long procStateSeq)642     void waitForNetworkStateUpdate(long procStateSeq);
643     /**
644      * Add a bare uid to the background restrictions whitelist.  Only the system uid may call this.
645      */
backgroundAllowlistUid(int uid)646     void backgroundAllowlistUid(int uid);
647 
648     // Start of P transactions
649     /**
650      *  Similar to {@link #startUserInBackground(int userId), but with a listener to report
651      *  user unlock progress.
652      */
startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener)653     boolean startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener);
654 
655     /**
656      * Method for the shell UID to start deletating its permission identity to an
657      * active instrumenation. The shell can delegate permissions only to one active
658      * instrumentation at a time. An active instrumentation is one running and
659      * started from the shell.
660      */
startDelegateShellPermissionIdentity(int uid, in String[] permissions)661     void startDelegateShellPermissionIdentity(int uid, in String[] permissions);
662 
663     /**
664      * Method for the shell UID to stop deletating its permission identity to an
665      * active instrumenation. An active instrumentation is one running and
666      * started from the shell.
667      */
stopDelegateShellPermissionIdentity()668     void stopDelegateShellPermissionIdentity();
669 
670     /**
671      * Method for the shell UID to get currently adopted permissions for an active instrumentation.
672      * An active instrumentation is one running and started from the shell.
673      */
getDelegatedShellPermissions()674     List<String> getDelegatedShellPermissions();
675 
676     /** Returns a file descriptor that'll be closed when the system server process dies. */
getLifeMonitor()677     ParcelFileDescriptor getLifeMonitor();
678 
679     /**
680      * Start user, if it us not already running, and bring it to foreground.
681      * unlockProgressListener can be null if monitoring progress is not necessary.
682      */
startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener)683     boolean startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener);
684 
685     /**
686      * Method for the app to tell system that it's wedged and would like to trigger an ANR.
687      */
appNotResponding(String reason)688     void appNotResponding(String reason);
689 
690     /**
691      * Return a list of {@link ApplicationStartInfo} records.
692      *
693      * <p class="note"> Note: System stores historical information in a ring buffer, older
694      * records would be overwritten by newer records. </p>
695      *
696      * @param packageName Optional, an empty value means match all packages belonging to the
697      *                    caller's UID. If this package belongs to another UID, you must hold
698      *                    {@link android.Manifest.permission#DUMP} in order to retrieve it.
699      * @param maxNum      Optional, the maximum number of results should be returned; A value of 0
700      *                    means to ignore this parameter and return all matching records
701      * @param userId      The userId in the multi-user environment.
702      *
703      * @return a list of {@link ApplicationStartInfo} records with the matching criteria, sorted in
704      *         the order from most recent to least recent.
705      */
getHistoricalProcessStartReasons(String packageName, int maxNum, int userId)706     ParceledListSlice<ApplicationStartInfo> getHistoricalProcessStartReasons(String packageName,
707             int maxNum, int userId);
708 
709 
710     /**
711      * Sets a callback for {@link ApplicationStartInfo} upon completion of collecting startup data.
712      *
713      * <p class="note"> Note: completion of startup is no guaranteed and as such this callback may not occur.</p>
714      *
715      * @param listener    A listener to for the callback upon completion of startup data collection.
716      * @param userId      The userId in the multi-user environment.
717      */
setApplicationStartInfoCompleteListener(IApplicationStartInfoCompleteListener listener, int userId)718     void setApplicationStartInfoCompleteListener(IApplicationStartInfoCompleteListener listener,
719             int userId);
720 
721 
722     /**
723      * Removes callback for {@link ApplicationStartInfo} upon completion of collecting startup data.
724      *
725      * @param userId      The userId in the multi-user environment.
726      */
removeApplicationStartInfoCompleteListener(int userId)727     void removeApplicationStartInfoCompleteListener(int userId);
728 
729     /**
730      * Return a list of {@link ApplicationExitInfo} records.
731      *
732      * <p class="note"> Note: System stores these historical information in a ring buffer, older
733      * records would be overwritten by newer records. </p>
734      *
735      * <p class="note"> Note: In the case that this application bound to an external service with
736      * flag {@link android.content.Context#BIND_EXTERNAL_SERVICE}, the process of that external
737      * service will be included in this package's exit info. </p>
738      *
739      * @param packageName Optional, an empty value means match all packages belonging to the
740      *                    caller's UID. If this package belongs to another UID, you must hold
741      *                    {@link android.Manifest.permission#DUMP} in order to retrieve it.
742      * @param pid         Optional, it could be a process ID that used to belong to this package but
743      *                    died later; A value of 0 means to ignore this parameter and return all
744      *                    matching records.
745      * @param maxNum      Optional, the maximum number of results should be returned; A value of 0
746      *                    means to ignore this parameter and return all matching records
747      * @param userId      The userId in the multi-user environment.
748      *
749      * @return a list of {@link ApplicationExitInfo} records with the matching criteria, sorted in
750      *         the order from most recent to least recent.
751      */
getHistoricalProcessExitReasons(String packageName, int pid, int maxNum, int userId)752     ParceledListSlice<ApplicationExitInfo> getHistoricalProcessExitReasons(String packageName,
753             int pid, int maxNum, int userId);
754 
755     /*
756      * Kill the given PIDs, but the killing will be delayed until the device is idle
757      * and the given process is imperceptible.
758      */
killProcessesWhenImperceptible(in int[] pids, String reason)759     void killProcessesWhenImperceptible(in int[] pids, String reason);
760 
761     /**
762      * Set locus context for a given activity.
763      * @param activity
764      * @param locusId a unique, stable id that identifies this activity instance from others.
765      * @param appToken ActivityRecord's appToken.
766      */
setActivityLocusContext(in ComponentName activity, in LocusId locusId, in IBinder appToken)767     void setActivityLocusContext(in ComponentName activity, in LocusId locusId,
768             in IBinder appToken);
769 
770     /**
771      * Set custom state data for this process. It will be included in the record of
772      * {@link ApplicationExitInfo} on the death of the current calling process; the new process
773      * of the app can retrieve this state data by calling
774      * {@link ApplicationExitInfo#getProcessStateSummary} on the record returned by
775      * {@link #getHistoricalProcessExitReasons}.
776      *
777      * <p> This would be useful for the calling app to save its stateful data: if it's
778      * killed later for any reason, the new process of the app can know what the
779      * previous process of the app was doing. For instance, you could use this to encode
780      * the current level in a game, or a set of features/experiments that were enabled. Later you
781      * could analyze under what circumstances the app tends to crash or use too much memory.
782      * However, it's not suggested to rely on this to restore the applications previous UI state
783      * or so, it's only meant for analyzing application healthy status.</p>
784      *
785      * <p> System might decide to throttle the calls to this API; so call this API in a reasonable
786      * manner, excessive calls to this API could result a {@link java.lang.RuntimeException}.
787      * </p>
788      *
789      * @param state The customized state data
790      */
setProcessStateSummary(in byte[] state)791     void setProcessStateSummary(in byte[] state);
792 
793     /**
794      * Return whether the app freezer is supported (true) or not (false) by this system.
795      */
isAppFreezerSupported()796     boolean isAppFreezerSupported();
797 
798     /**
799      * Return whether the app freezer is enabled (true) or not (false) by this system.
800      */
isAppFreezerEnabled()801     boolean isAppFreezerEnabled();
802 
803     /**
804      * Kills uid with the reason of permission change.
805      */
killUidForPermissionChange(int appId, int userId, String reason)806     void killUidForPermissionChange(int appId, int userId, String reason);
807 
808     /**
809      * Resets the state of the {@link com.android.server.am.AppErrors} instance.
810      * This is intended for testing within the CTS only and is protected by
811      * android.permission.RESET_APP_ERRORS.
812      */
resetAppErrors()813     void resetAppErrors();
814 
815     /**
816      * Control the app freezer state. Returns true in case of success, false if the operation
817      * didn't succeed (for example, when the app freezer isn't supported).
818      * Handling the freezer state via this method is reentrant, that is it can be
819      * disabled and re-enabled multiple times in parallel. As long as there's a 1:1 disable to
820      * enable match, the freezer is re-enabled at last enable only.
821      * @param enable set it to true to enable the app freezer, false to disable it.
822      */
enableAppFreezer(in boolean enable)823     boolean enableAppFreezer(in boolean enable);
824 
825     /**
826      * Suppress or reenable the rate limit on foreground service notification deferral.
827      * This is for use within CTS and is protected by android.permission.WRITE_DEVICE_CONFIG.
828      *
829      * @param enable false to suppress rate-limit policy; true to reenable it.
830      */
enableFgsNotificationRateLimit(in boolean enable)831     boolean enableFgsNotificationRateLimit(in boolean enable);
832 
833     /**
834      * Holds the AM lock for the specified amount of milliseconds.
835      * This is intended for use by the tests that need to imitate lock contention.
836      * The token should be obtained by
837      * {@link android.content.pm.PackageManager#getHoldLockToken()}.
838      */
holdLock(in IBinder token, in int durationMs)839     void holdLock(in IBinder token, in int durationMs);
840 
841     /**
842      * Starts a profile.
843      * @param userId the user id of the profile.
844      * @return true if the profile has been successfully started or if the profile is already
845      * running, false if profile failed to start.
846      * @throws IllegalArgumentException if the user is not a profile.
847      */
startProfile(int userId)848     boolean startProfile(int userId);
849 
850     /**
851      * Stops a profile.
852      * @param userId the user id of the profile.
853      * @return true if the profile has been successfully stopped or is already stopped. Otherwise
854      * the exceptions listed below are thrown.
855      * @throws IllegalArgumentException if the user is not a profile.
856      */
stopProfile(int userId)857     boolean stopProfile(int userId);
858 
859     /** Called by PendingIntent.queryIntentComponents() */
queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags)860     ParceledListSlice queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags);
861 
862     @JavaPassthrough(annotation=
863             "@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)864     int getUidProcessCapabilities(int uid, in String callingPackage);
865 
866     /** Blocks until all broadcast queues become idle. */
waitForBroadcastIdle()867     void waitForBroadcastIdle();
waitForBroadcastBarrier()868     void waitForBroadcastBarrier();
869 
870     /** Delays delivering broadcasts to the specified package. */
871     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
forceDelayBroadcastDelivery(in String targetPackage, long delayedDurationMs)872     void forceDelayBroadcastDelivery(in String targetPackage, long delayedDurationMs);
873 
874     /** Checks if the modern broadcast queue is enabled. */
875     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
isModernBroadcastQueueEnabled()876     boolean isModernBroadcastQueueEnabled();
877 
878     /** Checks if the process represented by the given pid is frozen. */
879     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
isProcessFrozen(int pid)880     boolean isProcessFrozen(int pid);
881 
882     /**
883      * @return The reason code of whether or not the given UID should be exempted from background
884      * restrictions here.
885      *
886      * <p>
887      * Note: Call it with caution as it'll try to acquire locks in other services.
888      * </p>
889      */
getBackgroundRestrictionExemptionReason(int uid)890     int getBackgroundRestrictionExemptionReason(int uid);
891 
892     // Start (?) of T transactions
893     /**
894      * Similar to {@link #startUserInBackgroundWithListener(int userId, IProgressListener unlockProgressListener)},
895      * but setting the user as the visible user of that display (i.e., allowing the user and its
896      * running profiles to launch activities on that display).
897      *
898      * <p>Typically used only by automotive builds when the vehicle has multiple displays.
899      */
900     @JavaPassthrough(annotation=
901             "@android.annotation.RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}, conditional = true)")
startUserInBackgroundVisibleOnDisplay(int userid, int displayId, IProgressListener unlockProgressListener)902     boolean startUserInBackgroundVisibleOnDisplay(int userid, int displayId, IProgressListener unlockProgressListener);
903 
904     /**
905      * Similar to {@link #startProfile(int userId)}, but with a listener to report user unlock
906      * progress.
907      */
startProfileWithListener(int userid, IProgressListener unlockProgressListener)908     boolean startProfileWithListener(int userid, IProgressListener unlockProgressListener);
909 
restartUserInBackground(int userId, int userStartMode)910     int restartUserInBackground(int userId, int userStartMode);
911 
912     /**
913      * Gets the ids of displays that can be used on {@link #startUserInBackgroundVisibleOnDisplay(int userId, int displayId)}.
914      *
915      * <p>Typically used only by automotive builds when the vehicle has multiple displays.
916      */
getDisplayIdsForStartingVisibleBackgroundUsers()917     @nullable int[] getDisplayIdsForStartingVisibleBackgroundUsers();
918 
919     /** Returns if the service is a short-service is still "alive" and past the timeout. */
shouldServiceTimeOut(in ComponentName className, in IBinder token)920     boolean shouldServiceTimeOut(in ComponentName className, in IBinder token);
921 
registerUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback)922     void registerUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback);
923     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)")
unregisterUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback)924     void unregisterUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback);
925     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)")
getUidFrozenState(in int[] uids)926     int[] getUidFrozenState(in int[] uids);
927 
928     /**
929      * Notify AMS about binder transactions to frozen apps.
930      *
931      * @param debugPid The binder transaction sender
932      * @param code The binder transaction code
933      * @param flags The binder transaction flags
934      * @param err The binder transaction error
935      */
frozenBinderTransactionDetected(int debugPid, int code, int flags, int err)936     oneway void frozenBinderTransactionDetected(int debugPid, int code, int flags, int err);
937 }
938