fix(android): prefer stored device auth after pairing

This commit is contained in:
Ayaan Zaidi
2026-04-08 21:32:45 +05:30
parent 1f899f8442
commit dcf821cfb6
2 changed files with 4 additions and 4 deletions

View File

@@ -886,7 +886,7 @@ class GatewaySession(
explicitGatewayToken
?: if (
explicitPassword == null &&
explicitBootstrapToken == null
(explicitBootstrapToken == null || storedToken != null)
) {
storedToken
} else {

View File

@@ -111,7 +111,7 @@ class GatewaySessionInvokeTest {
}
@Test
fun connect_prefersBootstrapTokenOverStoredDeviceToken() = runBlocking {
fun connect_prefersStoredDeviceTokenOverBootstrapToken() = runBlocking {
val json = testJson()
val connected = CompletableDeferred<Unit>()
val connectAuth = CompletableDeferred<JsonObject?>()
@@ -148,8 +148,8 @@ class GatewaySessionInvokeTest {
awaitConnectedOrThrow(connected, lastDisconnect, server)
val auth = withTimeout(TEST_TIMEOUT_MS) { connectAuth.await() }
assertEquals("bootstrap-token", auth?.get("bootstrapToken")?.jsonPrimitive?.content)
assertNull(auth?.get("token"))
assertEquals("device-token", auth?.get("token")?.jsonPrimitive?.content)
assertNull(auth?.get("bootstrapToken"))
} finally {
shutdownHarness(harness, server)
}