Merge "Update ActiveUnlockConfig dump" into tm-qpr-dev

This commit is contained in:
Beverly Tai
2023-02-14 18:38:44 +00:00
committed by Android (Google) Code Review
2 changed files with 108 additions and 115 deletions

View File

@@ -303,9 +303,18 @@ class ActiveUnlockConfig @Inject constructor(
pw.println(" requestActiveUnlockOnWakeup=$requestActiveUnlockOnWakeup") pw.println(" requestActiveUnlockOnWakeup=$requestActiveUnlockOnWakeup")
pw.println(" requestActiveUnlockOnUnlockIntent=$requestActiveUnlockOnUnlockIntent") pw.println(" requestActiveUnlockOnUnlockIntent=$requestActiveUnlockOnUnlockIntent")
pw.println(" requestActiveUnlockOnBioFail=$requestActiveUnlockOnBioFail") pw.println(" requestActiveUnlockOnBioFail=$requestActiveUnlockOnBioFail")
pw.println(" requestActiveUnlockOnUnlockIntentWhenBiometricEnrolled=${
onUnlockIntentWhenBiometricEnrolled.map { BiometricType.values()[it] } val onUnlockIntentWhenBiometricEnrolledString =
}") onUnlockIntentWhenBiometricEnrolled.map {
for (biometricType in BiometricType.values()) {
if (biometricType.intValue == it) {
return@map biometricType.name
}
}
return@map "UNKNOWN"
}
pw.println(" requestActiveUnlockOnUnlockIntentWhenBiometricEnrolled=" +
"$onUnlockIntentWhenBiometricEnrolledString")
pw.println(" requestActiveUnlockOnFaceError=$faceErrorsToTriggerBiometricFailOn") pw.println(" requestActiveUnlockOnFaceError=$faceErrorsToTriggerBiometricFailOn")
pw.println(" requestActiveUnlockOnFaceAcquireInfo=" + pw.println(" requestActiveUnlockOnFaceAcquireInfo=" +
"$faceAcquireInfoToTriggerBiometricFailOn") "$faceAcquireInfoToTriggerBiometricFailOn")

View File

