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

Commit c4c07dae authored by Rohit Sekhar's avatar Rohit Sekhar
Browse files

Revert "biometrics: Introduce node handling for onPress events"

Squashed revert of:
  Revert "biometrics: Introduce node handling for onPress events"
  This reverts commit 2677d6da.

  Revert "UdfpsController: Move writeToUdfpsNode to background executor"
  This reverts commit 4b194854.

  Revert "UdfpsController: Move HBM enable to dispatchOnUiReady()"
  This reverts commit 78b0fd50.

  Revert "biometrics: Skip unconfigureDisplay if mOnFingerDown"
  This reverts commit e8098c98.
parent e9215965
Loading
Loading
Loading
Loading
+0 −5
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>
+0 −4
Original line number Diff line number Diff line
@@ -57,10 +57,6 @@
          <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>

+0 −76
Original line number Diff line number Diff line
@@ -119,14 +119,9 @@ import kotlin.Unit;

import kotlinx.coroutines.CoroutineScope;

import java.io.File;
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;

@@ -232,52 +227,6 @@ 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 Handler mHandler;

    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) {
         mBiometricExecutor.execute(() -> {
             if (isFileWritable(path)) {
                 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);
                 }
             }
         });
    }

    private boolean isFileWritable(String path) {
         File file = new File(path);
         if (!file.exists()) {
              Log.e(TAG, "File does not exist: " + path);
              return false;
         }
         if (!file.canWrite()) {
              Log.e(TAG, "File is not writable: " + path);
              return false;
         }
         return true;
    }

    @VisibleForTesting
    public static final VibrationAttributes UDFPS_VIBRATION_ATTRIBUTES =
            new VibrationAttributes.Builder()
@@ -800,19 +749,6 @@ public class UdfpsController implements DozeReceiver, Dumpable {
        mDeviceEntryUdfpsTouchOverlayViewModel = deviceEntryUdfpsTouchOverlayViewModel;
        mDefaultUdfpsTouchOverlayViewModel = defaultUdfpsTouchOverlayViewModel;
        mPromptUdfpsTouchOverlayViewModel = promptUdfpsTouchOverlayViewModel;
        mHandler = new Handler(Looper.getMainLooper());

        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);

@@ -930,12 +866,6 @@ public class UdfpsController implements DozeReceiver, Dumpable {
        if (udfpsView.isDisplayConfigured()) {
            udfpsView.unconfigureDisplay();
        }

        // Check if the fingerprint is still pressed before proceeding
        if (mIsUdfpsNodeFeatureEnabled && mOnFingerDown) {
            Log.v(TAG, "Fingerprint is still pressed; skipping unconfigureDisplay.");
            return;
        }
    }

    /**
@@ -1071,9 +1001,6 @@ public class UdfpsController implements DozeReceiver, Dumpable {
        mFingerprintManager.onUdfpsUiEvent(FingerprintManager.UDFPS_UI_READY, requestId,
                mSensorProps.sensorId);
        mLatencyTracker.onActionEnd(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
        mHandler.postDelayed(() -> {
            updateUdfpsNodes("1");
        }, 50);
    }

    private void onFingerDown(
@@ -1195,9 +1122,6 @@ public class UdfpsController implements DozeReceiver, Dumpable {
            }
        }
        mOnFingerDown = false;

	updateUdfpsNodes("0");

        unconfigureDisplay(view);
        cancelAodSendFingerUpAction();
    }