summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiya Bera <diyab@google.com>2023-02-14 17:26:35 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-02-20 03:21:20 +0000
commit34582b0e2bf3c56c82ff469819a14cf02bdf9d12 (patch)
treeab4c01002c8b27865ac28be07ce51a77ee243205
parent998b911c4e0ee2a0e003795b81639ba1efefba29 (diff)
downloadbase-34582b0e2bf3c56c82ff469819a14cf02bdf9d12.tar.gz
Remove indicator theme for non-device entry activity
Test: Manual - Authenticate in keyguard, indicator theme matches dynamic theme Authenticate in biometric prompt, indicator theme does not have dynamic theme Enrollment, indicator theme does not have dynamic theme atest SideFpsControllerTest Fixes: 257824090 Change-Id: Ie706bba14bd9cab2069290ebe370d7fb82b4e4e9 (cherry picked from commit d4a0af407c00182bbad7f50fcbe596e85c88ebcf) Merged-In: Ie706bba14bd9cab2069290ebe370d7fb82b4e4e9
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt90
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java30
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt11
4 files changed, 103 insertions, 32 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
index 57bfe5421049..0098cda26b08 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
@@ -33,6 +33,7 @@ import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
+import android.hardware.biometrics.BiometricOverlayConstants;
import android.hardware.biometrics.BiometricSourceType;
import android.metrics.LogMaker;
import android.os.UserHandle;
@@ -379,7 +380,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
+ "isUnlockingWithFpAllowed=" + isUnlockingWithFpAllowed);
}
if (toShow) {
- mSideFpsController.get().show(SideFpsUiRequestSource.PRIMARY_BOUNCER);
+ mSideFpsController.get().show(SideFpsUiRequestSource.PRIMARY_BOUNCER,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD);
} else {
mSideFpsController.get().hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
index c799e91ad36b..6c490780b79a 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
@@ -19,6 +19,8 @@ import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.app.ActivityTaskManager
import android.content.Context
+import android.content.res.Configuration
+import android.graphics.Color
import android.graphics.PixelFormat
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
@@ -90,7 +92,7 @@ constructor(
private val featureFlags: FeatureFlags,
dumpManager: DumpManager
) : Dumpable {
- val requests: HashSet<SideFpsUiRequestSource> = HashSet()
+ private val requests: HashSet<SideFpsUiRequestSource> = HashSet()
@VisibleForTesting
val sensorProps: FingerprintSensorPropertiesInternal =
@@ -98,13 +100,17 @@ constructor(
?: throw IllegalStateException("no side fingerprint sensor")
@VisibleForTesting
- val orientationListener =
- BiometricDisplayListener(
+ val orientationReasonListener =
+ OrientationReasonListener(
context,
displayManager,
handler,
- BiometricDisplayListener.SensorType.SideFingerprint(sensorProps)
- ) { onOrientationChanged() }
+ sensorProps,
+ { reason -> onOrientationChanged(reason) },
+ BiometricOverlayConstants.REASON_UNKNOWN
+ )
+
+ @VisibleForTesting val orientationListener = orientationReasonListener.orientationListener
@VisibleForTesting
val overviewProxyListener =
@@ -168,7 +174,7 @@ constructor(
@BiometricOverlayConstants.ShowReason reason: Int
) =
if (reason.isReasonToAutoShow(activityTaskManager)) {
- show(SideFpsUiRequestSource.AUTO_SHOW)
+ show(SideFpsUiRequestSource.AUTO_SHOW, reason)
} else {
hide(SideFpsUiRequestSource.AUTO_SHOW)
}
@@ -198,11 +204,14 @@ constructor(
}
/** Shows the side fps overlay if not already shown. */
- fun show(request: SideFpsUiRequestSource) {
+ fun show(
+ request: SideFpsUiRequestSource,
+ @BiometricOverlayConstants.ShowReason reason: Int = BiometricOverlayConstants.REASON_UNKNOWN
+ ) {
requests.add(request)
mainExecutor.execute {
if (overlayView == null) {
- createOverlayForDisplay()
+ createOverlayForDisplay(reason)
} else {
Log.v(TAG, "overlay already shown")
}
@@ -226,13 +235,13 @@ constructor(
}
}
- private fun onOrientationChanged() {
+ private fun onOrientationChanged(@BiometricOverlayConstants.ShowReason reason: Int) {
if (overlayView != null) {
- createOverlayForDisplay()
+ createOverlayForDisplay(reason)
}
}
- private fun createOverlayForDisplay() {
+ private fun createOverlayForDisplay(@BiometricOverlayConstants.ShowReason reason: Int) {
val view = layoutInflater.inflate(R.layout.sidefps_view, null, false)
overlayView = view
val display = context.display!!
@@ -263,7 +272,8 @@ constructor(
updateOverlayParams(display, it.bounds)
}
}
- lottie.addOverlayDynamicColor(context)
+ orientationReasonListener.reason = reason
+ lottie.addOverlayDynamicColor(context, reason)
/**
* Intercepts TYPE_WINDOW_STATE_CHANGED accessibility event, preventing Talkback from
@@ -418,17 +428,36 @@ private fun Display.isNaturalOrientation(): Boolean =
private fun WindowInsets.hasBigNavigationBar(): Boolean =
getInsets(WindowInsets.Type.navigationBars()).bottom >= 70
-private fun LottieAnimationView.addOverlayDynamicColor(context: Context) {
+private fun LottieAnimationView.addOverlayDynamicColor(
+ context: Context,
+ @BiometricOverlayConstants.ShowReason reason: Int
+) {
fun update() {
val c = context.getColor(R.color.biometric_dialog_accent)
val chevronFill = context.getColor(R.color.sfps_chevron_fill)
- for (key in listOf(".blue600", ".blue400")) {
- addValueCallback(KeyPath(key, "**"), LottieProperty.COLOR_FILTER) {
- PorterDuffColorFilter(c, PorterDuff.Mode.SRC_ATOP)
+ val isKeyguard = reason == REASON_AUTH_KEYGUARD
+ if (isKeyguard) {
+ for (key in listOf(".blue600", ".blue400")) {
+ addValueCallback(KeyPath(key, "**"), LottieProperty.COLOR_FILTER) {
+ PorterDuffColorFilter(c, PorterDuff.Mode.SRC_ATOP)
+ }
+ }
+ addValueCallback(KeyPath(".black", "**"), LottieProperty.COLOR_FILTER) {
+ PorterDuffColorFilter(chevronFill, PorterDuff.Mode.SRC_ATOP)
+ }
+ } else if (!isDarkMode(context)) {
+ addValueCallback(KeyPath(".black", "**"), LottieProperty.COLOR_FILTER) {
+ PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP)
+ }
+ } else if (isDarkMode(context)) {
+ for (key in listOf(".blue600", ".blue400")) {
+ addValueCallback(KeyPath(key, "**"), LottieProperty.COLOR_FILTER) {
+ PorterDuffColorFilter(
+ context.getColor(R.color.settingslib_color_blue400),
+ PorterDuff.Mode.SRC_ATOP
+ )
+ }
}
- }
- addValueCallback(KeyPath(".black", "**"), LottieProperty.COLOR_FILTER) {
- PorterDuffColorFilter(chevronFill, PorterDuff.Mode.SRC_ATOP)
}
}
@@ -439,6 +468,29 @@ private fun LottieAnimationView.addOverlayDynamicColor(context: Context) {
}
}
+private fun isDarkMode(context: Context): Boolean {
+ val darkMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
+ return darkMode == Configuration.UI_MODE_NIGHT_YES
+}
+
+@VisibleForTesting
+class OrientationReasonListener(
+ context: Context,
+ displayManager: DisplayManager,
+ handler: Handler,
+ sensorProps: FingerprintSensorPropertiesInternal,
+ onOrientationChanged: (reason: Int) -> Unit,
+ @BiometricOverlayConstants.ShowReason var reason: Int
+) {
+ val orientationListener =
+ BiometricDisplayListener(
+ context,
+ displayManager,
+ handler,
+ BiometricDisplayListener.SensorType.SideFingerprint(sensorProps)
+ ) { onOrientationChanged(reason) }
+}
+
/**
* The source of a request to show the side fps visual indicator. This is distinct from
* [BiometricOverlayConstants] which corrresponds with the reason fingerprint authentication is
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
index 075ef9df9664..76646b3ea0ee 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.when;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.hardware.biometrics.BiometricOverlayConstants;
import android.hardware.biometrics.BiometricSourceType;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -350,7 +351,8 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
- verify(mSideFpsController).show(SideFpsUiRequestSource.PRIMARY_BOUNCER);
+ verify(mSideFpsController).show(SideFpsUiRequestSource.PRIMARY_BOUNCER,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD);
verify(mSideFpsController, never()).hide(any());
}
@@ -363,7 +365,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
@@ -375,7 +377,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
@@ -387,7 +389,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
@@ -395,13 +397,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
setupGetSecurityView();
setupConditionsToEnableSideFpsHint();
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
- verify(mSideFpsController, atLeastOnce()).show(SideFpsUiRequestSource.PRIMARY_BOUNCER);
+ verify(mSideFpsController, atLeastOnce()).show(SideFpsUiRequestSource.PRIMARY_BOUNCER,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD);
reset(mSideFpsController);
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.INVISIBLE);
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
@@ -416,13 +419,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
setupGetSecurityView();
setupConditionsToEnableSideFpsHint();
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
- verify(mSideFpsController, atLeastOnce()).show(SideFpsUiRequestSource.PRIMARY_BOUNCER);
+ verify(mSideFpsController, atLeastOnce()).show(SideFpsUiRequestSource.PRIMARY_BOUNCER,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD);
reset(mSideFpsController);
mKeyguardSecurityContainerController.onStartingToHide();
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
@@ -430,13 +434,14 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
setupGetSecurityView();
setupConditionsToEnableSideFpsHint();
mKeyguardSecurityContainerController.onBouncerVisibilityChanged(View.VISIBLE);
- verify(mSideFpsController, atLeastOnce()).show(SideFpsUiRequestSource.PRIMARY_BOUNCER);
+ verify(mSideFpsController, atLeastOnce()).show(SideFpsUiRequestSource.PRIMARY_BOUNCER,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD);
reset(mSideFpsController);
mKeyguardSecurityContainerController.onPause();
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
@@ -448,7 +453,8 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.onResume(0);
- verify(mSideFpsController).show(SideFpsUiRequestSource.PRIMARY_BOUNCER);
+ verify(mSideFpsController).show(SideFpsUiRequestSource.PRIMARY_BOUNCER,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD);
verify(mSideFpsController, never()).hide(any());
}
@@ -463,7 +469,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
mKeyguardSecurityContainerController.onResume(0);
verify(mSideFpsController).hide(SideFpsUiRequestSource.PRIMARY_BOUNCER);
- verify(mSideFpsController, never()).show(any());
+ verify(mSideFpsController, never()).show(any(), anyInt());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt
index 41beada11fa9..612e55732bc1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt
@@ -267,6 +267,17 @@ class SideFpsControllerTest : SysuiTestCase() {
}
@Test
+ fun testShowOverlayReasonWhenDisplayChanged() = testWithDisplay {
+ sideFpsController.show(SideFpsUiRequestSource.AUTO_SHOW, REASON_AUTH_KEYGUARD)
+ executor.runAllReady()
+ sideFpsController.orientationListener.onDisplayChanged(1 /* displayId */)
+ executor.runAllReady()
+
+ assertThat(sideFpsController.orientationReasonListener.reason)
+ .isEqualTo(REASON_AUTH_KEYGUARD)
+ }
+
+ @Test
fun testShowsAndHides() = testWithDisplay {
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
executor.runAllReady()