From 377838b451d53ed2e8cd9fc751e989d6ab877e18 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Fri, 6 Mar 2020 16:55:46 -0500 Subject: [PATCH] Reset protection path on rotation Fixes the issue where camera cutout protection paths were accruing rotation by not caching the unmodified path. Fixes: 150531720 Test: manual Change-Id: I0cece9900e86dc553401200346dc964c562b0ce0 --- .../android/systemui/CameraAvailabilityListener.kt | 2 +- .../src/com/android/systemui/ScreenDecorations.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/CameraAvailabilityListener.kt b/packages/SystemUI/src/com/android/systemui/CameraAvailabilityListener.kt index 24fa91b9e8385..284074e76ae2d 100644 --- a/packages/SystemUI/src/com/android/systemui/CameraAvailabilityListener.kt +++ b/packages/SystemUI/src/com/android/systemui/CameraAvailabilityListener.kt @@ -26,7 +26,7 @@ import java.util.concurrent.Executor import kotlin.math.roundToInt -const val TAG = "CameraOpTransitionController" +const val TAG = "CameraAvailabilityListener" /** * Listens for usage of the Camera and controls the ScreenDecorations transition to show extra diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 022a254ca9372..6ea6a748ae8d9 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -878,9 +878,10 @@ public class ScreenDecorations extends SystemUI implements Tunable, private final List mBounds = new ArrayList(); private final Rect mBoundingRect = new Rect(); private final Path mBoundingPath = new Path(); - // Don't initialize these because they are cached elsewhere and may not exist + // Don't initialize these yet because they may never exist private Rect mProtectionRect; private Path mProtectionPath; + private Path mProtectionPathOrig; private Rect mTotalBounds = new Rect(); // Whether or not to show the cutout protection path private boolean mShowProtection = false; @@ -969,7 +970,11 @@ public class ScreenDecorations extends SystemUI implements Tunable, } void setProtection(Path protectionPath, Rect pathBounds) { - mProtectionPath = protectionPath; + if (mProtectionPathOrig == null) { + mProtectionPathOrig = new Path(); + mProtectionPath = new Path(); + } + mProtectionPathOrig.set(protectionPath); mProtectionRect = pathBounds; } @@ -1053,7 +1058,9 @@ public class ScreenDecorations extends SystemUI implements Tunable, Matrix m = new Matrix(); transformPhysicalToLogicalCoordinates(mInfo.rotation, dw, dh, m); mBoundingPath.transform(m); - if (mProtectionPath != null) { + if (mProtectionPathOrig != null) { + // Reset the protection path so we don't aggregate rotations + mProtectionPath.set(mProtectionPathOrig); mProtectionPath.transform(m); } }