feat(dual-screen): bottom-screen Dashboard with downloads, notifications, screenshots, Steam chat and In-game stats (#1920)

A Dashboard mode for the second screen of dual-screen handhelds (developed on a Retroid Pocket Duo), the default on dual-screen devices. It opens on Chat at each Steam start and switches to In-game stats when a game starts.

- Downloads: Steam downloads and updates (SD-card libraries too), shader caches and DroidDeck store downloads.
- Notifications: other apps' notifications once access is allowed, kept in memory only.
- Screenshots: a game screenshot without the overlay, and a gallery of DroidDeck's and Steam's screenshots.
- Chat & voice: mic and game volume buttons, and Steam's web chat signed in with the Steam client's own session.
- In-game stats: FPS, CPU, GPU, RAM and battery plus the running game or Steam client type, and a racing dash from Codemasters, Forza and OutGauge games' data output, with War Thunder and Elite Dangerous layouts; speed in km/h or mph.
- Send dashboard data: turns a Codemasters game's data output on for the dash (per game or Automatic) and keeps the original setting to put back.
- DiRT 3 / DiRT Showdown: with their data output on they stop with error 10038 at race end; a ws2_32.dll stand-in (tools/dirt-ws2) is swapped into the prefix while the game runs, skipped on DroidDeck-Proton 11-11.10 which has the fix built in. Same behaviour as DiRTTelemetryErrorFix by RoccoC, based on Carsten Gottschling's fix.

About "telemetry": here it means a racing game's own live driving data (speed, gear, rpm, pedals), not app analytics. For In-game stats no information leaves the device and nothing is shared: the game sends its data to 127.0.0.1 on the same device, DroidDeck only listens there while the page is open and keeps the numbers in memory just long enough to draw them. DroidDeck sends no data about the user or their use of the app; logs leave the device only when the user taps Share logs.
This commit is contained in:
The412Banner authored and GitHub committed 2026-11-01 02:36:57 +00:00
1 parent bfa61b5139
commit 8a7022fc14
52 files changed
+4576 -63

No files matched your search

@@ -4,23 +4,38 @@ import org.junit.Assert.assertEquals
import org.junit.Test
class SecondScreenModeTest {
@Test fun withNothingRememberedTheControllerPicksThePanel() {
@Test fun withNothingRememberedTheDashboardOpens() {
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening(null, deckPad = true, dashboard = true))
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening(null, deckPad = false, dashboard = true))
}
@Test fun withNothingRememberedAndNoDashboardTheControllerPicksThePanel() {
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening(null, deckPad = true))
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening(null, deckPad = false))
}
@Test fun thePanelTheUserPickedLastOpensAgain() {
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("keyboard-trackpad", deckPad = true, dashboard = true))
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("deck-controls", deckPad = true, dashboard = true))
assertEquals(SecondScreenMode.TERMINAL, SecondScreenMode.opening("terminal", deckPad = true, dashboard = true))
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("keyboard-trackpad", deckPad = true))
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("deck-controls", deckPad = true))
assertEquals(SecondScreenMode.TERMINAL, SecondScreenMode.opening("terminal", deckPad = true))
}
@Test fun deckControlsNeedTheDeckPad() {
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("deck-controls", deckPad = false))
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("deck-controls", deckPad = false, dashboard = true))
}
@Test fun anUnknownOrClosedChoiceFallsBackToTheDefault() {
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening("none", deckPad = true, dashboard = true))
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening("gone", deckPad = false, dashboard = true))
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("none", deckPad = true))
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("gone", deckPad = false))
}
@Test fun theDashboardOpensAgainOnlyWhileItHasPages() {
assertEquals(SecondScreenMode.DASHBOARD, SecondScreenMode.opening("dashboard", deckPad = true, dashboard = true))
assertEquals(SecondScreenMode.DECK_CONTROLS, SecondScreenMode.opening("dashboard", deckPad = true, dashboard = false))
assertEquals(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.opening("dashboard", deckPad = false))
}
}
@@ -0,0 +1,38 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class BottomNotificationsTest {
private val own = "com.droiddeck.launcher"
@Test fun messagesFromOtherAppsAreKept() {
assertTrue(BottomNotifications.keep(own, "com.discord", ongoing = false, groupSummary = false, title = "Kurt", text = "ready?"))
}
@Test fun ownOngoingSummaryAndEmptyNotificationsAreSkipped() {
assertFalse(BottomNotifications.keep(own, own, ongoing = false, groupSummary = false, title = "Session", text = "running"))
assertFalse(BottomNotifications.keep(own, "com.spotify", ongoing = true, groupSummary = false, title = "Song", text = "Artist"))
assertFalse(BottomNotifications.keep(own, "com.discord", ongoing = false, groupSummary = true, title = "2 messages", text = ""))
assertFalse(BottomNotifications.keep(own, "com.discord", ongoing = false, groupSummary = false, title = " ", text = ""))
}
@Test fun anUpdatedNotificationMovesToTheTopOnce() {
val list = mutableListOf(
BottomNotification("a", "App", "one", "", 1L),
BottomNotification("b", "App", "two", "", 2L),
)
BottomNotifications.add(list, BottomNotification("b", "App", "two again", "", 3L))
assertEquals(listOf("b", "a"), list.map { it.key })
assertEquals("two again", list.first().title)
}
@Test fun theListKeepsTheNewestThirty() {
val list = mutableListOf<BottomNotification>()
repeat(35) { BottomNotifications.add(list, BottomNotification("k$it", "App", "t$it", "", it.toLong())) }
assertEquals(30, list.size)
assertEquals("k34", list.first().key)
}
}
@@ -0,0 +1,32 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
class BottomScreenshotsTest {
@get:Rule val tmp = TemporaryFolder()
@Test fun fileNamesSortByTime() {
val name = BottomScreenshots.fileName(0L)
assertTrue(name, name.startsWith("DroidDeck_") && name.endsWith(".jpg"))
assertEquals(29, name.length)
}
@Test fun steamScreenshotsAreFoundAndThumbnailsSkipped() {
val root = tmp.root
val shots = File(root, "root/.local/share/Steam/userdata/2932373/760/remote/220/screenshots")
File(shots, "thumbnails").mkdirs()
File(shots, "20261031010101_1.jpg").writeText("x")
File(shots, "thumbnails/20261031010101_1.jpg").writeText("x")
File(shots, "screenshots.vdf").writeText("x")
val x64 = File(root, "root/.droiddeck-x64/.local/share/Steam/userdata/2932373/760/remote/440/screenshots")
x64.mkdirs()
File(x64, "20261031020202_1.jpg").writeText("x")
val found = BottomScreenshots.steam(root).map { it.file!!.name }.sorted()
assertEquals(listOf("20261031010101_1.jpg", "20261031020202_1.jpg"), found)
}
}
@@ -0,0 +1,226 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import java.nio.ByteBuffer
import java.nio.ByteOrder
class GameTelemetryTest {
private fun packet(size: Int, fill: ByteBuffer.() -> Unit): ByteArray =
ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN).apply(fill).array()
@Test fun codemastersFloatsBecomeADash() {
val data = packet(264) {
putFloat(7 * 4, 25f) // m/s
putFloat(29 * 4, 0.8f)
putFloat(31 * 4, 0.1f)
putFloat(33 * 4, 3f)
putFloat(36 * 4, 1f)
putFloat(37 * 4, 650f) // rpm / 10
putFloat(63 * 4, 800f)
putFloat(45 * 4, 30f)
putFloat(46 * 4, 60f)
}
val t = GameTelemetry.parse(GameTelemetry.CODEMASTERS_PORT, data, data.size)!!
assertEquals(90f, t.speedKmh!!, 0.01f)
assertEquals("3", t.gear)
assertEquals(6500f, t.rpm!!, 0.01f)
assertEquals(8000f, t.maxRpm!!, 0.01f)
assertEquals(2, t.lap)
assertEquals(0.5f, t.fuel!!, 0.001f)
}
// Values from a DiRT Showdown packet recorded on a Retroid Pocket Duo (extradata 3 still sends 152 bytes there).
@Test fun codemastersShortPacketFromDirtShowdown() {
val data = packet(152) {
putFloat(1 * 4, 80.085f)
putFloat(7 * 4, 10.739f)
putFloat(29 * 4, 0.816f)
putFloat(33 * 4, 1f)
putFloat(37 * 4, 827.531f)
}
val t = GameTelemetry.parse(GameTelemetry.CODEMASTERS_PORT, data, data.size)!!
assertEquals(38.66f, t.speedKmh!!, 0.01f)
assertEquals("1", t.gear)
assertEquals(8275.31f, t.rpm!!, 0.01f)
assertEquals(0.816f, t.throttle!!, 0.001f)
assertEquals(1, t.lap)
assertEquals(80.085f, t.currentLapS!!, 0.001f)
assertNull(t.maxRpm)
assertNull(t.laps)
assertNull(t.position)
assertNull(t.fuel)
assertNull(t.lastLapS)
}
@Test fun codemastersReverseAndNeutral() {
fun gear(g: Float) = GameTelemetry.parse(GameTelemetry.CODEMASTERS_PORT, packet(264) { putFloat(33 * 4, g) }, 264)!!.gear
assertEquals("N", gear(0f))
assertEquals("R", gear(-1f))
assertEquals("R", gear(10f))
}
@Test fun forzaHorizonDashSitsTwelveBytesLater() {
val dash = 232 + 12
val data = packet(324) {
putInt(0, 1)
putFloat(8, 8000f)
putFloat(16, 5000f)
putFloat(dash + 12, 50f)
put(dash + 71, 255.toByte())
put(dash + 75, 4)
putShort(dash + 68, 2)
put(dash + 70, 5)
}
val t = GameTelemetry.parse(GameTelemetry.FORZA_PORT, data, data.size)!!
assertEquals(180f, t.speedKmh!!, 0.01f)
assertEquals("4", t.gear)
assertEquals(1f, t.throttle!!, 0.001f)
assertEquals(3, t.lap)
assertEquals(5, t.position)
}
@Test fun forzaMotorsportDashFollowsTheSled() {
val data = packet(311) {
putInt(0, 1)
putFloat(232 + 12, 10f)
put(232 + 75, 0)
}
val t = GameTelemetry.parse(GameTelemetry.FORZA_PORT, data, data.size)!!
assertEquals(36f, t.speedKmh!!, 0.01f)
assertEquals("R", t.gear)
}
@Test fun forzaInMenusHasNoDash() {
val t = GameTelemetry.parse(GameTelemetry.FORZA_PORT, packet(324) {}, 324)!!
assertNull(t.speedKmh)
}
@Test fun outGaugeGearsAreShiftedByOne() {
val data = packet(96) {
put(10, 3)
putFloat(12, 20f)
putFloat(16, 4000f)
}
val t = GameTelemetry.parse(GameTelemetry.OUTGAUGE_PORT, data, data.size)!!
assertEquals("2", t.gear)
assertEquals(72f, t.speedKmh!!, 0.01f)
assertEquals(4000f, t.rpm!!, 0.01f)
}
@Test fun listensOnIpv4Loopback() {
assertTrue(GameTelemetry.LISTEN_ADDRESS is java.net.Inet4Address)
assertEquals("127.0.0.1", GameTelemetry.LISTEN_ADDRESS.hostAddress)
}
@Test fun shortPacketsAreIgnored() {
assertNull(GameTelemetry.parse(GameTelemetry.CODEMASTERS_PORT, ByteArray(148), 148))
assertNull(GameTelemetry.parse(GameTelemetry.OUTGAUGE_PORT, ByteArray(40), 40))
assertNull(GameTelemetry.parse(1234, ByteArray(400), 400))
}
// DiRT Showdown's 38 floats already carry steering and both G-forces.
@Test fun codemastersGForceAndSteering() {
val data = packet(152) {
putFloat(30 * 4, -0.5f)
putFloat(33 * 4, 2f)
putFloat(34 * 4, 1.2f)
putFloat(35 * 4, -0.8f)
}
val t = GameTelemetry.parse(GameTelemetry.CODEMASTERS_PORT, data, data.size)!!
assertEquals(-0.5f, t.steer!!, 1e-4f)
assertEquals(1.2f, t.gLat!!, 1e-4f)
assertEquals(-0.8f, t.gLon!!, 1e-4f)
}
@Test fun forzaReadsBestLapSteeringGForceAndTires() {
val dash = 232
val data = packet(311) {
putInt(0, 1)
putFloat(20, 9.81f)
putFloat(28, -4.905f)
putFloat(dash + 24, 212f)
putFloat(dash + 28, 32f)
putFloat(dash + 32, 194f)
putFloat(dash + 36, 176f)
putFloat(dash + 52, 81.5f)
put(dash + 75, 3)
put(dash + 76, (-127).toByte())
}
val t = GameTelemetry.parse(GameTelemetry.FORZA_PORT, data, data.size)!!
assertEquals(1f, t.gLat!!, 1e-3f)
assertEquals(-0.5f, t.gLon!!, 1e-3f)
assertEquals(listOf(100f, 0f, 90f, 80f), t.tireTempsC!!.map { Math.round(it).toFloat() })
assertEquals(81.5f, t.bestLapS!!, 1e-4f)
assertEquals(-1f, t.steer!!, 1e-4f)
}
@Test fun forzaWithoutTireDataLeavesThemOut() {
val data = packet(311) { putInt(0, 1); put(232 + 75, 2) }
assertNull(GameTelemetry.parse(GameTelemetry.FORZA_PORT, data, data.size)!!.tireTempsC)
}
@Test fun outGaugeReadsTurboTemperaturesAndLights() {
val data = packet(92) {
put(10, 3)
putFloat(20, 0.8f)
putFloat(24, 92f)
putFloat(36, 104f)
putInt(40, GameTelemetry.DL_SHIFT or GameTelemetry.DL_ABS or GameTelemetry.DL_HANDBRAKE)
putInt(44, GameTelemetry.DL_SHIFT or GameTelemetry.DL_ABS)
}
val t = GameTelemetry.parse(GameTelemetry.OUTGAUGE_PORT, data, data.size)!!
assertEquals(0.8f, t.turboBar!!, 1e-4f)
assertEquals(92f, t.engineTempC!!, 1e-4f)
assertEquals(104f, t.oilTempC!!, 1e-4f)
assertEquals(GameTelemetry.DL_SHIFT or GameTelemetry.DL_ABS, t.lights)
}
// BeamNG leaves some OutGauge fields at zero; those stay hidden.
@Test fun outGaugeZeroFieldsStayHidden() {
val t = GameTelemetry.parse(GameTelemetry.OUTGAUGE_PORT, packet(92) { put(10, 2) }, 92)!!
assertNull(t.turboBar)
assertNull(t.engineTempC)
assertNull(t.lights)
}
}
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class GameStatusFilesTest {
@Test fun warThunderShowsNumbersOnlyDuringAMatch() {
assertEquals(emptyList<Pair<String, String>>(), GameStatusFiles.warThunder("""{"valid": false}"""))
val rows = GameStatusFiles.warThunder("""{"valid": true, "H, m": 1520, "TAS, km/h": 512.4, "name": "x"}""")
assertEquals(listOf("H, m" to "1520", "TAS, km/h" to "512.4"), rows)
}
@Test fun warThunderKeepsEveryNumberForTheFlightLayout() {
val json = buildString {
append("{\"valid\": true")
for (i in 0 until 20) append(", \"k$i\": $i")
append(", \"IAS, km/h\": 512, \"throttle 1, %\": 110}")
}
val rows = GameStatusFiles.warThunder(json)
assertEquals(22, rows.size)
assertTrue(com.droiddeck.launcher.ui.FlightLabels.drawable(rows))
assertEquals("110", rows.toMap()["throttle 1, %"])
}
@Test fun eliteAtTheMenusShowsNothing() {
assertNull(GameStatusFiles.elite("""{"timestamp": "2026-10-31T02:00:00Z", "event": "Status", "Flags": 0}"""))
}
@Test fun eliteInFlight() {
val e = GameStatusFiles.elite("""{"Flags": 16777240, "Pips": [4, 8, 0], "Fuel": {"FuelMain": 16.0, "FuelReservoir": 0.43},
"Cargo": 2.0, "LegalState": "Clean", "Balance": 1234567}""")!!
assertEquals(16.0, e.fuelMain!!, 0.001)
assertEquals(listOf(4, 8, 0), e.pips)
assertEquals("Clean", e.legal)
assertEquals(1234567L, e.balance)
}
}
@@ -0,0 +1,51 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Test
class StatsLayoutTest {
@Test fun unknownIdsFallBackToTheDefaults() {
assertEquals(StatsStrip.PANEL, StatsStrip.from(null))
assertEquals(StatsStrip.RINGS, StatsStrip.from("rings"))
assertEquals(StatsDash.AUTO, StatsDash.from("gone"))
assertEquals(StatsDash.TRACE, StatsDash.from("trace"))
}
@Test fun tappingTheStripCyclesThroughEveryStyle() {
assertEquals(StatsStrip.TILES, StatsStrip.PANEL.next())
assertEquals(StatsStrip.RINGS, StatsStrip.TILES.next())
assertEquals(StatsStrip.PANEL, StatsStrip.RINGS.next())
}
@Test fun autoPicksTheDashByTheGamesFormat() {
assertEquals(StatsDash.SPEEDOMETER, StatsDash.AUTO.resolve("Codemasters"))
assertEquals(StatsDash.CIRCUIT, StatsDash.AUTO.resolve("Forza"))
assertEquals(StatsDash.DIALS, StatsDash.AUTO.resolve("OutGauge"))
assertEquals(StatsDash.TRACE, StatsDash.TRACE.resolve("Forza"))
}
@Test fun tappingTheDashMovesOnFromTheOneOnScreen() {
assertEquals(StatsDash.CIRCUIT, StatsDash.tapped(StatsDash.SPEEDOMETER))
assertEquals(StatsDash.SPEEDOMETER, StatsDash.tapped(StatsDash.GLANCE))
assertEquals(StatsDash.SPEEDOMETER, StatsDash.tapped(StatsDash.AUTO))
}
@Test fun automaticSpeedUnitsFollowTheRegion() {
assertEquals(SpeedUnit.MPH, SpeedUnit.AUTO.resolve("US"))
assertEquals(SpeedUnit.MPH, SpeedUnit.AUTO.resolve("gb"))
assertEquals(SpeedUnit.KMH, SpeedUnit.AUTO.resolve("DE"))
assertEquals(SpeedUnit.KMH, SpeedUnit.AUTO.resolve(""))
assertEquals(SpeedUnit.KMH, SpeedUnit.KMH.resolve("US"))
assertEquals(SpeedUnit.MPH, SpeedUnit.MPH.resolve("DE"))
}
@Test fun speedUnitsCycleAndConvert() {
assertEquals(SpeedUnit.AUTO, SpeedUnit.from(null))
assertEquals(SpeedUnit.MPH, SpeedUnit.from("mph"))
assertEquals(SpeedUnit.KMH, SpeedUnit.AUTO.next())
assertEquals(SpeedUnit.MPH, SpeedUnit.KMH.next())
assertEquals(SpeedUnit.AUTO, SpeedUnit.MPH.next())
assertEquals(62.1f, 100f * SpeedUnit.MPH.perKmh, 0.05f)
assertEquals(100f, 100f * SpeedUnit.KMH.perKmh, 0f)
}
}
@@ -0,0 +1,62 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
class SteamDownloadsTest {
private fun manifest(flags: Long, done: Long, total: Long) = """
"AppState"
{
"appid" "220"
"name" "Half-Life 2"
"StateFlags" "$flags"
"BytesToDownload" "$total"
"BytesDownloaded" "$done"
}
""".trimIndent()
@Test fun anAppUnfinishedInBothSteamHomesIsListedOnce() {
val arm = SteamDownload("220", "Half-Life 2", 10L, 100L)
val x86 = SteamDownload("220", "Half-Life 2", 60L, 100L)
val other = SteamDownload("440", "Team Fortress 2", 5L, 50L)
assertEquals(listOf(x86, other), SteamDownloads.onePerApp(listOf(arm, x86, other)))
}
@Test fun anInstalledGameIsNotADownload() {
assertNull(SteamDownloads.fromManifest("220", "Half-Life 2", manifest(4, 100, 100)))
}
@Test fun aRunningUpdateShowsItsBytes() {
val d = SteamDownloads.fromManifest("220", "Half-Life 2", manifest(1026, 40, 100))!!
assertEquals(40L, d.done)
assertEquals(100L, d.total)
}
@Test fun aPausedUpdateSaysSo() {
assertTrue(SteamDownloads.fromManifest("220", "Half-Life 2", manifest(514, 40, 100))!!.paused)
}
@Test fun anUpdateNotSizedYetIsStillListed() {
assertEquals(0L, SteamDownloads.fromManifest("220", "Half-Life 2", manifest(6, 0, 0))!!.total)
}
@Test fun onlyShaderUpdatesStillRunningCount() {
val log = sequenceOf(
"[2026-10-30 06:33:02] AppID 220 Shader update changed : Running Update,Downloading,",
"[2026-10-30 06:33:02] AppID 440 Shader update changed : Running Update,",
"[2026-10-30 06:33:03] AppID 440 Shader update changed : None",
"[2026-10-30 06:33:03] AppID 570 App update changed : Running Update,",
)
assertEquals(listOf("220"), SteamDownloads.runningShaderUpdates(log))
}
@Test fun aClientRestartForgetsOlderShaderUpdates() {
val log = sequenceOf(
"[2026-10-30 06:33:02] AppID 220 Shader update changed : Running Update,",
"[2026-10-30 07:00:00] Client version: 1761000000",
)
assertEquals(emptyList<String>(), SteamDownloads.runningShaderUpdates(log))
}
}
@@ -0,0 +1,31 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class SteamWebLoginTest {
private fun hex(s: String) = ByteArray(s.length / 2) { s.substring(it * 2, it * 2 + 2).toInt(16).toByte() }
// Made with: openssl enc -aes-128-cbc -K <PBKDF2-SHA1("peanuts","saltysalt",1)> -iv <16 spaces>, prefixed "v10".
@Test fun chromiumV10ValuesDecrypt() {
val encrypted = hex("7631300b9cf0a6eee9cf1aaac601b85ca37cf9fe9e67078564f0e05835ae2aa3d9b0ab")
assertEquals("0123456789abcdef01234567", SteamWebLogin.decrypt(encrypted, hostHashed = false))
}
@Test fun newerStoresDropTheHostHash() {
val encrypted = hex("7631304d4114329f1e692e807b8b044d67460f5e14d92ffb48b9f83be318ebd0d84c727674aea32f351b8a33c8aa42553dfeb5")
assertEquals("hello", SteamWebLogin.decrypt(encrypted, hostHashed = true))
}
@Test fun otherFormatsAreSkipped() {
assertNull(SteamWebLogin.decrypt("v11garbage".toByteArray(), hostHashed = false))
assertNull(SteamWebLogin.decrypt(ByteArray(2), hostHashed = false))
}
@Test fun theSignInIsSentTheWaySteamPagesSendIt() {
assertEquals("steamLoginSecure=76561190000000000%7C%7Ca.b.c; Path=/; Secure; HttpOnly",
SteamWebLogin.header("steamLoginSecure", "76561190000000000||a.b.c", httpOnly = true))
assertEquals("sessionid=0123; Path=/; Secure", SteamWebLogin.header("sessionid", "0123", httpOnly = false))
}
}
@@ -0,0 +1,116 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
class TelemetryOutputTest {
@get:Rule val tmp = TemporaryFolder()
// DiRT Showdown's own line, as found in its prefix on the Retroid Pocket Duo.
private val showdown = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<hardware_settings_config>\n" +
"\t<audio mono=\"false\" />\n\t<motion enabled=\"true\" ip=\"dbox\" port=\"20777\" delay=\"1\" extradata=\"0\" />\n" +
"</hardware_settings_config>\n"
@Test fun turningOnPointsTheMotionLineHereAndKeepsTheRest() {
val on = TelemetryOutput.turnedOn(showdown)!!
assertTrue(on.contains("<motion enabled=\"true\" ip=\"127.0.0.1\" port=\"20777\" delay=\"1\" extradata=\"3\" />"))
assertEquals(showdown.replace("ip=\"dbox\"", "ip=\"127.0.0.1\"").replace("extradata=\"0\"", "extradata=\"3\""), on)
assertTrue(TelemetryOutput.pointsHere(TelemetryOutput.element(on)!!.value))
assertFalse(TelemetryOutput.pointsHere(TelemetryOutput.element(showdown)!!.value))
}
@Test fun theUdpLineWinsOverTheMotionLineAndLongerTagsAreIgnored() {
val xml = "<x><motion_platform><dbox enabled=\"true\" /></motion_platform>" +
"<motion enabled=\"true\" ip=\"dbox\" port=\"20777\" />" +
"<udp enabled=\"false\" extradata=\"0\" ip=\"127.0.0.1\" port=\"20777\" delay=\"1\" /></x>"
assertTrue(TelemetryOutput.element(xml)!!.value.startsWith("<udp "))
val on = TelemetryOutput.turnedOn(xml)!!
assertTrue(on.contains("<udp enabled=\"true\" extradata=\"3\" ip=\"127.0.0.1\" port=\"20777\" delay=\"1\" />"))
assertTrue(on.contains("<motion enabled=\"true\" ip=\"dbox\" port=\"20777\" />"))
assertNull(TelemetryOutput.element("<x><motion_platform enabled=\"true\" /></x>"))
}
@Test fun turningOffPutsTheOriginalLineBackOrSwitchesItOff() {
val on = TelemetryOutput.turnedOn(showdown)!!
assertEquals(showdown, TelemetryOutput.turnedOff(on, showdown))
assertTrue(TelemetryOutput.turnedOff(on, null)!!.contains("<motion enabled=\"false\" ip=\"127.0.0.1\""))
}
@Test fun missingAttributesAreAdded() {
assertEquals("<udp enabled=\"true\" ip=\"127.0.0.1\" />", TelemetryOutput.withAttr("<udp enabled=\"true\" />", "ip", "127.0.0.1"))
assertEquals("<udp a=\"1\" port=\"20777\">", TelemetryOutput.withAttr("<udp a=\"1\">", "port", "20777"))
assertTrue(TelemetryOutput.pointsHere("<udp enabled=\"true\" ip=\"127.0.0.1\" port=\"20777\" />"))
}
@Test fun scanFindsTheGameAndARoundTripRestoresTheFile() {
val compatdata = tmp.newFolder("steamapps", "compatdata")
val config = configFile(compatdata, "2848447563", "DiRT Showdown")
config.writeText(showdown)
configFile(compatdata, "12345", "Some Other Game").writeText("<hardware_settings_config />")
val games = TelemetryOutput.scan(listOf(compatdata))
assertEquals(listOf("DiRT Showdown"), games.map { it.name })
assertEquals("2848447563", games[0].prefixId)
assertFalse(games[0].on)
assertTrue(TelemetryOutput.set(games[0], true))
assertTrue(File(config.path + TelemetryOutput.ORIGINAL_SUFFIX).isFile)
assertTrue(TelemetryOutput.scan(listOf(compatdata))[0].on)
assertTrue(TelemetryOutput.set(games[0], false))
assertEquals(showdown, config.readText())
assertFalse(File(config.path + TelemetryOutput.ORIGINAL_SUFFIX).exists())
assertFalse(TelemetryOutput.scan(listOf(compatdata))[0].on)
}
@Test fun theRunningGameIsMatchedByItsPrefixId() {
assertTrue(TelemetryOutput.isRunning("2848447563", "2848447563"))
assertTrue(TelemetryOutput.isRunning("-1446519733", "2848447563"))
assertFalse(TelemetryOutput.isRunning("2848447563", "690790"))
assertFalse(TelemetryOutput.isRunning("2848447563", null))
assertTrue(TelemetryOutput.isRunning("2848447563", "program:/games/x.exe"))
}
@Test fun automaticSkipsGamesThatAreOnSwitchedOffOrRunning() {
val f = File("x")
val dirt4 = TelemetryOutput.Game("DiRT 4", "421020", f, on = false)
val rally = TelemetryOutput.Game("DiRT Rally 2.0", "690790", f, on = false)
val grid = TelemetryOutput.Game("GRID", "703860", f, on = true)
val games = listOf(dirt4, rally, grid)
assertEquals(listOf(dirt4, rally), TelemetryOutput.automaticTargets(games, emptySet(), null))
assertEquals(listOf(rally), TelemetryOutput.automaticTargets(games, setOf("421020/DiRT 4"), null))
assertEquals(listOf(dirt4), TelemetryOutput.automaticTargets(games, emptySet(), "690790"))
assertEquals("690790/DiRT Rally 2.0", TelemetryOutput.key(rally))
}
@Test fun switchingAutomaticOffRestoresOnlyGamesDroidDeckChanged() {
val compatdata = tmp.newFolder("steamapps", "compatdata")
val changed = configFile(compatdata, "2848447563", "DiRT Showdown").apply { writeText(showdown) }
val own = configFile(compatdata, "690790", "DiRT Rally 2.0")
.apply { writeText("<x><udp enabled=\"true\" ip=\"127.0.0.1\" port=\"20777\" /></x>") }
assertTrue(TelemetryOutput.set(TelemetryOutput.scan(listOf(compatdata)).first { it.name == "DiRT Showdown" }, true))
val targets = TelemetryOutput.restoreTargets(TelemetryOutput.scan(listOf(compatdata)), null)
assertEquals(listOf(changed), targets.map { it.file })
assertTrue(own.isFile)
assertTrue(TelemetryOutput.restoreTargets(TelemetryOutput.scan(listOf(compatdata)), "2848447563").isEmpty())
}
@Test fun automaticTurnsOnDirt3AndShowdownLikeTheOtherGames() {
val f = File("x")
val showdownGame = TelemetryOutput.Game("DiRT Showdown", "2848447563", f, on = false)
val dirt3 = TelemetryOutput.Game("DiRT3", "321040", f, on = false)
val rally = TelemetryOutput.Game("DiRT Rally 2.0", "690790", f, on = false)
assertEquals(listOf(showdownGame, dirt3, rally), TelemetryOutput.automaticTargets(listOf(showdownGame, dirt3, rally), emptySet(), null))
assertEquals(listOf(rally), TelemetryOutput.automaticTargets(listOf(showdownGame, dirt3, rally), setOf("2848447563/DiRT Showdown", "321040/DiRT3"), null))
}
private fun configFile(compatdata: File, id: String, game: String): File =
File(compatdata, "$id/pfx/drive_c/users/steamuser/Documents/My Games/$game/hardwaresettings/hardware_settings_config.xml")
.apply { parentFile!!.mkdirs() }
}
@@ -0,0 +1,42 @@
package com.droiddeck.launcher.ui
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class BottomChatPageTest {
@Test fun steamSitesOpenOthersDoNot() {
assertTrue(steamChatAllows("steamcommunity.com"))
assertTrue(steamChatAllows("login.steampowered.com"))
assertTrue(steamChatAllows("steam-chat.com"))
assertTrue(steamChatAllows("community.cloudflare.steamstatic.com"))
assertFalse(steamChatAllows("steamcommunity.com.example.net"))
assertFalse(steamChatAllows("evilsteamcommunity.com"))
assertFalse(steamChatAllows(null))
}
@Test fun chatFitScriptUsesADotDecimalInEveryLocale() {
val before = java.util.Locale.getDefault()
try {
java.util.Locale.setDefault(java.util.Locale.GERMANY)
val js = steamChatFitScript(821, 0.75f)
assertTrue(js.contains("m.content='width=821, initial-scale=0.75'"))
assertTrue(js.contains("s.textContent='$STEAM_CHAT_FIT_CSS'"))
assertFalse(STEAM_CHAT_FIT_CSS.contains('\''))
} finally {
java.util.Locale.setDefault(before)
}
}
@Test fun theGroupChatListLeavesRoomForTheOnlineFriends() {
assertTrue(STEAM_CHAT_FIT_CSS.contains(".ChatRoomList_Empty{display:none!important}"))
assertTrue(STEAM_CHAT_FIT_CSS.contains(".chatRoomListContainer{height:auto!important;max-height:25vh!important}"))
assertTrue(STEAM_CHAT_FIT_CSS.contains(".chat_main>:has(~.chat_main_flex){display:none!important}"))
}
@Test fun desktopAgentKeepsTheWebViewChromeVersion() {
val ua = desktopUserAgent("Mozilla/5.0 (Linux; Android 15; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.122 Mobile Safari/537.36")
assertEquals("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.122 Safari/537.36", ua)
}
}
@@ -0,0 +1,71 @@
package com.droiddeck.launcher.ui
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
class BottomDashboardTest {
@Test fun theRememberedPageOpensAgain() {
assertEquals("shots", pickBottomPage("shots", listOf("downloads", "shots")))
}
@Test fun aGoneOrMissingPageFallsBackToTheFirst() {
assertEquals("downloads", pickBottomPage("gone", listOf("downloads", "shots")))
assertEquals("downloads", pickBottomPage(null, listOf("downloads", "shots")))
assertNull(pickBottomPage("shots", emptyList()))
}
@Test fun withNothingPickedTheChatOpens() {
val ids = listOf("telemetry", "downloads", "notifications", "screenshots", "chat")
assertEquals("chat", pickBottomPage(null, ids))
assertEquals("chat", pickBottomPage("gone", ids))
assertEquals("telemetry", pickBottomPage("telemetry", ids))
assertEquals("screenshots", pickBottomPage("screenshots", ids))
}
@Test fun aGameStartShowsTheInGameStats() {
assertEquals("telemetry", pageForGameStart(listOf("telemetry", "downloads", "chat")))
assertNull(pageForGameStart(listOf("downloads", "chat")))
}
@Test fun tabNamesShowOnlyWhileEveryTabFits() {
// Retroid Pocket Duo bottom panel: 1280x960 at 320 dpi = 640 dp wide.
assertTrue(bottomTabsWithLabels(640f, 4))
assertFalse(bottomTabsWithLabels(640f, 5))
assertFalse(bottomTabsWithLabels(360f, 3))
}
}
class BottomDownloadsRateTest {
@Test fun rateIsBytesPerSecondBetweenReads() {
assertEquals(1_000_000L, downloadRate(0L, 0L, 2_000_000L, 2_000L))
}
@Test fun noMovementOrARestartIsZero() {
assertEquals(0L, downloadRate(500L, 0L, 500L, 2_000L))
assertEquals(0L, downloadRate(500L, 0L, 100L, 2_000L))
assertEquals(0L, downloadRate(-1L, 0L, 100L, 2_000L))
}
}
class BottomTelemetryLapTimeTest {
@Test fun lapTimesReadAsMinutesSecondsMillis() {
assertEquals("1:23.456", lapTime(83.456f))
assertEquals("0:05.000", lapTime(5f))
}
@Test fun eachSessionStartsWithoutAPickedTab() {
SessionBottomTab.pick("2026-11-01-01-steam", "screenshots")
assertEquals("screenshots", SessionBottomTab.picked("2026-11-01-01-steam"))
assertNull(SessionBottomTab.picked("2026-11-01-02-steam"))
assertNull(SessionBottomTab.picked(null))
assertEquals("chat", pickBottomPage(SessionBottomTab.picked("2026-11-01-02-steam"), listOf("telemetry", "chat", "screenshots")))
}
@Test fun theStripNamesTheSteamClient() {
assertEquals(com.droiddeck.launcher.R.string.stats_steam_client_x86, steamClientLabel("x86_64"))
assertEquals(com.droiddeck.launcher.R.string.stats_steam_client_arm, steamClientLabel("arm64"))
}
}