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

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

biometrics: Introduce node handling for onPress events

parent f354048a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -52,6 +52,10 @@
          <item>4095,0</item>
          <item>4095,0</item>
    </string-array>
    </string-array>


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

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


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


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


@@ -222,6 +226,35 @@ public class UdfpsController implements DozeReceiver, Dumpable {
    private boolean mAttemptedToDismissKeyguard;
    private boolean mAttemptedToDismissKeyguard;
    private final Set<Callback> mCallbacks = new HashSet<>();
    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
    @VisibleForTesting
    public static final VibrationAttributes UDFPS_VIBRATION_ATTRIBUTES =
    public static final VibrationAttributes UDFPS_VIBRATION_ATTRIBUTES =
            new VibrationAttributes.Builder()
            new VibrationAttributes.Builder()
@@ -754,6 +787,18 @@ public class UdfpsController implements DozeReceiver, Dumpable {
        mDeviceEntryUdfpsTouchOverlayViewModel = deviceEntryUdfpsTouchOverlayViewModel;
        mDeviceEntryUdfpsTouchOverlayViewModel = deviceEntryUdfpsTouchOverlayViewModel;
        mDefaultUdfpsTouchOverlayViewModel = defaultUdfpsTouchOverlayViewModel;
        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);
        mDumpManager.registerDumpable(TAG, this);


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


        updateUdfpsNodes("1");

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

	updateUdfpsNodes("0");

        unconfigureDisplay(view);
        unconfigureDisplay(view);
        cancelAodSendFingerUpAction();
        cancelAodSendFingerUpAction();
    }
    }