Merge "Use opaque window as reference to show snapshot starting window"

This commit is contained in:
TreeHugger Robot
2019-12-19 13:52:40 +00:00
committed by Android (Google) Code Review
6 changed files with 34 additions and 33 deletions

View File

@@ -335,13 +335,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
*/
boolean isAnimatingLw();
/**
* @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
* for example) will be affected by the flags specified in this window. This is the
* case when the surface is on screen but not exiting.
*/
boolean canAffectSystemUiFlags();
/**
* Is this window considered to be gone for purposes of layout?
*/

View File

@@ -5576,12 +5576,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
/**
* @return The to top most child window for which {@link LayoutParams#isFullscreen()} returns
* true.
* true and isn't fully transparent.
*/
WindowState getTopFullscreenWindow() {
WindowState getTopFullscreenOpaqueWindow() {
for (int i = mChildren.size() - 1; i >= 0; i--) {
final WindowState win = mChildren.get(i);
if (win != null && win.mAttrs.isFullscreen()) {
if (win != null && win.mAttrs.isFullscreen() && !win.isFullyTransparent()) {
return win;
}
}

View File

@@ -565,16 +565,16 @@ class TaskSnapshotController {
}
/**
* @return The SystemUI visibility flags for the top fullscreen window in the given
* @return The SystemUI visibility flags for the top fullscreen opaque window in the given
* {@param task}.
*/
private int getSystemUiVisibility(Task task) {
final ActivityRecord topFullscreenActivity = task.getTopFullscreenActivity();
final WindowState topFullscreenWindow = topFullscreenActivity != null
? topFullscreenActivity.getTopFullscreenWindow()
final WindowState topFullscreenOpaqueWindow = topFullscreenActivity != null
? topFullscreenActivity.getTopFullscreenOpaqueWindow()
: null;
if (topFullscreenWindow != null) {
return topFullscreenWindow.getSystemUiVisibility();
if (topFullscreenOpaqueWindow != null) {
return topFullscreenOpaqueWindow.getSystemUiVisibility();
}
return 0;
}

View File

@@ -155,7 +155,7 @@ class TaskSnapshotSurface implements StartingSurface {
final MergedConfiguration tmpMergedConfiguration = new MergedConfiguration();
final TaskDescription taskDescription = new TaskDescription();
taskDescription.setBackgroundColor(WHITE);
final WindowState topFullscreenWindow;
final WindowState topFullscreenOpaqueWindow;
final int sysUiVis;
final int windowFlags;
final int windowPrivateFlags;
@@ -175,15 +175,15 @@ class TaskSnapshotSurface implements StartingSurface {
+ task);
return null;
}
topFullscreenWindow = topFullscreenActivity.getTopFullscreenWindow();
if (mainWindow == null || topFullscreenWindow == null) {
topFullscreenOpaqueWindow = topFullscreenActivity.getTopFullscreenOpaqueWindow();
if (mainWindow == null || topFullscreenOpaqueWindow == null) {
Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find main window for activity="
+ activity);
return null;
}
sysUiVis = topFullscreenWindow.getSystemUiVisibility();
windowFlags = topFullscreenWindow.getAttrs().flags;
windowPrivateFlags = topFullscreenWindow.getAttrs().privateFlags;
sysUiVis = topFullscreenOpaqueWindow.getSystemUiVisibility();
windowFlags = topFullscreenOpaqueWindow.getAttrs().flags;
windowPrivateFlags = topFullscreenOpaqueWindow.getAttrs().privateFlags;
layoutParams.packageName = mainWindow.getAttrs().packageName;
layoutParams.windowAnimations = mainWindow.getAttrs().windowAnimations;
@@ -206,7 +206,7 @@ class TaskSnapshotSurface implements StartingSurface {
}
taskBounds = new Rect();
task.getBounds(taskBounds);
currentOrientation = topFullscreenWindow.getConfiguration().orientation;
currentOrientation = topFullscreenOpaqueWindow.getConfiguration().orientation;
}
try {
final int res = session.addToDisplay(window, window.mSeq, layoutParams,
@@ -222,7 +222,7 @@ class TaskSnapshotSurface implements StartingSurface {
final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
windowFlags, windowPrivateFlags, taskBounds,
currentOrientation, topFullscreenWindow.getClientInsetsState());
currentOrientation, topFullscreenOpaqueWindow.getClientInsetsState());
window.setOuter(snapshotSurface);
try {
session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,

View File

@@ -1642,11 +1642,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
&& (parentAndClientVisible || isAnimating(TRANSITION | PARENTS));
}
// TODO: Another visibility method that was added late in the release to minimize risk.
@Override
public boolean canAffectSystemUiFlags() {
final boolean translucent = mAttrs.alpha == 0.0f;
if (translucent) {
boolean isFullyTransparent() {
return mAttrs.alpha == 0f;
}
/**
* @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
* for example) will be affected by the flags specified in this window. This is the
* case when the surface is on screen but not exiting.
*/
boolean canAffectSystemUiFlags() {
if (isFullyTransparent()) {
return false;
}
if (mActivityRecord == null) {

View File

@@ -135,17 +135,19 @@ public class AppWindowTokenTests extends WindowTestsBase {
@Test
@Presubmit
public void testGetTopFullscreenWindow() {
assertNull(mActivity.getTopFullscreenWindow());
public void testGetTopFullscreenOpaqueWindow() {
assertNull(mActivity.getTopFullscreenOpaqueWindow());
final WindowState window1 = createWindow(null, TYPE_BASE_APPLICATION, mActivity, "window1");
final WindowState window11 = createWindow(null, TYPE_APPLICATION, mActivity, "window11");
final WindowState window12 = createWindow(null, TYPE_APPLICATION, mActivity, "window12");
assertEquals(window12, mActivity.getTopFullscreenWindow());
assertEquals(window12, mActivity.getTopFullscreenOpaqueWindow());
window12.mAttrs.width = 500;
assertEquals(window11, mActivity.getTopFullscreenWindow());
assertEquals(window11, mActivity.getTopFullscreenOpaqueWindow());
window11.mAttrs.width = 500;
assertEquals(window1, mActivity.getTopFullscreenWindow());
assertEquals(window1, mActivity.getTopFullscreenOpaqueWindow());
window1.mAttrs.alpha = 0f;
assertNull(mActivity.getTopFullscreenOpaqueWindow());
mActivity.removeImmediately();
}