blob: 7302e529c1ebe8828333884a7a79be9f833f9f8a [file] [log] [blame]
Wale Ogunwale6767eae2018-05-03 15:52:51 -07001/*
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
Wale Ogunwale9e4f3e02018-05-17 09:35:39 -070017package com.android.server.wm;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070018
19import android.annotation.NonNull;
20import android.annotation.Nullable;
Wale Ogunwale31913b52018-10-13 08:29:31 -070021import android.annotation.UserIdInt;
Winson Chung3fb0f252019-01-08 17:41:55 -080022import android.app.ActivityManager;
Wale Ogunwale9e4f3e02018-05-17 09:35:39 -070023import android.app.AppProtoEnums;
24import android.app.IActivityManager;
25import android.app.IApplicationThread;
Wale Ogunwale1f5e53d2018-11-05 05:12:46 -080026import android.app.ProfilerInfo;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070027import android.content.ComponentName;
Wale Ogunwaleee6eca12018-09-19 20:37:53 -070028import android.content.IIntentSender;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070029import android.content.Intent;
Wale Ogunwale53783742018-09-16 10:21:51 -070030import android.content.pm.ApplicationInfo;
31import android.content.res.CompatibilityInfo;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070032import android.os.Bundle;
33import android.os.IBinder;
Wale Ogunwale31913b52018-10-13 08:29:31 -070034import android.os.RemoteException;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070035import android.service.voice.IVoiceInteractionSession;
Wale Ogunwale31913b52018-10-13 08:29:31 -070036import android.util.proto.ProtoOutputStream;
Louis Chang89f43fc2018-10-05 10:59:14 +080037
Wale Ogunwale6767eae2018-05-03 15:52:51 -070038import com.android.internal.app.IVoiceInteractor;
Wale Ogunwaleee6eca12018-09-19 20:37:53 -070039import com.android.server.am.PendingIntentRecord;
Wale Ogunwale31913b52018-10-13 08:29:31 -070040import com.android.server.am.UserState;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070041
Wale Ogunwale31913b52018-10-13 08:29:31 -070042import java.io.FileDescriptor;
43import java.io.PrintWriter;
Wale Ogunwaleee6eca12018-09-19 20:37:53 -070044import java.lang.ref.WeakReference;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070045import java.util.List;
Wale Ogunwale31913b52018-10-13 08:29:31 -070046import java.util.Set;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070047
48/**
49 * Activity Task manager local system service interface.
50 * @hide Only for use within system server
51 */
52public 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 /**
Sunny Goyald40c3452019-03-20 12:46:55 -070090 * 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 /**
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700100 * 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 {
120 void onAwakeStateChanged(boolean isAwake);
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 */
129 public static abstract class SleepToken {
130
131 /** Releases the sleep token. */
132 public abstract void release();
133 }
134
135 /**
136 * Acquires a sleep token for the specified display with the specified tag.
137 *
138 * @param tag A string identifying the purpose of the token (eg. "Dream").
139 * @param displayId The display to apply the sleep token to.
140 */
141 public abstract SleepToken acquireSleepToken(@NonNull String tag, int displayId);
142
143 /**
144 * Returns home activity for the specified user.
145 *
146 * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
147 */
148 public abstract ComponentName getHomeActivityForUser(int userId);
149
150 public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
151 IVoiceInteractionSession mSession,
152 IVoiceInteractor mInteractor);
153
154 /**
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700155 * Callback for window manager to let activity manager know that the app transition was
156 * cancelled.
157 */
158 public abstract void notifyAppTransitionCancelled();
159
160 /**
161 * Callback for window manager to let activity manager know that the app transition is finished.
162 */
163 public abstract void notifyAppTransitionFinished();
164
165 /**
166 * Returns the top activity from each of the currently visible stacks. The first entry will be
167 * the focused activity.
168 */
169 public abstract List<IBinder> getTopVisibleActivities();
170
171 /**
172 * Callback for window manager to let activity manager know that docked stack changes its
173 * minimized state.
174 */
175 public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
176
177 /**
Issei Suzukicac2a502019-04-16 16:52:50 +0200178 * Notify listeners that contents are drawn for the first time on a single task display.
179 *
180 * @param displayId An ID of the display on which contents are drawn.
181 */
182 public abstract void notifySingleTaskDisplayDrawn(int displayId);
183
184 /**
Philip P. Moltmannee295092020-02-10 08:46:26 -0800185 * Start activity {@code intents} as if {@code packageName/featureId} on user {@code userId} did
186 * it.
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700187 *
188 * - DO NOT call it with the calling UID cleared.
189 * - All the necessary caller permission checks must be done at callsites.
190 *
191 * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
192 */
Philip P. Moltmannee295092020-02-10 08:46:26 -0800193 public abstract int startActivitiesAsPackage(String packageName, String featureId,
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700194 int userId, Intent[] intents, Bundle bOptions);
195
196 /**
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700197 * Start intents as a package.
198 *
199 * @param uid Make a call as if this UID did.
Michal Karpinski84d9ebd2019-01-17 18:28:59 +0000200 * @param realCallingPid PID of the real caller.
201 * @param realCallingUid UID of the real caller.
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700202 * @param callingPackage Make a call as if this package did.
Philip P. Moltmannee295092020-02-10 08:46:26 -0800203 * @param callingFeatureId Make a call as if this feature in the package did.
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700204 * @param intents Intents to start.
205 * @param userId Start the intents on this user.
206 * @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID.
207 * @param originatingPendingIntent PendingIntentRecord that originated this activity start or
208 * null if not originated by PendingIntent
Michal Karpinskiac116df2018-12-10 17:51:42 +0000209 * @param allowBackgroundActivityStart Whether the background activity start should be allowed
210 * from originatingPendingIntent
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700211 */
Michal Karpinski84d9ebd2019-01-17 18:28:59 +0000212 public abstract int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid,
Philip P. Moltmannee295092020-02-10 08:46:26 -0800213 String callingPackage, @Nullable String callingFeatureId, Intent[] intents,
214 String[] resolvedTypes, IBinder resultTo, SafeActivityOptions options, int userId,
215 boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
Michal Karpinskiac116df2018-12-10 17:51:42 +0000216 boolean allowBackgroundActivityStart);
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700217
218 public abstract int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
Philip P. Moltmannee295092020-02-10 08:46:26 -0800219 String callingPackage, @Nullable String callingFeaturId, Intent intent,
220 String resolvedType, IBinder resultTo, String resultWho, int requestCode,
221 int startFlags, SafeActivityOptions options, int userId, Task inTask, String reason,
222 boolean validateIncomingUser, PendingIntentRecord originatingPendingIntent,
223 boolean allowBackgroundActivityStart);
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700224
225 /**
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700226 * Start activity {@code intent} without calling user-id check.
227 *
228 * - DO NOT call it with the calling UID cleared.
229 * - The caller must do the calling user ID check.
230 *
231 * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
232 */
233 public abstract int startActivityAsUser(IApplicationThread caller, String callingPackage,
Philip P. Moltmannee295092020-02-10 08:46:26 -0800234 @Nullable String callingFeatureId, Intent intent, @Nullable Bundle options, int userId);
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700235
236 /**
237 * Called when Keyguard flags might have changed.
238 *
239 * @param callback Callback to run after activity visibilities have been reevaluated. This can
240 * be used from window manager so that when the callback is called, it's
241 * guaranteed that all apps have their visibility updated accordingly.
lumark588a3e82018-07-20 18:53:54 +0800242 * @param displayId The id of the display where the keyguard flags changed.
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700243 */
lumark588a3e82018-07-20 18:53:54 +0800244 public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId);
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700245
246 /**
247 * Called when the trusted state of Keyguard has changed.
248 */
249 public abstract void notifyKeyguardTrustedChanged();
250
251 /**
252 * Called after virtual display Id is updated by
253 * {@link com.android.server.vr.Vr2dDisplay} with a specific
254 * {@param vr2dDisplayId}.
255 */
256 public abstract void setVr2dDisplayId(int vr2dDisplayId);
257
258 /**
259 * Set focus on an activity.
260 * @param token The IApplicationToken for the activity
261 */
262 public abstract void setFocusedActivity(IBinder token);
263
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700264 public abstract void registerScreenObserver(ScreenObserver observer);
265
266 /**
267 * Returns is the caller has the same uid as the Recents component
268 */
269 public abstract boolean isCallerRecents(int callingUid);
270
271 /**
272 * Returns whether the recents component is the home activity for the given user.
273 */
274 public abstract boolean isRecentsComponentHomeActivity(int userId);
275
276 /**
277 * Cancels any currently running recents animation.
278 */
279 public abstract void cancelRecentsAnimation(boolean restoreHomeStackPosition);
280
281 /**
282 * This enforces {@code func} can only be called if either the caller is Recents activity or
283 * has {@code permission}.
284 */
285 public abstract void enforceCallerIsRecentsOrHasPermission(String permission, String func);
286
Wale Ogunwaled0412b32018-05-08 09:25:50 -0700287 /**
288 * Called after the voice interaction service has changed.
289 */
290 public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component);
291
Wale Ogunwalea6191b42018-05-09 07:41:32 -0700292 /**
293 * Set a uid that is allowed to bypass stopped app switches, launching an app
294 * whenever it wants.
295 *
296 * @param type Type of the caller -- unique string the caller supplies to identify itself
297 * and disambiguate with other calles.
298 * @param uid The uid of the app to be allowed, or -1 to clear the uid for this type.
299 * @param userId The user it is allowed for.
300 */
301 public abstract void setAllowAppSwitches(@NonNull String type, int uid, int userId);
302
303 /**
304 * Called when a user has been deleted. This can happen during normal device usage
305 * or just at startup, when partially removed users are purged. Any state persisted by the
306 * ActivityManager should be purged now.
307 *
308 * @param userId The user being cleaned up.
309 */
310 public abstract void onUserStopped(int userId);
311 public abstract boolean isGetTasksAllowed(String caller, int callingPid, int callingUid);
Wale Ogunwale9e4f3e02018-05-17 09:35:39 -0700312
313 public abstract void onProcessAdded(WindowProcessController proc);
314 public abstract void onProcessRemoved(String name, int uid);
315 public abstract void onCleanUpApplicationRecord(WindowProcessController proc);
Wale Ogunwalef6733932018-06-27 05:14:34 -0700316 public abstract int getTopProcessState();
Wale Ogunwale53783742018-09-16 10:21:51 -0700317 public abstract boolean isHeavyWeightProcess(WindowProcessController proc);
318 public abstract void clearHeavyWeightProcessIfEquals(WindowProcessController proc);
319 public abstract void finishHeavyWeightApp();
Wale Ogunwalef6733932018-06-27 05:14:34 -0700320
321 public abstract boolean isSleeping();
322 public abstract boolean isShuttingDown();
323 public abstract boolean shuttingDown(boolean booted, int timeout);
324 public abstract void enableScreenAfterBoot(boolean booted);
325 public abstract boolean showStrictModeViolationDialog();
326 public abstract void showSystemReadyErrorDialogsIfNeeded();
Wale Ogunwale906f9c62018-07-23 11:23:44 -0700327
Wale Ogunwale906f9c62018-07-23 11:23:44 -0700328 public abstract void onProcessMapped(int pid, WindowProcessController proc);
329 public abstract void onProcessUnMapped(int pid);
Wale Ogunwale008163e2018-07-23 23:11:08 -0700330
331 public abstract void onPackageDataCleared(String name);
332 public abstract void onPackageUninstalled(String name);
Wale Ogunwale53783742018-09-16 10:21:51 -0700333 public abstract void onPackageAdded(String name, boolean replacing);
Wale Ogunwale31913b52018-10-13 08:29:31 -0700334 public abstract void onPackageReplaced(ApplicationInfo aInfo);
Wale Ogunwale53783742018-09-16 10:21:51 -0700335
336 public abstract CompatibilityInfo compatibilityInfoForPackage(ApplicationInfo ai);
Yunfan Chen75157d72018-07-27 14:47:21 +0900337
Sunny Goyald40c3452019-03-20 12:46:55 -0700338 public final class ActivityTokens {
339 private final @NonNull IBinder mActivityToken;
340 private final @NonNull IBinder mAssistToken;
341 private final @NonNull IApplicationThread mAppThread;
342
343 public ActivityTokens(@NonNull IBinder activityToken,
344 @NonNull IBinder assistToken, @NonNull IApplicationThread appThread) {
345 mActivityToken = activityToken;
346 mAssistToken = assistToken;
347 mAppThread = appThread;
348 }
349
350 /**
351 * @return The activity token.
352 */
353 public @NonNull IBinder getActivityToken() {
354 return mActivityToken;
355 }
356
357 /**
358 * @return The assist token.
359 */
360 public @NonNull IBinder getAssistToken() {
361 return mAssistToken;
362 }
363
364 /**
365 * @return The assist token.
366 */
367 public @NonNull IApplicationThread getApplicationThread() {
368 return mAppThread;
369 }
370 }
371
Yunfan Chen75157d72018-07-27 14:47:21 +0900372 /**
373 * Set the corresponding display information for the process global configuration. To be called
374 * when we need to show IME on a different display.
375 *
376 * @param pid The process id associated with the IME window.
377 * @param displayId The ID of the display showing the IME.
378 */
379 public abstract void onImeWindowSetOnDisplay(int pid, int displayId);
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700380
381 public abstract void sendActivityResult(int callingUid, IBinder activityToken,
382 String resultWho, int requestCode, int resultCode, Intent data);
383 public abstract void clearPendingResultForActivity(
384 IBinder activityToken, WeakReference<PendingIntentRecord> pir);
Sunny Goyald40c3452019-03-20 12:46:55 -0700385
386 /**
387 * @return the activity token and IApplicationThread for the top activity in the task or null
388 * if there isn't a top activity with a valid process.
389 */
390 @Nullable
391 public abstract ActivityTokens getTopActivityForTask(int taskId);
392
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700393 public abstract IIntentSender getIntentSender(int type, String packageName,
Philip P. Moltmannee295092020-02-10 08:46:26 -0800394 @Nullable String featureId, int callingUid, int userId, IBinder token, String resultWho,
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700395 int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
396 Bundle bOptions);
Wale Ogunwalec4e63a42018-10-02 13:19:54 -0700397
398 /** @return the service connection holder for a given activity token. */
399 public abstract ActivityServiceConnectionsHolder getServiceConnectionsHolder(IBinder token);
Wale Ogunwale214f3482018-10-04 11:00:47 -0700400
401 /** @return The intent used to launch the home activity. */
402 public abstract Intent getHomeIntent();
403 public abstract boolean startHomeActivity(int userId, String reason);
Chilun8b1f1be2019-03-13 17:14:36 +0800404 /**
405 * This starts home activity on displays that can have system decorations based on displayId -
406 * Default display always use primary home component.
407 * For Secondary displays, the home activity must have category SECONDARY_HOME and then resolves
408 * according to the priorities listed below.
409 * - If default home is not set, always use the secondary home defined in the config.
410 * - Use currently selected primary home activity.
411 * - Use the activity in the same package as currently selected primary home activity.
412 * If there are multiple activities matched, use first one.
413 * - Use the secondary home defined in the config.
414 */
415 public abstract boolean startHomeOnDisplay(int userId, String reason, int displayId,
Chilun39232092019-03-22 14:41:30 +0800416 boolean allowInstrumenting, boolean fromHomeKey);
Louis Chang89f43fc2018-10-05 10:59:14 +0800417 /** Start home activities on all displays that support system decorations. */
418 public abstract boolean startHomeOnAllDisplays(int userId, String reason);
Wale Ogunwale214f3482018-10-04 11:00:47 -0700419 /** @return true if the given process is the factory test process. */
420 public abstract boolean isFactoryTestProcess(WindowProcessController wpc);
421 public abstract void updateTopComponentForFactoryTest();
Wale Ogunwale31913b52018-10-13 08:29:31 -0700422 public abstract void handleAppDied(WindowProcessController wpc, boolean restarting,
423 Runnable finishInstrumentationCallback);
424 public abstract void closeSystemDialogs(String reason);
425
426 /** Removes all components (e.g. activities, recents, ...) belonging to a disabled package. */
427 public abstract void cleanupDisabledPackageComponents(
428 String packageName, Set<String> disabledClasses, int userId, boolean booted);
429
430 /** Called whenever AM force stops a package. */
431 public abstract boolean onForceStopPackage(String packageName, boolean doit,
432 boolean evenPersistent, int userId);
433 /**
434 * Resumes all top activities in the system if they aren't resumed already.
435 * @param scheduleIdle If the idle message should be schedule after the top activities are
436 * resumed.
437 */
438 public abstract void resumeTopActivities(boolean scheduleIdle);
439
440 /** Called by AM just before it binds to an application process. */
441 public abstract void preBindApplication(WindowProcessController wpc);
442
443 /** Called by AM when an application process attaches. */
444 public abstract boolean attachApplication(WindowProcessController wpc) throws RemoteException;
445
446 /** @see IActivityManager#notifyLockedProfile(int) */
447 public abstract void notifyLockedProfile(@UserIdInt int userId, int currentUserId);
448
449 /** @see IActivityManager#startConfirmDeviceCredentialIntent(Intent, Bundle) */
450 public abstract void startConfirmDeviceCredentialIntent(Intent intent, Bundle options);
451
452 /** Writes current activity states to the proto stream. */
453 public abstract void writeActivitiesToProto(ProtoOutputStream proto);
454
455 /**
456 * Saves the current activity manager state and includes the saved state in the next dump of
457 * activity manager.
458 */
459 public abstract void saveANRState(String reason);
460
461 /** Clears the previously saved activity manager ANR state. */
462 public abstract void clearSavedANRState();
463
464 /** Dump the current state based on the command. */
465 public abstract void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args,
466 int opti, boolean dumpAll, boolean dumpClient, String dumpPackage);
467
468 /** Dump the current state for inclusion in process dump. */
469 public abstract boolean dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
470 String dumpPackage, int dumpAppId, boolean needSep, boolean testPssMode,
471 int wakefulness);
472
473 /** Writes the current window process states to the proto stream. */
sanryhuang498e77e2018-12-06 14:57:01 +0800474 public abstract void writeProcessesToProto(ProtoOutputStream proto, String dumpPackage,
475 int wakeFullness, boolean testPssMode);
Wale Ogunwale31913b52018-10-13 08:29:31 -0700476
477 /** Dump the current activities state. */
478 public abstract boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name,
479 String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly,
480 boolean dumpFocusedStackOnly);
481
Wale Ogunwaled4d67d02018-10-25 18:09:39 -0700482 /** Dump the current state for inclusion in oom dump. */
483 public abstract void dumpForOom(PrintWriter pw);
484
Wale Ogunwale31913b52018-10-13 08:29:31 -0700485 /** @return true if it the activity management system is okay with GC running now. */
486 public abstract boolean canGcNow();
487
488 /** @return the process for the top-most resumed activity in the system. */
489 public abstract WindowProcessController getTopApp();
490
491 /** Generate oom-score-adjustment rank for all tasks in the system based on z-order. */
492 public abstract void rankTaskLayersIfNeeded();
493
494 /** Destroy all activities. */
495 public abstract void scheduleDestroyAllActivities(String reason);
496
497 /** Remove user association with activities. */
498 public abstract void removeUser(int userId);
499
500 /** Switch current focused user for activities. */
501 public abstract boolean switchUser(int userId, UserState userState);
502
503 /** Called whenever an app crashes. */
504 public abstract void onHandleAppCrash(WindowProcessController wpc);
Wale Ogunwale64258362018-10-16 15:13:37 -0700505
506 /**
507 * Finish the topmost activities in all stacks that belong to the crashed app.
508 * @param crashedApp The app that crashed.
509 * @param reason Reason to perform this action.
510 * @return The task id that was finished in this stack, or INVALID_TASK_ID if none was finished.
511 */
512 public abstract int finishTopCrashedActivities(
513 WindowProcessController crashedApp, String reason);
Wale Ogunwalebff2df42018-10-18 17:09:19 -0700514
515 public abstract void onUidActive(int uid, int procState);
516 public abstract void onUidInactive(int uid);
517 public abstract void onActiveUidsCleared();
518 public abstract void onUidProcStateChanged(int uid, int procState);
Wale Ogunwale9de19442018-10-18 19:05:03 -0700519
520 public abstract void onUidAddedToPendingTempWhitelist(int uid, String tag);
521 public abstract void onUidRemovedFromPendingTempWhitelist(int uid);
Wale Ogunwalee2172292018-10-25 10:11:10 -0700522
523 /** Handle app crash event in {@link android.app.IActivityController} if there is one. */
524 public abstract boolean handleAppCrashInActivityController(String processName, int pid,
525 String shortMsg, String longMsg, long timeMillis, String stackTrace,
526 Runnable killCrashingAppCallback);
Wale Ogunwaled7889f52018-10-25 11:03:20 -0700527
528 public abstract void removeRecentTasksByPackageName(String packageName, int userId);
529 public abstract void cleanupRecentTasksForUser(int userId);
530 public abstract void loadRecentTasksForUser(int userId);
531 public abstract void onPackagesSuspendedChanged(String[] packages, boolean suspended,
532 int userId);
533 /** Flush recent tasks to disk. */
534 public abstract void flushRecentTasks();
Wale Ogunwaled4d67d02018-10-25 18:09:39 -0700535
536 public abstract WindowProcessController getHomeProcess();
537 public abstract WindowProcessController getPreviousProcess();
Wale Ogunwale27c48ae2018-10-25 19:01:01 -0700538
539 public abstract void clearLockedTasks(String reason);
540 public abstract void updateUserConfiguration();
Wale Ogunwale387b34c2018-10-25 19:59:40 -0700541 public abstract boolean canShowErrorDialogs();
Wale Ogunwale1f5e53d2018-11-05 05:12:46 -0800542
543 public abstract void setProfileApp(String profileApp);
544 public abstract void setProfileProc(WindowProcessController wpc);
545 public abstract void setProfilerInfo(ProfilerInfo profilerInfo);
Igor Murashkinc0b47e42018-11-07 15:54:18 -0800546
547 public abstract ActivityMetricsLaunchObserverRegistry getLaunchObserverRegistry();
Winson Chung3fb0f252019-01-08 17:41:55 -0800548
549 /**
550 * Gets bitmap snapshot of the provided task id.
551 */
Jorim Jaggi925bb3c2019-06-04 19:51:45 +0200552 public abstract ActivityManager.TaskSnapshot getTaskSnapshotNoRestore(int taskId,
Winson Chung3fb0f252019-01-08 17:41:55 -0800553 boolean reducedResolution);
Michal Karpinskicc88d7e2019-01-24 15:32:12 +0000554
Alan Stokeseea8d3e2019-04-10 17:37:25 +0100555 /** Returns true if uid is considered foreground for activity start purposes. */
Michal Karpinskicc88d7e2019-01-24 15:32:12 +0000556 public abstract boolean isUidForeground(int uid);
Michal Karpinski4026cae2019-02-12 11:51:47 +0000557
558 /**
Ricky Wai96f5c352019-04-10 18:40:17 +0100559 * Called by DevicePolicyManagerService to set the uid of the device owner.
Michal Karpinski4026cae2019-02-12 11:51:47 +0000560 */
Ricky Wai96f5c352019-04-10 18:40:17 +0100561 public abstract void setDeviceOwnerUid(int uid);
Ricky Wai2452e2d2019-03-18 19:19:08 +0000562
563 /** Set all associated companion app that belongs to an userId. */
564 public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages);
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700565}