Skip to content

Commit 143358e

Browse files
committed
Location: Fix MovingWifiHelper update
1 parent d17a6fa commit 143358e

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

  • play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi

play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/MovingWifiHelper.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private val MOVING_WIFI_HOTSPOTS = setOf(
7070
"Vestische WLAN",
7171
"agilis-Wifi",
7272
"freeWIFIahead!",
73+
"metronom free WLAN",
7374
// Greece
7475
"AegeanWiFi",
7576
// Hong Kong
@@ -93,6 +94,7 @@ private val MOVING_WIFI_HOTSPOTS = setOf(
9394
"SBB-FREE",
9495
"SWISS Connect",
9596
"Edelweiss Entertainment",
97+
"LXCREW",
9698
// Thailand
9799
"THAI Wireless IFE",
98100
// United Kingdom
@@ -200,7 +202,7 @@ class MovingWifiHelper(private val context: Context) {
200202
continue
201203
}
202204
try {
203-
return use(connection) to exceptions
205+
return use(connection) to emptyList()
204206
} catch (e: Exception) {
205207
exceptions.add(e)
206208
break
@@ -224,17 +226,19 @@ class MovingWifiHelper(private val context: Context) {
224226
val allExceptions = mutableListOf<Exception>()
225227
for (source in sources) {
226228
val url = URL(source.url)
227-
withContext(Dispatchers.IO) {
228-
val (location, exceptions) = tryConnections(listOfNotNull(network) + null, url) {
229+
val (location, exceptions) = withContext(Dispatchers.IO) {
230+
tryConnections(listOfNotNull(network) + null, url) {
229231
val location = Location(current.ssid ?: "wifi")
230232
source.parse(location, it.inputStream.readBytes())
231233
}
232-
if (location != null) return@withContext location
233-
allExceptions.addAll(exceptions)
234234
}
235+
if (location != null) return location
236+
allExceptions.addAll(exceptions)
235237
}
236238
if (allExceptions.size == 1) throw allExceptions.single()
237-
throw RuntimeException(allExceptions.joinToString("\n"))
239+
val e = RuntimeException("${allExceptions.size} attempts failed")
240+
allExceptions.forEach { e.addSuppressed(it) }
241+
throw e
238242
}
239243

240244
fun isLocallyRetrievable(wifi: WifiDetails): Boolean =

0 commit comments

Comments
 (0)