fix: add legacy-compatible Android phone link

This commit is contained in:
zhy200308
2026-08-12 16:40:43 +08:00
parent 2ff0741fff
commit ccaaab7002
12 changed files with 243 additions and 49 deletions
@@ -4,12 +4,28 @@ import org.junit.Assert.*
import org.junit.Test
import java.nio.ByteBuffer
import java.nio.ByteOrder
import java.io.ByteArrayInputStream
import java.util.concurrent.Callable
import java.util.concurrent.ExecutorCompletionService
import java.util.concurrent.Executors
import java.util.zip.CRC32
class ProtocolTest {
@Test
fun phoneShareHashRequiresTheAdvertisedExactSize() {
val bytes = "phone-share-stable-snapshot".toByteArray()
assertEquals(
"83511688f11a9cb98da9339966f6a0b97e48913102aaad39ae395d2e88f3f65f",
phoneShareSha256Exact(ByteArrayInputStream(bytes), bytes.size.toLong()),
)
assertThrows(IllegalArgumentException::class.java) {
phoneShareSha256Exact(ByteArrayInputStream(bytes), bytes.size.toLong() + 1L)
}
assertThrows(IllegalArgumentException::class.java) {
phoneShareSha256Exact(ByteArrayInputStream(bytes), bytes.size.toLong() - 1L)
}
}
@Test
fun directDiscoveryCarriesTheAndroidDeviceName() {
val request = directDiscoveryRequest(