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

Commit ef62ecad authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor Committed by Nishith Khanna
Browse files

biometrics: Introduce node handling for onPress events

parent 31d5039b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Boolean to enable/disable the UDFPS onPress node functionality -->
    <bool name="config_enableUdfpsSysfsNodes">false</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,10 @@
          <item>4095,0</item>
    </string-array>

    <!-- Array of UDFPS node paths -->
    <string-array name="config_udfpsSysfsNodePaths">
    </string-array>

    <!-- Doze: does the double tap sensor need a proximity check? -->
    <bool name="doze_double_tap_proximity_check">false</bool>

+50 −0
Original line number Diff line number Diff line
@@ -118,9 +118,13 @@ import kotlin.Unit;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.ExperimentalCoroutinesApi;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;

@@ -225,6 +229,35 @@ public class UdfpsController implements DozeReceiver, Dumpable {
    private boolean mAttemptedToDismissKeyguard;
    private final Set<Callback> mCallbacks = new HashSet<>();

    private final boolean mIsUdfpsNodeFeatureEnabled;
    private final List<String> mUdfpsSysfsNodePaths;

    private void updateUdfpsNodes(String value) {
        if (!mIsUdfpsNodeFeatureEnabled) {
            Log.d(TAG, "UDFPS node functionality is disabled via overlay.");
            return;
        }

        if (mUdfpsSysfsNodePaths == null || mUdfpsSysfsNodePaths.isEmpty()) {
            Log.e(TAG, "UDFPS node paths are not properly initialized.");
            return;
        }

        for (String path : mUdfpsSysfsNodePaths) {
            writeToUdfpsNode(path, value);
        }
    }

    private void writeToUdfpsNode(String path, String value) {

        try (FileWriter writer = new FileWriter(path)) {
            writer.write(value);
            Log.d(TAG, "Successfully set " + path + " to " + value);
        } catch (IOException e) {
            Log.e(TAG, "Failed to write to " + path, e);
        }
    }

    @VisibleForTesting
    public static final VibrationAttributes UDFPS_VIBRATION_ATTRIBUTES =
            new VibrationAttributes.Builder()
@@ -803,6 +836,18 @@ public class UdfpsController implements DozeReceiver, Dumpable {
        mDeviceEntryUdfpsTouchOverlayViewModel = deviceEntryUdfpsTouchOverlayViewModel;
        mDefaultUdfpsTouchOverlayViewModel = defaultUdfpsTouchOverlayViewModel;

        mIsUdfpsNodeFeatureEnabled = mContext.getResources().getBoolean(
            com.android.systemui.res.R.bool.config_enableUdfpsSysfsNodes
        );
        Log.d(TAG, "UDFPS sysfs node feature enabled: " + mIsUdfpsNodeFeatureEnabled);

        mUdfpsSysfsNodePaths = Arrays.asList(
            mContext.getResources().getStringArray(
                com.android.systemui.res.R.array.config_udfpsSysfsNodePaths
            )
        );
        Log.d(TAG, "Initialized UDFPS node paths: " + mUdfpsSysfsNodePaths);

        mDumpManager.registerDumpable(TAG, this);

        mOrientationListener = new BiometricDisplayListener(
@@ -1122,6 +1167,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                minor, major, orientation, time, gestureStart, isAod);
        Trace.endAsyncSection("UdfpsController.e2e.onPointerDown", 0);

        updateUdfpsNodes("1");

        final View view = mOverlay.getTouchOverlay();
        if (view != null && isOptical()) {
            if (mIgnoreRefreshRate) {
@@ -1182,6 +1229,9 @@ public class UdfpsController implements DozeReceiver, Dumpable {
            }
        }
        mOnFingerDown = false;

	updateUdfpsNodes("0");

        unconfigureDisplay(view);
        cancelAodSendFingerUpAction();
    }