Add mandatory biometric prompt to platform surfaces (4/N)
1. Enable developer options via build info 2. Enable developer options via toggle under system -> developer options Flag: android.hardware.biometrics.flags.mandatory_biometrics Fixes: 355500452 Test: atest BuildNumberPreferenceControllerTest DevelopmentSettingsDashboardFragmentTest Change-Id: Iecbe34024d287e71e235becec3ce5a2bd5c1697f
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.development;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED;
|
||||
import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES;
|
||||
import static android.view.flags.Flags.sensitiveContentAppProtectionApi;
|
||||
@@ -100,11 +101,13 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
NfcRebootDialog.OnNfcRebootDialogConfirmedListener, BluetoothSnoopLogHost {
|
||||
|
||||
private static final String TAG = "DevSettingsDashboard";
|
||||
@VisibleForTesting static final int REQUEST_BIOMETRIC_PROMPT = 100;
|
||||
|
||||
private final BluetoothA2dpConfigStore mBluetoothA2dpConfigStore =
|
||||
new BluetoothA2dpConfigStore();
|
||||
|
||||
private boolean mIsAvailable = true;
|
||||
private boolean mIsBiometricsAuthenticated;
|
||||
private SettingsMainSwitchBar mSwitchBar;
|
||||
private DevelopmentSwitchBarController mSwitchBarController;
|
||||
private List<AbstractPreferenceController> mPreferenceControllers = new ArrayList<>();
|
||||
@@ -216,6 +219,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final ContentResolver cr = getContext().getContentResolver();
|
||||
mIsBiometricsAuthenticated = false;
|
||||
cr.registerContentObserver(mDevelopEnabled, false, mDeveloperSettingsObserver);
|
||||
|
||||
// Restore UI state based on whether developer options is enabled
|
||||
@@ -360,7 +364,18 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext());
|
||||
if (isChecked != developmentEnabledState) {
|
||||
if (isChecked) {
|
||||
EnableDevelopmentSettingWarningDialog.show(this /* host */);
|
||||
final int userId = getContext().getUserId();
|
||||
if (Utils.requestBiometricAuthenticationForMandatoryBiometrics(getContext(),
|
||||
mIsBiometricsAuthenticated,
|
||||
false /* biometricsAuthenticationRequested */, userId)) {
|
||||
mSwitchBar.setChecked(false);
|
||||
Utils.launchBiometricPromptForMandatoryBiometrics(this,
|
||||
REQUEST_BIOMETRIC_PROMPT, userId, false /* hideBackground */);
|
||||
} else {
|
||||
//Reset biometrics once enable dialog is shown
|
||||
mIsBiometricsAuthenticated = false;
|
||||
EnableDevelopmentSettingWarningDialog.show(this /* host */);
|
||||
}
|
||||
} else {
|
||||
final BluetoothA2dpHwOffloadPreferenceController a2dpController =
|
||||
getDevelopmentOptionsController(
|
||||
@@ -534,6 +549,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
boolean handledResult = false;
|
||||
if (requestCode == REQUEST_BIOMETRIC_PROMPT) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
mIsBiometricsAuthenticated = true;
|
||||
mSwitchBar.setChecked(true);
|
||||
}
|
||||
}
|
||||
for (AbstractPreferenceController controller : mPreferenceControllers) {
|
||||
if (controller instanceof OnActivityResultListener) {
|
||||
// We do not break early because it is possible for multiple controllers to
|
||||
|
Reference in New Issue
Block a user