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

Commit e596ba68 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Settings should be per-profile

Also, don't show keyguard option for work profile

Fixes: 129905061

Test: Builds
Change-Id: I18f573f39ee4e54a3385cc65079bb794633cc560
parent 39ca0215
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] -->
+20 −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);
        }
@@ -162,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) {
@@ -175,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
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import com.android.settings.core.TogglePreferenceController;
 * Preference controller that manages the ability to use face authentication with/without
 * user attention. See {@link FaceManager#setRequireAttention(boolean, byte[])}.
 */
public class FaceSettingsAttentionPreferenceController extends TogglePreferenceController {
public class FaceSettingsAttentionPreferenceController extends FaceSettingsPreferenceController {

    public static final String KEY = "security_settings_face_require_attention";

+5 −5
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.settings.core.TogglePreferenceController;
/**
 * Preference controller giving the user an option to always require confirmation.
 */
public class FaceSettingsConfirmPreferenceController extends TogglePreferenceController {
public class FaceSettingsConfirmPreferenceController extends FaceSettingsPreferenceController {

    private static final String KEY = "security_settings_face_require_confirmation";

@@ -45,14 +45,14 @@ public class FaceSettingsConfirmPreferenceController extends TogglePreferenceCon

    @Override
    public boolean isChecked() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
                FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, DEFAULT) == ON;
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, DEFAULT, getUserId()) == ON;
    }

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

    @Override
Loading