Show confirmation dialog for removing enrollment
Fixes: 123605413 Test: builds Change-Id: I9e918977909bcf461a29eb36f157c3a261c6dcc4
This commit is contained in:
@@ -941,6 +941,11 @@
|
|||||||
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
|
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
|
||||||
<string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
|
<string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
|
||||||
<annotation id="url">Learn more</annotation></string>
|
<annotation id="url">Learn more</annotation></string>
|
||||||
|
<!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
|
||||||
|
<string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
|
||||||
|
<!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="security_settings_face_settings_remove_dialog_details">Data recorded by face unlock will be permanently and securely deleted. After removal, you will need your PIN, pattern, or password to unlock your phone, sign in to apps, and confirm payments.</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Fingerprint enrollment and settings --><skip />
|
<!-- Fingerprint enrollment and settings --><skip />
|
||||||
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
|
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
|
||||||
|
@@ -31,6 +31,7 @@ import android.provider.SearchIndexableResource;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
@@ -56,6 +57,7 @@ public class FaceSettings extends DashboardFragment {
|
|||||||
private int mUserId;
|
private int mUserId;
|
||||||
private byte[] mToken;
|
private byte[] mToken;
|
||||||
private FaceSettingsAttentionPreferenceController mAttentionController;
|
private FaceSettingsAttentionPreferenceController mAttentionController;
|
||||||
|
private FaceSettingsRemoveButtonPreferenceController mRemoveController;
|
||||||
|
|
||||||
private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
|
private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
@@ -166,8 +168,9 @@ public class FaceSettings extends DashboardFragment {
|
|||||||
if (controller instanceof FaceSettingsAttentionPreferenceController) {
|
if (controller instanceof FaceSettingsAttentionPreferenceController) {
|
||||||
mAttentionController = (FaceSettingsAttentionPreferenceController) controller;
|
mAttentionController = (FaceSettingsAttentionPreferenceController) controller;
|
||||||
} else if (controller instanceof FaceSettingsRemoveButtonPreferenceController) {
|
} else if (controller instanceof FaceSettingsRemoveButtonPreferenceController) {
|
||||||
((FaceSettingsRemoveButtonPreferenceController) controller)
|
mRemoveController = (FaceSettingsRemoveButtonPreferenceController) controller;
|
||||||
.setListener(mRemovalListener);
|
mRemoveController.setListener(mRemovalListener);
|
||||||
|
mRemoveController.setActivity((SettingsActivity) getActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,9 +16,14 @@
|
|||||||
|
|
||||||
package com.android.settings.biometrics.face;
|
package com.android.settings.biometrics.face;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.hardware.face.Face;
|
import android.hardware.face.Face;
|
||||||
import android.hardware.face.FaceManager;
|
import android.hardware.face.FaceManager;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -28,7 +33,9 @@ import android.widget.Toast;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -43,6 +50,33 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
|
|||||||
private static final String TAG = "FaceSettings/Remove";
|
private static final String TAG = "FaceSettings/Remove";
|
||||||
private static final String KEY = "security_settings_face_delete_faces_container";
|
private static final String KEY = "security_settings_face_delete_faces_container";
|
||||||
|
|
||||||
|
public static class ConfirmRemoveDialog extends InstrumentedDialogFragment {
|
||||||
|
|
||||||
|
private DialogInterface.OnClickListener mOnClickListener;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.DIALOG_FACE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
|
||||||
|
builder.setTitle(R.string.security_settings_face_settings_remove_dialog_title)
|
||||||
|
.setMessage(R.string.security_settings_face_settings_remove_dialog_details)
|
||||||
|
.setPositiveButton(R.string.okay, mOnClickListener)
|
||||||
|
.setNegativeButton(R.string.cancel, mOnClickListener);
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnClickListener(DialogInterface.OnClickListener listener) {
|
||||||
|
mOnClickListener = listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
void onRemoved();
|
void onRemoved();
|
||||||
}
|
}
|
||||||
@@ -50,6 +84,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
|
|||||||
private Button mButton;
|
private Button mButton;
|
||||||
private List<Face> mFaces;
|
private List<Face> mFaces;
|
||||||
private Listener mListener;
|
private Listener mListener;
|
||||||
|
private SettingsActivity mActivity;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final int mUserId;
|
private final int mUserId;
|
||||||
@@ -77,6 +112,27 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final DialogInterface.OnClickListener mOnClickListener
|
||||||
|
= new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
|
if (mFaces.isEmpty()) {
|
||||||
|
Log.e(TAG, "No faces");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mFaces.size() > 1) {
|
||||||
|
Log.e(TAG, "Multiple enrollments: " + mFaces.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the first/only face
|
||||||
|
mFaceManager.remove(mFaces.get(0), mUserId, mRemovalCallback);
|
||||||
|
} else {
|
||||||
|
mButton.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public FaceSettingsRemoveButtonPreferenceController(Context context, String preferenceKey) {
|
public FaceSettingsRemoveButtonPreferenceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -115,20 +171,17 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v == mButton) {
|
if (v == mButton) {
|
||||||
mButton.setEnabled(false);
|
mButton.setEnabled(false);
|
||||||
if (mFaces.isEmpty()) {
|
ConfirmRemoveDialog dialog = new ConfirmRemoveDialog();
|
||||||
Log.e(TAG, "No faces");
|
dialog.setOnClickListener(mOnClickListener);
|
||||||
return;
|
dialog.show(mActivity.getSupportFragmentManager(), ConfirmRemoveDialog.class.getName());
|
||||||
}
|
|
||||||
if (mFaces.size() > 1) {
|
|
||||||
Log.e(TAG, "Multiple enrollments: " + mFaces.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the first/only face
|
|
||||||
mFaceManager.remove(mFaces.get(0), mUserId, mRemovalCallback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListener(Listener listener) {
|
public void setListener(Listener listener) {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setActivity(SettingsActivity activity) {
|
||||||
|
mActivity = activity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user