From 776dd9e55613e3e630159371cb2c5f37075626d5 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 25 May 2021 13:44:08 -0700 Subject: [PATCH] ViewRootImpl: Correct opaque flag usage In performTraversals, "params" may be null. In this case we were not passing params to the WM indicating no changes (an obscure artifact of the protocol). In R the WM would simply ignore this however our updateOpacity logic in S is treating null as "translucent" it seems easiest to just pass mWindowAttributes directly avoiding the null case. While the opacity was broken, it seems an animation was added to StartingSurfaceDrawer which depends on having a translucent window. We also update this code to request a transparent pixel format as would have been required in the R API. Bug: 186555833 Test: Existing tests pass Change-Id: I180bf1796bbb4b7049ae9811f674f31014c2a400 --- core/java/android/view/ViewRootImpl.java | 7 ++++--- .../wm/shell/startingsurface/StartingSurfaceDrawer.java | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index afd6878da4290..67cf85cee9ac4 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2783,7 +2783,7 @@ public final class ViewRootImpl implements ViewParent, & WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0; final boolean dragResizing = freeformResizing || dockedResizing; if (mSurfaceControl.isValid()) { - updateOpacity(params, dragResizing); + updateOpacity(mWindowAttributes, dragResizing); } if (DEBUG_LAYOUT) Log.v(mTag, "relayout: frame=" + frame.toShortString() @@ -7749,9 +7749,10 @@ public final class ViewRootImpl implements ViewParent, return relayoutResult; } - private void updateOpacity(@Nullable WindowManager.LayoutParams params, boolean dragResizing) { + private void updateOpacity(WindowManager.LayoutParams params, boolean dragResizing) { boolean opaque = false; - if (params != null && !PixelFormat.formatHasAlpha(params.format) + + if (!PixelFormat.formatHasAlpha(params.format) // Don't make surface with surfaceInsets opaque as they display a // translucent shadow. && params.surfaceInsets.left == 0 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java index 1a03ebd4caae8..362cdce756e77 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java @@ -29,6 +29,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.PixelFormat; import android.graphics.Rect; import android.hardware.display.DisplayManager; import android.os.IBinder; @@ -215,6 +216,7 @@ public class StartingSurfaceDrawer { WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); params.setFitInsetsSides(0); params.setFitInsetsTypes(0); + params.format = PixelFormat.TRANSLUCENT; int windowFlags = WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN