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