Merge "Add mandatory biometric prompt to platform surfaces (4/N)" into main
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
|
||||
|
||||
@@ -55,6 +55,7 @@ public class BuildNumberPreferenceController extends BasePreferenceController im
|
||||
|
||||
static final int TAPS_TO_BE_A_DEVELOPER = 7;
|
||||
static final int REQUEST_CONFIRM_PASSWORD_FOR_DEV_PREF = 100;
|
||||
static final int REQUEST_IDENTITY_CHECK_FOR_DEV_PREF = 101;
|
||||
|
||||
private Activity mActivity;
|
||||
private InstrumentedPreferenceFragment mFragment;
|
||||
@@ -217,10 +218,24 @@ public class BuildNumberPreferenceController extends BasePreferenceController im
|
||||
* @return if activity result is handled.
|
||||
*/
|
||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode != REQUEST_CONFIRM_PASSWORD_FOR_DEV_PREF) {
|
||||
if (requestCode != REQUEST_CONFIRM_PASSWORD_FOR_DEV_PREF
|
||||
&& requestCode != REQUEST_IDENTITY_CHECK_FOR_DEV_PREF) {
|
||||
return false;
|
||||
}
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == REQUEST_CONFIRM_PASSWORD_FOR_DEV_PREF
|
||||
&& resultCode == Activity.RESULT_OK) {
|
||||
final int userId = mContext.getUserId();
|
||||
if (Utils.requestBiometricAuthenticationForMandatoryBiometrics(mContext,
|
||||
false /* biometricsSuccessfullyAuthenticated */,
|
||||
false /* biometricsAuthenticationRequested */,
|
||||
userId)) {
|
||||
Utils.launchBiometricPromptForMandatoryBiometrics(mFragment,
|
||||
REQUEST_IDENTITY_CHECK_FOR_DEV_PREF, userId, false /* hideBackground */);
|
||||
} else {
|
||||
enableDevelopmentSettings();
|
||||
}
|
||||
} else if (requestCode == REQUEST_IDENTITY_CHECK_FOR_DEV_PREF
|
||||
&& resultCode == Activity.RESULT_OK) {
|
||||
enableDevelopmentSettings();
|
||||
}
|
||||
mProcessingLastDevHit = false;
|
||||
|
||||
Reference in New Issue
Block a user