Loading res/layout/face_enroll_button.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2019 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/security_settings_face_settings_enroll_button" android:layout_marginStart="@dimen/screen_margin_sides" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="start" android:text="@string/security_settings_face_settings_enroll"/> </LinearLayout> No newline at end of file res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -948,6 +948,8 @@ <string name="security_settings_face_settings_require_confirmation_details">When authenticating in apps, always require confirmation</string> <!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] --> <string name="security_settings_face_settings_remove_face_data">Remove face data</string> <!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] --> <string name="security_settings_face_settings_enroll">Set up face authentication</string> <!-- 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. <annotation id="url">Learn more</annotation></string> Loading res/xml/security_settings_face.xml +5 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,11 @@ android:key="security_settings_face_delete_faces_container" android:selectable="false" android:layout="@layout/face_remove_button" /> <com.android.settingslib.widget.LayoutPreference android:key="security_settings_face_enroll_faces_container" android:selectable="false" android:layout="@layout/face_enroll_button " /> </PreferenceCategory> <PreferenceCategory Loading src/com/android/settings/biometrics/BiometricEnrollBase.java +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity { public static final int BIOMETRIC_FIND_SENSOR_REQUEST = 2; public static final int LEARN_MORE_REQUEST = 3; public static final int CONFIRM_REQUEST = 4; public static final int ENROLLING = 5; public static final int ENROLL_REQUEST = 5; protected boolean mLaunchedConfirmLock; protected byte[] mToken; Loading src/com/android/settings/biometrics/face/FaceSettings.java +37 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import android.os.UserManager; import android.provider.SearchIndexableResource; import android.util.Log; import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.Utils; Loading Loading @@ -60,12 +62,23 @@ public class FaceSettings extends DashboardFragment { private byte[] mToken; private FaceSettingsAttentionPreferenceController mAttentionController; private FaceSettingsRemoveButtonPreferenceController mRemoveController; private FaceSettingsEnrollButtonPreferenceController mEnrollController; private List<AbstractPreferenceController> mControllers; private List<Preference> mTogglePreferences; private Preference mRemoveButton; private Preference mEnrollButton; private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> { if (getActivity() != null) { getActivity().finish(); // Disable the toggles until the user re-enrolls for (Preference preference : mTogglePreferences) { preference.setEnabled(false); } // Hide the "remove" button and show the "set up face authentication" button. mRemoveButton.setVisible(false); mEnrollButton.setVisible(true); }; public static boolean isAvailable(Context context) { Loading Loading @@ -103,10 +116,22 @@ public class FaceSettings extends DashboardFragment { mUserId = getActivity().getIntent().getIntExtra( Intent.EXTRA_USER_ID, UserHandle.myUserId()); Preference keyguardPref = findPreference(FaceSettingsKeyguardPreferenceController.KEY); Preference appPref = findPreference(FaceSettingsAppPreferenceController.KEY); Preference attentionPref = findPreference(FaceSettingsAttentionPreferenceController.KEY); Preference confirmPref = findPreference(FaceSettingsConfirmPreferenceController.KEY); mTogglePreferences = new ArrayList<>( Arrays.asList(keyguardPref, appPref, attentionPref, confirmPref)); mRemoveButton = findPreference(FaceSettingsRemoveButtonPreferenceController.KEY); mEnrollButton = findPreference(FaceSettingsEnrollButtonPreferenceController.KEY); // There is no better way to do this :/ for (AbstractPreferenceController controller : mControllers) { if (controller instanceof FaceSettingsPreferenceController) { ((FaceSettingsPreferenceController) controller).setUserId(mUserId); } else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) { ((FaceSettingsEnrollButtonPreferenceController) controller).setUserId(mUserId); } } mRemoveController.setUserId(mUserId); Loading Loading @@ -137,7 +162,12 @@ public class FaceSettings extends DashboardFragment { super.onResume(); if (mToken != null) { mAttentionController.setToken(mToken); mEnrollController.setToken(mToken); } final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId); mEnrollButton.setVisible(!hasEnrolled); mRemoveButton.setVisible(hasEnrolled); } @Override Loading @@ -152,6 +182,7 @@ public class FaceSettings extends DashboardFragment { ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); if (mToken != null) { mAttentionController.setToken(mToken); mEnrollController.setToken(mToken); } } } Loading Loading @@ -188,6 +219,9 @@ public class FaceSettings extends DashboardFragment { mRemoveController = (FaceSettingsRemoveButtonPreferenceController) controller; mRemoveController.setListener(mRemovalListener); mRemoveController.setActivity((SettingsActivity) getActivity()); } else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) { mEnrollController = (FaceSettingsEnrollButtonPreferenceController) controller; mEnrollController.setActivity((SettingsActivity) getActivity()); } } Loading @@ -204,6 +238,7 @@ public class FaceSettings extends DashboardFragment { controllers.add(new FaceSettingsRemoveButtonPreferenceController(context)); controllers.add(new FaceSettingsFooterPreferenceController(context)); controllers.add(new FaceSettingsConfirmPreferenceController(context)); controllers.add(new FaceSettingsEnrollButtonPreferenceController(context)); return controllers; } Loading Loading
res/layout/face_enroll_button.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2019 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/security_settings_face_settings_enroll_button" android:layout_marginStart="@dimen/screen_margin_sides" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="start" android:text="@string/security_settings_face_settings_enroll"/> </LinearLayout> No newline at end of file
res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -948,6 +948,8 @@ <string name="security_settings_face_settings_require_confirmation_details">When authenticating in apps, always require confirmation</string> <!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] --> <string name="security_settings_face_settings_remove_face_data">Remove face data</string> <!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] --> <string name="security_settings_face_settings_enroll">Set up face authentication</string> <!-- 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. <annotation id="url">Learn more</annotation></string> Loading
res/xml/security_settings_face.xml +5 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,11 @@ android:key="security_settings_face_delete_faces_container" android:selectable="false" android:layout="@layout/face_remove_button" /> <com.android.settingslib.widget.LayoutPreference android:key="security_settings_face_enroll_faces_container" android:selectable="false" android:layout="@layout/face_enroll_button " /> </PreferenceCategory> <PreferenceCategory Loading
src/com/android/settings/biometrics/BiometricEnrollBase.java +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity { public static final int BIOMETRIC_FIND_SENSOR_REQUEST = 2; public static final int LEARN_MORE_REQUEST = 3; public static final int CONFIRM_REQUEST = 4; public static final int ENROLLING = 5; public static final int ENROLL_REQUEST = 5; protected boolean mLaunchedConfirmLock; protected byte[] mToken; Loading
src/com/android/settings/biometrics/face/FaceSettings.java +37 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import android.os.UserManager; import android.provider.SearchIndexableResource; import android.util.Log; import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.Utils; Loading Loading @@ -60,12 +62,23 @@ public class FaceSettings extends DashboardFragment { private byte[] mToken; private FaceSettingsAttentionPreferenceController mAttentionController; private FaceSettingsRemoveButtonPreferenceController mRemoveController; private FaceSettingsEnrollButtonPreferenceController mEnrollController; private List<AbstractPreferenceController> mControllers; private List<Preference> mTogglePreferences; private Preference mRemoveButton; private Preference mEnrollButton; private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> { if (getActivity() != null) { getActivity().finish(); // Disable the toggles until the user re-enrolls for (Preference preference : mTogglePreferences) { preference.setEnabled(false); } // Hide the "remove" button and show the "set up face authentication" button. mRemoveButton.setVisible(false); mEnrollButton.setVisible(true); }; public static boolean isAvailable(Context context) { Loading Loading @@ -103,10 +116,22 @@ public class FaceSettings extends DashboardFragment { mUserId = getActivity().getIntent().getIntExtra( Intent.EXTRA_USER_ID, UserHandle.myUserId()); Preference keyguardPref = findPreference(FaceSettingsKeyguardPreferenceController.KEY); Preference appPref = findPreference(FaceSettingsAppPreferenceController.KEY); Preference attentionPref = findPreference(FaceSettingsAttentionPreferenceController.KEY); Preference confirmPref = findPreference(FaceSettingsConfirmPreferenceController.KEY); mTogglePreferences = new ArrayList<>( Arrays.asList(keyguardPref, appPref, attentionPref, confirmPref)); mRemoveButton = findPreference(FaceSettingsRemoveButtonPreferenceController.KEY); mEnrollButton = findPreference(FaceSettingsEnrollButtonPreferenceController.KEY); // There is no better way to do this :/ for (AbstractPreferenceController controller : mControllers) { if (controller instanceof FaceSettingsPreferenceController) { ((FaceSettingsPreferenceController) controller).setUserId(mUserId); } else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) { ((FaceSettingsEnrollButtonPreferenceController) controller).setUserId(mUserId); } } mRemoveController.setUserId(mUserId); Loading Loading @@ -137,7 +162,12 @@ public class FaceSettings extends DashboardFragment { super.onResume(); if (mToken != null) { mAttentionController.setToken(mToken); mEnrollController.setToken(mToken); } final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId); mEnrollButton.setVisible(!hasEnrolled); mRemoveButton.setVisible(hasEnrolled); } @Override Loading @@ -152,6 +182,7 @@ public class FaceSettings extends DashboardFragment { ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); if (mToken != null) { mAttentionController.setToken(mToken); mEnrollController.setToken(mToken); } } } Loading Loading @@ -188,6 +219,9 @@ public class FaceSettings extends DashboardFragment { mRemoveController = (FaceSettingsRemoveButtonPreferenceController) controller; mRemoveController.setListener(mRemovalListener); mRemoveController.setActivity((SettingsActivity) getActivity()); } else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) { mEnrollController = (FaceSettingsEnrollButtonPreferenceController) controller; mEnrollController.setActivity((SettingsActivity) getActivity()); } } Loading @@ -204,6 +238,7 @@ public class FaceSettings extends DashboardFragment { controllers.add(new FaceSettingsRemoveButtonPreferenceController(context)); controllers.add(new FaceSettingsFooterPreferenceController(context)); controllers.add(new FaceSettingsConfirmPreferenceController(context)); controllers.add(new FaceSettingsEnrollButtonPreferenceController(context)); return controllers; } Loading