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.ApplicationErrorReport;
21 import android.app.ContentProviderHolder;
22 import android.app.GrantedUriPermission;
23 import android.app.IApplicationThread;
24 import android.app.IActivityController;
25 import android.app.IAppTask;
26 import android.app.IAssistDataReceiver;
27 import android.app.IInstrumentationWatcher;
28 import android.app.IProcessObserver;
29 import android.app.IServiceConnection;
30 import android.app.IStopUserCallback;
31 import android.app.ITaskStackListener;
32 import android.app.IUiAutomationConnection;
33 import android.app.IUidObserver;
34 import android.app.IUserSwitchObserver;
35 import android.app.Notification;
36 import android.app.PendingIntent;
37 import android.app.PictureInPictureParams;
38 import android.app.ProfilerInfo;
39 import android.app.WaitResult;
40 import android.app.assist.AssistContent;
41 import android.app.assist.AssistStructure;
42 import android.content.ComponentName;
43 import android.content.IIntentReceiver;
44 import android.content.IIntentSender;
45 import android.content.Intent;
46 import android.content.IntentFilter;
47 import android.content.IntentSender;
48 import android.content.pm.ApplicationInfo;
49 import android.content.pm.ConfigurationInfo;
50 import android.content.pm.IPackageDataObserver;
51 import android.content.pm.ParceledListSlice;
52 import android.content.pm.ProviderInfo;
53 import android.content.pm.UserInfo;
54 import android.content.res.Configuration;
55 import android.graphics.Bitmap;
56 import android.graphics.GraphicBuffer;
57 import android.graphics.Point;
58 import android.graphics.Rect;
59 import android.net.Uri;
60 import android.os.Bundle;
61 import android.os.Debug;
62 import android.os.IBinder;
63 import android.os.IProgressListener;
64 import android.os.ParcelFileDescriptor;
65 import android.os.PersistableBundle;
66 import android.os.RemoteCallback;
67 import android.os.StrictMode;
68 import android.os.WorkSource;
69 import android.service.voice.IVoiceInteractionSession;
70 import android.view.IRecentsAnimationRunner;
71 import android.view.RemoteAnimationDefinition;
72 import android.view.RemoteAnimationAdapter;
73 import com.android.internal.app.IVoiceInteractor;
74 import com.android.internal.os.IResultReceiver;
75 import com.android.internal.policy.IKeyguardDismissCallback;
76 
77 import java.util.List;
78 
79 /**
80  * System private API for talking with the activity manager service.  This
81  * provides calls from the application back to the activity manager.
82  *
83  * {@hide}
84  */
85 interface IActivityManager {
86     // WARNING: when these transactions are updated, check if they are any callers on the native
87     // side. If so, make sure they are using the correct transaction ids and arguments.
88     // If a transaction which will also be used on the native side is being inserted, add it to
89     // below block of transactions.
90 
91     // Since these transactions are also called from native code, these must be kept in sync with
92     // the ones in frameworks/native/libs/binder/include/binder/IActivityManager.h
93     // =============== Beginning of transactions used on native side as well ======================
openContentUri(in String uriString)94     ParcelFileDescriptor openContentUri(in String uriString);
registerUidObserver(in IUidObserver observer, int which, int cutpoint, String callingPackage)95     void registerUidObserver(in IUidObserver observer, int which, int cutpoint,
96             String callingPackage);
unregisterUidObserver(in IUidObserver observer)97     void unregisterUidObserver(in IUidObserver observer);
isUidActive(int uid, String callingPackage)98     boolean isUidActive(int uid, String callingPackage);
getUidProcessState(int uid, in String callingPackage)99     int getUidProcessState(int uid, in String callingPackage);
100     // =============== End of transactions used on native side as well ============================
101 
102     // Special low-level communication with activity manager.
handleApplicationCrash(in IBinder app, in ApplicationErrorReport.ParcelableCrashInfo crashInfo)103     void handleApplicationCrash(in IBinder app,
104             in ApplicationErrorReport.ParcelableCrashInfo crashInfo);
105     @UnsupportedAppUsage
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)106     int startActivity(in IApplicationThread caller, in String callingPackage, in Intent intent,
107             in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
108             int flags, in ProfilerInfo profilerInfo, in Bundle options);
109     @UnsupportedAppUsage
unhandledBack()110     void unhandledBack();
111     @UnsupportedAppUsage
finishActivity(in IBinder token, int code, in Intent data, int finishTask)112     boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);
113     @UnsupportedAppUsage
registerReceiver(in IApplicationThread caller, in String callerPackage, in IIntentReceiver receiver, in IntentFilter filter, in String requiredPermission, int userId, int flags)114     Intent registerReceiver(in IApplicationThread caller, in String callerPackage,
115             in IIntentReceiver receiver, in IntentFilter filter,
116             in String requiredPermission, int userId, int flags);
117     @UnsupportedAppUsage
unregisterReceiver(in IIntentReceiver receiver)118     void unregisterReceiver(in IIntentReceiver receiver);
119     @UnsupportedAppUsage
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)120     int broadcastIntent(in IApplicationThread caller, in Intent intent,
121             in String resolvedType, in IIntentReceiver resultTo, int resultCode,
122             in String resultData, in Bundle map, in String[] requiredPermissions,
123             int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId)124     void unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId);
125     @UnsupportedAppUsage
finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map, boolean abortBroadcast, int flags)126     oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
127             boolean abortBroadcast, int flags);
attachApplication(in IApplicationThread app, long startSeq)128     void attachApplication(in IApplicationThread app, long startSeq);
getTasks(int maxNum)129     List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
130     @UnsupportedAppUsage
getFilteredTasks(int maxNum, int ignoreActivityType, int ignoreWindowingMode)131     List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum, int ignoreActivityType,
132             int ignoreWindowingMode);
133     @UnsupportedAppUsage
moveTaskToFront(in IApplicationThread caller, in String callingPackage, int task, int flags, in Bundle options)134     void moveTaskToFront(in IApplicationThread caller, in String callingPackage, int task,
135             int flags, in Bundle options);
136     @UnsupportedAppUsage
getTaskForActivity(in IBinder token, in boolean onlyRoot)137     int getTaskForActivity(in IBinder token, in boolean onlyRoot);
getContentProvider(in IApplicationThread caller, in String callingPackage, in String name, int userId, boolean stable)138     ContentProviderHolder getContentProvider(in IApplicationThread caller, in String callingPackage,
139             in String name, int userId, boolean stable);
140     @UnsupportedAppUsage
publishContentProviders(in IApplicationThread caller, in List<ContentProviderHolder> providers)141     void publishContentProviders(in IApplicationThread caller,
142             in List<ContentProviderHolder> providers);
refContentProvider(in IBinder connection, int stableDelta, int unstableDelta)143     boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta);
getRunningServiceControlPanel(in ComponentName service)144     PendingIntent getRunningServiceControlPanel(in ComponentName service);
startService(in IApplicationThread caller, in Intent service, in String resolvedType, boolean requireForeground, in String callingPackage, int userId)145     ComponentName startService(in IApplicationThread caller, in Intent service,
146             in String resolvedType, boolean requireForeground, in String callingPackage, int userId);
147     @UnsupportedAppUsage
stopService(in IApplicationThread caller, in Intent service, in String resolvedType, int userId)148     int stopService(in IApplicationThread caller, in Intent service,
149             in String resolvedType, int userId);
150     // Currently keeping old bindService because it is on the greylist
151     @UnsupportedAppUsage
bindService(in IApplicationThread caller, in IBinder token, in Intent service, in String resolvedType, in IServiceConnection connection, int flags, in String callingPackage, int userId)152     int bindService(in IApplicationThread caller, in IBinder token, in Intent service,
153             in String resolvedType, in IServiceConnection connection, int flags,
154             in String callingPackage, int userId);
bindIsolatedService(in IApplicationThread caller, in IBinder token, in Intent service, in String resolvedType, in IServiceConnection connection, int flags, in String instanceName, in String callingPackage, int userId)155     int bindIsolatedService(in IApplicationThread caller, in IBinder token, in Intent service,
156             in String resolvedType, in IServiceConnection connection, int flags,
157             in String instanceName, in String callingPackage, int userId);
updateServiceGroup(in IServiceConnection connection, int group, int importance)158     void updateServiceGroup(in IServiceConnection connection, int group, int importance);
159     @UnsupportedAppUsage
unbindService(in IServiceConnection connection)160     boolean unbindService(in IServiceConnection connection);
publishService(in IBinder token, in Intent intent, in IBinder service)161     void publishService(in IBinder token, in Intent intent, in IBinder service);
162     @UnsupportedAppUsage
setDebugApp(in String packageName, boolean waitForDebugger, boolean persistent)163     void setDebugApp(in String packageName, boolean waitForDebugger, boolean persistent);
setAgentApp(in String packageName, @nullable String agent)164     void setAgentApp(in String packageName, @nullable String agent);
165     @UnsupportedAppUsage
setAlwaysFinish(boolean enabled)166     void setAlwaysFinish(boolean enabled);
167     @UnsupportedAppUsage
startInstrumentation(in ComponentName className, in String profileFile, int flags, in Bundle arguments, in IInstrumentationWatcher watcher, in IUiAutomationConnection connection, int userId, in String abiOverride)168     boolean startInstrumentation(in ComponentName className, in String profileFile,
169             int flags, in Bundle arguments, in IInstrumentationWatcher watcher,
170             in IUiAutomationConnection connection, int userId,
171             in String abiOverride);
addInstrumentationResults(in IApplicationThread target, in Bundle results)172     void addInstrumentationResults(in IApplicationThread target, in Bundle results);
finishInstrumentation(in IApplicationThread target, int resultCode, in Bundle results)173     void finishInstrumentation(in IApplicationThread target, int resultCode,
174             in Bundle results);
175     /**
176      * @return A copy of global {@link Configuration}, contains general settings for the entire
177      *         system. Corresponds to the configuration of the default display.
178      * @throws RemoteException
179      */
180     @UnsupportedAppUsage
getConfiguration()181     Configuration getConfiguration();
182     /**
183      * Updates global configuration and applies changes to the entire system.
184      * @param values Update values for global configuration. If null is passed it will request the
185      *               Window Manager to compute new config for the default display.
186      * @throws RemoteException
187      * @return Returns true if the configuration was updated.
188      */
189     @UnsupportedAppUsage
updateConfiguration(in Configuration values)190     boolean updateConfiguration(in Configuration values);
191     /**
192      * Updates mcc mnc configuration and applies changes to the entire system.
193      *
194      * @param mcc mcc configuration to update.
195      * @param mnc mnc configuration to update.
196      * @throws RemoteException; IllegalArgumentException if mcc or mnc is null.
197      * @return Returns {@code true} if the configuration was updated;
198      *         {@code false} otherwise.
199      */
updateMccMncConfiguration(in String mcc, in String mnc)200     boolean updateMccMncConfiguration(in String mcc, in String mnc);
stopServiceToken(in ComponentName className, in IBinder token, int startId)201     boolean stopServiceToken(in ComponentName className, in IBinder token, int startId);
202     @UnsupportedAppUsage
setProcessLimit(int max)203     void setProcessLimit(int max);
204     @UnsupportedAppUsage
getProcessLimit()205     int getProcessLimit();
206     @UnsupportedAppUsage
checkPermission(in String permission, int pid, int uid)207     int checkPermission(in String permission, int pid, int uid);
checkUriPermission(in Uri uri, int pid, int uid, int mode, int userId, in IBinder callerToken)208     int checkUriPermission(in Uri uri, int pid, int uid, int mode, int userId,
209             in IBinder callerToken);
grantUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri, int mode, int userId)210     void grantUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri,
211             int mode, int userId);
revokeUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri, int mode, int userId)212     void revokeUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri,
213             int mode, int userId);
214     @UnsupportedAppUsage
setActivityController(in IActivityController watcher, boolean imAMonkey)215     void setActivityController(in IActivityController watcher, boolean imAMonkey);
showWaitingForDebugger(in IApplicationThread who, boolean waiting)216     void showWaitingForDebugger(in IApplicationThread who, boolean waiting);
217     /*
218      * This will deliver the specified signal to all the persistent processes. Currently only
219      * SIGUSR1 is delivered. All others are ignored.
220      */
signalPersistentProcesses(int signal)221     void signalPersistentProcesses(int signal);
222 
223     @UnsupportedAppUsage
getRecentTasks(int maxNum, int flags, int userId)224     ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
225     @UnsupportedAppUsage
serviceDoneExecuting(in IBinder token, int type, int startId, int res)226     oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res);
227     @UnsupportedAppUsage
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)228     IIntentSender getIntentSender(int type, in String packageName, in IBinder token,
229             in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes,
230             int flags, in Bundle options, int userId);
cancelIntentSender(in IIntentSender sender)231     void cancelIntentSender(in IIntentSender sender);
getPackageForIntentSender(in IIntentSender sender)232     String getPackageForIntentSender(in IIntentSender sender);
registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver)233     void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver)234     void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
enterSafeMode()235     void enterSafeMode();
noteWakeupAlarm(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String sourcePkg, in String tag)236     void noteWakeupAlarm(in IIntentSender sender, in WorkSource workSource, int sourceUid,
237             in String sourcePkg, in String tag);
removeContentProvider(in IBinder connection, boolean stable)238     oneway void removeContentProvider(in IBinder connection, boolean stable);
239     @UnsupportedAppUsage
setRequestedOrientation(in IBinder token, int requestedOrientation)240     void setRequestedOrientation(in IBinder token, int requestedOrientation);
unbindFinished(in IBinder token, in Intent service, boolean doRebind)241     void unbindFinished(in IBinder token, in Intent service, boolean doRebind);
242     @UnsupportedAppUsage
setProcessImportant(in IBinder token, int pid, boolean isForeground, String reason)243     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)244     void setServiceForeground(in ComponentName className, in IBinder token,
245             int id, in Notification notification, int flags, int foregroundServiceType);
getForegroundServiceType(in ComponentName className, in IBinder token)246     int getForegroundServiceType(in ComponentName className, in IBinder token);
247     @UnsupportedAppUsage
moveActivityTaskToBack(in IBinder token, boolean nonRoot)248     boolean moveActivityTaskToBack(in IBinder token, boolean nonRoot);
249     @UnsupportedAppUsage
getMemoryInfo(out ActivityManager.MemoryInfo outInfo)250     void getMemoryInfo(out ActivityManager.MemoryInfo outInfo);
getProcessesInErrorState()251     List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState();
clearApplicationUserData(in String packageName, boolean keepState, in IPackageDataObserver observer, int userId)252     boolean clearApplicationUserData(in String packageName, boolean keepState,
253             in IPackageDataObserver observer, int userId);
254     @UnsupportedAppUsage
forceStopPackage(in String packageName, int userId)255     void forceStopPackage(in String packageName, int userId);
killPids(in int[] pids, in String reason, boolean secure)256     boolean killPids(in int[] pids, in String reason, boolean secure);
257     @UnsupportedAppUsage
getServices(int maxNum, int flags)258     List<ActivityManager.RunningServiceInfo> getServices(int maxNum, int flags);
259     // Retrieve running application processes in the system
260     @UnsupportedAppUsage
getRunningAppProcesses()261     List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses();
peekService(in Intent service, in String resolvedType, in String callingPackage)262     IBinder peekService(in Intent service, in String resolvedType, in String callingPackage);
263     // Turn on/off profiling in a particular process.
264     @UnsupportedAppUsage
profileControl(in String process, int userId, boolean start, in ProfilerInfo profilerInfo, int profileType)265     boolean profileControl(in String process, int userId, boolean start,
266             in ProfilerInfo profilerInfo, int profileType);
267     @UnsupportedAppUsage
shutdown(int timeout)268     boolean shutdown(int timeout);
269     @UnsupportedAppUsage
stopAppSwitches()270     void stopAppSwitches();
271     @UnsupportedAppUsage
resumeAppSwitches()272     void resumeAppSwitches();
bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId)273     boolean bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId);
backupAgentCreated(in String packageName, in IBinder agent, int userId)274     void backupAgentCreated(in String packageName, in IBinder agent, int userId);
unbindBackupAgent(in ApplicationInfo appInfo)275     void unbindBackupAgent(in ApplicationInfo appInfo);
getUidForIntentSender(in IIntentSender sender)276     int getUidForIntentSender(in IIntentSender sender);
handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, boolean requireFull, in String name, in String callerPackage)277     int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
278             boolean requireFull, in String name, in String callerPackage);
addPackageDependency(in String packageName)279     void addPackageDependency(in String packageName);
killApplication(in String pkg, int appId, int userId, in String reason)280     void killApplication(in String pkg, int appId, int userId, in String reason);
281     @UnsupportedAppUsage
closeSystemDialogs(in String reason)282     void closeSystemDialogs(in String reason);
283     @UnsupportedAppUsage
getProcessMemoryInfo(in int[] pids)284     Debug.MemoryInfo[] getProcessMemoryInfo(in int[] pids);
killApplicationProcess(in String processName, int uid)285     void killApplicationProcess(in String processName, int uid);
286     // Special low-level communication with activity manager.
handleApplicationWtf(in IBinder app, in String tag, boolean system, in ApplicationErrorReport.ParcelableCrashInfo crashInfo)287     boolean handleApplicationWtf(in IBinder app, in String tag, boolean system,
288             in ApplicationErrorReport.ParcelableCrashInfo crashInfo);
289     @UnsupportedAppUsage
killBackgroundProcesses(in String packageName, int userId)290     void killBackgroundProcesses(in String packageName, int userId);
isUserAMonkey()291     boolean isUserAMonkey();
292     // Retrieve info of applications installed on external media that are currently
293     // running.
getRunningExternalApplications()294     List<ApplicationInfo> getRunningExternalApplications();
295     @UnsupportedAppUsage
finishHeavyWeightApp()296     void finishHeavyWeightApp();
297     // A StrictMode violation to be handled.
298     @UnsupportedAppUsage
handleApplicationStrictModeViolation(in IBinder app, int penaltyMask, in StrictMode.ViolationInfo crashInfo)299     void handleApplicationStrictModeViolation(in IBinder app, int penaltyMask,
300             in StrictMode.ViolationInfo crashInfo);
isTopActivityImmersive()301     boolean isTopActivityImmersive();
crashApplication(int uid, int initialPid, in String packageName, int userId, in String message, boolean force)302     void crashApplication(int uid, int initialPid, in String packageName, int userId,
303             in String message, boolean force);
304     @UnsupportedAppUsage
getProviderMimeType(in Uri uri, int userId)305     String getProviderMimeType(in Uri uri, int userId);
306     // 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)307     boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo,
308             boolean runGc, in String path, in ParcelFileDescriptor fd,
309             in RemoteCallback finishCallback);
310     @UnsupportedAppUsage
isUserRunning(int userid, int flags)311     boolean isUserRunning(int userid, int flags);
312     @UnsupportedAppUsage
setPackageScreenCompatMode(in String packageName, int mode)313     void setPackageScreenCompatMode(in String packageName, int mode);
314     @UnsupportedAppUsage
switchUser(int userid)315     boolean switchUser(int userid);
316     @UnsupportedAppUsage
removeTask(int taskId)317     boolean removeTask(int taskId);
318     @UnsupportedAppUsage
registerProcessObserver(in IProcessObserver observer)319     void registerProcessObserver(in IProcessObserver observer);
320     @UnsupportedAppUsage
unregisterProcessObserver(in IProcessObserver observer)321     void unregisterProcessObserver(in IProcessObserver observer);
isIntentSenderTargetedToPackage(in IIntentSender sender)322     boolean isIntentSenderTargetedToPackage(in IIntentSender sender);
323     @UnsupportedAppUsage
updatePersistentConfiguration(in Configuration values)324     void updatePersistentConfiguration(in Configuration values);
325     @UnsupportedAppUsage
getProcessPss(in int[] pids)326     long[] getProcessPss(in int[] pids);
showBootMessage(in CharSequence msg, boolean always)327     void showBootMessage(in CharSequence msg, boolean always);
328     @UnsupportedAppUsage
killAllBackgroundProcesses()329     void killAllBackgroundProcesses();
getContentProviderExternal(in String name, int userId, in IBinder token, String tag)330     ContentProviderHolder getContentProviderExternal(in String name, int userId,
331             in IBinder token, String tag);
332     /** @deprecated - Use {@link #removeContentProviderExternalAsUser} which takes a user ID. */
333     @UnsupportedAppUsage
removeContentProviderExternal(in String name, in IBinder token)334     void removeContentProviderExternal(in String name, in IBinder token);
removeContentProviderExternalAsUser(in String name, in IBinder token, int userId)335     void removeContentProviderExternalAsUser(in String name, in IBinder token, int userId);
336     // Get memory information about the calling process.
getMyMemoryState(out ActivityManager.RunningAppProcessInfo outInfo)337     void getMyMemoryState(out ActivityManager.RunningAppProcessInfo outInfo);
killProcessesBelowForeground(in String reason)338     boolean killProcessesBelowForeground(in String reason);
339     @UnsupportedAppUsage
getCurrentUser()340     UserInfo getCurrentUser();
341     // This is not public because you need to be very careful in how you
342     // manage your activity to make sure it is always the uid you expect.
343     @UnsupportedAppUsage
getLaunchedFromUid(in IBinder activityToken)344     int getLaunchedFromUid(in IBinder activityToken);
345     @UnsupportedAppUsage
unstableProviderDied(in IBinder connection)346     void unstableProviderDied(in IBinder connection);
347     @UnsupportedAppUsage
isIntentSenderAnActivity(in IIntentSender sender)348     boolean isIntentSenderAnActivity(in IIntentSender sender);
isIntentSenderAForegroundService(in IIntentSender sender)349     boolean isIntentSenderAForegroundService(in IIntentSender sender);
isIntentSenderABroadcast(in IIntentSender sender)350     boolean isIntentSenderABroadcast(in IIntentSender sender);
351     @UnsupportedAppUsage
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)352     int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
353             in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
354             int requestCode, int flags, in ProfilerInfo profilerInfo,
355             in Bundle options, int userId);
356     @UnsupportedAppUsage
stopUser(int userid, boolean force, in IStopUserCallback callback)357     int stopUser(int userid, boolean force, in IStopUserCallback callback);
358     @UnsupportedAppUsage
registerUserSwitchObserver(in IUserSwitchObserver observer, in String name)359     void registerUserSwitchObserver(in IUserSwitchObserver observer, in String name);
unregisterUserSwitchObserver(in IUserSwitchObserver observer)360     void unregisterUserSwitchObserver(in IUserSwitchObserver observer);
getRunningUserIds()361     int[] getRunningUserIds();
362 
363     // Request a heap dump for the system server.
requestSystemServerHeapDump()364     void requestSystemServerHeapDump();
365 
366     // Deprecated - This method is only used by a few internal components and it will soon be
367     // replaced by a proper bug report API (which will be restricted to a few, pre-defined apps).
368     // No new code should be calling it.
369     @UnsupportedAppUsage
requestBugReport(int bugreportType)370     void requestBugReport(int bugreportType);
371 
372     /**
373      *  Takes a telephony bug report and notifies the user with the title and description
374      *  that are passed to this API as parameters
375      *
376      *  @param shareTitle should be a valid legible string less than 50 chars long
377      *  @param shareDescription should be less than 91 bytes when encoded into UTF-8 format
378      *
379      *  @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the
380      *          paremeters cannot be encoding to an UTF-8 charset.
381      */
requestTelephonyBugReport(in String shareTitle, in String shareDescription)382     void requestTelephonyBugReport(in String shareTitle, in String shareDescription);
383 
384     /**
385      *  Deprecated - This method is only used by Wifi, and it will soon be replaced by a proper
386      *  bug report API.
387      *
388      *  Takes a minimal bugreport of Wifi-related state.
389      *
390      *  @param shareTitle should be a valid legible string less than 50 chars long
391      *  @param shareDescription should be less than 91 bytes when encoded into UTF-8 format
392      *
393      *  @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the
394      *          parameters cannot be encoding to an UTF-8 charset.
395      */
requestWifiBugReport(in String shareTitle, in String shareDescription)396     void requestWifiBugReport(in String shareTitle, in String shareDescription);
397 
398     @UnsupportedAppUsage
getIntentForIntentSender(in IIntentSender sender)399     Intent getIntentForIntentSender(in IIntentSender sender);
400     // This is not public because you need to be very careful in how you
401     // manage your activity to make sure it is always the uid you expect.
402     @UnsupportedAppUsage
getLaunchedFromPackage(in IBinder activityToken)403     String getLaunchedFromPackage(in IBinder activityToken);
killUid(int appId, int userId, in String reason)404     void killUid(int appId, int userId, in String reason);
setUserIsMonkey(boolean monkey)405     void setUserIsMonkey(boolean monkey);
406     @UnsupportedAppUsage
hang(in IBinder who, boolean allowRestart)407     void hang(in IBinder who, boolean allowRestart);
408 
409     @UnsupportedAppUsage
getAllStackInfos()410     List<ActivityManager.StackInfo> getAllStackInfos();
411     @UnsupportedAppUsage
moveTaskToStack(int taskId, int stackId, boolean toTop)412     void moveTaskToStack(int taskId, int stackId, boolean toTop);
413     /**
414      * Resizes the input stack id to the given bounds.
415      *
416      * @param stackId Id of the stack to resize.
417      * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
418      * @param allowResizeInDockedMode True if the resize should be allowed when the docked stack is
419      *                                active.
420      * @param preserveWindows True if the windows of activities contained in the stack should be
421      *                        preserved.
422      * @param animate True if the stack resize should be animated.
423      * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
424      *                          default animation duration should be used.
425      * @throws RemoteException
426      */
427     @UnsupportedAppUsage
resizeStack(int stackId, in Rect bounds, boolean allowResizeInDockedMode, boolean preserveWindows, boolean animate, int animationDuration)428     void resizeStack(int stackId, in Rect bounds, boolean allowResizeInDockedMode,
429             boolean preserveWindows, boolean animate, int animationDuration);
setFocusedStack(int stackId)430     void setFocusedStack(int stackId);
getFocusedStackInfo()431     ActivityManager.StackInfo getFocusedStackInfo();
432     @UnsupportedAppUsage
restart()433     void restart();
performIdleMaintenance()434     void performIdleMaintenance();
appNotRespondingViaProvider(in IBinder connection)435     void appNotRespondingViaProvider(in IBinder connection);
436     @UnsupportedAppUsage
getTaskBounds(int taskId)437     Rect getTaskBounds(int taskId);
438     @UnsupportedAppUsage
setProcessMemoryTrimLevel(in String process, int uid, int level)439     boolean setProcessMemoryTrimLevel(in String process, int uid, int level);
440 
441 
442     // Start of L transactions
getTagForIntentSender(in IIntentSender sender, in String prefix)443     String getTagForIntentSender(in IIntentSender sender, in String prefix);
444     @UnsupportedAppUsage
startUserInBackground(int userid)445     boolean startUserInBackground(int userid);
446     @UnsupportedAppUsage
isInLockTaskMode()447     boolean isInLockTaskMode();
448     @UnsupportedAppUsage
startRecentsActivity(in Intent intent, in IAssistDataReceiver assistDataReceiver, in IRecentsAnimationRunner recentsAnimationRunner)449     void startRecentsActivity(in Intent intent, in IAssistDataReceiver assistDataReceiver,
450             in IRecentsAnimationRunner recentsAnimationRunner);
451     @UnsupportedAppUsage
cancelRecentsAnimation(boolean restoreHomeStackPosition)452     void cancelRecentsAnimation(boolean restoreHomeStackPosition);
453     @UnsupportedAppUsage
startActivityFromRecents(int taskId, in Bundle options)454     int startActivityFromRecents(int taskId, in Bundle options);
455     @UnsupportedAppUsage
startSystemLockTaskMode(int taskId)456     void startSystemLockTaskMode(int taskId);
457     @UnsupportedAppUsage
isTopOfTask(in IBinder token)458     boolean isTopOfTask(in IBinder token);
bootAnimationComplete()459     void bootAnimationComplete();
checkPermissionWithToken(in String permission, int pid, int uid, in IBinder callerToken)460     int checkPermissionWithToken(in String permission, int pid, int uid,
461             in IBinder callerToken);
462     @UnsupportedAppUsage
registerTaskStackListener(in ITaskStackListener listener)463     void registerTaskStackListener(in ITaskStackListener listener);
unregisterTaskStackListener(in ITaskStackListener listener)464     void unregisterTaskStackListener(in ITaskStackListener listener);
notifyCleartextNetwork(int uid, in byte[] firstPacket)465     void notifyCleartextNetwork(int uid, in byte[] firstPacket);
466     @UnsupportedAppUsage
setTaskResizeable(int taskId, int resizeableMode)467     void setTaskResizeable(int taskId, int resizeableMode);
468     @UnsupportedAppUsage
resizeTask(int taskId, in Rect bounds, int resizeMode)469     void resizeTask(int taskId, in Rect bounds, int resizeMode);
470     @UnsupportedAppUsage
getLockTaskModeState()471     int getLockTaskModeState();
472     @UnsupportedAppUsage
setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize, in String reportPackage)473     void setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize,
474             in String reportPackage);
dumpHeapFinished(in String path)475     void dumpHeapFinished(in String path);
updateLockTaskPackages(int userId, in String[] packages)476     void updateLockTaskPackages(int userId, in String[] packages);
noteAlarmStart(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag)477     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)478     void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
479     @UnsupportedAppUsage
getPackageProcessState(in String packageName, in String callingPackage)480     int getPackageProcessState(in String packageName, in String callingPackage);
updateDeviceOwner(in String packageName)481     void updateDeviceOwner(in String packageName);
482 
483     // Start of N transactions
484     // Start Binder transaction tracking for all applications.
485     @UnsupportedAppUsage
startBinderTracking()486     boolean startBinderTracking();
487     // Stop Binder transaction tracking for all applications and dump trace data to the given file
488     // descriptor.
489     @UnsupportedAppUsage
stopBinderTrackingAndDump(in ParcelFileDescriptor fd)490     boolean stopBinderTrackingAndDump(in ParcelFileDescriptor fd);
491     /**
492      * Try to place task to provided position. The final position might be different depending on
493      * current user and stacks state. The task will be moved to target stack if it's currently in
494      * different stack.
495      */
496     @UnsupportedAppUsage
positionTaskInStack(int taskId, int stackId, int position)497     void positionTaskInStack(int taskId, int stackId, int position);
498     @UnsupportedAppUsage
suppressResizeConfigChanges(boolean suppress)499     void suppressResizeConfigChanges(boolean suppress);
500     @UnsupportedAppUsage
moveTopActivityToPinnedStack(int stackId, in Rect bounds)501     boolean moveTopActivityToPinnedStack(int stackId, in Rect bounds);
isAppStartModeDisabled(int uid, in String packageName)502     boolean isAppStartModeDisabled(int uid, in String packageName);
503     @UnsupportedAppUsage
unlockUser(int userid, in byte[] token, in byte[] secret, in IProgressListener listener)504     boolean unlockUser(int userid, in byte[] token, in byte[] secret,
505             in IProgressListener listener);
killPackageDependents(in String packageName, int userId)506     void killPackageDependents(in String packageName, int userId);
507     /**
508      * Resizes the docked stack, and all other stacks as the result of the dock stack bounds change.
509      *
510      * @param dockedBounds The bounds for the docked stack.
511      * @param tempDockedTaskBounds The temporary bounds for the tasks in the docked stack, which
512      *                             might be different from the stack bounds to allow more
513      *                             flexibility while resizing, or {@code null} if they should be the
514      *                             same as the stack bounds.
515      * @param tempDockedTaskInsetBounds The temporary bounds for the tasks to calculate the insets.
516      *                                  When resizing, we usually "freeze" the layout of a task. To
517      *                                  achieve that, we also need to "freeze" the insets, which
518      *                                  gets achieved by changing task bounds but not bounds used
519      *                                  to calculate the insets in this transient state
520      * @param tempOtherTaskBounds The temporary bounds for the tasks in all other stacks, or
521      *                            {@code null} if they should be the same as the stack bounds.
522      * @param tempOtherTaskInsetBounds Like {@code tempDockedTaskInsetBounds}, but for the other
523      *                                 stacks.
524      * @throws RemoteException
525      */
526     @UnsupportedAppUsage
resizeDockedStack(in Rect dockedBounds, in Rect tempDockedTaskBounds, in Rect tempDockedTaskInsetBounds, in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds)527     void resizeDockedStack(in Rect dockedBounds, in Rect tempDockedTaskBounds,
528             in Rect tempDockedTaskInsetBounds,
529             in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds);
530     @UnsupportedAppUsage
removeStack(int stackId)531     void removeStack(int stackId);
makePackageIdle(String packageName, int userId)532     void makePackageIdle(String packageName, int userId);
getMemoryTrimLevel()533     int getMemoryTrimLevel();
isVrModePackageEnabled(in ComponentName packageName)534     boolean isVrModePackageEnabled(in ComponentName packageName);
notifyLockedProfile(int userId)535     void notifyLockedProfile(int userId);
startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options)536     void startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options);
537     @UnsupportedAppUsage
sendIdleJobTrigger()538     void sendIdleJobTrigger();
sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in String requiredPermission, in Bundle options)539     int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code,
540             in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver,
541             in String requiredPermission, in Bundle options);
isBackgroundRestricted(in String packageName)542     boolean isBackgroundRestricted(in String packageName);
543 
544     // Start of N MR1 transactions
setRenderThread(int tid)545     void setRenderThread(int tid);
546     /**
547      * Lets activity manager know whether the calling process is currently showing "top-level" UI
548      * that is not an activity, i.e. windows on the screen the user is currently interacting with.
549      *
550      * <p>This flag can only be set for persistent processes.
551      *
552      * @param hasTopUi Whether the calling process has "top-level" UI.
553      */
setHasTopUi(boolean hasTopUi)554     void setHasTopUi(boolean hasTopUi);
555 
556     // Start of O transactions
restartUserInBackground(int userId)557     int restartUserInBackground(int userId);
558     /** Cancels the window transitions for the given task. */
559     @UnsupportedAppUsage
cancelTaskWindowTransition(int taskId)560     void cancelTaskWindowTransition(int taskId);
561     /**
562      * @param taskId the id of the task to retrieve the sAutoapshots for
563      * @param reducedResolution if set, if the snapshot needs to be loaded from disk, this will load
564      *                          a reduced resolution of it, which is much faster
565      * @return a graphic buffer representing a screenshot of a task
566      */
567     @UnsupportedAppUsage
getTaskSnapshot(int taskId, boolean reducedResolution)568     ActivityManager.TaskSnapshot getTaskSnapshot(int taskId, boolean reducedResolution);
scheduleApplicationInfoChanged(in List<String> packageNames, int userId)569     void scheduleApplicationInfoChanged(in List<String> packageNames, int userId);
setPersistentVrThread(int tid)570     void setPersistentVrThread(int tid);
571 
waitForNetworkStateUpdate(long procStateSeq)572     void waitForNetworkStateUpdate(long procStateSeq);
573     /**
574      * Add a bare uid to the background restrictions whitelist.  Only the system uid may call this.
575      */
backgroundWhitelistUid(int uid)576     void backgroundWhitelistUid(int uid);
577 
578     // Start of P transactions
579     /**
580      *  Similar to {@link #startUserInBackground(int userId), but with a listener to report
581      *  user unlock progress.
582      */
startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener)583     boolean startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener);
584 
585     /**
586      * Method for the shell UID to start deletating its permission identity to an
587      * active instrumenation. The shell can delegate permissions only to one active
588      * instrumentation at a time. An active instrumentation is one running and
589      * started from the shell.
590      */
startDelegateShellPermissionIdentity(int uid, in String[] permissions)591     void startDelegateShellPermissionIdentity(int uid, in String[] permissions);
592 
593     /**
594      * Method for the shell UID to stop deletating its permission identity to an
595      * active instrumenation. An active instrumentation is one running and
596      * started from the shell.
597      */
stopDelegateShellPermissionIdentity()598     void stopDelegateShellPermissionIdentity();
599 
600     /** Returns a file descriptor that'll be closed when the system server process dies. */
getLifeMonitor()601     ParcelFileDescriptor getLifeMonitor();
602 
603     /**
604      * Start user, if it us not already running, and bring it to foreground.
605      * unlockProgressListener can be null if monitoring progress is not necessary.
606      */
startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener)607     boolean startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener);
608 }
609