[Biometric Onboarding & Edu] move screen lock settings to choose lock
- Hide gear menu in LockScreenSafetySource - Move screen lock settings to ChooseLockGeneric Bug: 370940762 Test: atest ScreenLockPreferenceDetailsUtilsTest Flag: com.android.settings.flags.biometrics_onboarding_education Change-Id: I07c7bb16ecc2ea6e7cd64a4e1d6bf4f493c5b951
This commit is contained in:
@@ -67,9 +67,45 @@
|
||||
android:title="@string/biometrics_unlock_skip_biometrics"
|
||||
android:persistent="false"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="unlock_settings"
|
||||
android:title="@string/security_settings_fingerprint_settings_preferences_category"
|
||||
settings:isPreferenceVisible="false">
|
||||
|
||||
<!-- available in pattern -->
|
||||
<SwitchPreferenceCompat
|
||||
android:key="visiblepattern"
|
||||
android:title="@string/lockpattern_settings_enable_visible_pattern_title" />
|
||||
|
||||
<!-- available in pin -->
|
||||
<SwitchPreferenceCompat
|
||||
android:key="auto_pin_confirm"
|
||||
android:title="@string/lock_screen_auto_pin_confirm_title"
|
||||
android:summary="@string/lock_screen_auto_pin_confirm_summary" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="enhancedPinPrivacy"
|
||||
android:title="@string/lockpattern_settings_enhanced_pin_privacy_title"
|
||||
android:summary="@string/lockpattern_settings_enhanced_pin_privacy_summary" />
|
||||
|
||||
|
||||
<!-- available in pin/pattern/password -->
|
||||
<com.android.settings.security.screenlock.ProtectedTimeoutListPreference
|
||||
android:key="lock_after_timeout"
|
||||
android:title="@string/lock_after_timeout"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:entries="@array/lock_after_timeout_entries"
|
||||
android:entryValues="@array/lock_after_timeout_values" />
|
||||
|
||||
<!-- available in pin/pattern/password -->
|
||||
<SwitchPreferenceCompat
|
||||
android:key="power_button_instantly_locks"
|
||||
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="lock_settings_footer"
|
||||
android:selectable="false"
|
||||
settings:searchable="false"/>
|
||||
android:key="lock_settings_footer"
|
||||
android:selectable="false"
|
||||
settings:searchable="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -71,6 +71,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
@@ -87,13 +88,22 @@ import com.android.settings.biometrics.BiometricUtils;
|
||||
import com.android.settings.biometrics.IdentityCheckBiometricErrorDialog;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.safetycenter.LockScreenSafetySource;
|
||||
import com.android.settings.search.SearchFeatureProvider;
|
||||
import com.android.settings.security.screenlock.AutoPinConfirmPreferenceController;
|
||||
import com.android.settings.security.screenlock.LockAfterTimeoutPreferenceController;
|
||||
import com.android.settings.security.screenlock.PatternVisiblePreferenceController;
|
||||
import com.android.settings.security.screenlock.PinPrivacyPreferenceController;
|
||||
import com.android.settings.security.screenlock.PowerButtonInstantLockPreferenceController;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Activity class that provides a generic implementation for displaying options to choose a lock
|
||||
* type, either for setting up a new lock or updating an existing lock.
|
||||
@@ -131,6 +141,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
private static final String WAITING_FOR_CONFIRMATION = "waiting_for_confirmation";
|
||||
public static final String HIDE_INSECURE_OPTIONS = "hide_insecure_options";
|
||||
public static final String TAG_FRP_WARNING_DIALOG = "frp_warning_dialog";
|
||||
|
||||
public static final String KEY_LOCK_SETTINGS = "unlock_settings";
|
||||
public static final String KEY_LOCK_SETTINGS_FOOTER ="lock_settings_footer";
|
||||
|
||||
/**
|
||||
@@ -214,6 +226,9 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
private boolean mWaitingForBiometricEnrollment = false;
|
||||
private boolean mEnrollFingerPrintOnly = false;
|
||||
|
||||
private final ArrayList<AbstractPreferenceController> mUnlockSettingsControllers =
|
||||
new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.CHOOSE_LOCK_GENERIC;
|
||||
@@ -652,6 +667,12 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
footer.setVisible(false);
|
||||
}
|
||||
|
||||
if (Flags.biometricsOnboardingEducation()
|
||||
&& !WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||
buildUnlockSettingsPreferenceControllers();
|
||||
setUpUnlockSettingsPreference();
|
||||
}
|
||||
|
||||
// Used for testing purposes
|
||||
findPreference(ScreenLockType.NONE.preferenceKey).setViewId(R.id.lock_none);
|
||||
findPreference(KEY_SKIP_FINGERPRINT).setViewId(R.id.lock_none);
|
||||
@@ -661,6 +682,37 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
findPreference(ScreenLockType.PASSWORD.preferenceKey).setViewId(R.id.lock_password);
|
||||
}
|
||||
|
||||
private void buildUnlockSettingsPreferenceControllers() {
|
||||
mUnlockSettingsControllers.add(new PatternVisiblePreferenceController(
|
||||
getContext(), mUserId, mLockPatternUtils));
|
||||
mUnlockSettingsControllers.add(new PinPrivacyPreferenceController(
|
||||
getContext(), mUserId, mLockPatternUtils));
|
||||
mUnlockSettingsControllers.add(new PowerButtonInstantLockPreferenceController(
|
||||
getContext(), mUserId, mLockPatternUtils));
|
||||
mUnlockSettingsControllers.add(new LockAfterTimeoutPreferenceController(
|
||||
getContext(), mUserId, mLockPatternUtils));
|
||||
mUnlockSettingsControllers.add(new AutoPinConfirmPreferenceController(
|
||||
getContext(), mUserId, mLockPatternUtils, this));
|
||||
}
|
||||
|
||||
private void setUpUnlockSettingsPreference() {
|
||||
boolean showUnlockSettingsCategory = false;
|
||||
for (AbstractPreferenceController controller : mUnlockSettingsControllers) {
|
||||
final boolean isAvailable = controller.isAvailable();
|
||||
final Preference preference = findPreference(controller.getPreferenceKey());
|
||||
preference.setVisible(isAvailable);
|
||||
if (!isAvailable) {
|
||||
continue;
|
||||
}
|
||||
preference.setOnPreferenceChangeListener(
|
||||
(Preference.OnPreferenceChangeListener) controller);
|
||||
controller.updateState(preference);
|
||||
showUnlockSettingsCategory = true;
|
||||
}
|
||||
final PreferenceCategory unlockSettingsCategory = findPreference(KEY_LOCK_SETTINGS);
|
||||
unlockSettingsCategory.setVisible(showUnlockSettingsCategory);
|
||||
}
|
||||
|
||||
private String getFooterString() {
|
||||
@StringRes int stringId;
|
||||
switch (mController.getAggregatedPasswordComplexity()) {
|
||||
|
@@ -92,7 +92,8 @@ public class ScreenLockPreferenceDetailsUtils {
|
||||
* Returns whether the Gear Menu should be shown.
|
||||
*/
|
||||
public boolean shouldShowGearMenu() {
|
||||
return isLockPatternSecure();
|
||||
return !com.android.settings.flags.Flags.biometricsOnboardingEducation()
|
||||
&& isLockPatternSecure();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,12 +32,17 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.security.screenlock.ScreenLockSettings;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -46,6 +51,7 @@ import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -58,6 +64,8 @@ public class ScreenLockPreferenceDetailsUtilsTest {
|
||||
private static final int SOURCE_METRICS_CATEGORY = 10;
|
||||
private static final int USER_ID = 11;
|
||||
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
@Mock
|
||||
private LockPatternUtils mLockPatternUtils;
|
||||
@Mock
|
||||
@@ -267,14 +275,32 @@ public class ScreenLockPreferenceDetailsUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldShowGearMenu_patternIsSecure_shouldReturnTrue() {
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRIC_ONBOARDING_EDUCATION)
|
||||
public void shouldShowGearMenu_patternIsSecure_flagOn_shouldReturnFalse() {
|
||||
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||
|
||||
assertThat(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRIC_ONBOARDING_EDUCATION)
|
||||
public void shouldShowGearMenu_patternIsNotSecure_flagOff_shouldReturnFalse() {
|
||||
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
|
||||
|
||||
assertThat(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRIC_ONBOARDING_EDUCATION)
|
||||
public void shouldShowGearMenu_patternIsSecure_flagOff_shouldReturnTrue() {
|
||||
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||
|
||||
assertThat(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldShowGearMenu_patternIsNotSecure_shouldReturnFalse() {
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRIC_ONBOARDING_EDUCATION)
|
||||
public void shouldShowGearMenu_patternIsNotSecure_flagOn_shouldReturnFalse() {
|
||||
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
|
||||
|
||||
assertThat(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).isFalse();
|
||||
|
Reference in New Issue
Block a user