[PM-30394] PM-29960: Skip biometric prompt on Xiaomi HyperOS (#6316)

This commit is contained in:
Gavin Gui
2026-01-14 09:08:57 -07:00
committed by GitHub
parent 2d824f96f5
commit 353e7e9a4e
2 changed files with 41 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
@file:OmitFromCoverage
package com.bitwarden.core.util
import com.bitwarden.annotation.OmitFromCoverage
private const val KEY_XIAOMI_HYPER_OS_NAME = "ro.mi.os.version.name"
/**
* Returns true if the device is running Xiaomi HyperOS.
*/
fun isHyperOS(): Boolean = !getSystemProperty(KEY_XIAOMI_HYPER_OS_NAME).isNullOrEmpty()
/**
* Reads an Android system property using the android.os.SystemProperties API
*
* @param key the name of the system property
* @return the property value, or null if unavailable
*/
@Suppress("SameParameterValue", "PrivateApi")
private fun getSystemProperty(key: String): String? {
return try {
val systemProperties = Class.forName("android.os.SystemProperties")
val getMethod = systemProperties.getMethod("get", String::class.java)
getMethod.invoke(null, key) as? String
} catch (_: Throwable) {
null
}
}