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
This commit is contained in:
Diya Bera
2023-02-14 17:26:35 +00:00
parent 7c1e07e54c
commit d4a0af407c
4 changed files with 103 additions and 32 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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

View File

@@ -266,6 +266,17 @@ class SideFpsControllerTest : SysuiTestCase() {
verify(displayManager).unregisterDisplayListener(any())
}
@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)