Merge "Show a dialog preventing fingerprint enrollment in split mode." into udc-dev
This commit is contained in:
@@ -41,6 +41,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.biometrics.BiometricUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment;
|
||||
import com.android.settings.core.SettingsBaseActivity;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
@@ -166,6 +167,14 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
return true;
|
||||
} else if (getFingerprintPreferenceKey().equals(key)) {
|
||||
mDoNotFinishActivity = true;
|
||||
|
||||
if (shouldSkipForUdfpsInMultiWindowMode()) {
|
||||
new FingerprintSettingsFragment.FingerprintSplitScreenDialog().show(
|
||||
getActivity().getSupportFragmentManager(),
|
||||
FingerprintSettingsFragment.FingerprintSplitScreenDialog.class.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
mFingerprintManager.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
|
||||
try {
|
||||
final byte[] token = requestGatekeeperHat(context, mGkPwHandle, mUserId,
|
||||
@@ -377,4 +386,27 @@ public abstract class BiometricsSettingsBase extends DashboardFragment {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the click should be skipped.
|
||||
* True if the following conditions are all met:
|
||||
* 1. It's split mode.
|
||||
* 2. It's udfps.
|
||||
* 3. There is no enrolled fingerprint. (If there is enrolled fingerprint, FingerprintSettings
|
||||
* will handle the adding fingerprint.
|
||||
*/
|
||||
private boolean shouldSkipForUdfpsInMultiWindowMode() {
|
||||
if (!getActivity().isInMultiWindowMode() || mFingerprintManager.hasEnrolledFingerprints(
|
||||
mUserId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (FingerprintSensorPropertiesInternal prop :
|
||||
mFingerprintManager.getSensorPropertiesInternal()) {
|
||||
if (prop.isAnyUdfpsType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -159,7 +159,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
|
||||
private static final String TAG = "FingerprintSettings";
|
||||
private static final String KEY_FINGERPRINT_ITEM_PREFIX = "key_fingerprint_item";
|
||||
private static final String KEY_FINGERPRINT_ADD = "key_fingerprint_add";
|
||||
@VisibleForTesting
|
||||
static final String KEY_FINGERPRINT_ADD = "key_fingerprint_add";
|
||||
private static final String KEY_FINGERPRINT_ENABLE_KEYGUARD_TOGGLE =
|
||||
"fingerprint_enable_keyguard_toggle";
|
||||
private static final String KEY_LAUNCHED_CONFIRM = "launched_confirm";
|
||||
@@ -178,8 +179,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
|
||||
private static final int CONFIRM_REQUEST = 101;
|
||||
private static final int CHOOSE_LOCK_GENERIC_REQUEST = 102;
|
||||
|
||||
private static final int ADD_FINGERPRINT_REQUEST = 10;
|
||||
@VisibleForTesting
|
||||
static final int ADD_FINGERPRINT_REQUEST = 10;
|
||||
private static final int AUTO_ADD_FIRST_FINGERPRINT_REQUEST = 11;
|
||||
|
||||
protected static final boolean DEBUG = false;
|
||||
@@ -694,6 +695,15 @@ public class FingerprintSettings extends SubSettings {
|
||||
public boolean onPreferenceTreeClick(Preference pref) {
|
||||
final String key = pref.getKey();
|
||||
if (KEY_FINGERPRINT_ADD.equals(key)) {
|
||||
// If it's udfps in split mode, show the error dialog and don't need to show adding
|
||||
// fingerprint intent.
|
||||
if (shouldSkipForUdfpsInMultiWindowMode()) {
|
||||
new FingerprintSplitScreenDialog().show(
|
||||
getActivity().getSupportFragmentManager(),
|
||||
FingerprintSplitScreenDialog.class.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
mIsEnrolling = true;
|
||||
Intent intent = new Intent();
|
||||
if (FeatureFlagUtils.isEnabled(getContext(),
|
||||
@@ -997,6 +1007,14 @@ public class FingerprintSettings extends SubSettings {
|
||||
updatePreferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the click should be skipped.
|
||||
* True if it's udfps and it's in split mode.
|
||||
*/
|
||||
private boolean shouldSkipForUdfpsInMultiWindowMode() {
|
||||
return getActivity().isInMultiWindowMode() && isUdfps();
|
||||
}
|
||||
|
||||
private final Runnable mFingerprintLockoutReset = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1246,6 +1264,29 @@ public class FingerprintSettings extends SubSettings {
|
||||
return alertDialog;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This alert dialog shows when fingerprint is being added in multi window mode.
|
||||
*/
|
||||
public static class FingerprintSplitScreenDialog extends InstrumentedDialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(
|
||||
R.string.biometric_settings_add_fingerprint_in_split_mode_title)
|
||||
.setMessage(
|
||||
R.string.biometric_settings_add_fingerprint_in_split_mode_message)
|
||||
.setPositiveButton(
|
||||
R.string.biometric_settings_add_fingerprint_in_split_mode_ok,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> dialog.dismiss());
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.DIALOG_ADD_FINGERPRINT_ERROR_IN_SPLIT_MODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FingerprintPreference extends TwoTargetPreference {
|
||||
|
Reference in New Issue
Block a user