@@ -24,13 +24,19 @@ import android.os.Handler
import android.os.PowerManager import android.os.PowerManager
import android.os.PowerManager.WAKE_REASON_BIOMETRIC import android.os.PowerManager.WAKE_REASON_BIOMETRIC
import android.os.UserHandle import android.os.UserHandle
import android.provider.Settings import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ERRORS
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_WAKE
import android.provider.Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS
import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager import com.android.systemui.dump.DumpManager
import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.capture
import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.eq
import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.settings.FakeSettings
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
@@ -41,20 +47,11 @@ import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations
import java.io.PrintWriter
@SmallTest @SmallTest
class ActiveUnlockConfigTest : SysuiTestCase() { class ActiveUnlockConfigTest : SysuiTestCase() {
private val fakeWakeUri = Uri.Builder().appendPath("wake").build() private lateinit var secureSettings: FakeSettings
private val fakeUnlockIntentUri = Uri.Builder().appendPath("unlock-intent").build()
private val fakeBioFailUri = Uri.Builder().appendPath("bio-fail").build()
private val fakeFaceErrorsUri = Uri.Builder().appendPath("face-errors").build()
private val fakeFaceAcquiredUri = Uri.Builder().appendPath("face-acquired").build()
private val fakeUnlockIntentBioEnroll = Uri.Builder().appendPath("unlock-intent-bio").build()
private val fakeWakeupsConsideredUnlockIntents =
Uri.Builder().appendPath("wakeups-considered-unlock-intent").build()
@Mock
private lateinit var secureSettings: SecureSettings
@Mock @Mock
private lateinit var contentResolver: ContentResolver private lateinit var contentResolver: ContentResolver
@Mock @Mock
@@ -63,33 +60,20 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
private lateinit var dumpManager: DumpManager private lateinit var dumpManager: DumpManager
@Mock @Mock
private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
@Mock private lateinit var mockPrintWriter: PrintWriter
@Captor @Captor
private lateinit var settingsObserverCaptor: ArgumentCaptor<ContentObserver> private lateinit var settingsObserverCaptor: ArgumentCaptor<ContentObserver>
private lateinit var activeUnlockConfig: ActiveUnlockConfig private lateinit var activeUnlockConfig: ActiveUnlockConfig
private var currentUser: Int = 0
@Before @Before
fun setUp() { fun setUp() {
MockitoAnnotations.initMocks(this) MockitoAnnotations.initMocks(this)
`when`(secureSettings.getUriFor(Settings.Secure.ACTIVE_UNLOCK_ON_WAKE)) currentUser = KeyguardUpdateMonitor.getCurrentUser()
.thenReturn(fakeWakeUri) secureSettings = FakeSettings()
`when`(secureSettings.getUriFor(Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT))
.thenReturn(fakeUnlockIntentUri)
`when`(secureSettings.getUriFor(Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
.thenReturn(fakeBioFailUri)
`when`(secureSettings.getUriFor(Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ERRORS))
.thenReturn(fakeFaceErrorsUri)
`when`(secureSettings.getUriFor(Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO))
.thenReturn(fakeFaceAcquiredUri)
`when`(secureSettings.getUriFor(
Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED))
.thenReturn(fakeUnlockIntentBioEnroll)
`when`(secureSettings.getUriFor(
Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS))
.thenReturn(fakeWakeupsConsideredUnlockIntents)
activeUnlockConfig = ActiveUnlockConfig( activeUnlockConfig = ActiveUnlockConfig(
handler, handler,
secureSettings, secureSettings,
@@ -105,8 +89,6 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun onWakeupSettingChanged() { fun onWakeupSettingChanged() {
verifyRegisterSettingObserver()
// GIVEN no active unlock settings enabled // GIVEN no active unlock settings enabled
assertFalse( assertFalse(
activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
@@ -114,9 +96,8 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
) )
// WHEN unlock on wake is allowed // WHEN unlock on wake is allowed
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_WAKE, secureSettings.putIntForUser(ACTIVE_UNLOCK_ON_WAKE, 1, currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_WAKE))
updateSetting(fakeWakeUri)
// THEN active unlock triggers allowed on: wake, unlock-intent, and biometric failure // THEN active unlock triggers allowed on: wake, unlock-intent, and biometric failure
assertTrue( assertTrue(
@@ -135,8 +116,6 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun onUnlockIntentSettingChanged() { fun onUnlockIntentSettingChanged() {
verifyRegisterSettingObserver()
// GIVEN no active unlock settings enabled // GIVEN no active unlock settings enabled
assertFalse( assertFalse(
activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
@@ -144,9 +123,8 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
) )
// WHEN unlock on biometric failed is allowed // WHEN unlock on biometric failed is allowed
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT, secureSettings.putIntForUser(ACTIVE_UNLOCK_ON_UNLOCK_INTENT, 1, currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT))
updateSetting(fakeUnlockIntentUri)
// THEN active unlock triggers allowed on: biometric failure ONLY // THEN active unlock triggers allowed on: biometric failure ONLY
assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
@@ -159,21 +137,19 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun onBioFailSettingChanged() { fun onBioFailSettingChanged() {
verifyRegisterSettingObserver()
// GIVEN no active unlock settings enabled and triggering unlock intent on biometric // GIVEN no active unlock settings enabled and triggering unlock intent on biometric
// enrollment setting is disabled (empty string is disabled, null would use the default) // enrollment setting is disabled (empty string is disabled, null would use the default)
`when`(secureSettings.getStringForUser( secureSettings.putStringForUser(
Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, "", currentUser)
0)).thenReturn("") updateSetting(secureSettings.getUriFor(
updateSetting(fakeUnlockIntentBioEnroll) ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
))
assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
ActiveUnlockConfig.ActiveUnlockRequestOrigin.BIOMETRIC_FAIL)) ActiveUnlockConfig.ActiveUnlockRequestOrigin.BIOMETRIC_FAIL))
// WHEN unlock on biometric failed is allowed // WHEN unlock on biometric failed is allowed
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, secureSettings.putIntForUser(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, 1, currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
updateSetting(fakeBioFailUri)
// THEN active unlock triggers allowed on: biometric failure ONLY // THEN active unlock triggers allowed on: biometric failure ONLY
assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
@@ -186,17 +162,14 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun faceErrorSettingsChanged() { fun faceErrorSettingsChanged() {
verifyRegisterSettingObserver()
// GIVEN unlock on biometric fail // GIVEN unlock on biometric fail
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, secureSettings.putIntForUser(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, 1, currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
updateSetting(fakeBioFailUri)
// WHEN face error timeout (3), allow trigger active unlock // WHEN face error timeout (3), allow trigger active unlock
`when`(secureSettings.getStringForUser(Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ERRORS, secureSettings.putStringForUser(
0)).thenReturn("3") ACTIVE_UNLOCK_ON_FACE_ERRORS, "3", currentUser)
updateSetting(fakeFaceAcquiredUri) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_FACE_ERRORS))
// THEN active unlock triggers allowed on error TIMEOUT // THEN active unlock triggers allowed on error TIMEOUT
assertTrue(activeUnlockConfig.shouldRequestActiveUnlockOnFaceError( assertTrue(activeUnlockConfig.shouldRequestActiveUnlockOnFaceError(
@@ -208,19 +181,17 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun faceAcquiredSettingsChanged() { fun faceAcquiredSettingsChanged() {
verifyRegisterSettingObserver()
// GIVEN unlock on biometric fail // GIVEN unlock on biometric fail
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, secureSettings.putStringForUser(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, "1", currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
updateSetting(fakeBioFailUri)
// WHEN face acquiredMsg DARK_GLASSESand MOUTH_COVERING are allowed to trigger // WHEN face acquiredMsg DARK_GLASSESand MOUTH_COVERING are allowed to trigger
`when`(secureSettings.getStringForUser(Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO, secureSettings.putStringForUser(
0)).thenReturn( ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO,
"${BiometricFaceConstants.FACE_ACQUIRED_MOUTH_COVERING_DETECTED}" + "${BiometricFaceConstants.FACE_ACQUIRED_MOUTH_COVERING_DETECTED}" +
"|${BiometricFaceConstants.FACE_ACQUIRED_DARK_GLASSES_DETECTED}") "|${BiometricFaceConstants.FACE_ACQUIRED_DARK_GLASSES_DETECTED}",
updateSetting(fakeFaceAcquiredUri) currentUser)
updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO))
// THEN active unlock triggers allowed on acquired messages DARK_GLASSES & MOUTH_COVERING // THEN active unlock triggers allowed on acquired messages DARK_GLASSES & MOUTH_COVERING
assertTrue(activeUnlockConfig.shouldRequestActiveUnlockOnFaceAcquireInfo( assertTrue(activeUnlockConfig.shouldRequestActiveUnlockOnFaceAcquireInfo(
@@ -236,23 +207,23 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun triggerOnUnlockIntentWhenBiometricEnrolledNone() { fun triggerOnUnlockIntentWhenBiometricEnrolledNone() {
verifyRegisterSettingObserver()
// GIVEN unlock on biometric fail // GIVEN unlock on biometric fail
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, secureSettings.putIntForUser(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, 1, currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
updateSetting(fakeBioFailUri)
// GIVEN fingerprint and face are NOT enrolled // GIVEN fingerprint and face are NOT enrolled
activeUnlockConfig.keyguardUpdateMonitor = keyguardUpdateMonitor activeUnlockConfig.keyguardUpdateMonitor = keyguardUpdateMonitor
`when`(keyguardUpdateMonitor.isFaceEnrolled()).thenReturn(false) `when`(keyguardUpdateMonitor.isFaceEnrolled).thenReturn(false)
`when`(keyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(0)).thenReturn(false) `when`(keyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(0)).thenReturn(false)
// WHEN unlock intent is allowed when NO biometrics are enrolled (0) // WHEN unlock intent is allowed when NO biometrics are enrolled (0)
`when`(secureSettings.getStringForUser(
Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, secureSettings.putStringForUser(
0)).thenReturn("${ActiveUnlockConfig.BiometricType.NONE.intValue}") ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED,
updateSetting(fakeUnlockIntentBioEnroll) "${ActiveUnlockConfig.BiometricType.NONE.intValue}", currentUser)
updateSetting(secureSettings.getUriFor(
ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
))
// THEN active unlock triggers allowed on unlock intent // THEN active unlock triggers allowed on unlock intent
assertTrue(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( assertTrue(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
@@ -261,12 +232,9 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun triggerOnUnlockIntentWhenBiometricEnrolledFingerprintOrFaceOnly() { fun triggerOnUnlockIntentWhenBiometricEnrolledFingerprintOrFaceOnly() {
verifyRegisterSettingObserver()
// GIVEN unlock on biometric fail // GIVEN unlock on biometric fail
`when`(secureSettings.getIntForUser(Settings.Secure.ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, secureSettings.putIntForUser(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL, 1, currentUser)
0, 0)).thenReturn(1) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
updateSetting(fakeBioFailUri)
// GIVEN fingerprint and face are both enrolled // GIVEN fingerprint and face are both enrolled
activeUnlockConfig.keyguardUpdateMonitor = keyguardUpdateMonitor activeUnlockConfig.keyguardUpdateMonitor = keyguardUpdateMonitor
@@ -275,12 +243,14 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
// WHEN unlock intent is allowed when ONLY fingerprint is enrolled or NO biometircs // WHEN unlock intent is allowed when ONLY fingerprint is enrolled or NO biometircs
// are enrolled // are enrolled
`when`(secureSettings.getStringForUser( secureSettings.putStringForUser(
Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED, ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED,
0)).thenReturn(
"${ActiveUnlockConfig.BiometricType.ANY_FACE.intValue}" + "${ActiveUnlockConfig.BiometricType.ANY_FACE.intValue}" +
"|${ActiveUnlockConfig.BiometricType.ANY_FINGERPRINT.intValue}") "|${ActiveUnlockConfig.BiometricType.ANY_FINGERPRINT.intValue}",
updateSetting(fakeUnlockIntentBioEnroll) currentUser)
updateSetting(secureSettings.getUriFor(
ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
))
// THEN active unlock triggers NOT allowed on unlock intent // THEN active unlock triggers NOT allowed on unlock intent
assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin( assertFalse(activeUnlockConfig.shouldAllowActiveUnlockFromOrigin(
@@ -305,13 +275,12 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun isWakeupConsideredUnlockIntent_singleValue() { fun isWakeupConsideredUnlockIntent_singleValue() {
verifyRegisterSettingObserver()
// GIVEN lift is considered an unlock intent // GIVEN lift is considered an unlock intent
`when`(secureSettings.getStringForUser( secureSettings.putIntForUser(
Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS, ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
0)).thenReturn(PowerManager.WAKE_REASON_LIFT.toString()) PowerManager.WAKE_REASON_LIFT,
updateSetting(fakeWakeupsConsideredUnlockIntents) currentUser)
updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS))
// THEN only WAKE_REASON_LIFT is considered an unlock intent // THEN only WAKE_REASON_LIFT is considered an unlock intent
for (wakeReason in 0..WAKE_REASON_BIOMETRIC) { for (wakeReason in 0..WAKE_REASON_BIOMETRIC) {
@@ -325,17 +294,15 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun isWakeupConsideredUnlockIntent_multiValue() { fun isWakeupConsideredUnlockIntent_multiValue() {
verifyRegisterSettingObserver()
// GIVEN lift and tap are considered an unlock intent // GIVEN lift and tap are considered an unlock intent
`when`(secureSettings.getStringForUser( secureSettings.putStringForUser(
Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS, ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
0)).thenReturn(
PowerManager.WAKE_REASON_LIFT.toString() + PowerManager.WAKE_REASON_LIFT.toString() +
"|" + "|" +
PowerManager.WAKE_REASON_TAP.toString() PowerManager.WAKE_REASON_TAP.toString(),
currentUser
) )
updateSetting(fakeWakeupsConsideredUnlockIntents) updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS))
// THEN WAKE_REASON_LIFT and WAKE_REASON TAP are considered an unlock intent // THEN WAKE_REASON_LIFT and WAKE_REASON TAP are considered an unlock intent
for (wakeReason in 0..WAKE_REASON_BIOMETRIC) { for (wakeReason in 0..WAKE_REASON_BIOMETRIC) {
@@ -354,13 +321,10 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
@Test @Test
fun isWakeupConsideredUnlockIntent_emptyValues() { fun isWakeupConsideredUnlockIntent_emptyValues() {
verifyRegisterSettingObserver()
// GIVEN lift and tap are considered an unlock intent // GIVEN lift and tap are considered an unlock intent
`when`(secureSettings.getStringForUser( secureSettings.putStringForUser(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS, " ",
Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS, currentUser)
0)).thenReturn(" ") updateSetting(secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS))
updateSetting(fakeWakeupsConsideredUnlockIntents)
// THEN no wake up gestures are considered an unlock intent // THEN no wake up gestures are considered an unlock intent
for (wakeReason in 0..WAKE_REASON_BIOMETRIC) { for (wakeReason in 0..WAKE_REASON_BIOMETRIC) {
@@ -373,7 +337,23 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
PowerManager.WAKE_REASON_UNFOLD_DEVICE)) PowerManager.WAKE_REASON_UNFOLD_DEVICE))
} }
@Test
fun dump_onUnlockIntentWhenBiometricEnrolled_invalidNum_noArrayOutOfBoundsException() {
// GIVEN an invalid input (-1)
secureSettings.putStringForUser(ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED,
"-1", currentUser)
// WHEN the setting updates
updateSetting(secureSettings.getUriFor(
ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
))
// THEN no exception thrown
activeUnlockConfig.dump(mockPrintWriter, emptyArray())
}
private fun updateSetting(uri: Uri) { private fun updateSetting(uri: Uri) {
verifyRegisterSettingObserver()
settingsObserverCaptor.value.onChange( settingsObserverCaptor.value.onChange(
false, false,
listOf(uri), listOf(uri),
@@ -383,13 +363,17 @@ class ActiveUnlockConfigTest : SysuiTestCase() {
} }
private fun verifyRegisterSettingObserver() { private fun verifyRegisterSettingObserver() {
verifyRegisterSettingObserver(fakeWakeUri) verifyRegisterSettingObserver(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_WAKE))
verifyRegisterSettingObserver(fakeUnlockIntentUri) verifyRegisterSettingObserver(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT))
verifyRegisterSettingObserver(fakeBioFailUri) verifyRegisterSettingObserver(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_BIOMETRIC_FAIL))
verifyRegisterSettingObserver(fakeFaceErrorsUri) verifyRegisterSettingObserver(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_FACE_ERRORS))
verifyRegisterSettingObserver(fakeFaceAcquiredUri) verifyRegisterSettingObserver(secureSettings.getUriFor(ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO))
verifyRegisterSettingObserver(fakeUnlockIntentBioEnroll) verifyRegisterSettingObserver(secureSettings.getUriFor(
verifyRegisterSettingObserver(fakeWakeupsConsideredUnlockIntents) ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
))
verifyRegisterSettingObserver(secureSettings.getUriFor(
ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS
))
} }
private fun verifyRegisterSettingObserver(uri: Uri) { private fun verifyRegisterSettingObserver(uri: Uri) {