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; |
Sunny Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 37 | import android.util.Pair; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 38 | import android.util.SparseIntArray; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 39 | import android.util.proto.ProtoOutputStream; |
Louis Chang | 89f43fc | 2018-10-05 10:59:14 +0800 | [diff] [blame] | 40 | |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 41 | import com.android.internal.app.IVoiceInteractor; |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 42 | import com.android.server.am.PendingIntentRecord; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 43 | import com.android.server.am.UserState; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 44 | |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 45 | import java.io.FileDescriptor; |
| 46 | import java.io.PrintWriter; |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 47 | import java.lang.ref.WeakReference; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 48 | import java.util.List; |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 49 | import java.util.Set; |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Activity Task manager local system service interface. |
| 53 | * @hide Only for use within system server |
| 54 | */ |
| 55 | public 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 Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 93 | * 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 Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 103 | * 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 Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 203 | * Start intents as a package. |
| 204 | * |
| 205 | * @param uid Make a call as if this UID did. |
Michal Karpinski | 84d9ebd | 2019-01-17 18:28:59 +0000 | [diff] [blame] | 206 | * @param realCallingPid PID of the real caller. |
| 207 | * @param realCallingUid UID of the real caller. |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 208 | * @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 Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 214 | * @param allowBackgroundActivityStart Whether the background activity start should be allowed |
| 215 | * from originatingPendingIntent |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 216 | */ |
Michal Karpinski | 84d9ebd | 2019-01-17 18:28:59 +0000 | [diff] [blame] | 217 | 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 Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 221 | boolean allowBackgroundActivityStart); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 222 | |
| 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 Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 227 | PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 228 | |
| 229 | /** |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 230 | * 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. |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 246 | * @param displayId The id of the display where the keyguard flags changed. |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 247 | */ |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 248 | public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId); |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 249 | |
| 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 Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 268 | 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 Ogunwale | d0412b3 | 2018-05-08 09:25:50 -0700 | [diff] [blame] | 291 | /** |
| 292 | * Called after the voice interaction service has changed. |
| 293 | */ |
| 294 | public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component); |
| 295 | |
Wale Ogunwale | a6191b4 | 2018-05-09 07:41:32 -0700 | [diff] [blame] | 296 | /** |
| 297 | * Set a uid that is allowed to bypass stopped app switches, launching an app |
| 298 | * whenever it wants. |
| 299 | * |
| 300 | * @param type Type of the caller -- unique string the caller supplies to identify itself |
| 301 | * and disambiguate with other calles. |
| 302 | * @param uid The uid of the app to be allowed, or -1 to clear the uid for this type. |
| 303 | * @param userId The user it is allowed for. |
| 304 | */ |
| 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 Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 316 | |
| 317 | public abstract void onProcessAdded(WindowProcessController proc); |
| 318 | public abstract void onProcessRemoved(String name, int uid); |
| 319 | public abstract void onCleanUpApplicationRecord(WindowProcessController proc); |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 320 | public abstract int getTopProcessState(); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 321 | public abstract boolean isHeavyWeightProcess(WindowProcessController proc); |
| 322 | public abstract void clearHeavyWeightProcessIfEquals(WindowProcessController proc); |
| 323 | public abstract void finishHeavyWeightApp(); |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 324 | |
| 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 Ogunwale | 906f9c6 | 2018-07-23 11:23:44 -0700 | [diff] [blame] | 331 | |
Wale Ogunwale | 906f9c6 | 2018-07-23 11:23:44 -0700 | [diff] [blame] | 332 | public abstract void onProcessMapped(int pid, WindowProcessController proc); |
| 333 | public abstract void onProcessUnMapped(int pid); |
Wale Ogunwale | 008163e | 2018-07-23 23:11:08 -0700 | [diff] [blame] | 334 | |
| 335 | public abstract void onPackageDataCleared(String name); |
| 336 | public abstract void onPackageUninstalled(String name); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 337 | public abstract void onPackageAdded(String name, boolean replacing); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 338 | public abstract void onPackageReplaced(ApplicationInfo aInfo); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 339 | |
| 340 | public abstract CompatibilityInfo compatibilityInfoForPackage(ApplicationInfo ai); |
Yunfan Chen | 75157d7 | 2018-07-27 14:47:21 +0900 | [diff] [blame] | 341 | |
Sunny Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 342 | 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 Chen | 75157d7 | 2018-07-27 14:47:21 +0900 | [diff] [blame] | 376 | /** |
| 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 Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 384 | |
| 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 Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 389 | |
| 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 Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 397 | 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 Ogunwale | c4e63a4 | 2018-10-02 13:19:54 -0700 | [diff] [blame] | 401 | |
| 402 | /** @return the service connection holder for a given activity token. */ |
| 403 | public abstract ActivityServiceConnectionsHolder getServiceConnectionsHolder(IBinder token); |
Wale Ogunwale | 214f348 | 2018-10-04 11:00:47 -0700 | [diff] [blame] | 404 | |
| 405 | /** @return The intent used to launch the home activity. */ |
| 406 | public abstract Intent getHomeIntent(); |
| 407 | public abstract boolean startHomeActivity(int userId, String reason); |
Chilun | 8b1f1be | 2019-03-13 17:14:36 +0800 | [diff] [blame] | 408 | /** |
| 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, |
Chilun | 3923209 | 2019-03-22 14:41:30 +0800 | [diff] [blame] | 420 | boolean allowInstrumenting, boolean fromHomeKey); |
Louis Chang | 89f43fc | 2018-10-05 10:59:14 +0800 | [diff] [blame] | 421 | /** Start home activities on all displays that support system decorations. */ |
| 422 | public abstract boolean startHomeOnAllDisplays(int userId, String reason); |
Wale Ogunwale | 214f348 | 2018-10-04 11:00:47 -0700 | [diff] [blame] | 423 | /** @return true if the given process is the factory test process. */ |
| 424 | public abstract boolean isFactoryTestProcess(WindowProcessController wpc); |
| 425 | public abstract void updateTopComponentForFactoryTest(); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 426 | 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. */ |
sanryhuang | 498e77e | 2018-12-06 14:57:01 +0800 | [diff] [blame] | 478 | public abstract void writeProcessesToProto(ProtoOutputStream proto, String dumpPackage, |
| 479 | int wakeFullness, boolean testPssMode); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 480 | |
| 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 Ogunwale | d4d67d0 | 2018-10-25 18:09:39 -0700 | [diff] [blame] | 486 | /** Dump the current state for inclusion in oom dump. */ |
| 487 | public abstract void dumpForOom(PrintWriter pw); |
| 488 | |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 489 | /** @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 Ogunwale | 6425836 | 2018-10-16 15:13:37 -0700 | [diff] [blame] | 509 | |
| 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 Ogunwale | bff2df4 | 2018-10-18 17:09:19 -0700 | [diff] [blame] | 518 | |
| 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 Ogunwale | 9de1944 | 2018-10-18 19:05:03 -0700 | [diff] [blame] | 523 | |
| 524 | public abstract void onUidAddedToPendingTempWhitelist(int uid, String tag); |
| 525 | public abstract void onUidRemovedFromPendingTempWhitelist(int uid); |
Wale Ogunwale | e217229 | 2018-10-25 10:11:10 -0700 | [diff] [blame] | 526 | |
| 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 Ogunwale | d7889f5 | 2018-10-25 11:03:20 -0700 | [diff] [blame] | 531 | |
| 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 Ogunwale | d4d67d0 | 2018-10-25 18:09:39 -0700 | [diff] [blame] | 539 | |
| 540 | public abstract WindowProcessController getHomeProcess(); |
| 541 | public abstract WindowProcessController getPreviousProcess(); |
Wale Ogunwale | 27c48ae | 2018-10-25 19:01:01 -0700 | [diff] [blame] | 542 | |
| 543 | public abstract void clearLockedTasks(String reason); |
| 544 | public abstract void updateUserConfiguration(); |
Wale Ogunwale | 387b34c | 2018-10-25 19:59:40 -0700 | [diff] [blame] | 545 | public abstract boolean canShowErrorDialogs(); |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 546 | |
| 547 | public abstract void setProfileApp(String profileApp); |
| 548 | public abstract void setProfileProc(WindowProcessController wpc); |
| 549 | public abstract void setProfilerInfo(ProfilerInfo profilerInfo); |
Igor Murashkin | c0b47e4 | 2018-11-07 15:54:18 -0800 | [diff] [blame] | 550 | |
| 551 | public abstract ActivityMetricsLaunchObserverRegistry getLaunchObserverRegistry(); |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 552 | |
| 553 | /** |
| 554 | * Gets bitmap snapshot of the provided task id. |
| 555 | */ |
Jorim Jaggi | 925bb3c | 2019-06-04 19:51:45 +0200 | [diff] [blame] | 556 | public abstract ActivityManager.TaskSnapshot getTaskSnapshotNoRestore(int taskId, |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 557 | boolean reducedResolution); |
Michal Karpinski | cc88d7e | 2019-01-24 15:32:12 +0000 | [diff] [blame] | 558 | |
Alan Stokes | eea8d3e | 2019-04-10 17:37:25 +0100 | [diff] [blame] | 559 | /** Returns true if uid is considered foreground for activity start purposes. */ |
Michal Karpinski | cc88d7e | 2019-01-24 15:32:12 +0000 | [diff] [blame] | 560 | public abstract boolean isUidForeground(int uid); |
Michal Karpinski | 4026cae | 2019-02-12 11:51:47 +0000 | [diff] [blame] | 561 | |
| 562 | /** |
Ricky Wai | 96f5c35 | 2019-04-10 18:40:17 +0100 | [diff] [blame] | 563 | * Called by DevicePolicyManagerService to set the uid of the device owner. |
Michal Karpinski | 4026cae | 2019-02-12 11:51:47 +0000 | [diff] [blame] | 564 | */ |
Ricky Wai | 96f5c35 | 2019-04-10 18:40:17 +0100 | [diff] [blame] | 565 | public abstract void setDeviceOwnerUid(int uid); |
Ricky Wai | 2452e2d | 2019-03-18 19:19:08 +0000 | [diff] [blame] | 566 | |
| 567 | /** Set all associated companion app that belongs to an userId. */ |
| 568 | public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages); |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 569 | } |