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

Commit 09f24694 authored by Edgar Wang's avatar Edgar Wang Committed by android-build-merger
Browse files

Merge "Add skip lock screen in Notification & security lock screen settings"...

Merge "Add skip lock screen in Notification & security lock screen settings" into qt-r1-dev am: 8e3b2020
am: 063cc347

Change-Id: Ic856426092578e47418498de40e22aa484badb19
parents 6f2c6641 063cc347
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -72,6 +72,13 @@
            android:summary="@string/lock_screen_notifs_redact_work_summary"
            settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />

        <SwitchPreference
            android:key="notification_lockscreen_bypass"
            android:title="@string/lockscreen_bypass_title"
            android:summary="@string/lockscreen_bypass_summary"
            settings:searchable="false"
            settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" />

    </PreferenceCategory>

    <PreferenceCategory
+7 −0
Original line number Diff line number Diff line
@@ -30,6 +30,13 @@
            android:summary="@string/summary_placeholder"
            settings:keywords="@string/keywords_lock_screen_notif"/>

        <SwitchPreference
            android:key="security_dispaly_lockscreen_bypass"
            android:title="@string/lockscreen_bypass_title"
            android:summary="@string/lockscreen_bypass_summary"
            settings:searchable="false"
            settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" />

        <com.android.settingslib.RestrictedSwitchPreference
            android:key="security_lockscreen_add_users_when_locked"
            android:title="@string/user_add_on_lockscreen_menu"
+0 −2
Original line number Diff line number Diff line
@@ -149,7 +149,6 @@ public class FaceSettings extends DashboardFragment {
        // Don't show keyguard controller for work profile settings.
        if (mUserManager.isManagedProfile(mUserId)) {
            removePreference(FaceSettingsKeyguardPreferenceController.KEY);
            removePreference(FaceSettingsLockscreenBypassPreferenceController.KEY);
        }

        if (savedInstanceState != null) {
@@ -261,7 +260,6 @@ public class FaceSettings extends DashboardFragment {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
        controllers.add(new FaceSettingsVideoPreferenceController(context));
        controllers.add(new FaceSettingsKeyguardPreferenceController(context));
        controllers.add(new FaceSettingsLockscreenBypassPreferenceController(context));
        controllers.add(new FaceSettingsAppPreferenceController(context));
        controllers.add(new FaceSettingsAttentionPreferenceController(context));
        controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));
+9 −4
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.settings.biometrics.face;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.face.FaceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;

import androidx.preference.Preference;
@@ -32,16 +34,15 @@ public class FaceSettingsLockscreenBypassPreferenceController

    @VisibleForTesting
    protected FaceManager mFaceManager;

    public FaceSettingsLockscreenBypassPreferenceController(Context context) {
        this(context, KEY);
    }
    private UserManager mUserManager;

    public FaceSettingsLockscreenBypassPreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
            mFaceManager = context.getSystemService(FaceManager.class);
        }

        mUserManager = context.getSystemService(UserManager.class);
    }

    @Override
@@ -75,6 +76,10 @@ public class FaceSettingsLockscreenBypassPreferenceController

    @Override
    public int getAvailabilityStatus() {
        if (mUserManager.isManagedProfile(UserHandle.myUserId())) {
            return UNSUPPORTED_ON_DEVICE;
        }

        if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
            return mFaceManager.hasEnrolledTemplates() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
        } else {
+13 −1
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ package com.android.settings.biometrics.face;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.hardware.face.FaceManager;
import android.os.UserManager;
import android.provider.Settings;

import androidx.preference.SwitchPreference;
@@ -41,6 +43,8 @@ public class FaceSettingsLockscreenBypassPreferenceControllerTest {
    @Mock
    private FaceManager mFaceManager;
    private SwitchPreference mPreference;
    @Mock
    private UserManager mUserManager;

    private Context mContext;
    private FaceSettingsLockscreenBypassPreferenceController mController;
@@ -51,8 +55,9 @@ public class FaceSettingsLockscreenBypassPreferenceControllerTest {
        mContext = RuntimeEnvironment.application;
        mPreference = new SwitchPreference(mContext);

        mController = new FaceSettingsLockscreenBypassPreferenceController(mContext);
        mController = new FaceSettingsLockscreenBypassPreferenceController(mContext, "test_key");
        ReflectionHelpers.setField(mController, "mFaceManager", mFaceManager);
        ReflectionHelpers.setField(mController, "mUserManager", mUserManager);
    }

    @Test
@@ -62,6 +67,13 @@ public class FaceSettingsLockscreenBypassPreferenceControllerTest {
        assertThat(mController.isAvailable()).isTrue();
    }

    @Test
    public void isAvailable_isManagedProfile_shouldReturnUnsupported() {
        when(mUserManager.isManagedProfile(anyInt())).thenReturn(true);

        assertThat(mController.isAvailable()).isFalse();
    }

    @Test
    public void onPreferenceChange_settingIsUpdated() {
        boolean defaultValue = mContext.getResources().getBoolean(