Enable SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS by default.

Bug: 260617060
Test: manually tested on device
Change-Id: I94a3f9ba3229df06f69a763a6ffb0b8bb8ccebe1
This commit is contained in:
Hao Dong
2023-01-31 06:22:36 +08:00
parent d669abe326
commit b6c3ecffd6
3 changed files with 2 additions and 165 deletions

View File

@@ -213,7 +213,7 @@ public class FeatureFlagUtils {
DEFAULT_FLAGS.put(SETTINGS_PREFER_ACCESSIBILITY_MENU_IN_SYSTEM, "false");
DEFAULT_FLAGS.put(SETTINGS_AUDIO_ROUTING, "false");
DEFAULT_FLAGS.put(SETTINGS_FLASH_ALERTS, "false");
DEFAULT_FLAGS.put(SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, "false");
DEFAULT_FLAGS.put(SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, "true");
DEFAULT_FLAGS.put(SETTINGS_ENABLE_LOCKSCREEN_TRANSFER_API, "false");
}

View File

@@ -21,12 +21,9 @@ import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_BP
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_KEYGUARD
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_OTHER
import android.hardware.biometrics.BiometricOverlayConstants.REASON_AUTH_SETTINGS
import android.hardware.biometrics.BiometricOverlayConstants.REASON_ENROLL_ENROLLING
import android.hardware.biometrics.BiometricOverlayConstants.REASON_ENROLL_FIND_SENSOR
import android.hardware.biometrics.BiometricOverlayConstants.ShowReason
import android.hardware.fingerprint.FingerprintManager
import android.hardware.fingerprint.IUdfpsOverlayControllerCallback
import android.provider.Settings
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import android.view.LayoutInflater
@@ -106,7 +103,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
@Mock private lateinit var controllerCallback: IUdfpsOverlayControllerCallback
@Mock private lateinit var udfpsController: UdfpsController
@Mock private lateinit var udfpsView: UdfpsView
@Mock private lateinit var udfpsEnrollView: UdfpsEnrollView
@Mock private lateinit var udfpsKeyguardView: UdfpsKeyguardView
@Mock private lateinit var activityLaunchAnimator: ActivityLaunchAnimator
@Mock private lateinit var featureFlags: FeatureFlags
@@ -121,18 +117,14 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
@Before
fun setup() {
context.orCreateTestableResources.addOverride(R.integer.config_udfpsEnrollProgressBar, 20)
whenever(inflater.inflate(R.layout.udfps_view, null, false))
.thenReturn(udfpsView)
whenever(inflater.inflate(R.layout.udfps_enroll_view, null))
.thenReturn(udfpsEnrollView)
whenever(inflater.inflate(R.layout.udfps_bp_view, null))
.thenReturn(mock(UdfpsBpView::class.java))
whenever(inflater.inflate(R.layout.udfps_keyguard_view, null))
.thenReturn(udfpsKeyguardView)
whenever(inflater.inflate(R.layout.udfps_fpm_empty_view, null))
.thenReturn(mock(UdfpsFpmEmptyView::class.java))
whenever(udfpsEnrollView.context).thenReturn(context)
}
private fun withReason(
@@ -161,37 +153,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
verify(udfpsKeyguardView).updateSensorLocation(eq(overlayParams.sensorBounds))
}
@Test
fun showUdfpsOverlay_settings() = withReason(REASON_AUTH_SETTINGS) { showUdfpsOverlay() }
@Test
fun showUdfpsOverlay_locate() = withReason(REASON_ENROLL_FIND_SENSOR) {
showUdfpsOverlay(isEnrollUseCase = true)
}
@Test
fun showUdfpsOverlay_locate_withEnrollmentUiRemoved() {
Settings.Global.putInt(mContext.contentResolver, SETTING_REMOVE_ENROLLMENT_UI, 1)
withReason(REASON_ENROLL_FIND_SENSOR, isDebuggable = true) {
showUdfpsOverlay(isEnrollUseCase = false)
}
Settings.Global.putInt(mContext.contentResolver, SETTING_REMOVE_ENROLLMENT_UI, 0)
}
@Test
fun showUdfpsOverlay_enroll() = withReason(REASON_ENROLL_ENROLLING) {
showUdfpsOverlay(isEnrollUseCase = true)
}
@Test
fun showUdfpsOverlay_enroll_withEnrollmentUiRemoved() {
Settings.Global.putInt(mContext.contentResolver, SETTING_REMOVE_ENROLLMENT_UI, 1)
withReason(REASON_ENROLL_ENROLLING, isDebuggable = true) {
showUdfpsOverlay(isEnrollUseCase = false)
}
Settings.Global.putInt(mContext.contentResolver, SETTING_REMOVE_ENROLLMENT_UI, 0)
}
@Test
fun showUdfpsOverlay_other() = withReason(REASON_AUTH_OTHER) { showUdfpsOverlay() }
@@ -281,7 +242,7 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
}
}
private fun showUdfpsOverlay(isEnrollUseCase: Boolean = false) {
private fun showUdfpsOverlay() {
val didShow = controllerOverlay.show(udfpsController, overlayParams)
verify(windowManager).addView(eq(controllerOverlay.overlayView), any())
@@ -293,12 +254,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
assertThat(controllerOverlay.isShowing).isTrue()
assertThat(controllerOverlay.isHiding).isFalse()
assertThat(controllerOverlay.overlayView).isNotNull()
if (isEnrollUseCase) {
verify(udfpsEnrollView).updateSensorLocation(eq(overlayParams.sensorBounds))
assertThat(controllerOverlay.enrollHelper).isNotNull()
} else {
assertThat(controllerOverlay.enrollHelper).isNull()
}
}
@Test
@@ -310,12 +265,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
@Test
fun hideUdfpsOverlay_settings() = withReason(REASON_AUTH_SETTINGS) { hideUdfpsOverlay() }
@Test
fun hideUdfpsOverlay_locate() = withReason(REASON_ENROLL_FIND_SENSOR) { hideUdfpsOverlay() }
@Test
fun hideUdfpsOverlay_enroll() = withReason(REASON_ENROLL_ENROLLING) { hideUdfpsOverlay() }
@Test
fun hideUdfpsOverlay_other() = withReason(REASON_AUTH_OTHER) { hideUdfpsOverlay() }
@@ -345,44 +294,6 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
assertThat(controllerOverlay.show(udfpsController, overlayParams)).isFalse()
}
@Test
fun forwardEnrollProgressEvents() = withReason(REASON_ENROLL_ENROLLING) {
controllerOverlay.show(udfpsController, overlayParams)
with(EnrollListener(controllerOverlay)) {
controllerOverlay.onEnrollmentProgress(/* remaining */20)
controllerOverlay.onAcquiredGood()
assertThat(progress).isTrue()
assertThat(help).isFalse()
assertThat(acquired).isFalse()
}
}
@Test
fun forwardEnrollHelpEvents() = withReason(REASON_ENROLL_ENROLLING) {
controllerOverlay.show(udfpsController, overlayParams)
with(EnrollListener(controllerOverlay)) {
controllerOverlay.onEnrollmentHelp()
assertThat(progress).isFalse()
assertThat(help).isTrue()
assertThat(acquired).isFalse()
}
}
@Test
fun forwardEnrollAcquiredEvents() = withReason(REASON_ENROLL_ENROLLING) {
controllerOverlay.show(udfpsController, overlayParams)
with(EnrollListener(controllerOverlay)) {
controllerOverlay.onEnrollmentProgress(/* remaining */ 1)
controllerOverlay.onAcquiredGood()
assertThat(progress).isTrue()
assertThat(help).isFalse()
assertThat(acquired).isTrue()
}
}
@Test
fun cancels() = withReason(REASON_AUTH_BP) {
controllerOverlay.cancel()
@@ -404,27 +315,3 @@ class UdfpsControllerOverlayTest : SysuiTestCase() {
assertThat(controllerOverlay.matchesRequestId(REQUEST_ID + 1)).isFalse()
}
}
private class EnrollListener(
overlay: UdfpsControllerOverlay,
var progress: Boolean = false,
var help: Boolean = false,
var acquired: Boolean = false
) : UdfpsEnrollHelper.Listener {
init {
overlay.enrollHelper!!.setListener(this)
}
override fun onEnrollmentProgress(remaining: Int, totalSteps: Int) {
progress = true
}
override fun onEnrollmentHelp(remaining: Int, totalSteps: Int) {
help = true
}
override fun onLastStepAcquired() {
acquired = true
}
}

View File

@@ -1,50 +0,0 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.biometrics;
import static com.google.common.truth.Truth.assertThat;
import android.content.res.Configuration;
import android.graphics.Color;
import android.testing.AndroidTestingRunner;
import androidx.test.filters.SmallTest;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class UdfpsEnrollViewTest extends SysuiTestCase {
private static String ENROLL_PROGRESS_COLOR_LIGHT = "#699FF3";
private static String ENROLL_PROGRESS_COLOR_DARK = "#7DA7F1";
@Test
public void fingerprintUdfpsEnroll_usesCorrectThemeCheckmarkFillColor() {
final Configuration config = mContext.getResources().getConfiguration();
final boolean isDarkThemeOn = (config.uiMode & Configuration.UI_MODE_NIGHT_MASK)
== Configuration.UI_MODE_NIGHT_YES;
final int currentColor = mContext.getColor(R.color.udfps_enroll_progress);
assertThat(currentColor).isEqualTo(Color.parseColor(isDarkThemeOn
? ENROLL_PROGRESS_COLOR_DARK : ENROLL_PROGRESS_COLOR_LIGHT));
}
}