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