Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | package com.android.server.wm; |
| 18 | |
Chiawei Wang | 02202d1 | 2019-01-03 18:12:13 +0800 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 20 | |
Matthew Ng | cb7ac67 | 2017-07-21 17:27:42 -0700 | [diff] [blame] | 21 | import static com.android.server.wm.TaskSnapshotPersister.DISABLE_FULL_SIZED_BITMAPS; |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 22 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT; |
Winson Chung | 3e13ef8 | 2017-06-29 12:41:14 -0700 | [diff] [blame] | 23 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 24 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 25 | |
Evan Rosky | 08e2093 | 2019-05-14 10:54:07 -0700 | [diff] [blame] | 26 | import android.annotation.NonNull; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 27 | import android.annotation.Nullable; |
Jorim Jaggi | 3d73260 | 2017-02-22 17:56:40 +0100 | [diff] [blame] | 28 | import android.app.ActivityManager; |
Jorim Jaggi | e2c77f9 | 2016-12-29 14:57:22 +0100 | [diff] [blame] | 29 | import android.app.ActivityManager.TaskSnapshot; |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 30 | import android.content.pm.PackageManager; |
Jorim Jaggi | 6aead1c | 2017-05-23 15:07:44 +0200 | [diff] [blame] | 31 | import android.graphics.Bitmap; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 32 | import android.graphics.GraphicBuffer; |
Winson Chung | 02378b4 | 2018-06-04 16:40:09 -0700 | [diff] [blame] | 33 | import android.graphics.PixelFormat; |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 34 | import android.graphics.RecordingCanvas; |
Jorim Jaggi | 30d64f3 | 2017-04-07 16:33:17 +0200 | [diff] [blame] | 35 | import android.graphics.Rect; |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 36 | import android.graphics.RenderNode; |
Jorim Jaggi | f9084ec | 2017-01-16 13:16:59 +0100 | [diff] [blame] | 37 | import android.os.Environment; |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 38 | import android.os.Handler; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 39 | import android.util.ArraySet; |
Winson Chung | 3e13ef8 | 2017-06-29 12:41:14 -0700 | [diff] [blame] | 40 | import android.util.Slog; |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 41 | import android.view.SurfaceControl; |
Winson Chung | 9109276 | 2017-05-24 14:08:48 -0700 | [diff] [blame] | 42 | import android.view.ThreadedRenderer; |
Jorim Jaggi | d635a4a | 2017-05-03 15:21:26 +0200 | [diff] [blame] | 43 | import android.view.WindowManager.LayoutParams; |
Guang Zhu | 09486a3 | 2017-06-06 03:27:44 +0000 | [diff] [blame] | 44 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 45 | import com.android.internal.annotations.VisibleForTesting; |
Winson Chung | 51f42d2 | 2018-02-01 14:59:38 -0800 | [diff] [blame] | 46 | import com.android.internal.graphics.ColorUtils; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 47 | import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; |
| 48 | import com.android.server.policy.WindowManagerPolicy.StartingSurface; |
Jorim Jaggi | d635a4a | 2017-05-03 15:21:26 +0200 | [diff] [blame] | 49 | import com.android.server.wm.TaskSnapshotSurface.SystemBarBackgroundPainter; |
Jorim Jaggi | 817ebdd | 2018-03-26 15:46:01 +0200 | [diff] [blame] | 50 | import com.android.server.wm.utils.InsetUtils; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 51 | |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 52 | import com.google.android.collect.Sets; |
| 53 | |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 54 | import java.io.PrintWriter; |
| 55 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 56 | /** |
| 57 | * When an app token becomes invisible, we take a snapshot (bitmap) of the corresponding task and |
| 58 | * put it into our cache. Internally we use gralloc buffers to be able to draw them wherever we |
| 59 | * like without any copying. |
| 60 | * <p> |
| 61 | * System applications may retrieve a snapshot to represent the current state of a task, and draw |
| 62 | * them in their own process. |
| 63 | * <p> |
| 64 | * When we task becomes visible again, we show a starting window with the snapshot as the content to |
| 65 | * make app transitions more responsive. |
| 66 | * <p> |
| 67 | * To access this class, acquire the global window manager lock. |
| 68 | */ |
| 69 | class TaskSnapshotController { |
Winson Chung | 3e13ef8 | 2017-06-29 12:41:14 -0700 | [diff] [blame] | 70 | private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskSnapshotController" : TAG_WM; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 71 | |
Jorim Jaggi | 8f4fe6e | 2017-03-14 18:21:40 +0100 | [diff] [blame] | 72 | /** |
| 73 | * Return value for {@link #getSnapshotMode}: We are allowed to take a real screenshot to be |
| 74 | * used as the snapshot. |
| 75 | */ |
| 76 | @VisibleForTesting |
| 77 | static final int SNAPSHOT_MODE_REAL = 0; |
| 78 | |
| 79 | /** |
| 80 | * Return value for {@link #getSnapshotMode}: We are not allowed to take a real screenshot but |
| 81 | * we should try to use the app theme to create a dummy representation of the app. |
| 82 | */ |
| 83 | @VisibleForTesting |
| 84 | static final int SNAPSHOT_MODE_APP_THEME = 1; |
| 85 | |
| 86 | /** |
| 87 | * Return value for {@link #getSnapshotMode}: We aren't allowed to take any snapshot. |
| 88 | */ |
| 89 | @VisibleForTesting |
| 90 | static final int SNAPSHOT_MODE_NONE = 2; |
| 91 | |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 92 | /** |
| 93 | * Constant for <code>scaleFactor</code> when calling {@link #snapshotTask} which is |
| 94 | * interpreted as using the most appropriate scale ratio for the system. |
| 95 | * This may yield a smaller ratio on low memory devices. |
| 96 | */ |
| 97 | @VisibleForTesting |
| 98 | static final float SNAPSHOT_SCALE_AUTO = -1f; |
| 99 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 100 | private final WindowManagerService mService; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 101 | |
Jorim Jaggi | 7361bab | 2017-01-16 17:17:58 +0100 | [diff] [blame] | 102 | private final TaskSnapshotCache mCache; |
Kevin | 716a9db | 2018-12-18 16:53:39 -0800 | [diff] [blame] | 103 | private final TaskSnapshotPersister mPersister; |
| 104 | private final TaskSnapshotLoader mLoader; |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 105 | private final ArraySet<Task> mSkipClosingAppSnapshotTasks = new ArraySet<>(); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 106 | private final ArraySet<Task> mTmpTasks = new ArraySet<>(); |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 107 | private final Handler mHandler = new Handler(); |
Winson Chung | ffde2ea | 2019-06-17 17:19:13 -0700 | [diff] [blame] | 108 | private final float mFullSnapshotScale; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 109 | |
chaviw | 23ee71c | 2017-12-18 11:29:41 -0800 | [diff] [blame] | 110 | private final Rect mTmpRect = new Rect(); |
| 111 | |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 112 | /** |
| 113 | * Flag indicating whether we are running on an Android TV device. |
| 114 | */ |
| 115 | private final boolean mIsRunningOnTv; |
| 116 | |
Juho Ha | f5dd7cc | 2017-06-15 11:38:56 +0900 | [diff] [blame] | 117 | /** |
| 118 | * Flag indicating whether we are running on an IoT device. |
| 119 | */ |
| 120 | private final boolean mIsRunningOnIoT; |
| 121 | |
Matthew Ng | 9537819 | 2017-08-16 11:57:00 -0700 | [diff] [blame] | 122 | /** |
| 123 | * Flag indicating whether we are running on an Android Wear device. |
| 124 | */ |
| 125 | private final boolean mIsRunningOnWear; |
| 126 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 127 | TaskSnapshotController(WindowManagerService service) { |
| 128 | mService = service; |
Kevin | 716a9db | 2018-12-18 16:53:39 -0800 | [diff] [blame] | 129 | mPersister = new TaskSnapshotPersister(mService, Environment::getDataSystemCeDirectory); |
| 130 | mLoader = new TaskSnapshotLoader(mPersister); |
Jorim Jaggi | 7361bab | 2017-01-16 17:17:58 +0100 | [diff] [blame] | 131 | mCache = new TaskSnapshotCache(mService, mLoader); |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 132 | mIsRunningOnTv = mService.mContext.getPackageManager().hasSystemFeature( |
| 133 | PackageManager.FEATURE_LEANBACK); |
Juho Ha | f5dd7cc | 2017-06-15 11:38:56 +0900 | [diff] [blame] | 134 | mIsRunningOnIoT = mService.mContext.getPackageManager().hasSystemFeature( |
| 135 | PackageManager.FEATURE_EMBEDDED); |
Matthew Ng | 9537819 | 2017-08-16 11:57:00 -0700 | [diff] [blame] | 136 | mIsRunningOnWear = mService.mContext.getPackageManager().hasSystemFeature( |
| 137 | PackageManager.FEATURE_WATCH); |
Winson Chung | ffde2ea | 2019-06-17 17:19:13 -0700 | [diff] [blame] | 138 | mFullSnapshotScale = mService.mContext.getResources().getFloat( |
| 139 | com.android.internal.R.dimen.config_fullTaskSnapshotScale); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Jorim Jaggi | f9084ec | 2017-01-16 13:16:59 +0100 | [diff] [blame] | 142 | void systemReady() { |
| 143 | mPersister.start(); |
| 144 | } |
| 145 | |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 146 | void onTransitionStarting(DisplayContent displayContent) { |
| 147 | handleClosingApps(displayContent.mClosingApps); |
Jorim Jaggi | 8b702ed | 2017-01-20 16:59:03 +0100 | [diff] [blame] | 148 | } |
| 149 | |
Jorim Jaggi | 8b702ed | 2017-01-20 16:59:03 +0100 | [diff] [blame] | 150 | /** |
| 151 | * Called when the visibility of an app changes outside of the regular app transition flow. |
| 152 | */ |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 153 | void notifyAppVisibilityChanged(ActivityRecord appWindowToken, boolean visible) { |
Jorim Jaggi | 8b702ed | 2017-01-20 16:59:03 +0100 | [diff] [blame] | 154 | if (!visible) { |
| 155 | handleClosingApps(Sets.newArraySet(appWindowToken)); |
| 156 | } |
| 157 | } |
| 158 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 159 | private void handleClosingApps(ArraySet<ActivityRecord> closingApps) { |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 160 | if (shouldDisableSnapshots()) { |
Jorim Jaggi | 3d73260 | 2017-02-22 17:56:40 +0100 | [diff] [blame] | 161 | return; |
| 162 | } |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 163 | |
| 164 | // We need to take a snapshot of the task if and only if all activities of the task are |
| 165 | // either closing or hidden. |
Jorim Jaggi | 8b702ed | 2017-01-20 16:59:03 +0100 | [diff] [blame] | 166 | getClosingTasks(closingApps, mTmpTasks); |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 167 | snapshotTasks(mTmpTasks); |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 168 | mSkipClosingAppSnapshotTasks.clear(); |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 169 | } |
| 170 | |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 171 | /** |
| 172 | * Adds the given {@param tasks} to the list of tasks which should not have their snapshots |
| 173 | * taken upon the next processing of the set of closing apps. The caller is responsible for |
| 174 | * calling {@link #snapshotTasks} to ensure that the task has an up-to-date snapshot. |
| 175 | */ |
| 176 | @VisibleForTesting |
| 177 | void addSkipClosingAppSnapshotTasks(ArraySet<Task> tasks) { |
| 178 | mSkipClosingAppSnapshotTasks.addAll(tasks); |
| 179 | } |
| 180 | |
| 181 | void snapshotTasks(ArraySet<Task> tasks) { |
Winson Chung | bed6c32 | 2019-12-20 16:23:10 -0800 | [diff] [blame] | 182 | snapshotTasks(tasks, false /* allowSnapshotHome */); |
Riddle Hsu | 440f88b | 2019-11-06 22:17:35 +0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | private void snapshotTasks(ArraySet<Task> tasks, boolean allowSnapshotHome) { |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 186 | for (int i = tasks.size() - 1; i >= 0; i--) { |
| 187 | final Task task = tasks.valueAt(i); |
Jorim Jaggi | 8f4fe6e | 2017-03-14 18:21:40 +0100 | [diff] [blame] | 188 | final TaskSnapshot snapshot; |
Riddle Hsu | 440f88b | 2019-11-06 22:17:35 +0800 | [diff] [blame] | 189 | final boolean snapshotHome = allowSnapshotHome && task.isActivityTypeHome(); |
| 190 | if (snapshotHome) { |
| 191 | snapshot = snapshotTask(task); |
| 192 | } else { |
| 193 | switch (getSnapshotMode(task)) { |
| 194 | case SNAPSHOT_MODE_NONE: |
| 195 | continue; |
| 196 | case SNAPSHOT_MODE_APP_THEME: |
| 197 | snapshot = drawAppThemeSnapshot(task); |
| 198 | break; |
| 199 | case SNAPSHOT_MODE_REAL: |
| 200 | snapshot = snapshotTask(task); |
| 201 | break; |
| 202 | default: |
| 203 | snapshot = null; |
| 204 | break; |
| 205 | } |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 206 | } |
Jorim Jaggi | e2c77f9 | 2016-12-29 14:57:22 +0100 | [diff] [blame] | 207 | if (snapshot != null) { |
Winson Chung | 3e13ef8 | 2017-06-29 12:41:14 -0700 | [diff] [blame] | 208 | final GraphicBuffer buffer = snapshot.getSnapshot(); |
| 209 | if (buffer.getWidth() == 0 || buffer.getHeight() == 0) { |
| 210 | buffer.destroy(); |
| 211 | Slog.e(TAG, "Invalid task snapshot dimensions " + buffer.getWidth() + "x" |
| 212 | + buffer.getHeight()); |
| 213 | } else { |
| 214 | mCache.putSnapshot(task, snapshot); |
Riddle Hsu | 440f88b | 2019-11-06 22:17:35 +0800 | [diff] [blame] | 215 | // Don't persist or notify the change for the temporal snapshot. |
| 216 | if (!snapshotHome) { |
| 217 | mPersister.persistSnapshot(task.mTaskId, task.mUserId, snapshot); |
| 218 | task.onSnapshotChanged(snapshot); |
| 219 | } |
Jorim Jaggi | fb9d78a | 2017-01-05 18:57:12 +0100 | [diff] [blame] | 220 | } |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | } |
| 224 | |
Jorim Jaggi | 7361bab | 2017-01-16 17:17:58 +0100 | [diff] [blame] | 225 | /** |
| 226 | * Retrieves a snapshot. If {@param restoreFromDisk} equals {@code true}, DO HOLD THE WINDOW |
| 227 | * MANAGER LOCK WHEN CALLING THIS METHOD! |
| 228 | */ |
Jorim Jaggi | 35e3f53 | 2017-03-17 17:06:50 +0100 | [diff] [blame] | 229 | @Nullable TaskSnapshot getSnapshot(int taskId, int userId, boolean restoreFromDisk, |
| 230 | boolean reducedResolution) { |
Matthew Ng | cb7ac67 | 2017-07-21 17:27:42 -0700 | [diff] [blame] | 231 | return mCache.getSnapshot(taskId, userId, restoreFromDisk, reducedResolution |
| 232 | || DISABLE_FULL_SIZED_BITMAPS); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /** |
Jay Aliomer | 8b2671b | 2019-10-24 13:18:06 -0400 | [diff] [blame] | 236 | * @see WindowManagerInternal#clearSnapshotCache |
| 237 | */ |
| 238 | public void clearSnapshotCache() { |
| 239 | mCache.clearRunningCache(); |
| 240 | } |
| 241 | |
| 242 | /** |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 243 | * Creates a starting surface for {@param token} with {@param snapshot}. DO NOT HOLD THE WINDOW |
| 244 | * MANAGER LOCK WHEN CALLING THIS METHOD! |
| 245 | */ |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 246 | StartingSurface createStartingSurface(ActivityRecord activity, |
Jorim Jaggi | 30d64f3 | 2017-04-07 16:33:17 +0200 | [diff] [blame] | 247 | TaskSnapshot snapshot) { |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 248 | return TaskSnapshotSurface.create(mService, activity, snapshot); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Issei Suzuki | 88e2142 | 2018-07-24 16:29:09 +0200 | [diff] [blame] | 251 | /** |
| 252 | * Find the window for a given task to take a snapshot. Top child of the task is usually the one |
| 253 | * we're looking for, but during app transitions, trampoline activities can appear in the |
| 254 | * children, which should be ignored. |
| 255 | */ |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 256 | @Nullable private ActivityRecord findAppTokenForSnapshot(Task task) { |
Wale Ogunwale | a38654f | 2019-11-17 20:37:15 -0800 | [diff] [blame] | 257 | return task.getActivity((r) -> { |
| 258 | if (r == null || !r.isSurfaceShowing() || r.findMainWindow() == null) { |
| 259 | return false; |
Issei Suzuki | 88e2142 | 2018-07-24 16:29:09 +0200 | [diff] [blame] | 260 | } |
Wale Ogunwale | a38654f | 2019-11-17 20:37:15 -0800 | [diff] [blame] | 261 | return r.forAllWindows( |
Issei Suzuki | 88e2142 | 2018-07-24 16:29:09 +0200 | [diff] [blame] | 262 | // Ensure at least one window for the top app is visible before attempting to |
| 263 | // take a screenshot. Visible here means that the WSA surface is shown and has |
| 264 | // an alpha greater than 0. |
| 265 | ws -> ws.mWinAnimator != null && ws.mWinAnimator.getShown() |
| 266 | && ws.mWinAnimator.mLastAlpha > 0f, true /* traverseTopToBottom */); |
Wale Ogunwale | a38654f | 2019-11-17 20:37:15 -0800 | [diff] [blame] | 267 | |
| 268 | }); |
Issei Suzuki | 88e2142 | 2018-07-24 16:29:09 +0200 | [diff] [blame] | 269 | } |
| 270 | |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 271 | /** |
| 272 | * Validates the state of the Task is appropriate to capture a snapshot, collects |
| 273 | * information from the task and populates the builder. |
| 274 | * |
| 275 | * @param task the task to capture |
| 276 | * @param scaleFraction the scale fraction between 0-1.0, or {@link #SNAPSHOT_SCALE_AUTO} |
| 277 | * to automatically select |
| 278 | * @param pixelFormat the desired pixel format, or {@link PixelFormat#UNKNOWN} to |
| 279 | * automatically select |
| 280 | * @param builder the snapshot builder to populate |
| 281 | * |
| 282 | * @return true if the state of the task is ok to proceed |
| 283 | */ |
Riddle Hsu | c802e4b | 2019-12-20 16:54:33 +0800 | [diff] [blame] | 284 | @VisibleForTesting |
| 285 | boolean prepareTaskSnapshot(Task task, float scaleFraction, int pixelFormat, |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 286 | TaskSnapshot.Builder builder) { |
| 287 | if (!mService.mPolicy.isScreenOn()) { |
| 288 | if (DEBUG_SCREENSHOT) { |
| 289 | Slog.i(TAG_WM, "Attempted to take screenshot while display was off."); |
| 290 | } |
| 291 | return false; |
| 292 | } |
| 293 | final ActivityRecord activity = findAppTokenForSnapshot(task); |
| 294 | if (activity == null) { |
| 295 | if (DEBUG_SCREENSHOT) { |
| 296 | Slog.w(TAG_WM, "Failed to take screenshot. No visible windows for " + task); |
| 297 | } |
| 298 | return false; |
| 299 | } |
| 300 | if (activity.hasCommittedReparentToAnimationLeash()) { |
| 301 | if (DEBUG_SCREENSHOT) { |
| 302 | Slog.w(TAG_WM, "Failed to take screenshot. App is animating " + activity); |
| 303 | } |
| 304 | return false; |
| 305 | } |
| 306 | |
| 307 | final WindowState mainWindow = activity.findMainWindow(); |
| 308 | if (mainWindow == null) { |
| 309 | Slog.w(TAG_WM, "Failed to take screenshot. No main window for " + task); |
| 310 | return false; |
| 311 | } |
| 312 | |
| 313 | builder.setIsRealSnapshot(true); |
| 314 | builder.setId(System.currentTimeMillis()); |
| 315 | builder.setContentInsets(getInsets(mainWindow)); |
| 316 | |
| 317 | final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic(); |
| 318 | |
| 319 | if (scaleFraction == SNAPSHOT_SCALE_AUTO) { |
| 320 | builder.setScaleFraction(isLowRamDevice |
| 321 | ? mPersister.getReducedScale() |
| 322 | : mFullSnapshotScale); |
| 323 | builder.setReducedResolution(isLowRamDevice); |
| 324 | } else { |
| 325 | builder.setScaleFraction(scaleFraction); |
| 326 | builder.setReducedResolution(scaleFraction < 1.0f); |
| 327 | } |
| 328 | |
| 329 | final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE; |
| 330 | final boolean isShowWallpaper = (mainWindow.getAttrs().flags & FLAG_SHOW_WALLPAPER) != 0; |
| 331 | |
| 332 | if (pixelFormat == PixelFormat.UNKNOWN) { |
| 333 | pixelFormat = mPersister.use16BitFormat() && activity.fillsParent() |
| 334 | && !(isWindowTranslucent && isShowWallpaper) |
| 335 | ? PixelFormat.RGB_565 |
| 336 | : PixelFormat.RGBA_8888; |
| 337 | } |
| 338 | |
| 339 | final boolean isTranslucent = PixelFormat.formatHasAlpha(pixelFormat) |
| 340 | && (!activity.fillsParent() || isWindowTranslucent); |
| 341 | |
| 342 | builder.setTopActivityComponent(activity.mActivityComponent); |
Riddle Hsu | c802e4b | 2019-12-20 16:54:33 +0800 | [diff] [blame] | 343 | builder.setPixelFormat(pixelFormat); |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 344 | builder.setIsTranslucent(isTranslucent); |
| 345 | builder.setOrientation(activity.getTask().getConfiguration().orientation); |
| 346 | builder.setWindowingMode(task.getWindowingMode()); |
| 347 | builder.setSystemUiVisibility(getSystemUiVisibility(task)); |
| 348 | return true; |
| 349 | } |
| 350 | |
Evan Rosky | 08e2093 | 2019-05-14 10:54:07 -0700 | [diff] [blame] | 351 | @Nullable |
| 352 | SurfaceControl.ScreenshotGraphicBuffer createTaskSnapshot(@NonNull Task task, |
| 353 | float scaleFraction) { |
Chiawei Wang | 02202d1 | 2019-01-03 18:12:13 +0800 | [diff] [blame] | 354 | return createTaskSnapshot(task, scaleFraction, PixelFormat.RGBA_8888); |
| 355 | } |
| 356 | |
| 357 | @Nullable |
| 358 | SurfaceControl.ScreenshotGraphicBuffer createTaskSnapshot(@NonNull Task task, |
| 359 | float scaleFraction, int pixelFormat) { |
Evan Rosky | 08e2093 | 2019-05-14 10:54:07 -0700 | [diff] [blame] | 360 | if (task.getSurfaceControl() == null) { |
| 361 | if (DEBUG_SCREENSHOT) { |
| 362 | Slog.w(TAG_WM, "Failed to take screenshot. No surface control for " + task); |
| 363 | } |
| 364 | return null; |
| 365 | } |
| 366 | task.getBounds(mTmpRect); |
| 367 | mTmpRect.offsetTo(0, 0); |
| 368 | final SurfaceControl.ScreenshotGraphicBuffer screenshotBuffer = |
| 369 | SurfaceControl.captureLayers( |
Chiawei Wang | 02202d1 | 2019-01-03 18:12:13 +0800 | [diff] [blame] | 370 | task.getSurfaceControl(), mTmpRect, scaleFraction, pixelFormat); |
Evan Rosky | 08e2093 | 2019-05-14 10:54:07 -0700 | [diff] [blame] | 371 | final GraphicBuffer buffer = screenshotBuffer != null ? screenshotBuffer.getGraphicBuffer() |
| 372 | : null; |
| 373 | if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) { |
| 374 | return null; |
| 375 | } |
| 376 | return screenshotBuffer; |
| 377 | } |
| 378 | |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 379 | @Nullable |
| 380 | TaskSnapshot snapshotTask(Task task) { |
| 381 | return snapshotTask(task, SNAPSHOT_SCALE_AUTO, PixelFormat.UNKNOWN); |
| 382 | } |
| 383 | |
| 384 | @Nullable |
| 385 | TaskSnapshot snapshotTask(Task task, float scaleFraction, int pixelFormat) { |
| 386 | TaskSnapshot.Builder builder = new TaskSnapshot.Builder(); |
| 387 | |
| 388 | if (!prepareTaskSnapshot(task, scaleFraction, pixelFormat, builder)) { |
| 389 | // Failed some pre-req. Has been logged. |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 390 | return null; |
| 391 | } |
chaviw | 7f1fa99 | 2018-01-10 13:52:12 -0800 | [diff] [blame] | 392 | |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 393 | final SurfaceControl.ScreenshotGraphicBuffer screenshotBuffer = |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 394 | createTaskSnapshot(task, builder.getScaleFraction(), |
| 395 | builder.getPixelFormat()); |
Evan Rosky | 08e2093 | 2019-05-14 10:54:07 -0700 | [diff] [blame] | 396 | |
| 397 | if (screenshotBuffer == null) { |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 398 | // Failed to acquire image. Has been logged. |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 399 | return null; |
| 400 | } |
Mark Renouf | 98ba8e6 | 2019-11-18 12:42:16 -0500 | [diff] [blame] | 401 | builder.setSnapshot(screenshotBuffer.getGraphicBuffer()); |
| 402 | builder.setColorSpace(screenshotBuffer.getColorSpace()); |
| 403 | return builder.build(); |
Jorim Jaggi | 30d64f3 | 2017-04-07 16:33:17 +0200 | [diff] [blame] | 404 | } |
| 405 | |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 406 | private boolean shouldDisableSnapshots() { |
Jorim Jaggi | e7d2b85 | 2017-08-28 17:55:15 +0200 | [diff] [blame] | 407 | return mIsRunningOnWear || mIsRunningOnTv || mIsRunningOnIoT; |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 408 | } |
| 409 | |
Jorim Jaggi | 817ebdd | 2018-03-26 15:46:01 +0200 | [diff] [blame] | 410 | private Rect getInsets(WindowState state) { |
Adrian Roos | 20e0789 | 2018-02-23 19:12:01 +0100 | [diff] [blame] | 411 | // XXX(b/72757033): These are insets relative to the window frame, but we're really |
| 412 | // interested in the insets relative to the task bounds. |
chaviw | 9c81e63 | 2018-07-31 11:17:52 -0700 | [diff] [blame] | 413 | final Rect insets = minRect(state.getContentInsets(), state.getStableInsets()); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 414 | InsetUtils.addInsets(insets, state.mActivityRecord.getLetterboxInsets()); |
Adrian Roos | 20e0789 | 2018-02-23 19:12:01 +0100 | [diff] [blame] | 415 | return insets; |
| 416 | } |
Adrian Roos | 98a146d | 2017-11-29 16:39:44 +0100 | [diff] [blame] | 417 | |
Adrian Roos | 20e0789 | 2018-02-23 19:12:01 +0100 | [diff] [blame] | 418 | private Rect minRect(Rect rect1, Rect rect2) { |
| 419 | return new Rect(Math.min(rect1.left, rect2.left), |
| 420 | Math.min(rect1.top, rect2.top), |
| 421 | Math.min(rect1.right, rect2.right), |
| 422 | Math.min(rect1.bottom, rect2.bottom)); |
| 423 | } |
Adrian Roos | 98a146d | 2017-11-29 16:39:44 +0100 | [diff] [blame] | 424 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 425 | /** |
| 426 | * Retrieves all closing tasks based on the list of closing apps during an app transition. |
| 427 | */ |
| 428 | @VisibleForTesting |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 429 | void getClosingTasks(ArraySet<ActivityRecord> closingApps, ArraySet<Task> outClosingTasks) { |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 430 | outClosingTasks.clear(); |
| 431 | for (int i = closingApps.size() - 1; i >= 0; i--) { |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 432 | final ActivityRecord activity = closingApps.valueAt(i); |
| 433 | final Task task = activity.getTask(); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 434 | |
| 435 | // If the task of the app is not visible anymore, it means no other app in that task |
| 436 | // is opening. Thus, the task is closing. |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 437 | if (task != null && !task.isVisible() && !mSkipClosingAppSnapshotTasks.contains(task)) { |
Bryce Lee | 6d41026 | 2017-02-28 15:30:17 -0800 | [diff] [blame] | 438 | outClosingTasks.add(task); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
Jorim Jaggi | 0fe7ce96 | 2017-02-22 16:45:48 +0100 | [diff] [blame] | 443 | @VisibleForTesting |
Jorim Jaggi | 8f4fe6e | 2017-03-14 18:21:40 +0100 | [diff] [blame] | 444 | int getSnapshotMode(Task task) { |
Wale Ogunwale | a38654f | 2019-11-17 20:37:15 -0800 | [diff] [blame] | 445 | final ActivityRecord topChild = task.getTopMostActivity(); |
Winson Chung | bff1837 | 2018-04-27 16:12:54 -0700 | [diff] [blame] | 446 | if (!task.isActivityTypeStandardOrUndefined() && !task.isActivityTypeAssistant()) { |
Jorim Jaggi | 8f4fe6e | 2017-03-14 18:21:40 +0100 | [diff] [blame] | 447 | return SNAPSHOT_MODE_NONE; |
Jorim Jaggi | d635a4a | 2017-05-03 15:21:26 +0200 | [diff] [blame] | 448 | } else if (topChild != null && topChild.shouldUseAppThemeSnapshot()) { |
Jorim Jaggi | 8f4fe6e | 2017-03-14 18:21:40 +0100 | [diff] [blame] | 449 | return SNAPSHOT_MODE_APP_THEME; |
| 450 | } else { |
| 451 | return SNAPSHOT_MODE_REAL; |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * If we are not allowed to take a real screenshot, this attempts to represent the app as best |
| 457 | * as possible by using the theme's window background. |
| 458 | */ |
| 459 | private TaskSnapshot drawAppThemeSnapshot(Task task) { |
Wale Ogunwale | a38654f | 2019-11-17 20:37:15 -0800 | [diff] [blame] | 460 | final ActivityRecord topChild = task.getTopMostActivity(); |
Jorim Jaggi | 8f4fe6e | 2017-03-14 18:21:40 +0100 | [diff] [blame] | 461 | if (topChild == null) { |
| 462 | return null; |
| 463 | } |
| 464 | final WindowState mainWindow = topChild.findMainWindow(); |
| 465 | if (mainWindow == null) { |
| 466 | return null; |
| 467 | } |
Winson Chung | 51f42d2 | 2018-02-01 14:59:38 -0800 | [diff] [blame] | 468 | final int color = ColorUtils.setAlphaComponent( |
| 469 | task.getTaskDescription().getBackgroundColor(), 255); |
Jorim Jaggi | d635a4a | 2017-05-03 15:21:26 +0200 | [diff] [blame] | 470 | final LayoutParams attrs = mainWindow.getAttrs(); |
| 471 | final SystemBarBackgroundPainter decorPainter = new SystemBarBackgroundPainter(attrs.flags, |
Winson Chung | ffde2ea | 2019-06-17 17:19:13 -0700 | [diff] [blame] | 472 | attrs.privateFlags, attrs.systemUiVisibility, task.getTaskDescription(), |
Jorim Jaggi | 0dd0cf9 | 2019-12-27 15:17:44 +0100 | [diff] [blame^] | 473 | mFullSnapshotScale, mainWindow.getRequestedInsetsState()); |
Winson Chung | ffde2ea | 2019-06-17 17:19:13 -0700 | [diff] [blame] | 474 | final int width = (int) (task.getBounds().width() * mFullSnapshotScale); |
| 475 | final int height = (int) (task.getBounds().height() * mFullSnapshotScale); |
Winson Chung | 9109276 | 2017-05-24 14:08:48 -0700 | [diff] [blame] | 476 | |
| 477 | final RenderNode node = RenderNode.create("TaskSnapshotController", null); |
| 478 | node.setLeftTopRightBottom(0, 0, width, height); |
| 479 | node.setClipToBounds(false); |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 480 | final RecordingCanvas c = node.start(width, height); |
Winson Chung | 9109276 | 2017-05-24 14:08:48 -0700 | [diff] [blame] | 481 | c.drawColor(color); |
chaviw | 9c81e63 | 2018-07-31 11:17:52 -0700 | [diff] [blame] | 482 | decorPainter.setInsets(mainWindow.getContentInsets(), mainWindow.getStableInsets()); |
Jorim Jaggi | d635a4a | 2017-05-03 15:21:26 +0200 | [diff] [blame] | 483 | decorPainter.drawDecors(c, null /* statusBarExcludeFrame */); |
Winson Chung | 9109276 | 2017-05-24 14:08:48 -0700 | [diff] [blame] | 484 | node.end(c); |
| 485 | final Bitmap hwBitmap = ThreadedRenderer.createHardwareBitmap(node, width, height); |
Winson Chung | 6267f99 | 2017-10-06 14:01:10 -0700 | [diff] [blame] | 486 | if (hwBitmap == null) { |
| 487 | return null; |
| 488 | } |
Winson Chung | 67d93c2 | 2019-06-13 10:36:58 -0700 | [diff] [blame] | 489 | |
Winson Chung | 02378b4 | 2018-06-04 16:40:09 -0700 | [diff] [blame] | 490 | // Note, the app theme snapshot is never translucent because we enforce a non-translucent |
| 491 | // color above |
Hongwei Wang | 3b9bdcf | 2019-07-15 10:23:03 -0700 | [diff] [blame] | 492 | return new TaskSnapshot( |
| 493 | System.currentTimeMillis() /* id */, |
| 494 | topChild.mActivityComponent, hwBitmap.createGraphicBufferHandle(), |
Winson Chung | 67d93c2 | 2019-06-13 10:36:58 -0700 | [diff] [blame] | 495 | hwBitmap.getColorSpace(), topChild.getTask().getConfiguration().orientation, |
Jorim Jaggi | 2be23a9 | 2019-06-13 16:22:35 +0200 | [diff] [blame] | 496 | getInsets(mainWindow), ActivityManager.isLowRamDeviceStatic() /* reduced */, |
Winson Chung | ffde2ea | 2019-06-17 17:19:13 -0700 | [diff] [blame] | 497 | mFullSnapshotScale, false /* isRealSnapshot */, task.getWindowingMode(), |
Peiyong Lin | 21e499a | 2019-04-03 16:37:46 -0700 | [diff] [blame] | 498 | getSystemUiVisibility(task), false); |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 499 | } |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 500 | |
| 501 | /** |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 502 | * Called when an {@link ActivityRecord} has been removed. |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 503 | */ |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 504 | void onAppRemoved(ActivityRecord activity) { |
| 505 | mCache.onAppRemoved(activity); |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | /** |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 509 | * Called when the process of an {@link ActivityRecord} has died. |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 510 | */ |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 511 | void onAppDied(ActivityRecord activity) { |
| 512 | mCache.onAppDied(activity); |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Jorim Jaggi | f9084ec | 2017-01-16 13:16:59 +0100 | [diff] [blame] | 515 | void notifyTaskRemovedFromRecents(int taskId, int userId) { |
Jorim Jaggi | 7361bab | 2017-01-16 17:17:58 +0100 | [diff] [blame] | 516 | mCache.onTaskRemoved(taskId); |
Jorim Jaggi | f9084ec | 2017-01-16 13:16:59 +0100 | [diff] [blame] | 517 | mPersister.onTaskRemovedFromRecents(taskId, userId); |
| 518 | } |
| 519 | |
Riddle Hsu | 440f88b | 2019-11-06 22:17:35 +0800 | [diff] [blame] | 520 | void removeSnapshotCache(int taskId) { |
| 521 | mCache.removeRunningEntry(taskId); |
| 522 | } |
| 523 | |
Jorim Jaggi | f9084ec | 2017-01-16 13:16:59 +0100 | [diff] [blame] | 524 | /** |
| 525 | * See {@link TaskSnapshotPersister#removeObsoleteFiles} |
| 526 | */ |
| 527 | void removeObsoleteTaskFiles(ArraySet<Integer> persistentTaskIds, int[] runningUserIds) { |
| 528 | mPersister.removeObsoleteFiles(persistentTaskIds, runningUserIds); |
| 529 | } |
| 530 | |
Jorim Jaggi | a41b729 | 2017-05-11 23:50:34 +0200 | [diff] [blame] | 531 | /** |
| 532 | * Temporarily pauses/unpauses persisting of task snapshots. |
| 533 | * |
| 534 | * @param paused Whether task snapshot persisting should be paused. |
| 535 | */ |
| 536 | void setPersisterPaused(boolean paused) { |
| 537 | mPersister.setPaused(paused); |
| 538 | } |
| 539 | |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 540 | /** |
| 541 | * Called when screen is being turned off. |
| 542 | */ |
| 543 | void screenTurningOff(ScreenOffListener listener) { |
Keyvan Amiri | e681cec | 2017-06-05 22:48:26 -0700 | [diff] [blame] | 544 | if (shouldDisableSnapshots()) { |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 545 | listener.onScreenOff(); |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | // We can't take a snapshot when screen is off, so take a snapshot now! |
| 550 | mHandler.post(() -> { |
| 551 | try { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 552 | synchronized (mService.mGlobalLock) { |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 553 | mTmpTasks.clear(); |
| 554 | mService.mRoot.forAllTasks(task -> { |
| 555 | if (task.isVisible()) { |
| 556 | mTmpTasks.add(task); |
| 557 | } |
| 558 | }); |
Riddle Hsu | 440f88b | 2019-11-06 22:17:35 +0800 | [diff] [blame] | 559 | // Allow taking snapshot of home when turning screen off to reduce the delay of |
| 560 | // unlocking/waking to home. |
| 561 | snapshotTasks(mTmpTasks, true /* allowSnapshotHome */); |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 562 | } |
| 563 | } finally { |
| 564 | listener.onScreenOff(); |
| 565 | } |
| 566 | }); |
| 567 | } |
| 568 | |
Winson Chung | 173020c | 2018-05-04 15:36:47 -0700 | [diff] [blame] | 569 | /** |
Riddle Hsu | 84bc3d7 | 2019-12-19 19:24:07 +0800 | [diff] [blame] | 570 | * @return The SystemUI visibility flags for the top fullscreen opaque window in the given |
Winson Chung | 173020c | 2018-05-04 15:36:47 -0700 | [diff] [blame] | 571 | * {@param task}. |
| 572 | */ |
| 573 | private int getSystemUiVisibility(Task task) { |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 574 | final ActivityRecord topFullscreenActivity = task.getTopFullscreenActivity(); |
Riddle Hsu | 84bc3d7 | 2019-12-19 19:24:07 +0800 | [diff] [blame] | 575 | final WindowState topFullscreenOpaqueWindow = topFullscreenActivity != null |
| 576 | ? topFullscreenActivity.getTopFullscreenOpaqueWindow() |
Winson Chung | 173020c | 2018-05-04 15:36:47 -0700 | [diff] [blame] | 577 | : null; |
Riddle Hsu | 84bc3d7 | 2019-12-19 19:24:07 +0800 | [diff] [blame] | 578 | if (topFullscreenOpaqueWindow != null) { |
| 579 | return topFullscreenOpaqueWindow.getSystemUiVisibility(); |
Winson Chung | 173020c | 2018-05-04 15:36:47 -0700 | [diff] [blame] | 580 | } |
| 581 | return 0; |
| 582 | } |
| 583 | |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 584 | void dump(PrintWriter pw, String prefix) { |
Winson Chung | ffde2ea | 2019-06-17 17:19:13 -0700 | [diff] [blame] | 585 | pw.println(prefix + "mFullSnapshotScale=" + mFullSnapshotScale); |
Jorim Jaggi | 10abe2f | 2017-01-03 16:44:46 +0100 | [diff] [blame] | 586 | mCache.dump(pw, prefix); |
| 587 | } |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 588 | } |