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

Commit 9b13af4c authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊 Committed by Markus S
Browse files

Settings: Allow user configurable fingerprint wake-and-unlock

Change-Id: I4ee28af18fcd387f51249358809bd79190a0cc8f
parent d3a632f0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -81,6 +81,11 @@
    <string name="tethering_allow_vpn_upstreams_title">Allow clients to use VPNs</string>
    <string name="tethering_allow_vpn_upstreams_summary">Permit hotspot clients to use this device\u2019s VPN connections for upstream connectivity</string>

    <!-- Fingerprint wake-and-unlock -->
    <string name="fingerprint_wake_unlock_title">Touch fingerprint to unlock</string>
    <string name="fingerprint_wake_unlock_touch">Listens for events while the screen is off</string>
    <string name="fingerprint_wake_unlock_press">Only listens for events once the screen is on</string>

    <!-- Lock screen pattern size -->
    <string name="lock_pattern_size_3" translatable="false">3 \u00d7 3</string>
    <string name="lock_pattern_size_4" translatable="false">4 \u00d7 4</string>
+7 −0
Original line number Diff line number Diff line
@@ -54,4 +54,11 @@
        android:title="@string/unlock_scramble_pin_layout_title"
        android:summary="@string/unlock_scramble_pin_layout_summary" />

    <!-- Fingerprint wake-and-unlock toggle -->
    <SwitchPreference
        android:key="fingerprint_wake_unlock"
        android:title="@string/fingerprint_wake_unlock_title"
        android:summaryOn="@string/fingerprint_wake_unlock_touch"
        android:summaryOff="@string/fingerprint_wake_unlock_press" />

</PreferenceScreen>
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.content.Context;
import android.os.UserHandle;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;

import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;

import lineageos.providers.LineageSettings;

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

    static final String KEY_FINGERPRINT_WAKE_UNLOCK = "fingerprint_wake_unlock";

    public FingerprintUnlockPreferenceController(Context context) {
        super(context);
    }

    private int getFingerprintSettings() {
        return LineageSettings.System.getIntForUser(
                mContext.getContentResolver(),
                LineageSettings.System.FINGERPRINT_WAKE_UNLOCK, 1,
                UserHandle.USER_CURRENT);
    }

    @Override
    public boolean isAvailable() {
        // Enable it for just powerbutton fps devices
        // Disable for devices config_fingerprintWakeAndUnlock set to false.
        return getFingerprintSettings() != 2 && mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_is_powerbutton_fps);
    }

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

    @Override
    public void updateState(Preference preference) {
        ((TwoStatePreference) preference).setChecked(getFingerprintSettings() == 1);
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        LineageSettings.System.putIntForUser(mContext.getContentResolver(),
                LineageSettings.System.FINGERPRINT_WAKE_UNLOCK,
                (Boolean) newValue ? 1 : 0, UserHandle.USER_CURRENT);
        return true;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public class ScreenLockSettings extends DashboardFragment
                context, MY_USER_ID, lockPatternUtils));
        controllers.add(new PinScramblePreferenceController(
                context, MY_USER_ID, lockPatternUtils));
        controllers.add(new FingerprintUnlockPreferenceController(context));
        controllers.add(new OwnerInfoPreferenceController(context, parent));
        return controllers;
    }