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