• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 com.android.server.wm;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.UserIdInt;
22 import android.app.ActivityManager;
23 import android.app.AppProtoEnums;
24 import android.app.IActivityManager;
25 import android.app.IApplicationThread;
26 import android.app.ProfilerInfo;
27 import android.content.ComponentName;
28 import android.content.IIntentSender;
29 import android.content.Intent;
30 import android.content.pm.ApplicationInfo;
31 import android.content.res.CompatibilityInfo;
32 import android.os.Bundle;
33 import android.os.IBinder;
34 import android.os.RemoteException;
35 import android.service.voice.IVoiceInteractionSession;
36 import android.util.proto.ProtoOutputStream;
37 
38 import com.android.internal.app.IVoiceInteractor;
39 import com.android.server.am.PendingIntentRecord;
40 import com.android.server.am.UserState;
41 
42 import java.io.FileDescriptor;
43 import java.io.PrintWriter;
44 import java.lang.ref.WeakReference;
45 import java.util.List;
46 import java.util.Set;
47 
48 /**
49  * Activity Task manager local system service interface.
50  * @hide Only for use within system server
51  */
52 public abstract class ActivityTaskManagerInternal {
53 
54     /**
55      * Type for {@link #notifyAppTransitionStarting}: The transition was started because we drew
56      * the splash screen.
57      */
58     public static final int APP_TRANSITION_SPLASH_SCREEN =
59               AppProtoEnums.APP_TRANSITION_SPLASH_SCREEN; // 1
60 
61     /**
62      * Type for {@link #notifyAppTransitionStarting}: The transition was started because we all
63      * app windows were drawn
64      */
65     public static final int APP_TRANSITION_WINDOWS_DRAWN =
66               AppProtoEnums.APP_TRANSITION_WINDOWS_DRAWN; // 2
67 
68     /**
69      * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
70      * timeout.
71      */
72     public static final int APP_TRANSITION_TIMEOUT =
73               AppProtoEnums.APP_TRANSITION_TIMEOUT; // 3
74 
75     /**
76      * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
77      * we drew a task snapshot.
78      */
79     public static final int APP_TRANSITION_SNAPSHOT =
80               AppProtoEnums.APP_TRANSITION_SNAPSHOT; // 4
81 
82     /**
83      * Type for {@link #notifyAppTransitionStarting}: The transition was started because it was a
84      * recents animation and we only needed to wait on the wallpaper.
85      */
86     public static final int APP_TRANSITION_RECENTS_ANIM =
87             AppProtoEnums.APP_TRANSITION_RECENTS_ANIM; // 5
88 
89     /**
90      * The id of the task source of assist state.
91      */
92     public static final String ASSIST_TASK_ID = "taskId";
93 
94     /**
95      * The id of the activity source of assist state.
96      */
97     public static final String ASSIST_ACTIVITY_ID = "activityId";
98 
99     /**
100      * The bundle key to extract the assist data.
101      */
102     public static final String ASSIST_KEY_DATA = "data";
103 
104     /**
105      * The bundle key to extract the assist structure.
106      */
107     public static final String ASSIST_KEY_STRUCTURE = "structure";
108 
109     /**
110      * The bundle key to extract the assist content.
111      */
112     public static final String ASSIST_KEY_CONTENT = "content";
113 
114     /**
115      * The bundle key to extract the assist receiver extras.
116      */
117     public static final String ASSIST_KEY_RECEIVER_EXTRAS = "receiverExtras";
118 
119     public interface ScreenObserver {
onAwakeStateChanged(boolean isAwake)120         void onAwakeStateChanged(boolean isAwake);
onKeyguardStateChanged(boolean isShowing)121         void onKeyguardStateChanged(boolean isShowing);
122     }
123 
124     /**
125      * Sleep tokens cause the activity manager to put the top activity to sleep.
126      * They are used by components such as dreams that may hide and block interaction
127      * with underlying activities.
128      * The Acquirer provides an interface that encapsulates the underlying work, so the user does
129      * not need to handle the token by him/herself.
130      */
131     public interface SleepTokenAcquirer {
132 
133         /**
134          * Acquires a sleep token.
135          * @param displayId The display to apply to.
136          */
acquire(int displayId)137         void acquire(int displayId);
138 
139         /**
140          * Releases the sleep token.
141          * @param displayId The display to apply to.
142          */
release(int displayId)143         void release(int displayId);
144     }
145 
146     /**
147      * Creates a sleep token acquirer for the specified display with the specified tag.
148      *
149      * @param tag A string identifying the purpose (eg. "Dream").
150      */
createSleepTokenAcquirer(@onNull String tag)151     public abstract SleepTokenAcquirer createSleepTokenAcquirer(@NonNull String tag);
152 
153     /**
154      * Returns home activity for the specified user.
155      *
156      * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
157      */
getHomeActivityForUser(int userId)158     public abstract ComponentName getHomeActivityForUser(int userId);
159 
onLocalVoiceInteractionStarted(IBinder callingActivity, IVoiceInteractionSession mSession, IVoiceInteractor mInteractor)160     public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
161             IVoiceInteractionSession mSession,
162             IVoiceInteractor mInteractor);
163 
164     /**
165      * Returns the top activity from each of the currently visible stacks. The first entry will be
166      * the focused activity.
167      */
getTopVisibleActivities()168     public abstract List<IBinder> getTopVisibleActivities();
169 
170     /**
171      * Returns whether {@code uid} has any resumed activity.
172      */
hasResumedActivity(int uid)173     public abstract boolean hasResumedActivity(int uid);
174 
175     /**
176      * Notify listeners that contents are drawn for the first time on a single task display.
177      *
178      * @param displayId An ID of the display on which contents are drawn.
179      */
notifySingleTaskDisplayDrawn(int displayId)180     public abstract void notifySingleTaskDisplayDrawn(int displayId);
181 
182     /**
183      * Start activity {@code intents} as if {@code packageName/featureId} on user {@code userId} did
184      * it.
185      *
186      * - DO NOT call it with the calling UID cleared.
187      * - All the necessary caller permission checks must be done at callsites.
188      *
189      * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
190      */
startActivitiesAsPackage(String packageName, String featureId, int userId, Intent[] intents, Bundle bOptions)191     public abstract int startActivitiesAsPackage(String packageName, String featureId,
192             int userId, Intent[] intents, Bundle bOptions);
193 
194     /**
195      * Start intents as a package.
196      *
197      * @param uid Make a call as if this UID did.
198      * @param realCallingPid PID of the real caller.
199      * @param realCallingUid UID of the real caller.
200      * @param callingPackage Make a call as if this package did.
201      * @param callingFeatureId Make a call as if this feature in the package did.
202      * @param intents Intents to start.
203      * @param userId Start the intents on this user.
204      * @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID.
205      * @param originatingPendingIntent PendingIntentRecord that originated this activity start or
206      *        null if not originated by PendingIntent
207      * @param allowBackgroundActivityStart Whether the background activity start should be allowed
208      *        from originatingPendingIntent
209      */
startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid, String callingPackage, @Nullable String callingFeatureId, Intent[] intents, String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId, boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart)210     public abstract int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid,
211             String callingPackage, @Nullable String callingFeatureId, Intent[] intents,
212             String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
213             boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
214             boolean allowBackgroundActivityStart);
215 
startActivityInPackage(int uid, int realCallingPid, int realCallingUid, String callingPackage, @Nullable String callingFeaturId, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, SafeActivityOptions options, int userId, Task inTask, String reason, boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart)216     public abstract int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
217             String callingPackage, @Nullable String callingFeaturId, Intent intent,
218             String resolvedType, IBinder resultTo, String resultWho, int requestCode,
219             int startFlags, SafeActivityOptions options, int userId, Task inTask, String reason,
220             boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
221             boolean allowBackgroundActivityStart);
222 
223     /**
224      * Start activity {@code intent} without calling user-id check.
225      *
226      * - DO NOT call it with the calling UID cleared.
227      * - The caller must do the calling user ID check.
228      *
229      * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
230      */
startActivityAsUser(IApplicationThread caller, String callingPackage, @Nullable String callingFeatureId, Intent intent, @Nullable IBinder resultTo, int startFlags, @Nullable Bundle options, int userId)231     public abstract int startActivityAsUser(IApplicationThread caller, String callingPackage,
232             @Nullable String callingFeatureId, Intent intent, @Nullable IBinder resultTo,
233             int startFlags, @Nullable Bundle options, int userId);
234 
235     /**
236      * Called when Keyguard flags might have changed.
237      *
238      * @param callback Callback to run after activity visibilities have been reevaluated. This can
239      *                 be used from window manager so that when the callback is called, it's
240      *                 guaranteed that all apps have their visibility updated accordingly.
241      * @param displayId The id of the display where the keyguard flags changed.
242      */
notifyKeyguardFlagsChanged(@ullable Runnable callback, int displayId)243     public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId);
244 
245     /**
246      * Called when the trusted state of Keyguard has changed.
247      */
notifyKeyguardTrustedChanged()248     public abstract void notifyKeyguardTrustedChanged();
249 
250     /**
251      * Called after virtual display Id is updated by
252      * {@link com.android.server.vr.Vr2dDisplay} with a specific
253      * {@param vr2dDisplayId}.
254      */
setVr2dDisplayId(int vr2dDisplayId)255     public abstract void setVr2dDisplayId(int vr2dDisplayId);
256 
257     /**
258      * Set focus on an activity.
259      * @param token The IApplicationToken for the activity
260      */
setFocusedActivity(IBinder token)261     public abstract void setFocusedActivity(IBinder token);
262 
registerScreenObserver(ScreenObserver observer)263     public abstract void registerScreenObserver(ScreenObserver observer);
264 
265     /**
266      * Returns is the caller has the same uid as the Recents component
267      */
isCallerRecents(int callingUid)268     public abstract boolean isCallerRecents(int callingUid);
269 
270     /**
271      * Returns whether the recents component is the home activity for the given user.
272      */
isRecentsComponentHomeActivity(int userId)273     public abstract boolean isRecentsComponentHomeActivity(int userId);
274 
275     /**
276      * Cancels any currently running recents animation.
277      */
cancelRecentsAnimation(boolean restoreHomeStackPosition)278     public abstract void cancelRecentsAnimation(boolean restoreHomeStackPosition);
279 
280     /**
281      * This enforces {@code func} can only be called if either the caller is Recents activity or
282      * has {@code permission}.
283      */
enforceCallerIsRecentsOrHasPermission(String permission, String func)284     public abstract void enforceCallerIsRecentsOrHasPermission(String permission, String func);
285 
286     /**
287      * Called after the voice interaction service has changed.
288      */
notifyActiveVoiceInteractionServiceChanged(ComponentName component)289     public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component);
290 
291     /**
292      * Called when the device changes its dreaming state.
293      */
notifyDreamStateChanged(boolean dreaming)294     public abstract void notifyDreamStateChanged(boolean dreaming);
295 
296     /**
297      * Set a uid that is allowed to bypass stopped app switches, launching an app
298      * whenever it wants.
299      *
300      * @param type Type of the caller -- unique string the caller supplies to identify itself
301      * and disambiguate with other calles.
302      * @param uid The uid of the app to be allowed, or -1 to clear the uid for this type.
303      * @param userId The user it is allowed for.
304      */
setAllowAppSwitches(@onNull String type, int uid, int userId)305     public abstract void setAllowAppSwitches(@NonNull String type, int uid, int userId);
306 
307     /**
308      * Called when a user has been stopped.
309      *
310      * @param userId The user being stopped.
311      */
onUserStopped(int userId)312     public abstract void onUserStopped(int userId);
isGetTasksAllowed(String caller, int callingPid, int callingUid)313     public abstract boolean isGetTasksAllowed(String caller, int callingPid, int callingUid);
314 
onProcessAdded(WindowProcessController proc)315     public abstract void onProcessAdded(WindowProcessController proc);
onProcessRemoved(String name, int uid)316     public abstract void onProcessRemoved(String name, int uid);
onCleanUpApplicationRecord(WindowProcessController proc)317     public abstract void onCleanUpApplicationRecord(WindowProcessController proc);
getTopProcessState()318     public abstract int getTopProcessState();
isHeavyWeightProcess(WindowProcessController proc)319     public abstract boolean isHeavyWeightProcess(WindowProcessController proc);
clearHeavyWeightProcessIfEquals(WindowProcessController proc)320     public abstract void clearHeavyWeightProcessIfEquals(WindowProcessController proc);
finishHeavyWeightApp()321     public abstract void finishHeavyWeightApp();
322 
isDreaming()323     public abstract boolean isDreaming();
isSleeping()324     public abstract boolean isSleeping();
isShuttingDown()325     public abstract boolean isShuttingDown();
shuttingDown(boolean booted, int timeout)326     public abstract boolean shuttingDown(boolean booted, int timeout);
enableScreenAfterBoot(boolean booted)327     public abstract void enableScreenAfterBoot(boolean booted);
showStrictModeViolationDialog()328     public abstract boolean showStrictModeViolationDialog();
showSystemReadyErrorDialogsIfNeeded()329     public abstract void showSystemReadyErrorDialogsIfNeeded();
330 
onProcessMapped(int pid, WindowProcessController proc)331     public abstract void onProcessMapped(int pid, WindowProcessController proc);
onProcessUnMapped(int pid)332     public abstract void onProcessUnMapped(int pid);
333 
onPackageDataCleared(String name)334     public abstract void onPackageDataCleared(String name);
onPackageUninstalled(String name)335     public abstract void onPackageUninstalled(String name);
onPackageAdded(String name, boolean replacing)336     public abstract void onPackageAdded(String name, boolean replacing);
onPackageReplaced(ApplicationInfo aInfo)337     public abstract void onPackageReplaced(ApplicationInfo aInfo);
338 
compatibilityInfoForPackage(ApplicationInfo ai)339     public abstract CompatibilityInfo compatibilityInfoForPackage(ApplicationInfo ai);
340 
341     public final class ActivityTokens {
342         private final @NonNull IBinder mActivityToken;
343         private final @NonNull IBinder mAssistToken;
344         private final @NonNull IApplicationThread mAppThread;
345 
ActivityTokens(@onNull IBinder activityToken, @NonNull IBinder assistToken, @NonNull IApplicationThread appThread)346         public ActivityTokens(@NonNull IBinder activityToken,
347                 @NonNull IBinder assistToken, @NonNull IApplicationThread appThread) {
348             mActivityToken = activityToken;
349             mAssistToken = assistToken;
350             mAppThread = appThread;
351         }
352 
353         /**
354          * @return The activity token.
355          */
getActivityToken()356         public @NonNull IBinder getActivityToken() {
357             return mActivityToken;
358         }
359 
360         /**
361          * @return The assist token.
362          */
getAssistToken()363         public @NonNull IBinder getAssistToken() {
364             return mAssistToken;
365         }
366 
367         /**
368          * @return The assist token.
369          */
getApplicationThread()370         public @NonNull IApplicationThread getApplicationThread() {
371             return mAppThread;
372         }
373     }
374 
375     /**
376      * Set the corresponding display information for the process global configuration. To be called
377      * when we need to show IME on a different display.
378      *
379      * @param pid The process id associated with the IME window.
380      * @param displayId The ID of the display showing the IME.
381      */
onImeWindowSetOnDisplay(int pid, int displayId)382     public abstract void onImeWindowSetOnDisplay(int pid, int displayId);
383 
sendActivityResult(int callingUid, IBinder activityToken, String resultWho, int requestCode, int resultCode, Intent data)384     public abstract void sendActivityResult(int callingUid, IBinder activityToken,
385             String resultWho, int requestCode, int resultCode, Intent data);
clearPendingResultForActivity( IBinder activityToken, WeakReference<PendingIntentRecord> pir)386     public abstract void clearPendingResultForActivity(
387             IBinder activityToken, WeakReference<PendingIntentRecord> pir);
388 
389     /**
390      * @return the activity token and IApplicationThread for the top activity in the task or null
391      * if there isn't a top activity with a valid process.
392      */
393     @Nullable
getTopActivityForTask(int taskId)394     public abstract ActivityTokens getTopActivityForTask(int taskId);
395 
getIntentSender(int type, String packageName, @Nullable String featureId, int callingUid, int userId, IBinder token, String resultWho, int requestCode, Intent[] intents, String[] resolvedTypes, int flags, Bundle bOptions)396     public abstract IIntentSender getIntentSender(int type, String packageName,
397             @Nullable String featureId, int callingUid, int userId, IBinder token, String resultWho,
398             int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
399             Bundle bOptions);
400 
401     /** @return the service connection holder for a given activity token. */
getServiceConnectionsHolder(IBinder token)402     public abstract ActivityServiceConnectionsHolder getServiceConnectionsHolder(IBinder token);
403 
404     /** @return The intent used to launch the home activity. */
getHomeIntent()405     public abstract Intent getHomeIntent();
startHomeActivity(int userId, String reason)406     public abstract boolean startHomeActivity(int userId, String reason);
407     /**
408      * This starts home activity on displays that can have system decorations based on displayId -
409      * Default display always use primary home component.
410      * For Secondary displays, the home activity must have category SECONDARY_HOME and then resolves
411      * according to the priorities listed below.
412      *  - If default home is not set, always use the secondary home defined in the config.
413      *  - Use currently selected primary home activity.
414      *  - Use the activity in the same package as currently selected primary home activity.
415      *    If there are multiple activities matched, use first one.
416      *  - Use the secondary home defined in the config.
417      */
startHomeOnDisplay(int userId, String reason, int displayId, boolean allowInstrumenting, boolean fromHomeKey)418     public abstract boolean startHomeOnDisplay(int userId, String reason, int displayId,
419             boolean allowInstrumenting, boolean fromHomeKey);
420     /** Start home activities on all displays that support system decorations. */
startHomeOnAllDisplays(int userId, String reason)421     public abstract boolean startHomeOnAllDisplays(int userId, String reason);
422     /** @return true if the given process is the factory test process. */
isFactoryTestProcess(WindowProcessController wpc)423     public abstract boolean isFactoryTestProcess(WindowProcessController wpc);
updateTopComponentForFactoryTest()424     public abstract void updateTopComponentForFactoryTest();
handleAppDied(WindowProcessController wpc, boolean restarting, Runnable finishInstrumentationCallback)425     public abstract void handleAppDied(WindowProcessController wpc, boolean restarting,
426             Runnable finishInstrumentationCallback);
closeSystemDialogs(String reason)427     public abstract void closeSystemDialogs(String reason);
428 
429     /** Removes all components (e.g. activities, recents, ...) belonging to a disabled package. */
cleanupDisabledPackageComponents( String packageName, Set<String> disabledClasses, int userId, boolean booted)430     public abstract void cleanupDisabledPackageComponents(
431             String packageName, Set<String> disabledClasses, int userId, boolean booted);
432 
433     /** Called whenever AM force stops a package. */
onForceStopPackage(String packageName, boolean doit, boolean evenPersistent, int userId)434     public abstract boolean onForceStopPackage(String packageName, boolean doit,
435             boolean evenPersistent, int userId);
436     /**
437      * Resumes all top activities in the system if they aren't resumed already.
438      * @param scheduleIdle If the idle message should be schedule after the top activities are
439      *                     resumed.
440      */
resumeTopActivities(boolean scheduleIdle)441     public abstract void resumeTopActivities(boolean scheduleIdle);
442 
443     /** Called by AM just before it binds to an application process. */
preBindApplication(WindowProcessController wpc)444     public abstract void preBindApplication(WindowProcessController wpc);
445 
446     /** Called by AM when an application process attaches. */
attachApplication(WindowProcessController wpc)447     public abstract boolean attachApplication(WindowProcessController wpc) throws RemoteException;
448 
449     /** @see IActivityManager#notifyLockedProfile(int) */
notifyLockedProfile(@serIdInt int userId, int currentUserId)450     public abstract void notifyLockedProfile(@UserIdInt int userId, int currentUserId);
451 
452     /** @see IActivityManager#startConfirmDeviceCredentialIntent(Intent, Bundle) */
startConfirmDeviceCredentialIntent(Intent intent, Bundle options)453     public abstract void startConfirmDeviceCredentialIntent(Intent intent, Bundle options);
454 
455     /** Writes current activity states to the proto stream. */
writeActivitiesToProto(ProtoOutputStream proto)456     public abstract void writeActivitiesToProto(ProtoOutputStream proto);
457 
458     /**
459      * Saves the current activity manager state and includes the saved state in the next dump of
460      * activity manager.
461      */
saveANRState(String reason)462     public abstract void saveANRState(String reason);
463 
464     /** Clears the previously saved activity manager ANR state. */
clearSavedANRState()465     public abstract void clearSavedANRState();
466 
467     /** Dump the current state based on the command. */
dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage)468     public abstract void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args,
469             int opti, boolean dumpAll, boolean dumpClient, String dumpPackage);
470 
471     /** Dump the current state for inclusion in process dump. */
dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll, String dumpPackage, int dumpAppId, boolean needSep, boolean testPssMode, int wakefulness)472     public abstract boolean dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
473             String dumpPackage, int dumpAppId, boolean needSep, boolean testPssMode,
474             int wakefulness);
475 
476     /** Writes the current window process states to the proto stream. */
writeProcessesToProto(ProtoOutputStream proto, String dumpPackage, int wakeFullness, boolean testPssMode)477     public abstract void writeProcessesToProto(ProtoOutputStream proto, String dumpPackage,
478             int wakeFullness, boolean testPssMode);
479 
480     /** Dump the current activities state. */
dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly, boolean dumpFocusedStackOnly)481     public abstract boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name,
482             String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly,
483             boolean dumpFocusedStackOnly);
484 
485     /** Dump the current state for inclusion in oom dump. */
dumpForOom(PrintWriter pw)486     public abstract void dumpForOom(PrintWriter pw);
487 
488     /** @return true if it the activity management system is okay with GC running now. */
canGcNow()489     public abstract boolean canGcNow();
490 
491     /** @return the process for the top-most resumed activity in the system. */
getTopApp()492     public abstract WindowProcessController getTopApp();
493 
494     /** Generate oom-score-adjustment rank for all tasks in the system based on z-order. */
rankTaskLayersIfNeeded()495     public abstract void rankTaskLayersIfNeeded();
496 
497     /** Destroy all activities. */
scheduleDestroyAllActivities(String reason)498     public abstract void scheduleDestroyAllActivities(String reason);
499 
500     /** Remove user association with activities. */
removeUser(int userId)501     public abstract void removeUser(int userId);
502 
503     /** Switch current focused user for activities. */
switchUser(int userId, UserState userState)504     public abstract boolean switchUser(int userId, UserState userState);
505 
506     /** Called whenever an app crashes. */
onHandleAppCrash(WindowProcessController wpc)507     public abstract void onHandleAppCrash(WindowProcessController wpc);
508 
509     /**
510      * Finish the topmost activities in all stacks that belong to the crashed app.
511      * @param crashedApp The app that crashed.
512      * @param reason Reason to perform this action.
513      * @return The task id that was finished in this stack, or INVALID_TASK_ID if none was finished.
514      */
finishTopCrashedActivities( WindowProcessController crashedApp, String reason)515     public abstract int finishTopCrashedActivities(
516             WindowProcessController crashedApp, String reason);
517 
onUidActive(int uid, int procState)518     public abstract void onUidActive(int uid, int procState);
onUidInactive(int uid)519     public abstract void onUidInactive(int uid);
onActiveUidsCleared()520     public abstract void onActiveUidsCleared();
onUidProcStateChanged(int uid, int procState)521     public abstract void onUidProcStateChanged(int uid, int procState);
522 
onUidAddedToPendingTempAllowlist(int uid, String tag)523     public abstract void onUidAddedToPendingTempAllowlist(int uid, String tag);
onUidRemovedFromPendingTempAllowlist(int uid)524     public abstract void onUidRemovedFromPendingTempAllowlist(int uid);
525 
526     /** Handle app crash event in {@link android.app.IActivityController} if there is one. */
handleAppCrashInActivityController(String processName, int pid, String shortMsg, String longMsg, long timeMillis, String stackTrace, Runnable killCrashingAppCallback)527     public abstract boolean handleAppCrashInActivityController(String processName, int pid,
528             String shortMsg, String longMsg, long timeMillis, String stackTrace,
529             Runnable killCrashingAppCallback);
530 
removeRecentTasksByPackageName(String packageName, int userId)531     public abstract void removeRecentTasksByPackageName(String packageName, int userId);
cleanupRecentTasksForUser(int userId)532     public abstract void cleanupRecentTasksForUser(int userId);
loadRecentTasksForUser(int userId)533     public abstract void loadRecentTasksForUser(int userId);
onPackagesSuspendedChanged(String[] packages, boolean suspended, int userId)534     public abstract void onPackagesSuspendedChanged(String[] packages, boolean suspended,
535             int userId);
536     /** Flush recent tasks to disk. */
flushRecentTasks()537     public abstract void flushRecentTasks();
538 
getHomeProcess()539     public abstract WindowProcessController getHomeProcess();
getPreviousProcess()540     public abstract WindowProcessController getPreviousProcess();
541 
clearLockedTasks(String reason)542     public abstract void clearLockedTasks(String reason);
updateUserConfiguration()543     public abstract void updateUserConfiguration();
canShowErrorDialogs()544     public abstract boolean canShowErrorDialogs();
545 
setProfileApp(String profileApp)546     public abstract void setProfileApp(String profileApp);
setProfileProc(WindowProcessController wpc)547     public abstract void setProfileProc(WindowProcessController wpc);
setProfilerInfo(ProfilerInfo profilerInfo)548     public abstract void setProfilerInfo(ProfilerInfo profilerInfo);
549 
getLaunchObserverRegistry()550     public abstract ActivityMetricsLaunchObserverRegistry getLaunchObserverRegistry();
551 
552     /**
553      * Gets bitmap snapshot of the provided task id.
554      *
555      * <p>Warning! this may restore the snapshot from disk so can block, don't call in a latency
556      * sensitive environment.
557      */
getTaskSnapshotBlocking(int taskId, boolean isLowResolution)558     public abstract ActivityManager.TaskSnapshot getTaskSnapshotBlocking(int taskId,
559             boolean isLowResolution);
560 
561     /** Returns true if uid is considered foreground for activity start purposes. */
isUidForeground(int uid)562     public abstract boolean isUidForeground(int uid);
563 
564     /**
565      * Called by DevicePolicyManagerService to set the uid of the device owner.
566      */
setDeviceOwnerUid(int uid)567     public abstract void setDeviceOwnerUid(int uid);
568 
569     /** Set all associated companion app that belongs to an userId. */
setCompanionAppPackages(int userId, Set<String> companionAppPackages)570     public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages);
571 
572     /**
573      * @param packageName The package to check
574      * @return Whether the package is the base of any locked task
575      */
isBaseOfLockedTask(String packageName)576     public abstract boolean isBaseOfLockedTask(String packageName);
577 }
578