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

Commit 36bdbb4f authored by eray orçunus's avatar eray orçunus Committed by Luca Stefani
Browse files

Settings: Forward port option to pass swipe-up-to-unlock



sam3000: fixups for pie
original commit message:

 * Adapt settings to Nougat SecuritySubSettings class
 * Interface switches in security_settings_*_sub.xml
 * Additional changes for dependencies
 * Cleanup the names to 'directly_show_lock'
 * Reorder the new preferences

lockscreen: Add option to pass swipe-up-to-unlock (2/3)

* Option appears on PIN,pattern and password methods
* User should press back button to see notifications, clock etc.
* Instantly hides keyguard if Smart Lock has unlocked phone.

CYNGNOS-1873
Change-Id: I31256770869b20842c69edb4a7a57b2bad7b3ea7
Signed-off-by: default avatareray orçunus <erayorcunus@gmail.com>
parent 4bbe003c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -49,4 +49,8 @@
    <!-- PIN scramble -->
    <string name="unlock_scramble_pin_layout_title">Scramble layout</string>
    <string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string>

    <!-- Whether the keyguard will directly show the lock entry -->
    <string name="directly_show_lock">Direct unlock</string>
    <string name="directly_show_lock_summary">Skip the swipe to unlock screen and immediately begin key entry</string>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -40,6 +40,12 @@
        android:key="power_button_instantly_locks"
        android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />

    <!-- available in pin/pattern/password -->
    <SwitchPreference
        android:key="directly_show_lock"
        android:title="@string/directly_show_lock"
        android:summary="@string/directly_show_lock_summary" />

    <!-- Lineage additions, available in pin/pattern/password/slide -->
    <SwitchPreference
        android:key="lockscreen_scramble_pin_layout"
+86 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 * Copyright (C) 2018 The LineageOS 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.security.screenlock;

import android.app.admin.DevicePolicyManager;
import android.content.Context;

import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;

import lineageos.providers.LineageSettings;

import org.lineageos.internal.util.LineageLockPatternUtils;

public class DirectlyShowLockPreferenceController extends AbstractPreferenceController
        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {

    private static final String KEY_DIRECTLY_SHOW_LOCK = "directly_show_lock";

    private final int mUserId;
    private final LockPatternUtils mLockPatternUtils;
    private final LineageLockPatternUtils mLineageLockPatternUtils;

    public DirectlyShowLockPreferenceController(Context context, int userId,
            LockPatternUtils lockPatternUtils) {
        super(context);
        mUserId = userId;
        mLockPatternUtils = lockPatternUtils;
        mLineageLockPatternUtils = new LineageLockPatternUtils(context);
    }

    @Override
    public boolean isAvailable() {
        if (!mLockPatternUtils.isSecure(mUserId)) {
            return false;
        }
        switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
            case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
            case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
            case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
            case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
            case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
                return true;
            default:
                return false;
        }
    }

    @Override
    public void updateState(Preference preference) {
        ((TwoStatePreference) preference).setChecked(
                mLineageLockPatternUtils.shouldPassToSecurityView(mUserId));
    }

    @Override
    public String getPreferenceKey() {
        return KEY_DIRECTLY_SHOW_LOCK;
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        mLineageLockPatternUtils.setPassToSecurityView((Boolean) newValue, mUserId);
        return true;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class ScreenLockSettings extends DashboardFragment
                context, MY_USER_ID, lockPatternUtils));
        controllers.add(new PowerButtonInstantLockPreferenceController(
                context, MY_USER_ID, lockPatternUtils));
        controllers.add(new DirectlyShowLockPreferenceController(
                context, MY_USER_ID, lockPatternUtils));
        controllers.add(new LockAfterTimeoutPreferenceController(
                context, MY_USER_ID, lockPatternUtils));
        controllers.add(new PinScramblePreferenceController(