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

Commit 97c2d301 authored by Sahil Sonar's avatar Sahil Sonar 💬 Committed by Mohammed Althaf T
Browse files

UdfpsController: Move writeToUdfpsNode to background executor

parent 4cc52777
Loading
Loading
Loading
Loading
+23 −6
Original line number Original line Diff line number Diff line
@@ -125,6 +125,7 @@ import kotlin.Unit;


import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScope;


import java.io.File;
import java.io.FileWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -259,7 +260,8 @@ public class UdfpsController implements DozeReceiver, Dumpable {
    }
    }


    private void writeToUdfpsNode(String path, String value) {
    private void writeToUdfpsNode(String path, String value) {

         mBiometricExecutor.execute(() -> {
             if (isFileWritable(path)) {
                 try (FileWriter writer = new FileWriter(path)) {
                 try (FileWriter writer = new FileWriter(path)) {
                      writer.write(value);
                      writer.write(value);
                      Log.d(TAG, "Successfully set " + path + " to " + value);
                      Log.d(TAG, "Successfully set " + path + " to " + value);
@@ -267,6 +269,21 @@ public class UdfpsController implements DozeReceiver, Dumpable {
                      Log.e(TAG, "Failed to write to " + path, 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
    @VisibleForTesting
    public static final VibrationAttributes UDFPS_VIBRATION_ATTRIBUTES =
    public static final VibrationAttributes UDFPS_VIBRATION_ATTRIBUTES =