mirror of
https://github.com/Boof2015/astra-mobile.git
synced 2026-08-12 05:10:52 +02:00
android auto improvements
This commit is contained in:
+2
@@ -195,6 +195,7 @@ class AstraAudioRouteModule : Module() {
|
||||
AudioDeviceInfo.TYPE_HDMI,
|
||||
AudioDeviceInfo.TYPE_HDMI_ARC,
|
||||
AudioDeviceInfo.TYPE_HDMI_EARC -> "hdmi"
|
||||
AudioDeviceInfo.TYPE_REMOTE_SUBMIX -> "remote"
|
||||
AudioDeviceInfo.TYPE_BUILTIN_EARPIECE,
|
||||
AudioDeviceInfo.TYPE_BUILTIN_SPEAKER -> "speaker"
|
||||
else -> "unknown"
|
||||
@@ -232,6 +233,7 @@ class AstraAudioRouteModule : Module() {
|
||||
"bluetooth" -> "Bluetooth"
|
||||
"usb" -> "USB audio"
|
||||
"hdmi" -> "HDMI audio"
|
||||
"remote" -> "Remote audio"
|
||||
else -> "Unknown output"
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -10,7 +10,8 @@ internal fun <T> selectPredictedOutputDevice(
|
||||
): T? {
|
||||
predicted.firstOrNull()?.let { return it }
|
||||
if (connected.isEmpty()) return null
|
||||
return connected.firstOrNull { kindFor(it) == "bluetooth" }
|
||||
return connected.firstOrNull { kindFor(it) == "remote" }
|
||||
?: connected.firstOrNull { kindFor(it) == "bluetooth" }
|
||||
?: connected.firstOrNull { kindFor(it) == "wired" }
|
||||
?: connected.firstOrNull { kindFor(it) == "usb" }
|
||||
?: connected.firstOrNull { kindFor(it) == "hdmi" }
|
||||
@@ -49,6 +50,7 @@ private fun addressToken(address: String?): String? {
|
||||
internal fun buildOutputRouteKey(kind: String, label: String, address: String?): String {
|
||||
if (kind == "speaker") return "speaker"
|
||||
if (kind == "wired") return "wired"
|
||||
if (kind == "remote") return "remote"
|
||||
if (kind !in setOf("bluetooth", "usb", "hdmi")) return "unknown"
|
||||
|
||||
addressToken(address)?.let { return "$kind:id:$it" }
|
||||
|
||||
+15
@@ -37,6 +37,20 @@ class OutputDeviceSelectorTest {
|
||||
assertEquals(bluetooth, selected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun legacyFallbackPrefersAnActiveRemoteMixForProjectedMedia() {
|
||||
val bluetooth = Device("car bluetooth", "bluetooth")
|
||||
val remote = Device("android auto", "remote")
|
||||
|
||||
val selected = selectPredictedOutputDevice(
|
||||
predicted = emptyList(),
|
||||
connected = listOf(bluetooth, remote),
|
||||
kindFor = Device::kind,
|
||||
)
|
||||
|
||||
assertEquals(remote, selected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun externalAddressProducesStablePrivacySafeKey() {
|
||||
val first = buildOutputRouteKey("bluetooth", "Sony WH-1000XM5", "AA:BB:CC:DD:EE:FF")
|
||||
@@ -63,6 +77,7 @@ class OutputDeviceSelectorTest {
|
||||
assertEquals("bluetooth", buildOutputRouteKey("bluetooth", "Bluetooth audio", null))
|
||||
assertEquals("usb", buildOutputRouteKey("usb", "USB audio", null))
|
||||
assertEquals("hdmi", buildOutputRouteKey("hdmi", "HDMI audio", null))
|
||||
assertEquals("remote", buildOutputRouteKey("remote", "Remote audio", null))
|
||||
assertEquals("unknown", buildOutputRouteKey("unknown", "Unknown output", null))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user