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 | /** |
Sunny Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 92 | * 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 Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 102 | * 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 Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 191 | * 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 Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 198 | * 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 Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 209 | * Start intents as a package. |
| 210 | * |
| 211 | * @param uid Make a call as if this UID did. |
Michal Karpinski | 84d9ebd | 2019-01-17 18:28:59 +0000 | [diff] [blame] | 212 | * @param realCallingPid PID of the real caller. |
| 213 | * @param realCallingUid UID of the real caller. |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 214 | * @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 Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 220 | * @param allowBackgroundActivityStart Whether the background activity start should be allowed |
| 221 | * from originatingPendingIntent |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 222 | */ |
Michal Karpinski | 84d9ebd | 2019-01-17 18:28:59 +0000 | [diff] [blame] | 223 | 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 Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 227 | boolean allowBackgroundActivityStart); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 228 | |
| 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 Karpinski | ac116df | 2018-12-10 17:51:42 +0000 | [diff] [blame] | 233 | PendingIntentRecord originatingPendingIntent, boolean allowBackgroundActivityStart); |
Wale Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 234 | |
| 235 | /** |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 236 | * 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. |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 252 | * @param displayId The id of the display where the keyguard flags changed. |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 253 | */ |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 254 | public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId); |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 255 | |
| 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 Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 274 | 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 Ogunwale | d0412b3 | 2018-05-08 09:25:50 -0700 | [diff] [blame] | 297 | /** |
| 298 | * Called after the voice interaction service has changed. |
| 299 | */ |
| 300 | public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component); |
| 301 | |
Wale Ogunwale | a6191b4 | 2018-05-09 07:41:32 -0700 | [diff] [blame] | 302 | /** |
| 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 Ogunwale | 9e4f3e0 | 2018-05-17 09:35:39 -0700 | [diff] [blame] | 322 | |
| 323 | public abstract void onProcessAdded(WindowProcessController proc); |
| 324 | public abstract void onProcessRemoved(String name, int uid); |
| 325 | public abstract void onCleanUpApplicationRecord(WindowProcessController proc); |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 326 | public abstract int getTopProcessState(); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 327 | public abstract boolean isHeavyWeightProcess(WindowProcessController proc); |
| 328 | public abstract void clearHeavyWeightProcessIfEquals(WindowProcessController proc); |
| 329 | public abstract void finishHeavyWeightApp(); |
Wale Ogunwale | f673393 | 2018-06-27 05:14:34 -0700 | [diff] [blame] | 330 | |
| 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 Ogunwale | 906f9c6 | 2018-07-23 11:23:44 -0700 | [diff] [blame] | 337 | |
Wale Ogunwale | 906f9c6 | 2018-07-23 11:23:44 -0700 | [diff] [blame] | 338 | public abstract void onProcessMapped(int pid, WindowProcessController proc); |
| 339 | public abstract void onProcessUnMapped(int pid); |
Wale Ogunwale | 008163e | 2018-07-23 23:11:08 -0700 | [diff] [blame] | 340 | |
| 341 | public abstract void onPackageDataCleared(String name); |
| 342 | public abstract void onPackageUninstalled(String name); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 343 | public abstract void onPackageAdded(String name, boolean replacing); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 344 | public abstract void onPackageReplaced(ApplicationInfo aInfo); |
Wale Ogunwale | 5378374 | 2018-09-16 10:21:51 -0700 | [diff] [blame] | 345 | |
| 346 | public abstract CompatibilityInfo compatibilityInfoForPackage(ApplicationInfo ai); |
Yunfan Chen | 75157d7 | 2018-07-27 14:47:21 +0900 | [diff] [blame] | 347 | |
Sunny Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 348 | 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 Chen | 75157d7 | 2018-07-27 14:47:21 +0900 | [diff] [blame] | 382 | /** |
| 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 Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 390 | |
| 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 Goyal | d40c345 | 2019-03-20 12:46:55 -0700 | [diff] [blame] | 395 | |
| 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 Ogunwale | ee6eca1 | 2018-09-19 20:37:53 -0700 | [diff] [blame] | 403 | 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 Ogunwale | c4e63a4 | 2018-10-02 13:19:54 -0700 | [diff] [blame] | 407 | |
| 408 | /** @return the service connection holder for a given activity token. */ |
| 409 | public abstract ActivityServiceConnectionsHolder getServiceConnectionsHolder(IBinder token); |
Wale Ogunwale | 214f348 | 2018-10-04 11:00:47 -0700 | [diff] [blame] | 410 | |
| 411 | /** @return The intent used to launch the home activity. */ |
| 412 | public abstract Intent getHomeIntent(); |
| 413 | public abstract boolean startHomeActivity(int userId, String reason); |
Chilun | 8b1f1be | 2019-03-13 17:14:36 +0800 | [diff] [blame] | 414 | /** |
| 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, |
Chilun | 3923209 | 2019-03-22 14:41:30 +0800 | [diff] [blame] | 426 | boolean allowInstrumenting, boolean fromHomeKey); |
Louis Chang | 89f43fc | 2018-10-05 10:59:14 +0800 | [diff] [blame] | 427 | /** Start home activities on all displays that support system decorations. */ |
| 428 | public abstract boolean startHomeOnAllDisplays(int userId, String reason); |
Wale Ogunwale | 214f348 | 2018-10-04 11:00:47 -0700 | [diff] [blame] | 429 | /** @return true if the given process is the factory test process. */ |
| 430 | public abstract boolean isFactoryTestProcess(WindowProcessController wpc); |
| 431 | public abstract void updateTopComponentForFactoryTest(); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 432 | 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. */ |
sanryhuang | 498e77e | 2018-12-06 14:57:01 +0800 | [diff] [blame] | 484 | public abstract void writeProcessesToProto(ProtoOutputStream proto, String dumpPackage, |
| 485 | int wakeFullness, boolean testPssMode); |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 486 | |
| 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 Ogunwale | d4d67d0 | 2018-10-25 18:09:39 -0700 | [diff] [blame] | 492 | /** Dump the current state for inclusion in oom dump. */ |
| 493 | public abstract void dumpForOom(PrintWriter pw); |
| 494 | |
Wale Ogunwale | 31913b5 | 2018-10-13 08:29:31 -0700 | [diff] [blame] | 495 | /** @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 Ogunwale | 6425836 | 2018-10-16 15:13:37 -0700 | [diff] [blame] | 515 | |
| 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 Ogunwale | bff2df4 | 2018-10-18 17:09:19 -0700 | [diff] [blame] | 524 | |
| 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 Ogunwale | 9de1944 | 2018-10-18 19:05:03 -0700 | [diff] [blame] | 529 | |
| 530 | public abstract void onUidAddedToPendingTempWhitelist(int uid, String tag); |
| 531 | public abstract void onUidRemovedFromPendingTempWhitelist(int uid); |
Wale Ogunwale | e217229 | 2018-10-25 10:11:10 -0700 | [diff] [blame] | 532 | |
| 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 Ogunwale | d7889f5 | 2018-10-25 11:03:20 -0700 | [diff] [blame] | 537 | |
| 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 Ogunwale | d4d67d0 | 2018-10-25 18:09:39 -0700 | [diff] [blame] | 545 | |
| 546 | public abstract WindowProcessController getHomeProcess(); |
| 547 | public abstract WindowProcessController getPreviousProcess(); |
Wale Ogunwale | 27c48ae | 2018-10-25 19:01:01 -0700 | [diff] [blame] | 548 | |
| 549 | public abstract void clearLockedTasks(String reason); |
| 550 | public abstract void updateUserConfiguration(); |
Wale Ogunwale | 387b34c | 2018-10-25 19:59:40 -0700 | [diff] [blame] | 551 | public abstract boolean canShowErrorDialogs(); |
Wale Ogunwale | 1f5e53d | 2018-11-05 05:12:46 -0800 | [diff] [blame] | 552 | |
| 553 | public abstract void setProfileApp(String profileApp); |
| 554 | public abstract void setProfileProc(WindowProcessController wpc); |
| 555 | public abstract void setProfilerInfo(ProfilerInfo profilerInfo); |
Igor Murashkin | c0b47e4 | 2018-11-07 15:54:18 -0800 | [diff] [blame] | 556 | |
| 557 | public abstract ActivityMetricsLaunchObserverRegistry getLaunchObserverRegistry(); |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 558 | |
| 559 | /** |
| 560 | * Gets bitmap snapshot of the provided task id. |
| 561 | */ |
Jorim Jaggi | 925bb3c | 2019-06-04 19:51:45 +0200 | [diff] [blame] | 562 | public abstract ActivityManager.TaskSnapshot getTaskSnapshotNoRestore(int taskId, |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 563 | boolean reducedResolution); |
Michal Karpinski | cc88d7e | 2019-01-24 15:32:12 +0000 | [diff] [blame] | 564 | |
Alan Stokes | eea8d3e | 2019-04-10 17:37:25 +0100 | [diff] [blame] | 565 | /** Returns true if uid is considered foreground for activity start purposes. */ |
Michal Karpinski | cc88d7e | 2019-01-24 15:32:12 +0000 | [diff] [blame] | 566 | public abstract boolean isUidForeground(int uid); |
Michal Karpinski | 4026cae | 2019-02-12 11:51:47 +0000 | [diff] [blame] | 567 | |
| 568 | /** |
Ricky Wai | 96f5c35 | 2019-04-10 18:40:17 +0100 | [diff] [blame] | 569 | * Called by DevicePolicyManagerService to set the uid of the device owner. |
Michal Karpinski | 4026cae | 2019-02-12 11:51:47 +0000 | [diff] [blame] | 570 | */ |
Ricky Wai | 96f5c35 | 2019-04-10 18:40:17 +0100 | [diff] [blame] | 571 | public abstract void setDeviceOwnerUid(int uid); |
Ricky Wai | 2452e2d | 2019-03-18 19:19:08 +0000 | [diff] [blame] | 572 | |
| 573 | /** Set all associated companion app that belongs to an userId. */ |
| 574 | public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages); |
Wale Ogunwale | 6767eae | 2018-05-03 15:52:51 -0700 | [diff] [blame] | 575 | } |