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

Commit 01c00962 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Do not hide lock screen settings conditionally

Users have reached out to us asking where are their settings and
cannot understand why things disappear.

Test: LockScreenPreferenceControllerTest
Change-Id: I05b182a26724fd14b0a8240e280f216ebf4d43b9
parent 68e501f8
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.settings.security.screenlock;

import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;

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

@@ -52,14 +50,7 @@ public class LockScreenPreferenceController extends BasePreferenceController imp

    @Override
    public int getAvailabilityStatus() {
        if (!mLockPatternUtils.isSecure(MY_USER_ID)) {
            return mLockPatternUtils.isLockScreenDisabled(MY_USER_ID)
                    ? DISABLED_FOR_USER : AVAILABLE_UNSEARCHABLE;
        } else {
            return mLockPatternUtils.getKeyguardStoredPasswordQuality(MY_USER_ID)
                    == PASSWORD_QUALITY_UNSPECIFIED
                    ? DISABLED_FOR_USER : AVAILABLE_UNSEARCHABLE;
        }
        return AVAILABLE_UNSEARCHABLE;
    }

    @Override
+4 −5
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;

import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;

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

@@ -87,11 +86,11 @@ public class LockScreenPreferenceControllerTest {
    }

    @Test
    public void getAvailabilityStatus_notSecure_lockscreenDisabled_DISABLED() {
    public void getAvailabilityStatus_notSecure_lockscreenDisabled_AVAILABLE() {
        when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
        when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(true);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
    }

    @Test
@@ -112,12 +111,12 @@ public class LockScreenPreferenceControllerTest {
    }

    @Test
    public void getAvailabilityStatus_secure_noLockScreen_DISABLED() {
    public void getAvailabilityStatus_secure_noLockScreen_AVAILABLE() {
        when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
        when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
                .thenReturn(PASSWORD_QUALITY_UNSPECIFIED);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
    }

    @Test