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

Commit 39a19a18 authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor
Browse files

biometrics: Add injection logging

parent 6524c7a8
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -17,44 +17,40 @@
package com.android.systemui.biometrics

import android.content.Context
import android.view.Surface

import android.util.Log
import java.io.File
import java.io.IOException


private const val TAG = "TetrisUdfpsDisplayModeProvider"

private const val HBM_PATH = "/sys/devices/platform/soc/1401a000.dsi0/hbm"
private const val UI_STATUS_PATH = "/sys/panel_feature/ui_status"


class TetrisUdfpsDisplayModeProvider constructor(
    private val context: Context
) : UdfpsDisplayModeProvider {
    override fun enable(onEnabled: Runnable?) {

        Log.d(TAG, "Enabling display mode")
        setNodeValue(HBM_PATH, "1")
        setNodeValue(UI_STATUS_PATH, "1")

        onEnabled?.run()
        Log.d(TAG, "Display mode enabled")
    }

    override fun disable(onDisabled: Runnable?) {

        Log.d(TAG, "Disabling display mode")
        setNodeValue(HBM_PATH, "0")
        setNodeValue(UI_STATUS_PATH, "0")

        onDisabled?.run()
        Log.d(TAG, "Display mode disabled")
    }

    private fun setNodeValue(nodePath: String, value: String) {
        try {
            File(nodePath).writeText(value)
            logger.v(TAG, "setNodeValue | Wrote $value to $nodePath")
            Log.v(TAG, "setNodeValue | Successfully wrote '$value' to $nodePath")
        } catch (e: IOException) {
            logger.e(TAG, "setNodeValue | Failed to write $value to $nodePath", e)
            Log.e(TAG, "setNodeValue | Failed to write '$value' to $nodePath", e)
        }
    }

}
+15 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.INotificationManager;
import android.app.Service;
import android.content.Context;
import android.service.dreams.IDreamManager;
import android.util.Log;

import androidx.annotation.Nullable;

@@ -265,6 +266,8 @@ import javax.inject.Named;
        })
public abstract class SystemUIModule {

private static final String TAG = "SystemUIModule";

    @Binds
    abstract BootCompleteCache bindBootCompleteCache(BootCompleteCacheImpl bootCompleteCache);

@@ -333,14 +336,24 @@ public abstract class SystemUIModule {
    @Provides
    static UdfpsDisplayModeProvider getUdfpsDisplayModeProvider(Context context) {
        String className = context.getString(R.string.config_udfpsDisplayModeProviderComponent);
        Log.d(TAG, "Loading UdfpsDisplayModeProvider class: " + className);

        try {
            Class<?> clazz = context.getClassLoader().loadClass(className);
            return (UdfpsDisplayModeProvider) clazz.getDeclaredConstructor(
                    new Class[] { Context.class }).newInstance(context);
            Log.d(TAG, "Class " + className + " loaded successfully.");

            UdfpsDisplayModeProvider provider = (UdfpsDisplayModeProvider) clazz
                    .getDeclaredConstructor(new Class[]{Context.class})
                    .newInstance(context);

            Log.d(TAG, "UdfpsDisplayModeProvider instance created successfully.");
            return provider;
        } catch (Throwable t) {
            Log.e(TAG, "Error loading UdfpsDisplayModeProvider " + className, t);
            throw new RuntimeException("Error loading UdfpsDisplayModeProvider " + className, t);
        }
    }

    @BindsOptionalOf
    abstract FingerprintInteractiveToAuthProvider optionalFingerprintInteractiveToAuthProvider();