blob: 5459edeb3d8be7b8d1549bb781fc52f423863bfc [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.os.SystemClock;
36import android.service.voice.IVoiceInteractionSession;
Sunny Goyald40c3452019-03-20 12:46:55 -070037import android.util.Pair;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070038import android.util.SparseIntArray;
Wale Ogunwale31913b52018-10-13 08:29:31 -070039import android.util.proto.ProtoOutputStream;
Louis Chang89f43fc2018-10-05 10:59:14 +080040
Wale Ogunwale6767eae2018-05-03 15:52:51 -070041import com.android.internal.app.IVoiceInteractor;
Wale Ogunwaleee6eca12018-09-19 20:37:53 -070042import com.android.server.am.PendingIntentRecord;
Wale Ogunwale31913b52018-10-13 08:29:31 -070043import com.android.server.am.UserState;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070044
Wale Ogunwale31913b52018-10-13 08:29:31 -070045import java.io.FileDescriptor;
46import java.io.PrintWriter;
Wale Ogunwaleee6eca12018-09-19 20:37:53 -070047import java.lang.ref.WeakReference;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070048import java.util.List;
Wale Ogunwale31913b52018-10-13 08:29:31 -070049import java.util.Set;
Wale Ogunwale6767eae2018-05-03 15:52:51 -070050
51/**
52 * Activity Task manager local system service interface.
53 * @hide Only for use within system server
54 */
55public abstract class ActivityTaskManagerInternal {
56
57 /**
58 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we drew
59 * the splash screen.
60 */
61 public static final int APP_TRANSITION_SPLASH_SCREEN =
62 AppProtoEnums.APP_TRANSITION_SPLASH_SCREEN; // 1
63
64 /**
65 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we all
66 * app windows were drawn
67 */
68 public static final int APP_TRANSITION_WINDOWS_DRAWN =
69 AppProtoEnums.APP_TRANSITION_WINDOWS_DRAWN; // 2
70
71 /**
72 * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
73 * timeout.
74 */
75 public static final int APP_TRANSITION_TIMEOUT =
76 AppProtoEnums.APP_TRANSITION_TIMEOUT; // 3
77
78 /**
79 * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
80 * we drew a task snapshot.
81 */
82 public static final int APP_TRANSITION_SNAPSHOT =
83 AppProtoEnums.APP_TRANSITION_SNAPSHOT; // 4
84
85 /**
86 * Type for {@link #notifyAppTransitionStarting}: The transition was started because it was a
87 * recents animation and we only needed to wait on the wallpaper.
88 */
89 public static final int APP_TRANSITION_RECENTS_ANIM =
90 AppProtoEnums.APP_TRANSITION_RECENTS_ANIM; // 5
91
92 /**
Sunny Goyald40c3452019-03-20 12:46:55 -070093 * The id of the task source of assist state.
94 */
95 public static final String ASSIST_TASK_ID = "taskId";
96
97 /**
98 * The id of the activity source of assist state.
99 */
100 public static final String ASSIST_ACTIVITY_ID = "activityId";
101
102 /**
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700103 * The bundle key to extract the assist data.
104 */
105 public static final String ASSIST_KEY_DATA = "data";
106
107 /**
108 * The bundle key to extract the assist structure.
109 */
110 public static final String ASSIST_KEY_STRUCTURE = "structure";
111
112 /**
113 * The bundle key to extract the assist content.
114 */
115 public static final String ASSIST_KEY_CONTENT = "content";
116
117 /**
118 * The bundle key to extract the assist receiver extras.
119 */
120 public static final String ASSIST_KEY_RECEIVER_EXTRAS = "receiverExtras";
121
122 public interface ScreenObserver {
123 void onAwakeStateChanged(boolean isAwake);
124 void onKeyguardStateChanged(boolean isShowing);
125 }
126
127 /**
128 * Sleep tokens cause the activity manager to put the top activity to sleep.
129 * They are used by components such as dreams that may hide and block interaction
130 * with underlying activities.
131 */
132 public static abstract class SleepToken {
133
134 /** Releases the sleep token. */
135 public abstract void release();
136 }
137
138 /**
139 * Acquires a sleep token for the specified display with the specified tag.
140 *
141 * @param tag A string identifying the purpose of the token (eg. "Dream").
142 * @param displayId The display to apply the sleep token to.
143 */
144 public abstract SleepToken acquireSleepToken(@NonNull String tag, int displayId);
145
146 /**
147 * Returns home activity for the specified user.
148 *
149 * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
150 */
151 public abstract ComponentName getHomeActivityForUser(int userId);
152
153 public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
154 IVoiceInteractionSession mSession,
155 IVoiceInteractor mInteractor);
156
157 /**
158 * Callback for window manager to let activity manager know that we are finally starting the
159 * app transition;
160 *
161 * @param reasons A map from windowing mode to a reason integer why the transition was started,
162 * which must be one of the APP_TRANSITION_* values.
163 * @param timestamp The time at which the app transition started in
164 * {@link SystemClock#uptimeMillis()} timebase.
165 */
166 public abstract void notifyAppTransitionStarting(SparseIntArray reasons, long timestamp);
167
168 /**
169 * Callback for window manager to let activity manager know that the app transition was
170 * cancelled.
171 */
172 public abstract void notifyAppTransitionCancelled();
173
174 /**
175 * Callback for window manager to let activity manager know that the app transition is finished.
176 */
177 public abstract void notifyAppTransitionFinished();
178
179 /**
180 * Returns the top activity from each of the currently visible stacks. The first entry will be
181 * the focused activity.
182 */
183 public abstract List<IBinder> getTopVisibleActivities();
184
185 /**
186 * Callback for window manager to let activity manager know that docked stack changes its
187 * minimized state.
188 */
189 public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
190
191 /**
192 * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
193 *
194 * - DO NOT call it with the calling UID cleared.
195 * - All the necessary caller permission checks must be done at callsites.
196 *
197 * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
198 */
199 public abstract int startActivitiesAsPackage(String packageName,
200 int userId, Intent[] intents, Bundle bOptions);
201
202 /**
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700203 * Start intents as a package.
204 *
205 * @param uid Make a call as if this UID did.
Michal Karpinski84d9ebd2019-01-17 18:28:59 +0000206 * @param realCallingPid PID of the real caller.
207 * @param realCallingUid UID of the real caller.
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700208 * @param callingPackage Make a call as if this package did.
209 * @param intents Intents to start.
210 * @param userId Start the intents on this user.
211 * @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID.
212 * @param originatingPendingIntent PendingIntentRecord that originated this activity start or
213 * null if not originated by PendingIntent
Michal Karpinskiac116df2018-12-10 17:51:42 +0000214 * @param allowBackgroundActivityStart Whether the background activity start should be allowed
215 * from originatingPendingIntent
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700216 */
Michal Karpinski84d9ebd2019-01-17 18:28:59 +0000217 public abstract int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid,
218 String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo,
219 SafeActivityOptions options, int userId, boolean validateIncomingUser,
220 PendingIntentRecord originatingPendingIntent,
Michal Karpinskiac116df2018-12-10 17:51:42 +0000221 boolean allowBackgroundActivityStart);
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700222
223 public abstract int startActivityInPackage(int uid, int realCallingPid, int realCallingUid,
224 String callingPackage, Intent intent, String resolvedType, IBinder resultTo,
225 String resultWho, int requestCode, int startFlags, SafeActivityOptions options,
226 int userId, TaskRecord inTask, String reason, boolean validateIncomingUser,
Michal Karpinskiac116df2018-12-10 17:51:42 +0000227 PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart);
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700228
229 /**
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700230 * Start activity {@code intent} without calling user-id check.
231 *
232 * - DO NOT call it with the calling UID cleared.
233 * - The caller must do the calling user ID check.
234 *
235 * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
236 */
237 public abstract int startActivityAsUser(IApplicationThread caller, String callingPackage,
238 Intent intent, @Nullable Bundle options, int userId);
239
240 /**
241 * Called when Keyguard flags might have changed.
242 *
243 * @param callback Callback to run after activity visibilities have been reevaluated. This can
244 * be used from window manager so that when the callback is called, it's
245 * guaranteed that all apps have their visibility updated accordingly.
lumark588a3e82018-07-20 18:53:54 +0800246 * @param displayId The id of the display where the keyguard flags changed.
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700247 */
lumark588a3e82018-07-20 18:53:54 +0800248 public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId);
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700249
250 /**
251 * Called when the trusted state of Keyguard has changed.
252 */
253 public abstract void notifyKeyguardTrustedChanged();
254
255 /**
256 * Called after virtual display Id is updated by
257 * {@link com.android.server.vr.Vr2dDisplay} with a specific
258 * {@param vr2dDisplayId}.
259 */
260 public abstract void setVr2dDisplayId(int vr2dDisplayId);
261
262 /**
263 * Set focus on an activity.
264 * @param token The IApplicationToken for the activity
265 */
266 public abstract void setFocusedActivity(IBinder token);
267
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700268 public abstract void registerScreenObserver(ScreenObserver observer);
269
270 /**
271 * Returns is the caller has the same uid as the Recents component
272 */
273 public abstract boolean isCallerRecents(int callingUid);
274
275 /**
276 * Returns whether the recents component is the home activity for the given user.
277 */
278 public abstract boolean isRecentsComponentHomeActivity(int userId);
279
280 /**
281 * Cancels any currently running recents animation.
282 */
283 public abstract void cancelRecentsAnimation(boolean restoreHomeStackPosition);
284
285 /**
286 * This enforces {@code func} can only be called if either the caller is Recents activity or
287 * has {@code permission}.
288 */
289 public abstract void enforceCallerIsRecentsOrHasPermission(String permission, String func);
290
Wale Ogunwaled0412b32018-05-08 09:25:50 -0700291 /**
292 * Called after the voice interaction service has changed.
293 */
294 public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component);
295
Wale Ogunwalea6191b42018-05-09 07:41:32 -0700296 /**
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 */
305 public abstract void setAllowAppSwitches(@NonNull String type, int uid, int userId);
306
307 /**
308 * Called when a user has been deleted. This can happen during normal device usage
309 * or just at startup, when partially removed users are purged. Any state persisted by the
310 * ActivityManager should be purged now.
311 *
312 * @param userId The user being cleaned up.
313 */
314 public abstract void onUserStopped(int userId);
315 public abstract boolean isGetTasksAllowed(String caller, int callingPid, int callingUid);
Wale Ogunwale9e4f3e02018-05-17 09:35:39 -0700316
317 public abstract void onProcessAdded(WindowProcessController proc);
318 public abstract void onProcessRemoved(String name, int uid);
319 public abstract void onCleanUpApplicationRecord(WindowProcessController proc);
Wale Ogunwalef6733932018-06-27 05:14:34 -0700320 public abstract int getTopProcessState();
Wale Ogunwale53783742018-09-16 10:21:51 -0700321 public abstract boolean isHeavyWeightProcess(WindowProcessController proc);
322 public abstract void clearHeavyWeightProcessIfEquals(WindowProcessController proc);
323 public abstract void finishHeavyWeightApp();
Wale Ogunwalef6733932018-06-27 05:14:34 -0700324
325 public abstract boolean isSleeping();
326 public abstract boolean isShuttingDown();
327 public abstract boolean shuttingDown(boolean booted, int timeout);
328 public abstract void enableScreenAfterBoot(boolean booted);
329 public abstract boolean showStrictModeViolationDialog();
330 public abstract void showSystemReadyErrorDialogsIfNeeded();
Wale Ogunwale906f9c62018-07-23 11:23:44 -0700331
Wale Ogunwale906f9c62018-07-23 11:23:44 -0700332 public abstract void onProcessMapped(int pid, WindowProcessController proc);
333 public abstract void onProcessUnMapped(int pid);
Wale Ogunwale008163e2018-07-23 23:11:08 -0700334
335 public abstract void onPackageDataCleared(String name);
336 public abstract void onPackageUninstalled(String name);
Wale Ogunwale53783742018-09-16 10:21:51 -0700337 public abstract void onPackageAdded(String name, boolean replacing);
Wale Ogunwale31913b52018-10-13 08:29:31 -0700338 public abstract void onPackageReplaced(ApplicationInfo aInfo);
Wale Ogunwale53783742018-09-16 10:21:51 -0700339
340 public abstract CompatibilityInfo compatibilityInfoForPackage(ApplicationInfo ai);
Yunfan Chen75157d72018-07-27 14:47:21 +0900341
Sunny Goyald40c3452019-03-20 12:46:55 -0700342 public final class ActivityTokens {
343 private final @NonNull IBinder mActivityToken;
344 private final @NonNull IBinder mAssistToken;
345 private final @NonNull IApplicationThread mAppThread;
346
347 public ActivityTokens(@NonNull IBinder activityToken,
348 @NonNull IBinder assistToken, @NonNull IApplicationThread appThread) {
349 mActivityToken = activityToken;
350 mAssistToken = assistToken;
351 mAppThread = appThread;
352 }
353
354 /**
355 * @return The activity token.
356 */
357 public @NonNull IBinder getActivityToken() {
358 return mActivityToken;
359 }
360
361 /**
362 * @return The assist token.
363 */
364 public @NonNull IBinder getAssistToken() {
365 return mAssistToken;
366 }
367
368 /**
369 * @return The assist token.
370 */
371 public @NonNull IApplicationThread getApplicationThread() {
372 return mAppThread;
373 }
374 }
375
Yunfan Chen75157d72018-07-27 14:47:21 +0900376 /**
377 * Set the corresponding display information for the process global configuration. To be called
378 * when we need to show IME on a different display.
379 *
380 * @param pid The process id associated with the IME window.
381 * @param displayId The ID of the display showing the IME.
382 */
383 public abstract void onImeWindowSetOnDisplay(int pid, int displayId);
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700384
385 public abstract void sendActivityResult(int callingUid, IBinder activityToken,
386 String resultWho, int requestCode, int resultCode, Intent data);
387 public abstract void clearPendingResultForActivity(
388 IBinder activityToken, WeakReference<PendingIntentRecord> pir);
Sunny Goyald40c3452019-03-20 12:46:55 -0700389
390 /**
391 * @return the activity token and IApplicationThread for the top activity in the task or null
392 * if there isn't a top activity with a valid process.
393 */
394 @Nullable
395 public abstract ActivityTokens getTopActivityForTask(int taskId);
396
Wale Ogunwaleee6eca12018-09-19 20:37:53 -0700397 public abstract IIntentSender getIntentSender(int type, String packageName,
398 int callingUid, int userId, IBinder token, String resultWho,
399 int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
400 Bundle bOptions);
Wale Ogunwalec4e63a42018-10-02 13:19:54 -0700401
402 /** @return the service connection holder for a given activity token. */
403 public abstract ActivityServiceConnectionsHolder getServiceConnectionsHolder(IBinder token);
Wale Ogunwale214f3482018-10-04 11:00:47 -0700404
405 /** @return The intent used to launch the home activity. */
406 public abstract Intent getHomeIntent();
407 public abstract boolean startHomeActivity(int userId, String reason);
Chilun8b1f1be2019-03-13 17:14:36 +0800408 /**
409 * This starts home activity on displays that can have system decorations based on displayId -
410 * Default display always use primary home component.
411 * For Secondary displays, the home activity must have category SECONDARY_HOME and then resolves
412 * according to the priorities listed below.
413 * - If default home is not set, always use the secondary home defined in the config.
414 * - Use currently selected primary home activity.
415 * - Use the activity in the same package as currently selected primary home activity.
416 * If there are multiple activities matched, use first one.
417 * - Use the secondary home defined in the config.
418 */
419 public abstract boolean startHomeOnDisplay(int userId, String reason, int displayId,
Chilun39232092019-03-22 14:41:30 +0800420 boolean allowInstrumenting, boolean fromHomeKey);
Louis Chang89f43fc2018-10-05 10:59:14 +0800421 /** Start home activities on all displays that support system decorations. */
422 public abstract boolean startHomeOnAllDisplays(int userId, String reason);
Wale Ogunwale214f3482018-10-04 11:00:47 -0700423 /** @return true if the given process is the factory test process. */
424 public abstract boolean isFactoryTestProcess(WindowProcessController wpc);
425 public abstract void updateTopComponentForFactoryTest();
Wale Ogunwale31913b52018-10-13 08:29:31 -0700426 public abstract void handleAppDied(WindowProcessController wpc, boolean restarting,
427 Runnable finishInstrumentationCallback);
428 public abstract void closeSystemDialogs(String reason);
429
430 /** Removes all components (e.g. activities, recents, ...) belonging to a disabled package. */
431 public abstract void cleanupDisabledPackageComponents(
432 String packageName, Set<String> disabledClasses, int userId, boolean booted);
433
434 /** Called whenever AM force stops a package. */
435 public abstract boolean onForceStopPackage(String packageName, boolean doit,
436 boolean evenPersistent, int userId);
437 /**
438 * Resumes all top activities in the system if they aren't resumed already.
439 * @param scheduleIdle If the idle message should be schedule after the top activities are
440 * resumed.
441 */
442 public abstract void resumeTopActivities(boolean scheduleIdle);
443
444 /** Called by AM just before it binds to an application process. */
445 public abstract void preBindApplication(WindowProcessController wpc);
446
447 /** Called by AM when an application process attaches. */
448 public abstract boolean attachApplication(WindowProcessController wpc) throws RemoteException;
449
450 /** @see IActivityManager#notifyLockedProfile(int) */
451 public abstract void notifyLockedProfile(@UserIdInt int userId, int currentUserId);
452
453 /** @see IActivityManager#startConfirmDeviceCredentialIntent(Intent, Bundle) */
454 public abstract void startConfirmDeviceCredentialIntent(Intent intent, Bundle options);
455
456 /** Writes current activity states to the proto stream. */
457 public abstract void writeActivitiesToProto(ProtoOutputStream proto);
458
459 /**
460 * Saves the current activity manager state and includes the saved state in the next dump of
461 * activity manager.
462 */
463 public abstract void saveANRState(String reason);
464
465 /** Clears the previously saved activity manager ANR state. */
466 public abstract void clearSavedANRState();
467
468 /** Dump the current state based on the command. */
469 public abstract void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args,
470 int opti, boolean dumpAll, boolean dumpClient, String dumpPackage);
471
472 /** Dump the current state for inclusion in process dump. */
473 public abstract boolean dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
474 String dumpPackage, int dumpAppId, boolean needSep, boolean testPssMode,
475 int wakefulness);
476
477 /** Writes the current window process states to the proto stream. */
sanryhuang498e77e2018-12-06 14:57:01 +0800478 public abstract void writeProcessesToProto(ProtoOutputStream proto, String dumpPackage,
479 int wakeFullness, boolean testPssMode);
Wale Ogunwale31913b52018-10-13 08:29:31 -0700480
481 /** Dump the current activities state. */
482 public abstract boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name,
483 String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly,
484 boolean dumpFocusedStackOnly);
485
Wale Ogunwaled4d67d02018-10-25 18:09:39 -0700486 /** Dump the current state for inclusion in oom dump. */
487 public abstract void dumpForOom(PrintWriter pw);
488
Wale Ogunwale31913b52018-10-13 08:29:31 -0700489 /** @return true if it the activity management system is okay with GC running now. */
490 public abstract boolean canGcNow();
491
492 /** @return the process for the top-most resumed activity in the system. */
493 public abstract WindowProcessController getTopApp();
494
495 /** Generate oom-score-adjustment rank for all tasks in the system based on z-order. */
496 public abstract void rankTaskLayersIfNeeded();
497
498 /** Destroy all activities. */
499 public abstract void scheduleDestroyAllActivities(String reason);
500
501 /** Remove user association with activities. */
502 public abstract void removeUser(int userId);
503
504 /** Switch current focused user for activities. */
505 public abstract boolean switchUser(int userId, UserState userState);
506
507 /** Called whenever an app crashes. */
508 public abstract void onHandleAppCrash(WindowProcessController wpc);
Wale Ogunwale64258362018-10-16 15:13:37 -0700509
510 /**
511 * Finish the topmost activities in all stacks that belong to the crashed app.
512 * @param crashedApp The app that crashed.
513 * @param reason Reason to perform this action.
514 * @return The task id that was finished in this stack, or INVALID_TASK_ID if none was finished.
515 */
516 public abstract int finishTopCrashedActivities(
517 WindowProcessController crashedApp, String reason);
Wale Ogunwalebff2df42018-10-18 17:09:19 -0700518
519 public abstract void onUidActive(int uid, int procState);
520 public abstract void onUidInactive(int uid);
521 public abstract void onActiveUidsCleared();
522 public abstract void onUidProcStateChanged(int uid, int procState);
Wale Ogunwale9de19442018-10-18 19:05:03 -0700523
524 public abstract void onUidAddedToPendingTempWhitelist(int uid, String tag);
525 public abstract void onUidRemovedFromPendingTempWhitelist(int uid);
Wale Ogunwalee2172292018-10-25 10:11:10 -0700526
527 /** Handle app crash event in {@link android.app.IActivityController} if there is one. */
528 public abstract boolean handleAppCrashInActivityController(String processName, int pid,
529 String shortMsg, String longMsg, long timeMillis, String stackTrace,
530 Runnable killCrashingAppCallback);
Wale Ogunwaled7889f52018-10-25 11:03:20 -0700531
532 public abstract void removeRecentTasksByPackageName(String packageName, int userId);
533 public abstract void cleanupRecentTasksForUser(int userId);
534 public abstract void loadRecentTasksForUser(int userId);
535 public abstract void onPackagesSuspendedChanged(String[] packages, boolean suspended,
536 int userId);
537 /** Flush recent tasks to disk. */
538 public abstract void flushRecentTasks();
Wale Ogunwaled4d67d02018-10-25 18:09:39 -0700539
540 public abstract WindowProcessController getHomeProcess();
541 public abstract WindowProcessController getPreviousProcess();
Wale Ogunwale27c48ae2018-10-25 19:01:01 -0700542
543 public abstract void clearLockedTasks(String reason);
544 public abstract void updateUserConfiguration();
Wale Ogunwale387b34c2018-10-25 19:59:40 -0700545 public abstract boolean canShowErrorDialogs();
Wale Ogunwale1f5e53d2018-11-05 05:12:46 -0800546
547 public abstract void setProfileApp(String profileApp);
548 public abstract void setProfileProc(WindowProcessController wpc);
549 public abstract void setProfilerInfo(ProfilerInfo profilerInfo);
Igor Murashkinc0b47e42018-11-07 15:54:18 -0800550
551 public abstract ActivityMetricsLaunchObserverRegistry getLaunchObserverRegistry();
Winson Chung3fb0f252019-01-08 17:41:55 -0800552
553 /**
554 * Gets bitmap snapshot of the provided task id.
555 */
Jorim Jaggi925bb3c2019-06-04 19:51:45 +0200556 public abstract ActivityManager.TaskSnapshot getTaskSnapshotNoRestore(int taskId,
Winson Chung3fb0f252019-01-08 17:41:55 -0800557 boolean reducedResolution);
Michal Karpinskicc88d7e2019-01-24 15:32:12 +0000558
Alan Stokeseea8d3e2019-04-10 17:37:25 +0100559 /** Returns true if uid is considered foreground for activity start purposes. */
Michal Karpinskicc88d7e2019-01-24 15:32:12 +0000560 public abstract boolean isUidForeground(int uid);
Michal Karpinski4026cae2019-02-12 11:51:47 +0000561
562 /**
Ricky Wai96f5c352019-04-10 18:40:17 +0100563 * Called by DevicePolicyManagerService to set the uid of the device owner.
Michal Karpinski4026cae2019-02-12 11:51:47 +0000564 */
Ricky Wai96f5c352019-04-10 18:40:17 +0100565 public abstract void setDeviceOwnerUid(int uid);
Ricky Wai2452e2d2019-03-18 19:19:08 +0000566
567 /** Set all associated companion app that belongs to an userId. */
568 public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages);
Wale Ogunwale6767eae2018-05-03 15:52:51 -0700569}