From a0d40d005a34c87f85ad24aac86e93e98564121b Mon Sep 17 00:00:00 2001 From: Blackmanx Date: Fri, 9 Feb 2024 17:32:36 +0100 Subject: [PATCH] UdfpsAnimation: Use UDFPS props verification before checking service Apparently, using getSensorPropertiesInternal here even if you grant TEST_BIOMETRICS permissions results in a crash in some devices. Let's use the previous udfps check first and move onto the new one for incompatible devices. --- .../udfps/UdfpsAnimationSectionController.kt | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/com/android/customization/model/udfps/UdfpsAnimationSectionController.kt b/src/com/android/customization/model/udfps/UdfpsAnimationSectionController.kt index beb962f..346c649 100644 --- a/src/com/android/customization/model/udfps/UdfpsAnimationSectionController.kt +++ b/src/com/android/customization/model/udfps/UdfpsAnimationSectionController.kt @@ -52,16 +52,21 @@ class UdfpsAnimationSectionController( } private fun isUdfpsAvailable(context: Context): Boolean { - val hasFingerprint = context.packageManager - .hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) - return if (hasFingerprint) { - val fingerprintManger = - context.getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager + return if (context.resources + .getIntArray(com.android.internal.R.array.config_udfps_sensor_props).isNotEmpty()) + true + else { + val hasFingerprint = context.packageManager + .hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) + if (hasFingerprint) { + val fingerprintManager = + context.getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager val udfpsProps = - fingerprintManger.getSensorPropertiesInternal().filter { it.isAnyUdfpsType() } + fingerprintManager.getSensorPropertiesInternal().filter { it.isAnyUdfpsType() } udfpsProps.isNotEmpty() // return - } else { - false + } else { + false + } } }