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

Commit 8bea74a3 authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor Committed by Sahil Sonar
Browse files

biometrics: Introduce node handling for onPress events

parent 2e978ff9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6,4 +6,7 @@
<resources>
    <!-- Whether the mobile signal icon pipeline should ignore IWlan status -->
    <bool name="config_mobileIconIgnoresIWlan">false</bool>

    <!-- Boolean to enable/disable the UDFPS onPress node functionality -->
    <bool name="config_enableUdfpsSysfsNodes">false</bool>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@
         before the screen has had chance to switch out of HBM mode -->
    <integer name="config_udfpsDimmingDisableDelay">0</integer>

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

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

+46 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.Rect;
import android.hardware.biometrics.BiometricFingerprintConstants;
import android.hardware.biometrics.SensorProperties;
@@ -111,9 +112,14 @@ import dagger.Lazy;

import kotlin.Unit;

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

@@ -225,6 +231,35 @@ public class UdfpsController implements DozeReceiver, Dumpable {
    private boolean mUseFrameworkDimming;
    private int[][] mBrightnessAlphaArray;

    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()
@@ -747,6 +782,12 @@ 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(
@@ -1126,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 +1225,9 @@ public class UdfpsController implements DozeReceiver, Dumpable {
            }
        }
        mOnFingerDown = false;

	updateUdfpsNodes("0");

        unconfigureDisplay(view);
        cancelAodSendFingerUpAction();