Set EXTRA_KEY_FOR_FINGERPRINT for choose lock screen.
Bug: 279823572 Test: atest FingerprintSettingsFragmentTest Test: atest ChooseLockGenericTest Change-Id: Ie4bc18bf245eb7a755862401c710d85381063ff9 Merged-In: Ie4bc18bf245eb7a755862401c710d85381063ff9
This commit is contained in:
@@ -1182,20 +1182,20 @@
|
||||
<string name="current_screen_lock">Current screen lock</string>
|
||||
|
||||
<!-- Title for preference that guides the user through creating a backup unlock pattern for fingerprint [CHAR LIMIT=45]-->
|
||||
<string name="fingerprint_unlock_set_unlock_pattern">Fingerprint + Pattern</string>
|
||||
<string name="fingerprint_unlock_set_unlock_pattern">Pattern \u2022 Fingerprint</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock PIN for fingerprint [CHAR LIMIT=45]-->
|
||||
<string name="fingerprint_unlock_set_unlock_pin">Fingerprint + PIN</string>
|
||||
<string name="fingerprint_unlock_set_unlock_pin">PIN \u2022 Fingerprint</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock password for fingerprint [CHAR LIMIT=45]-->
|
||||
<string name="fingerprint_unlock_set_unlock_password">Fingerprint + Password</string>
|
||||
<string name="fingerprint_unlock_set_unlock_password">Password \u2022 Fingerprint</string>
|
||||
<!-- Title for preference that guides the user to skip fingerprint setup [CHAR LIMIT=60]-->
|
||||
<string name="fingerprint_unlock_skip_fingerprint">Continue without fingerprint</string>
|
||||
|
||||
<!-- Title for preference that guides the user through creating a backup unlock pattern for Face Unlock [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_pattern">Face Unlock + Pattern</string>
|
||||
<string name="face_unlock_set_unlock_pattern">Pattern \u2022 Face</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock PIN for Face Unlock [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_pin">Face Unlock + PIN</string>
|
||||
<string name="face_unlock_set_unlock_pin">PIN \u2022 Face</string>
|
||||
<!-- Title for preference that guides the user through creating a backup unlock password for Face Unlock [CHAR LIMIT=45]-->
|
||||
<string name="face_unlock_set_unlock_password">Face Unlock + Password</string>
|
||||
<string name="face_unlock_set_unlock_password">Password \u2022 Face</string>
|
||||
<!-- Title for preference that guides the user to skip Face Unlock setup [CHAR LIMIT=60]-->
|
||||
<string name="face_unlock_skip_face">Continue without Face Unlock</string>
|
||||
|
||||
|
@@ -185,7 +185,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
private static final int MSG_FINGER_AUTH_HELP = 1004;
|
||||
|
||||
private static final int CONFIRM_REQUEST = 101;
|
||||
private static final int CHOOSE_LOCK_GENERIC_REQUEST = 102;
|
||||
@VisibleForTesting
|
||||
static final int CHOOSE_LOCK_GENERIC_REQUEST = 102;
|
||||
@VisibleForTesting
|
||||
static final int ADD_FINGERPRINT_REQUEST = 10;
|
||||
private static final int AUTO_ADD_FIRST_FINGERPRINT_REQUEST = 11;
|
||||
@@ -1014,7 +1015,7 @@ public class FingerprintSettings extends SubSettings {
|
||||
true);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
|
||||
startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
|
||||
}
|
||||
}
|
||||
|
@@ -20,8 +20,11 @@ import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFP
|
||||
|
||||
import static com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment;
|
||||
import static com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment.ADD_FINGERPRINT_REQUEST;
|
||||
import static com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment.CHOOSE_LOCK_GENERIC_REQUEST;
|
||||
import static com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment.KEY_FINGERPRINT_ADD;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -54,6 +57,7 @@ import com.android.settings.biometrics.BiometricsSplitScreenDialog;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowSettingsPreferenceFragment;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||
@@ -63,6 +67,7 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
@@ -74,7 +79,7 @@ import java.util.ArrayList;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowSettingsPreferenceFragment.class, ShadowUtils.class, ShadowFragment.class,
|
||||
ShadowUserManager.class})
|
||||
ShadowUserManager.class, ShadowLockPatternUtils.class})
|
||||
public class FingerprintSettingsFragmentTest {
|
||||
private FingerprintSettingsFragment mFragment;
|
||||
private Context mContext;
|
||||
@@ -92,10 +97,62 @@ public class FingerprintSettingsFragmentTest {
|
||||
doReturn(true).when(mFingerprintManager).isHardwareDetected();
|
||||
ShadowUtils.setFingerprintManager(mFingerprintManager);
|
||||
FakeFeatureFactory.setupForTest();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowUtils.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddFingerprint_inFullScreen_noDialog() {
|
||||
setUpFragment(false);
|
||||
// Click "Add Fingerprint"
|
||||
final Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY_FINGERPRINT_ADD);
|
||||
mFragment.onPreferenceTreeClick(preference);
|
||||
|
||||
verify(mFragment).startActivityForResult(any(), eq(ADD_FINGERPRINT_REQUEST));
|
||||
verify(mFragmentTransaction, never()).add(any(),
|
||||
eq(BiometricsSplitScreenDialog.class.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddFingerprint_inMultiWindow_showsDialog() {
|
||||
setUpFragment(false);
|
||||
|
||||
doReturn(true).when(mActivity).isInMultiWindowMode();
|
||||
|
||||
// Click "Add Fingerprint"
|
||||
final Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY_FINGERPRINT_ADD);
|
||||
mFragment.onPreferenceTreeClick(preference);
|
||||
|
||||
verify(mFragment, times(0)).startActivityForResult(any(), eq(ADD_FINGERPRINT_REQUEST));
|
||||
verify(mFragmentTransaction).add(any(), eq(BiometricsSplitScreenDialog.class.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChooseLockKeyForFingerprint() {
|
||||
setUpFragment(true);
|
||||
ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(
|
||||
Intent.class);
|
||||
verify(mFragment).startActivityForResult(intentArgumentCaptor.capture(),
|
||||
eq(CHOOSE_LOCK_GENERIC_REQUEST));
|
||||
|
||||
Intent intent = intentArgumentCaptor.getValue();
|
||||
assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT,
|
||||
false)).isTrue();
|
||||
}
|
||||
|
||||
private void setUpFragment(boolean showChooseLock) {
|
||||
Intent intent = new Intent();
|
||||
if (!showChooseLock) {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, 1L);
|
||||
}
|
||||
|
||||
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class, intent).get());
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
|
||||
@@ -112,49 +169,12 @@ public class FingerprintSettingsFragmentTest {
|
||||
doNothing().when(mFragment).startActivityForResult(any(Intent.class), anyInt());
|
||||
|
||||
setSensor();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowUtils.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddFingerprint_inFullScreen_noDialog() {
|
||||
// Start fragment
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(null);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
|
||||
mFragment.onResume();
|
||||
|
||||
// Click "Add Fingerprint"
|
||||
final Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY_FINGERPRINT_ADD);
|
||||
mFragment.onPreferenceTreeClick(preference);
|
||||
|
||||
verify(mFragment).startActivityForResult(any(), eq(ADD_FINGERPRINT_REQUEST));
|
||||
verify(mFragmentTransaction, never()).add(any(),
|
||||
eq(BiometricsSplitScreenDialog.class.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddFingerprint_inMultiWindow_showsDialog() {
|
||||
// Start fragment
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(null);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
|
||||
mFragment.onResume();
|
||||
|
||||
doReturn(true).when(mActivity).isInMultiWindowMode();
|
||||
|
||||
// Click "Add Fingerprint"
|
||||
final Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY_FINGERPRINT_ADD);
|
||||
mFragment.onPreferenceTreeClick(preference);
|
||||
|
||||
verify(mFragment, times(0)).startActivityForResult(any(), eq(ADD_FINGERPRINT_REQUEST));
|
||||
verify(mFragmentTransaction).add(any(), eq(BiometricsSplitScreenDialog.class.getName()));
|
||||
}
|
||||
|
||||
private void setSensor() {
|
||||
|
@@ -30,6 +30,8 @@ import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericF
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
|
||||
@@ -126,7 +128,9 @@ public class ChooseLockGenericTest {
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFakeFeatureFactory.mFaceFeatureProvider.isSetupWizardSupported(any())).thenReturn(
|
||||
false);
|
||||
true);
|
||||
ShadowUtils.setFingerprintManager(mFingerprintManager);
|
||||
ShadowUtils.setFaceManager(mFaceManager);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -540,35 +544,63 @@ public class ChooseLockGenericTest {
|
||||
|
||||
@Test
|
||||
public void updatePreferenceText_supportBiometrics_showFaceAndFingerprint() {
|
||||
ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_LOW);
|
||||
final PasswordPolicy policy = new PasswordPolicy();
|
||||
policy.quality = PASSWORD_QUALITY_ALPHABETIC;
|
||||
ShadowLockPatternUtils.setRequestedProfilePasswordMetrics(policy.getMinMetrics());
|
||||
|
||||
ShadowStorageManager.setIsFileEncrypted(false);
|
||||
final Intent intent = new Intent().putExtra(EXTRA_KEY_FOR_BIOMETRICS, true);
|
||||
initActivity(intent);
|
||||
|
||||
final Intent passwordIntent = mFragment.getLockPatternIntent();
|
||||
assertThat(passwordIntent.getIntExtra(ChooseLockPassword.EXTRA_KEY_MIN_COMPLEXITY,
|
||||
PASSWORD_COMPLEXITY_NONE)).isEqualTo(PASSWORD_COMPLEXITY_LOW);
|
||||
|
||||
final String supportFingerprint = capitalize(mActivity.getResources().getString(
|
||||
R.string.security_settings_fingerprint));
|
||||
final String supportFace = capitalize(mActivity.getResources().getString(
|
||||
R.string.keywords_face_settings));
|
||||
String pinTitle =
|
||||
(String) mFragment.findPreference(ScreenLockType.PIN.preferenceKey).getTitle();
|
||||
String patternTitle =
|
||||
(String) mFragment.findPreference(ScreenLockType.PATTERN.preferenceKey).getTitle();
|
||||
String passwordTitle =
|
||||
(String) mFragment.findPreference(ScreenLockType.PASSWORD.preferenceKey).getTitle();
|
||||
|
||||
assertThat(mFragment.getBiometricsPreferenceTitle(ScreenLockType.PIN)).contains(
|
||||
supportFingerprint);
|
||||
assertThat(mFragment.getBiometricsPreferenceTitle(ScreenLockType.PIN)).contains(
|
||||
supportFace);
|
||||
assertThat(mFragment.getBiometricsPreferenceTitle(ScreenLockType.PATTERN)).contains(
|
||||
supportFingerprint);
|
||||
assertThat(mFragment.getBiometricsPreferenceTitle(ScreenLockType.PATTERN)).contains(
|
||||
supportFace);
|
||||
assertThat(mFragment.getBiometricsPreferenceTitle(ScreenLockType.PASSWORD)).contains(
|
||||
supportFingerprint);
|
||||
assertThat(mFragment.getBiometricsPreferenceTitle(ScreenLockType.PASSWORD)).contains(
|
||||
supportFace);
|
||||
assertThat(pinTitle).contains(supportFingerprint);
|
||||
assertThat(pinTitle).contains(supportFace);
|
||||
assertThat(patternTitle).contains(supportFingerprint);
|
||||
assertThat(patternTitle).contains(supportFace);
|
||||
assertThat(passwordTitle).contains(supportFingerprint);
|
||||
assertThat(passwordTitle).contains(supportFace);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferenceText_supportFingerprint_showFingerprint() {
|
||||
ShadowStorageManager.setIsFileEncrypted(false);
|
||||
final Intent intent = new Intent().putExtra(EXTRA_KEY_FOR_FINGERPRINT, true);
|
||||
initActivity(intent);
|
||||
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
||||
|
||||
assertThat(mFragment.findPreference(ScreenLockType.PIN.preferenceKey).getTitle()).isEqualTo(
|
||||
mFragment.getString(R.string.fingerprint_unlock_set_unlock_pin));
|
||||
assertThat(mFragment.findPreference(
|
||||
ScreenLockType.PATTERN.preferenceKey).getTitle()).isEqualTo(
|
||||
mFragment.getString(R.string.fingerprint_unlock_set_unlock_pattern));
|
||||
assertThat(mFragment.findPreference(
|
||||
ScreenLockType.PASSWORD.preferenceKey).getTitle()).isEqualTo(
|
||||
mFragment.getString(R.string.fingerprint_unlock_set_unlock_password));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreferenceText_supportFace_showFace() {
|
||||
|
||||
ShadowStorageManager.setIsFileEncrypted(false);
|
||||
final Intent intent = new Intent().putExtra(EXTRA_KEY_FOR_FACE, true);
|
||||
initActivity(intent);
|
||||
mFragment.updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
||||
|
||||
assertThat(mFragment.findPreference(ScreenLockType.PIN.preferenceKey).getTitle()).isEqualTo(
|
||||
mFragment.getString(R.string.face_unlock_set_unlock_pin));
|
||||
assertThat(mFragment.findPreference(
|
||||
ScreenLockType.PATTERN.preferenceKey).getTitle()).isEqualTo(
|
||||
mFragment.getString(R.string.face_unlock_set_unlock_pattern));
|
||||
assertThat(mFragment.findPreference(
|
||||
ScreenLockType.PASSWORD.preferenceKey).getTitle()).isEqualTo(
|
||||
mFragment.getString(R.string.face_unlock_set_unlock_password));
|
||||
}
|
||||
|
||||
private void initActivity(@Nullable Intent intent) {
|
||||
|
Reference in New Issue
Block a user