From b60e1c037a0e0793f838024a2506c58f6bf46bb3 Mon Sep 17 00:00:00 2001 From: Andrii Kulian Date: Fri, 11 Aug 2017 16:39:53 -0700 Subject: Use fullscreen flag to define visibility of the background Use fullscreen state provided by AM as a more reliable source of truth to check if activity window hides other windows behind. Bug: 64615361 Test: Open Play Newsstand, click on article, go to and from Recents. Change-Id: Ibc40a4241ed131f74da47c0d22833d2c3994cbe0 --- .../server/wm/SurfaceControlWithBackground.java | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/SurfaceControlWithBackground.java b/services/core/java/com/android/server/wm/SurfaceControlWithBackground.java index d3c2c80e6ec1..ac06c6db4c5c 100644 --- a/services/core/java/com/android/server/wm/SurfaceControlWithBackground.java +++ b/services/core/java/com/android/server/wm/SurfaceControlWithBackground.java @@ -26,6 +26,10 @@ import android.view.Surface.OutOfResourcesException; import android.view.SurfaceControl; import android.view.SurfaceSession; +import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; +import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; + /** * SurfaceControl extension that has background sized to match its container. */ @@ -33,8 +37,7 @@ class SurfaceControlWithBackground extends SurfaceControl { // SurfaceControl that holds the background behind opaque letterboxed app windows. private SurfaceControl mBackgroundControl; - // Flags that define whether the background should be shown. - private boolean mOpaque; + // Flag that defines whether the background should be shown. private boolean mVisible; // Way to communicate with corresponding window. @@ -48,10 +51,12 @@ class SurfaceControlWithBackground extends SurfaceControl { private float mLastDsDx = 1, mLastDsDy = 1; private float mLastX, mLastY; + // Will skip alpha animation for background of starting window. + private boolean mIsStartingWindow; + public SurfaceControlWithBackground(SurfaceControlWithBackground other) { super(other); mBackgroundControl = other.mBackgroundControl; - mOpaque = other.mOpaque; mVisible = other.mVisible; mWindowSurfaceController = other.mWindowSurfaceController; } @@ -61,15 +66,17 @@ class SurfaceControlWithBackground extends SurfaceControl { WindowSurfaceController windowSurfaceController) throws OutOfResourcesException { super(s, name, w, h, format, flags, windowType, ownerUid); - // We should only show background when the window is letterboxed in a task. - if (!windowSurfaceController.mAnimator.mWin.isLetterboxedAppWindow()) { + // We should only show background behind app windows that are letterboxed in a task. + if (!windowSurfaceController.mAnimator.mWin.isLetterboxedAppWindow() + || windowType < FIRST_APPLICATION_WINDOW + || windowType > LAST_APPLICATION_WINDOW) { return; } mWindowSurfaceController = windowSurfaceController; mLastWidth = w; mLastHeight = h; - mOpaque = (flags & SurfaceControl.OPAQUE) != 0; mWindowSurfaceController.getContainerRect(mTmpContainerRect); + mIsStartingWindow = windowType == TYPE_APPLICATION_STARTING; mBackgroundControl = new SurfaceControl(s, "Background for - " + name, mTmpContainerRect.width(), mTmpContainerRect.height(), PixelFormat.OPAQUE, flags | SurfaceControl.FX_SURFACE_DIM); @@ -82,7 +89,10 @@ class SurfaceControlWithBackground extends SurfaceControl { if (mBackgroundControl == null) { return; } - mBackgroundControl.setAlpha(alpha); + // We won't animate alpha for starting window because it will be visible as a flash for user + // when fading out to reveal real app window. + final float backgroundAlpha = mIsStartingWindow && alpha < 1.f ? 0 : alpha; + mBackgroundControl.setAlpha(backgroundAlpha); } @Override @@ -217,7 +227,6 @@ class SurfaceControlWithBackground extends SurfaceControl { @Override public void setOpaque(boolean isOpaque) { super.setOpaque(isOpaque); - mOpaque = isOpaque; updateBackgroundVisibility(); } @@ -307,7 +316,8 @@ class SurfaceControlWithBackground extends SurfaceControl { if (mBackgroundControl == null) { return; } - if (mOpaque && mVisible) { + final AppWindowToken appWindowToken = mWindowSurfaceController.mAnimator.mWin.mAppToken; + if (appWindowToken != null && appWindowToken.fillsParent() && mVisible) { mBackgroundControl.show(); } else { mBackgroundControl.hide(); -- cgit v1.2.3