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

Commit 73a9fad7 authored by Beverly's avatar Beverly
Browse files

Add pixel_pitch parameter that must be updated per device

Pixel pitch is the number of microns per pixel on device.
This is used to size the UDFPS icon.

Bug: 319894241
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor DEVELOPMENT
Test: manual
Change-Id: Idb2b01ae7115117b20651bdd4959b67c0b92b166
parent 5b4e13aa
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1928,5 +1928,9 @@
    <dimen name="bouncer_user_switcher_view_mode_view_flipper_bottom_margin">0dp</dimen>

    <!-- UDFPS view attributes -->
    <dimen name="udfps_icon_size">6mm</dimen>
    <!-- UDFPS icon size in microns/um -->
    <dimen name="udfps_icon_size" format="float">6000</dimen>
    <!-- Microns/ums (1000 um = 1mm) per pixel for the given device. If unspecified, UI that
         relies on this value will not be sized correctly. -->
    <item name="pixel_pitch" format="float" type="dimen">-1</item>
</resources>
+14 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.biometrics.domain.interactor

import android.content.Context
import android.util.Log
import android.view.MotionEvent
import com.android.systemui.biometrics.AuthController
import com.android.systemui.biometrics.shared.model.UdfpsOverlayParams
@@ -42,12 +43,23 @@ import kotlinx.coroutines.flow.stateIn
class UdfpsOverlayInteractor
@Inject
constructor(
    @Application context: Context,
    @Application private val context: Context,
    private val authController: AuthController,
    private val selectedUserInteractor: SelectedUserInteractor,
    @Application scope: CoroutineScope
) {
    private val iconSize: Int = context.resources.getDimensionPixelSize(R.dimen.udfps_icon_size)
    private fun calculateIconSize(): Int {
        val pixelPitch = context.resources.getFloat(R.dimen.pixel_pitch)
        if (pixelPitch <= 0) {
            Log.e(
                "UdfpsOverlayInteractor",
                "invalid pixelPitch: $pixelPitch. Pixel pitch must be updated per device."
            )
        }
        return (context.resources.getFloat(R.dimen.udfps_icon_size) / pixelPitch).toInt()
    }

    private var iconSize: Int = calculateIconSize()

    /** Whether a touch is within the under-display fingerprint sensor area */
    fun isTouchWithinUdfpsArea(ev: MotionEvent): Boolean {