Skip to content

Instantly share code, notes, and snippets.

@ngxson
Last active April 22, 2022 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngxson/bd1c606d27d77f6c3a11f2d48a9600fc to your computer and use it in GitHub Desktop.
Save ngxson/bd1c606d27d77f6c3a11f2d48a9600fc to your computer and use it in GitHub Desktop.
Fingerprint scan (UDFPS) fix for laurel_sprout

Demo video: https://youtu.be/FZ92-Z80QNE

Tested on Evolution X (android 12.1)

Steps:

  1. Cherry-pick kernel modifications: https://github.com/ngxson/kernel_xiaomi_laurel_sprout/commits/feat/fod_dim_layer
    From https://github.com/ngxson/kernel_xiaomi_laurel_sprout/commit/382b0c5209a6cb71254d18a0874f2f5028441d97
    to https://github.com/ngxson/kernel_xiaomi_laurel_sprout/commit/a2bfea4962d05398847b1417a69bccc5f4b94dc9
  2. For device tree, replace files under /biometrics with these files: https://github.com/ngxson/device_xiaomi_laurel_sprout/tree/38b24ab58a428962e3e3c34bd70827ca469daf7b/biometrics
  3. Only required if you're using android 12.1: Open frameworks/base/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsHbmProvider.kt and replace with content below:
package com.android.systemui.biometrics

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

import android.os.Handler
import java.io.File

class DummyUdfpsHbmProvider constructor(
    private val context: Context
): UdfpsHbmProvider {
    override fun enableHbm(hbmType: Int, surface: Surface?, onHbmEnabled: Runnable?) {
        onHbmEnabled?.run()
    }

    override fun disableHbm(onHbmDisabled: Runnable?) {
        onHbmDisabled?.run()
        try {
            File("/sys/devices/platform/soc/soc:qcom,dsi-display/dimlayer_hbm").writeText("0")
            File("/sys/class/drm/card0-DSI-1/disp_param").writeText("0x20f0F20")
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}
  1. Compile the ROM
@magicxavi
Copy link

Not working, display still goes in HBM and no dim layer applied.

@ngxson
Copy link
Author

ngxson commented Apr 17, 2022

@magicxavi can you verify if this file exists: /sys/devices/platform/soc/soc:qcom,dsi-display/dimlayer_hbm
Also try sudo echo 1 > /sys/devices/platform/soc/soc:qcom,dsi-display/dimlayer_hbm to see if the dim layer shows

@magicxavi
Copy link

@magicxavi can you verify if this file exists: /sys/devices/platform/soc/soc:qcom,dsi-display/dimlayer_hbm Also try sudo echo 1 > /sys/devices/platform/soc/soc:qcom,dsi-display/dimlayer_hbm to see if the dim layer shows

yes, manually you can apply dim layer by setting 1 for the node, but it doesn't work automatically, maybe its permissions issue

@ngxson
Copy link
Author

ngxson commented Apr 22, 2022

@magicxavi Maybe. You can take a look at dmesg to confirm.
I have selinux set to permissive so I didn't take into account permission issue. Can you try adjusting selinux permissions? (Sorry I have no idea how to fix problems with selinux)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment