Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 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 | |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 17 | package com.android.server.wm; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 21 | import android.annotation.UserIdInt; |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 22 | import android.app.ActivityManager; |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 23 | import android.app.AppProtoEnums; |
| 24 | import android.app.IActivityManager; |
| 25 | import android.app.IApplicationThread; |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 26 | import android.app.ProfilerInfo; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 27 | import android.content.ComponentName; |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 28 | import android.content.IIntentSender; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 29 | import android.content.Intent; |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 30 | import android.content.pm.ApplicationInfo; |
| 31 | import android.content.res.CompatibilityInfo; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 32 | import android.os.Bundle; |
| 33 | import android.os.IBinder; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 34 | import android.os.RemoteException; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 35 | import android.os.SystemClock; |
| 36 | import android.service.voice.IVoiceInteractionSession; |
| 37 | import android.util.SparseIntArray; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 38 | import android.util.proto.ProtoOutputStream; |
Louis Chang | 89f43fc | 2018-10-05 10:59:14 +0800 | [diff] [blame] | 39 | |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 40 | import com.android.internal.app.IVoiceInteractor; |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 41 | import com.android.server.am.PendingIntentRecord; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 42 | import com.android.server.am.UserState; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 43 | |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 44 | import java.io.FileDescriptor; |
| 45 | import java.io.PrintWriter; |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 46 | import java.lang.ref.WeakReference; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 47 | import java.util.List; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 48 | import java.util.Set; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Activity Task manager local system service interface. |
| 52 | * @hide Only for use within system server |
| 53 | */ |
| 54 | public 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 | /** |
| 92 | * The bundle key to extract the assist data. |
| 93 | */ |
| 94 | public static final String ASSIST_KEY_DATA = "data"; |
| 95 | |
| 96 | /** |
| 97 | * The bundle key to extract the assist structure. |
| 98 | */ |
| 99 | public static final String ASSIST_KEY_STRUCTURE = "structure"; |
| 100 | |
| 101 | /** |
| 102 | * The bundle key to extract the assist content. |
| 103 | */ |
| 104 | public static final String ASSIST_KEY_CONTENT = "content"; |
| 105 | |
| 106 | /** |
| 107 | * The bundle key to extract the assist receiver extras. |
| 108 | */ |
| 109 | public static final String ASSIST_KEY_RECEIVER_EXTRAS = "receiverExtras"; |
| 110 | |
| 111 | public interface ScreenObserver { |
| 112 | void onAwakeStateChanged(boolean isAwake); |
| 113 | void onKeyguardStateChanged(boolean isShowing); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Sleep tokens cause the activity manager to put the top activity to sleep. |
| 118 | * They are used by components such as dreams that may hide and block interaction |
| 119 | * with underlying activities. |
| 120 | */ |
| 121 | public static abstract class SleepToken { |
| 122 | |
| 123 | /** Releases the sleep token. */ |
| 124 | public abstract void release(); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Acquires a sleep token for the specified display with the specified tag. |
| 129 | * |
| 130 | * @param tag A string identifying the purpose of the token (eg. "Dream"). |
| 131 | * @param displayId The display to apply the sleep token to. |
| 132 | */ |
| 133 | public abstract SleepToken acquireSleepToken(@NonNull String tag, int displayId); |
| 134 | |
| 135 | /** |
| 136 | * Returns home activity for the specified user. |
| 137 | * |
| 138 | * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL} |
| 139 | */ |
| 140 | public abstract ComponentName getHomeActivityForUser(int userId); |
| 141 | |
| 142 | public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity, |
| 143 | IVoiceInteractionSession mSession, |
| 144 | IVoiceInteractor mInteractor); |
| 145 | |
| 146 | /** |
| 147 | * Callback for window manager to let activity manager know that we are finally starting the |
| 148 | * app transition; |
| 149 | * |
| 150 | * @param reasons A map from windowing mode to a reason integer why the transition was started, |
| 151 | * which must be one of the APP_TRANSITION_* values. |
| 152 | * @param timestamp The time at which the app transition started in |
| 153 | * {@link SystemClock#uptimeMillis()} timebase. |
| 154 | */ |
| 155 | public abstract void notifyAppTransitionStarting(SparseIntArray reasons, long timestamp); |
| 156 | |
| 157 | /** |
| 158 | * Callback for window manager to let activity manager know that the app transition was |
| 159 | * cancelled. |
| 160 | */ |
| 161 | public abstract void notifyAppTransitionCancelled(); |
| 162 | |
| 163 | /** |
| 164 | * Callback for window manager to let activity manager know that the app transition is finished. |
| 165 | */ |
| 166 | public abstract void notifyAppTransitionFinished(); |
| 167 | |
| 168 | /** |
| 169 | * Returns the top activity from each of the currently visible stacks. The first entry will be |
| 170 | * the focused activity. |
| 171 | */ |
| 172 | public abstract List<IBinder> getTopVisibleActivities(); |
| 173 | |
| 174 | /** |
| 175 | * Callback for window manager to let activity manager know that docked stack changes its |
| 176 | * minimized state. |
| 177 | */ |
| 178 | public abstract void notifyDockedStackMinimizedChanged(boolean minimized); |
| 179 | |
| 180 | /** |
| 181 | * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it. |
| 182 | * |
| 183 | * - DO NOT call it with the calling UID cleared. |
| 184 | * - All the necessary caller permission checks must be done at callsites. |
| 185 | * |
| 186 | * @return error codes used by {@link IActivityManager#startActivity} and its siblings. |
| 187 | */ |
| 188 | public abstract int startActivitiesAsPackage(String packageName, |
| 189 | int userId, Intent[] intents, Bundle bOptions); |
| 190 | |
| 191 | /** |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 192 | * Start intents as a package. |
| 193 | * |
| 194 | * @param uid Make a call as if this UID did. |
Michal Karpinski | 84d9ebd | 2019-01-17 18:28:59 +0000 | [diff] [blame] | 195 | * @param realCallingPid PID of the real caller. |
| 196 | * @param realCallingUid UID of the real caller. |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 197 | * @param callingPackage Make a call as if this package did. |
| 198 | * @param intents Intents to start. |
| 199 | * @param userId Start the intents on this user. |
| 200 | * @param validateIncomingUser Set true to skip checking {@code userId} with the calling UID. |
| 201 | * @param originatingPendingIntent PendingIntentRecord that originated this activity start or |
| 202 | * null if not originated by PendingIntent |
Michal Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 203 | * @param allowBackgroundActivityStart Whether the background activity start should be allowed |
| 204 | * from originatingPendingIntent |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 205 | */ |
Michal Karpinski | 84d9ebd | 2019-01-17 18:28:59 +0000 | [diff] [blame] | 206 | public abstract int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid, |
| 207 | String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo, |
| 208 | SafeActivityOptions options, int userId, boolean validateIncomingUser, |
| 209 | PendingIntentRecord originatingPendingIntent, |
Michal Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 210 | boolean allowBackgroundActivityStart); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 211 | |
| 212 | public abstract int startActivityInPackage(int uid, int realCallingPid, int realCallingUid, |
| 213 | String callingPackage, Intent intent, String resolvedType, IBinder resultTo, |
| 214 | String resultWho, int requestCode, int startFlags, SafeActivityOptions options, |
| 215 | int userId, TaskRecord inTask, String reason, boolean validateIncomingUser, |
Michal Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 216 | PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 217 | |
| 218 | /** |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 219 | * Start activity {@code intent} without calling user-id check. |
| 220 | * |
| 221 | * - DO NOT call it with the calling UID cleared. |
| 222 | * - The caller must do the calling user ID check. |
| 223 | * |
| 224 | * @return error codes used by {@link IActivityManager#startActivity} and its siblings. |
| 225 | */ |
| 226 | public abstract int startActivityAsUser(IApplicationThread caller, String callingPackage, |
| 227 | Intent intent, @Nullable Bundle options, int userId); |
| 228 | |
| 229 | /** |
| 230 | * Called when Keyguard flags might have changed. |
| 231 | * |
| 232 | * @param callback Callback to run after activity visibilities have been reevaluated. This can |
| 233 | * be used from window manager so that when the callback is called, it's |
| 234 | * guaranteed that all apps have their visibility updated accordingly. |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 235 | * @param displayId The id of the display where the keyguard flags changed. |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 236 | */ |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 237 | public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId); |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 238 | |
| 239 | /** |
| 240 | * Called when the trusted state of Keyguard has changed. |
| 241 | */ |
| 242 | public abstract void notifyKeyguardTrustedChanged(); |
| 243 | |
| 244 | /** |
| 245 | * Called after virtual display Id is updated by |
| 246 | * {@link com.android.server.vr.Vr2dDisplay} with a specific |
| 247 | * {@param vr2dDisplayId}. |
| 248 | */ |
| 249 | public abstract void setVr2dDisplayId(int vr2dDisplayId); |
| 250 | |
| 251 | /** |
| 252 | * Set focus on an activity. |
| 253 | * @param token The IApplicationToken for the activity |
| 254 | */ |
| 255 | public abstract void setFocusedActivity(IBinder token); |
| 256 | |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 257 | public abstract void registerScreenObserver(ScreenObserver observer); |
| 258 | |
| 259 | /** |
| 260 | * Returns is the caller has the same uid as the Recents component |
| 261 | */ |
| 262 | public abstract boolean isCallerRecents(int callingUid); |
| 263 | |
| 264 | /** |
| 265 | * Returns whether the recents component is the home activity for the given user. |
| 266 | */ |
| 267 | public abstract boolean isRecentsComponentHomeActivity(int userId); |
| 268 | |
| 269 | /** |
| 270 | * Cancels any currently running recents animation. |
| 271 | */ |
| 272 | public abstract void cancelRecentsAnimation(boolean restoreHomeStackPosition); |
| 273 | |
| 274 | /** |
| 275 | * This enforces {@code func} can only be called if either the caller is Recents activity or |
| 276 | * has {@code permission}. |
| 277 | */ |
| 278 | public abstract void enforceCallerIsRecentsOrHasPermission(String permission, String func); |
| 279 | |
Wale Ogunwale | d0412b3 | 2018-05-08 09:25:50 -0700 | [diff] [blame] | 280 | /** |
| 281 | * Called after the voice interaction service has changed. |
| 282 | */ |
| 283 | public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component); |
| 284 | |
Wale Ogunwale | a6191b4 | 2018-05-09 07:41:32 -0700 | [diff] [blame] | 285 | /** |
| 286 | * Set a uid that is allowed to bypass stopped app switches, launching an app |
| 287 | * whenever it wants. |
| 288 | * |
| 289 | * @param type Type of the caller -- unique string the caller supplies to identify itself |
| 290 | * and disambiguate with other calles. |
| 291 | * @param uid The uid of the app to be allowed, or -1 to clear the uid for this type. |
| 292 | * @param userId The user it is allowed for. |
| 293 | */ |
| 294 | public abstract void setAllowAppSwitches(@NonNull String type, int uid, int userId); |
| 295 | |
| 296 | /** |
| 297 | * Called when a user has been deleted. This can happen during normal device usage |
| 298 | * or just at startup, when partially removed users are purged. Any state persisted by the |
| 299 | * ActivityManager should be purged now. |
| 300 | * |
| 301 | * @param userId The user being cleaned up. |
| 302 | */ |
| 303 | public abstract void onUserStopped(int userId); |
| 304 | public abstract boolean isGetTasksAllowed(String caller, int callingPid, int callingUid); |
Wale Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 305 | |
| 306 | public abstract void onProcessAdded(WindowProcessController proc); |
| 307 | public abstract void onProcessRemoved(String name, int uid); |
| 308 | public abstract void onCleanUpApplicationRecord(WindowProcessController proc); |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 309 | public abstract int getTopProcessState(); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 310 | public abstract boolean isHeavyWeightProcess(WindowProcessController proc); |
| 311 | public abstract void clearHeavyWeightProcessIfEquals(WindowProcessController proc); |
| 312 | public abstract void finishHeavyWeightApp(); |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 313 | |
| 314 | public abstract boolean isSleeping(); |
| 315 | public abstract boolean isShuttingDown(); |
| 316 | public abstract boolean shuttingDown(boolean booted, int timeout); |
| 317 | public abstract void enableScreenAfterBoot(boolean booted); |
| 318 | public abstract boolean showStrictModeViolationDialog(); |
| 319 | public abstract void showSystemReadyErrorDialogsIfNeeded(); |
Wale Ogunwale | 906f9c6 | 2018-07-23 11:23:44 -0700 | [diff] [blame] | 320 | |
Wale Ogunwale | 906f9c6 | 2018-07-23 11:23:44 -0700 | [diff] [blame] | 321 | public abstract void onProcessMapped(int pid, WindowProcessController proc); |
| 322 | public abstract void onProcessUnMapped(int pid); |
Wale Ogunwale | 008163e | 2018-07-23 23:11:08 -0700 | [diff] [blame] | 323 | |
| 324 | public abstract void onPackageDataCleared(String name); |
| 325 | public abstract void onPackageUninstalled(String name); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 326 | public abstract void onPackageAdded(String name, boolean replacing); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 327 | public abstract void onPackageReplaced(ApplicationInfo aInfo); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 328 | |
| 329 | public abstract CompatibilityInfo compatibilityInfoForPackage(ApplicationInfo ai); |
Yunfan Chen | 75157d7 | 2018-07-27 14:47:21 +0900 | [diff] [blame] | 330 | |
| 331 | /** |
| 332 | * Set the corresponding display information for the process global configuration. To be called |
| 333 | * when we need to show IME on a different display. |
| 334 | * |
| 335 | * @param pid The process id associated with the IME window. |
| 336 | * @param displayId The ID of the display showing the IME. |
| 337 | */ |
| 338 | public abstract void onImeWindowSetOnDisplay(int pid, int displayId); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 339 | |
| 340 | public abstract void sendActivityResult(int callingUid, IBinder activityToken, |
| 341 | String resultWho, int requestCode, int resultCode, Intent data); |
| 342 | public abstract void clearPendingResultForActivity( |
| 343 | IBinder activityToken, WeakReference<PendingIntentRecord> pir); |
| 344 | public abstract IIntentSender getIntentSender(int type, String packageName, |
| 345 | int callingUid, int userId, IBinder token, String resultWho, |
| 346 | int requestCode, Intent[] intents, String[] resolvedTypes, int flags, |
| 347 | Bundle bOptions); |
Wale Ogunwale | c4e63a4 | 2018-10-02 13:19:54 -0700 | [diff] [blame] | 348 | |
| 349 | /** @return the service connection holder for a given activity token. */ |
| 350 | public abstract ActivityServiceConnectionsHolder getServiceConnectionsHolder(IBinder token); |
Wale Ogunwale | 214f348 | 2018-10-04 11:00:47 -0700 | [diff] [blame] | 351 | |
| 352 | /** @return The intent used to launch the home activity. */ |
| 353 | public abstract Intent getHomeIntent(); |
| 354 | public abstract boolean startHomeActivity(int userId, String reason); |
Chilun | 8b1f1be | 2019-03-13 17:14:36 +0800 | [diff] [blame] | 355 | /** |
| 356 | * This starts home activity on displays that can have system decorations based on displayId - |
| 357 | * Default display always use primary home component. |
| 358 | * For Secondary displays, the home activity must have category SECONDARY_HOME and then resolves |
| 359 | * according to the priorities listed below. |
| 360 | * - If default home is not set, always use the secondary home defined in the config. |
| 361 | * - Use currently selected primary home activity. |
| 362 | * - Use the activity in the same package as currently selected primary home activity. |
| 363 | * If there are multiple activities matched, use first one. |
| 364 | * - Use the secondary home defined in the config. |
| 365 | */ |
| 366 | public abstract boolean startHomeOnDisplay(int userId, String reason, int displayId, |
| 367 | boolean fromHomeKey); |
Louis Chang | 89f43fc | 2018-10-05 10:59:14 +0800 | [diff] [blame] | 368 | /** Start home activities on all displays that support system decorations. */ |
| 369 | public abstract boolean startHomeOnAllDisplays(int userId, String reason); |
Wale Ogunwale | 214f348 | 2018-10-04 11:00:47 -0700 | [diff] [blame] | 370 | /** @return true if the given process is the factory test process. */ |
| 371 | public abstract boolean isFactoryTestProcess(WindowProcessController wpc); |
| 372 | public abstract void updateTopComponentForFactoryTest(); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 373 | public abstract void handleAppDied(WindowProcessController wpc, boolean restarting, |
| 374 | Runnable finishInstrumentationCallback); |
| 375 | public abstract void closeSystemDialogs(String reason); |
| 376 | |
| 377 | /** Removes all components (e.g. activities, recents, ...) belonging to a disabled package. */ |
| 378 | public abstract void cleanupDisabledPackageComponents( |
| 379 | String packageName, Set<String> disabledClasses, int userId, boolean booted); |
| 380 | |
| 381 | /** Called whenever AM force stops a package. */ |
| 382 | public abstract boolean onForceStopPackage(String packageName, boolean doit, |
| 383 | boolean evenPersistent, int userId); |
| 384 | /** |
| 385 | * Resumes all top activities in the system if they aren't resumed already. |
| 386 | * @param scheduleIdle If the idle message should be schedule after the top activities are |
| 387 | * resumed. |
| 388 | */ |
| 389 | public abstract void resumeTopActivities(boolean scheduleIdle); |
| 390 | |
| 391 | /** Called by AM just before it binds to an application process. */ |
| 392 | public abstract void preBindApplication(WindowProcessController wpc); |
| 393 | |
| 394 | /** Called by AM when an application process attaches. */ |
| 395 | public abstract boolean attachApplication(WindowProcessController wpc) throws RemoteException; |
| 396 | |
| 397 | /** @see IActivityManager#notifyLockedProfile(int) */ |
| 398 | public abstract void notifyLockedProfile(@UserIdInt int userId, int currentUserId); |
| 399 | |
| 400 | /** @see IActivityManager#startConfirmDeviceCredentialIntent(Intent, Bundle) */ |
| 401 | public abstract void startConfirmDeviceCredentialIntent(Intent intent, Bundle options); |
| 402 | |
| 403 | /** Writes current activity states to the proto stream. */ |
| 404 | public abstract void writeActivitiesToProto(ProtoOutputStream proto); |
| 405 | |
| 406 | /** |
| 407 | * Saves the current activity manager state and includes the saved state in the next dump of |
| 408 | * activity manager. |
| 409 | */ |
| 410 | public abstract void saveANRState(String reason); |
| 411 | |
| 412 | /** Clears the previously saved activity manager ANR state. */ |
| 413 | public abstract void clearSavedANRState(); |
| 414 | |
| 415 | /** Dump the current state based on the command. */ |
| 416 | public abstract void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args, |
| 417 | int opti, boolean dumpAll, boolean dumpClient, String dumpPackage); |
| 418 | |
| 419 | /** Dump the current state for inclusion in process dump. */ |
| 420 | public abstract boolean dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll, |
| 421 | String dumpPackage, int dumpAppId, boolean needSep, boolean testPssMode, |
| 422 | int wakefulness); |
| 423 | |
| 424 | /** Writes the current window process states to the proto stream. */ |
sanryhuang | 498e77e | 2018-12-06 14:57:01 +0800 | [diff] [blame] | 425 | public abstract void writeProcessesToProto(ProtoOutputStream proto, String dumpPackage, |
| 426 | int wakeFullness, boolean testPssMode); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 427 | |
| 428 | /** Dump the current activities state. */ |
| 429 | public abstract boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, |
| 430 | String[] args, int opti, boolean dumpAll, boolean dumpVisibleStacksOnly, |
| 431 | boolean dumpFocusedStackOnly); |
| 432 | |
Wale Ogunwale | d4d67d0 | 2018-10-25 18:09:39 -0700 | [diff] [blame] | 433 | /** Dump the current state for inclusion in oom dump. */ |
| 434 | public abstract void dumpForOom(PrintWriter pw); |
| 435 | |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 436 | /** @return true if it the activity management system is okay with GC running now. */ |
| 437 | public abstract boolean canGcNow(); |
| 438 | |
| 439 | /** @return the process for the top-most resumed activity in the system. */ |
| 440 | public abstract WindowProcessController getTopApp(); |
| 441 | |
| 442 | /** Generate oom-score-adjustment rank for all tasks in the system based on z-order. */ |
| 443 | public abstract void rankTaskLayersIfNeeded(); |
| 444 | |
| 445 | /** Destroy all activities. */ |
| 446 | public abstract void scheduleDestroyAllActivities(String reason); |
| 447 | |
| 448 | /** Remove user association with activities. */ |
| 449 | public abstract void removeUser(int userId); |
| 450 | |
| 451 | /** Switch current focused user for activities. */ |
| 452 | public abstract boolean switchUser(int userId, UserState userState); |
| 453 | |
| 454 | /** Called whenever an app crashes. */ |
| 455 | public abstract void onHandleAppCrash(WindowProcessController wpc); |
Wale Ogunwale | 6425836 | 2018-10-16 15:13:37 -0700 | [diff] [blame] | 456 | |
| 457 | /** |
| 458 | * Finish the topmost activities in all stacks that belong to the crashed app. |
| 459 | * @param crashedApp The app that crashed. |
| 460 | * @param reason Reason to perform this action. |
| 461 | * @return The task id that was finished in this stack, or INVALID_TASK_ID if none was finished. |
| 462 | */ |
| 463 | public abstract int finishTopCrashedActivities( |
| 464 | WindowProcessController crashedApp, String reason); |
Wale Ogunwale | bff2df4 | 2018-10-18 17:09:19 -0700 | [diff] [blame] | 465 | |
| 466 | public abstract void onUidActive(int uid, int procState); |
| 467 | public abstract void onUidInactive(int uid); |
| 468 | public abstract void onActiveUidsCleared(); |
| 469 | public abstract void onUidProcStateChanged(int uid, int procState); |
Wale Ogunwale | 9de1944 | 2018-10-18 19:05:03 -0700 | [diff] [blame] | 470 | |
| 471 | public abstract void onUidAddedToPendingTempWhitelist(int uid, String tag); |
| 472 | public abstract void onUidRemovedFromPendingTempWhitelist(int uid); |
Wale Ogunwale | e217229 | 2018-10-25 10:11:10 -0700 | [diff] [blame] | 473 | |
| 474 | /** Handle app crash event in {@link android.app.IActivityController} if there is one. */ |
| 475 | public abstract boolean handleAppCrashInActivityController(String processName, int pid, |
| 476 | String shortMsg, String longMsg, long timeMillis, String stackTrace, |
| 477 | Runnable killCrashingAppCallback); |
Wale Ogunwale | d7889f5 | 2018-10-25 11:03:20 -0700 | [diff] [blame] | 478 | |
| 479 | public abstract void removeRecentTasksByPackageName(String packageName, int userId); |
| 480 | public abstract void cleanupRecentTasksForUser(int userId); |
| 481 | public abstract void loadRecentTasksForUser(int userId); |
| 482 | public abstract void onPackagesSuspendedChanged(String[] packages, boolean suspended, |
| 483 | int userId); |
| 484 | /** Flush recent tasks to disk. */ |
| 485 | public abstract void flushRecentTasks(); |
Wale Ogunwale | d4d67d0 | 2018-10-25 18:09:39 -0700 | [diff] [blame] | 486 | |
| 487 | public abstract WindowProcessController getHomeProcess(); |
| 488 | public abstract WindowProcessController getPreviousProcess(); |
Wale Ogunwale | 27c48ae | 2018-10-25 19:01:01 -0700 | [diff] [blame] | 489 | |
| 490 | public abstract void clearLockedTasks(String reason); |
| 491 | public abstract void updateUserConfiguration(); |
Wale Ogunwale | 387b34c | 2018-10-25 19:59:40 -0700 | [diff] [blame] | 492 | public abstract boolean canShowErrorDialogs(); |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 493 | |
| 494 | public abstract void setProfileApp(String profileApp); |
| 495 | public abstract void setProfileProc(WindowProcessController wpc); |
| 496 | public abstract void setProfilerInfo(ProfilerInfo profilerInfo); |
Igor Murashkin | c0b47e4 | 2018-11-07 15:54:18 -0800 | [diff] [blame] | 497 | |
| 498 | public abstract ActivityMetricsLaunchObserverRegistry getLaunchObserverRegistry(); |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 499 | |
| 500 | /** |
| 501 | * Gets bitmap snapshot of the provided task id. |
| 502 | */ |
| 503 | public abstract ActivityManager.TaskSnapshot getTaskSnapshot(int taskId, |
| 504 | boolean reducedResolution); |
Michal Karpinski | cc88d7e | 2019-01-24 15:32:12 +0000 | [diff] [blame] | 505 | |
| 506 | /** Returns true if uid has a visible window or its process is in a top state. */ |
| 507 | public abstract boolean isUidForeground(int uid); |
Michal Karpinski | 4026cae | 2019-02-12 11:51:47 +0000 | [diff] [blame] | 508 | |
| 509 | /** |
| 510 | * Called by DevicePolicyManagerService to set the package name of the device owner. |
| 511 | */ |
| 512 | public abstract void setDeviceOwnerPackageName(String deviceOwnerPkg); |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 513 | } |