Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 388295a8 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge changes from topic "face-profile-qt-dev" into qt-dev

* changes:
  Settings should be per-profile
  Add face profile settings
parents f768b451 e596ba68
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -925,9 +925,9 @@
    <!-- Button text to exit face wizard after everything is done [CHAR LIMIT=15] -->
    <string name="security_settings_face_enroll_done">Done</string>
    <!-- Title for a category shown for the face settings page. [CHAR LIMIT=20] -->
    <string name="security_settings_face_settings_use_face_category">Use your face to</string>
    <string name="security_settings_face_settings_use_face_category">Use your face for</string>
    <!-- Text shown on a toggle which allows or disallows the device to use face for unlocking the device. [CHAR LIMIT=20] -->
    <string name="security_settings_face_settings_use_face_unlock_phone">Unlock your device</string>
    <string name="security_settings_face_settings_use_face_unlock_phone">Unlocking your device</string>
    <!-- Text shown on a toggle which allows or disallows the device to use face authentication for apps. This will be presented to the user together with the context of security_settings_face_settings_use_face_category. [CHAR LIMIT=30] -->
    <string name="security_settings_face_settings_use_face_for_apps">App sign-in \u0026 payments</string>
    <!-- Text shown on a toggle which disables/enables face authentication, depending if the user's eyes are open. [CHAR LIMIT=30] -->
+5 −0
Original line number Diff line number Diff line
@@ -87,6 +87,11 @@
            android:title="@string/security_settings_fingerprint_preference_title"
            android:summary="@string/summary_placeholder" />

        <Preference
            android:key="face_settings_profile"
            android:title="@string/security_settings_face_preference_title"
            android:summary="@string/summary_placeholder" />

    </PreferenceCategory>

    <PreferenceCategory
+40 −0
Original line number Diff line number Diff line
/*
 * 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
 */

package com.android.settings.biometrics.face;

import android.content.Context;
import android.os.UserHandle;

public class FaceProfileStatusPreferenceController extends FaceStatusPreferenceController {

    public static final String KEY_FACE_SETTINGS = "face_settings_profile";

    public FaceProfileStatusPreferenceController(Context context) {
        super(context, KEY_FACE_SETTINGS);
    }

    @Override
    protected boolean isUserSupported() {
        return mProfileChallengeUserId != UserHandle.USER_NULL
                && mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId);
    }

    @Override
    protected int getUserId() {
        return mProfileChallengeUserId;
    }
}
+21 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Intent;
import android.hardware.face.FaceManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.util.Log;

@@ -53,11 +54,13 @@ public class FaceSettings extends DashboardFragment {
    private static final String TAG = "FaceSettings";
    private static final String KEY_TOKEN = "key_token";

    private UserManager mUserManager;
    private FaceManager mFaceManager;
    private int mUserId;
    private byte[] mToken;
    private FaceSettingsAttentionPreferenceController mAttentionController;
    private FaceSettingsRemoveButtonPreferenceController mRemoveController;
    private List<AbstractPreferenceController> mControllers;

    private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
        if (getActivity() != null) {
@@ -95,10 +98,24 @@ public class FaceSettings extends DashboardFragment {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mUserManager = getPrefContext().getSystemService(UserManager.class);
        mFaceManager = getPrefContext().getSystemService(FaceManager.class);
        mUserId = getActivity().getIntent().getIntExtra(
                Intent.EXTRA_USER_ID, UserHandle.myUserId());

        // There is no better way to do this :/
        for (AbstractPreferenceController controller : mControllers) {
            if (controller instanceof  FaceSettingsPreferenceController) {
                ((FaceSettingsPreferenceController) controller).setUserId(mUserId);
            }
        }
        mRemoveController.setUserId(mUserId);

        // Don't show keyguard controller for work profile settings.
        if (mUserManager.isManagedProfile(mUserId)) {
            removePreference(FaceSettingsKeyguardPreferenceController.KEY);
        }

        if (savedInstanceState != null) {
            mToken = savedInstanceState.getByteArray(KEY_TOKEN);
        }
@@ -128,6 +145,7 @@ public class FaceSettings extends DashboardFragment {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == CONFIRM_REQUEST) {
            if (resultCode == RESULT_FINISHED || resultCode == RESULT_OK) {
                mFaceManager.setActiveUser(mUserId);
                // The pin/pattern/password was set.
                if (data != null) {
                    mToken = data.getByteArrayExtra(
@@ -161,10 +179,9 @@ public class FaceSettings extends DashboardFragment {
        if (!isAvailable(context)) {
            return null;
        }
        final List<AbstractPreferenceController> controllers =
                buildPreferenceControllers(context, getSettingsLifecycle());
        mControllers = buildPreferenceControllers(context, getSettingsLifecycle());
        // There's no great way of doing this right now :/
        for (AbstractPreferenceController controller : controllers) {
        for (AbstractPreferenceController controller : mControllers) {
            if (controller instanceof FaceSettingsAttentionPreferenceController) {
                mAttentionController = (FaceSettingsAttentionPreferenceController) controller;
            } else if (controller instanceof FaceSettingsRemoveButtonPreferenceController) {
@@ -174,7 +191,7 @@ public class FaceSettings extends DashboardFragment {
            }
        }

        return controllers;
        return mControllers;
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+5 −7
Original line number Diff line number Diff line
@@ -21,13 +21,11 @@ import static android.provider.Settings.Secure.FACE_UNLOCK_APP_ENABLED;
import android.content.Context;
import android.provider.Settings;

import com.android.settings.core.TogglePreferenceController;

/**
 * Preference controller for Face settings page controlling the ability to use
 * Face authentication in apps (through BiometricPrompt).
 */
public class FaceSettingsAppPreferenceController extends TogglePreferenceController {
public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceController {

    private static final String KEY = "security_settings_face_app";

@@ -48,14 +46,14 @@ public class FaceSettingsAppPreferenceController extends TogglePreferenceControl
        if (!FaceSettings.isAvailable(mContext)) {
            return false;
        }
        return Settings.Secure.getInt(
                mContext.getContentResolver(), FACE_UNLOCK_APP_ENABLED, DEFAULT) == ON;
        return Settings.Secure.getIntForUser(
                mContext.getContentResolver(), FACE_UNLOCK_APP_ENABLED, DEFAULT, getUserId()) == ON;
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        return Settings.Secure.putInt(mContext.getContentResolver(), FACE_UNLOCK_APP_ENABLED,
                isChecked ? ON : OFF);
        return Settings.Secure.putIntForUser(mContext.getContentResolver(), FACE_UNLOCK_APP_ENABLED,
                isChecked ? ON : OFF, getUserId());
    }

    @Override
Loading