Merge "Remove home snapshot immediately" into rvc-qpr-dev

This commit is contained in:
Riddle Hsu
2020-08-06 07:17:45 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 4 deletions

View File

@@ -16,6 +16,7 @@
package com.android.server.wm; package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.graphics.Color.WHITE; import static android.graphics.Color.WHITE;
import static android.graphics.Color.alpha; import static android.graphics.Color.alpha;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
@@ -142,6 +143,7 @@ class TaskSnapshotSurface implements StartingSurface {
private final Handler mHandler; private final Handler mHandler;
private boolean mSizeMismatch; private boolean mSizeMismatch;
private final Paint mBackgroundPaint = new Paint(); private final Paint mBackgroundPaint = new Paint();
private final int mActivityType;
private final int mStatusBarColor; private final int mStatusBarColor;
@VisibleForTesting final SystemBarBackgroundPainter mSystemBarBackgroundPainter; @VisibleForTesting final SystemBarBackgroundPainter mSystemBarBackgroundPainter;
private final int mOrientationOnCreation; private final int mOrientationOnCreation;
@@ -173,6 +175,7 @@ class TaskSnapshotSurface implements StartingSurface {
final int windowFlags; final int windowFlags;
final int windowPrivateFlags; final int windowPrivateFlags;
final int currentOrientation; final int currentOrientation;
final int activityType;
final InsetsState insetsState; final InsetsState insetsState;
synchronized (service.mGlobalLock) { synchronized (service.mGlobalLock) {
final WindowState mainWindow = activity.findMainWindow(); final WindowState mainWindow = activity.findMainWindow();
@@ -241,6 +244,7 @@ class TaskSnapshotSurface implements StartingSurface {
taskBounds = new Rect(); taskBounds = new Rect();
task.getBounds(taskBounds); task.getBounds(taskBounds);
currentOrientation = topFullscreenOpaqueWindow.getConfiguration().orientation; currentOrientation = topFullscreenOpaqueWindow.getConfiguration().orientation;
activityType = activity.getActivityType();
final InsetsPolicy insetsPolicy = topFullscreenOpaqueWindow.getDisplayContent() final InsetsPolicy insetsPolicy = topFullscreenOpaqueWindow.getDisplayContent()
.getInsetsPolicy(); .getInsetsPolicy();
@@ -261,7 +265,8 @@ class TaskSnapshotSurface implements StartingSurface {
} }
final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window, final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis, surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
windowFlags, windowPrivateFlags, taskBounds, currentOrientation, insetsState); windowFlags, windowPrivateFlags, taskBounds, currentOrientation, activityType,
insetsState);
window.setOuter(snapshotSurface); window.setOuter(snapshotSurface);
try { try {
session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1, session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,
@@ -282,7 +287,7 @@ class TaskSnapshotSurface implements StartingSurface {
TaskSnapshotSurface(WindowManagerService service, Window window, SurfaceControl surfaceControl, TaskSnapshotSurface(WindowManagerService service, Window window, SurfaceControl surfaceControl,
TaskSnapshot snapshot, CharSequence title, TaskDescription taskDescription, TaskSnapshot snapshot, CharSequence title, TaskDescription taskDescription,
int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds, int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds,
int currentOrientation, InsetsState insetsState) { int currentOrientation, int activityType, InsetsState insetsState) {
mService = service; mService = service;
mSurface = service.mSurfaceFactory.get(); mSurface = service.mSurfaceFactory.get();
mHandler = new Handler(mService.mH.getLooper()); mHandler = new Handler(mService.mH.getLooper());
@@ -298,6 +303,7 @@ class TaskSnapshotSurface implements StartingSurface {
windowPrivateFlags, sysUiVis, taskDescription, 1f, insetsState); windowPrivateFlags, sysUiVis, taskDescription, 1f, insetsState);
mStatusBarColor = taskDescription.getStatusBarColor(); mStatusBarColor = taskDescription.getStatusBarColor();
mOrientationOnCreation = currentOrientation; mOrientationOnCreation = currentOrientation;
mActivityType = activityType;
mTransaction = mService.mTransactionFactory.get(); mTransaction = mService.mTransactionFactory.get();
} }
@@ -305,7 +311,9 @@ class TaskSnapshotSurface implements StartingSurface {
public void remove() { public void remove() {
synchronized (mService.mGlobalLock) { synchronized (mService.mGlobalLock) {
final long now = SystemClock.uptimeMillis(); final long now = SystemClock.uptimeMillis();
if (mSizeMismatch && now - mShownTime < SIZE_MISMATCH_MINIMUM_TIME_MS) { if (mSizeMismatch && now - mShownTime < SIZE_MISMATCH_MINIMUM_TIME_MS
// Show the latest content as soon as possible for unlocking to home.
&& mActivityType != ACTIVITY_TYPE_HOME) {
mHandler.postAtTime(this::remove, mShownTime + SIZE_MISMATCH_MINIMUM_TIME_MS); mHandler.postAtTime(this::remove, mShownTime + SIZE_MISMATCH_MINIMUM_TIME_MS);
ProtoLog.v(WM_DEBUG_STARTING_WINDOW, ProtoLog.v(WM_DEBUG_STARTING_WINDOW,
"Defer removing snapshot surface in %dms", (now - mShownTime)); "Defer removing snapshot surface in %dms", (now - mShownTime));

View File

@@ -16,6 +16,7 @@
package com.android.server.wm; package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
@@ -88,7 +89,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
0 /* systemUiVisibility */, false /* isTranslucent */); 0 /* systemUiVisibility */, false /* isTranslucent */);
mSurface = new TaskSnapshotSurface(mWm, new Window(), new SurfaceControl(), snapshot, "Test", mSurface = new TaskSnapshotSurface(mWm, new Window(), new SurfaceControl(), snapshot, "Test",
createTaskDescription(Color.WHITE, Color.RED, Color.BLUE), sysuiVis, windowFlags, 0, createTaskDescription(Color.WHITE, Color.RED, Color.BLUE), sysuiVis, windowFlags, 0,
taskBounds, ORIENTATION_PORTRAIT, new InsetsState()); taskBounds, ORIENTATION_PORTRAIT, ACTIVITY_TYPE_STANDARD, new InsetsState());
} }
private static TaskDescription createTaskDescription(int background, int statusBar, private static TaskDescription createTaskDescription(int background, int statusBar,