Show supported UV methods in device info dialog

This commit is contained in:
mimi89999
2026-04-02 21:54:37 +02:00
parent 196ef84e72
commit 6ea479e52d
4 changed files with 60 additions and 2 deletions
+27 -2
View File
@@ -99,8 +99,12 @@ data class DeviceInfo(
val transports: List<String> = emptyList(),
val algorithms: List<AlgorithmInfo> = emptyList(),
val firmwareVersion: Int? = null,
val minPinLength: Int? = null
val minPinLength: Int? = null,
val uvModality: Int? = null
) {
val uvMethods: List<UvModality>
get() = uvModality?.let { UvModality.fromMask(it) } ?: emptyList()
val supportsCredMgmt: Boolean
get() = options["credMgmt"] == true
@@ -120,6 +124,25 @@ data class DeviceInfo(
get() = options["pinUvAuthToken"] == true
}
enum class UvModality(val bit: Int, val label: String) {
PRESENCE(0x0001, "Presence"),
FINGERPRINT(0x0002, "Fingerprint"),
PASSCODE_INTERNAL(0x0004, "Internal Passcode"),
VOICEPRINT(0x0008, "Voiceprint"),
FACEPRINT(0x0010, "Faceprint"),
LOCATION(0x0020, "Location"),
EYEPRINT(0x0040, "Eyeprint"),
PATTERN_INTERNAL(0x0080, "Internal Pattern"),
HANDPRINT(0x0100, "Handprint"),
PASSCODE_EXTERNAL(0x0800, "External Passcode"),
PATTERN_EXTERNAL(0x1000, "External Pattern");
companion object {
fun fromMask(mask: Int): List<UvModality> =
entries.filter { mask and it.bit != 0 }
}
}
object CTAP {
// Commands
const val CMD_MAKE_CREDENTIAL = 0x01
@@ -281,6 +304,7 @@ object CTAP {
val minPinLength = parsed.int(13)
val firmwareVersion = parsed.int(14)
val uvModality = parsed.int(18)
Result.success(DeviceInfo(
versions = versions,
@@ -294,7 +318,8 @@ object CTAP {
transports = transports,
algorithms = algorithms,
firmwareVersion = firmwareVersion,
minPinLength = minPinLength
minPinLength = minPinLength,
uvModality = uvModality
))
} catch (e: Exception) {
Result.failure(e)
@@ -32,6 +32,8 @@ class DeviceInfoDialogContent(
private val interfacesChipGroup: ChipGroup = view.findViewById(R.id.interfacesChipGroup)
private val algorithmsLabel: TextView = view.findViewById(R.id.algorithmsLabel)
private val algorithmsChipGroup: ChipGroup = view.findViewById(R.id.algorithmsChipGroup)
private val uvModalityLabel: TextView = view.findViewById(R.id.uvModalityLabel)
private val uvModalityChipGroup: ChipGroup = view.findViewById(R.id.uvModalityChipGroup)
private val limitsLabel: TextView = view.findViewById(R.id.limitsLabel)
private val limitsContainer: LinearLayout = view.findViewById(R.id.limitsContainer)
@@ -42,6 +44,7 @@ class DeviceInfoDialogContent(
populateExtensions()
populateAaguid()
populateOptions()
populateUvModality()
populateInterfaces()
populateAlgorithms()
populateLimits()
@@ -122,6 +125,18 @@ class DeviceInfoDialogContent(
}
}
private fun populateUvModality() {
val methods = deviceInfo.uvMethods
if (methods.isEmpty()) {
uvModalityLabel.visibility = View.GONE
uvModalityChipGroup.visibility = View.GONE
} else {
methods.forEach { method ->
uvModalityChipGroup.addView(createChip(method.label))
}
}
}
private fun populateInterfaces() {
if (deviceInfo.transports.isEmpty()) {
interfacesLabel.visibility = View.GONE
@@ -84,6 +84,23 @@
android:layout_marginBottom="16dp"
android:orientation="vertical" />
<!-- UV Modality -->
<TextView
android:id="@+id/uvModalityLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:text="@string/device_info_section_uv_modality"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/uvModalityChipGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:chipSpacingVertical="0dp" />
<!-- Supported Interfaces -->
<TextView
android:id="@+id/interfacesLabel"
+1
View File
@@ -206,6 +206,7 @@
<string name="device_info_section_interfaces">Supported Interfaces</string>
<string name="device_info_section_algorithms">Supported Algorithms</string>
<string name="device_info_section_limits">Limits</string>
<string name="device_info_section_uv_modality">Supported User Verification Methods</string>
<string name="device_info_dialog_title">Device Status</string>
<!-- Device Info Option Names -->