android: 2.14.2 - fix network label showing cellular while on Wi-Fi
underlyingNetworkLabel() returned the first non-VPN network from allNetworks, whose order is unspecified - Android keeps the cellular network agent alive in parallel with Wi-Fi, so on Wi-Fi the details sheet could show "Сотовая сеть". Wi-Fi now wins when present (same precedence as NetworkMonitor's trust decision); cellular is only reported when no Wi-Fi network exists.
This commit is contained in:
1 parent
7185aa4ba5
commit
bc256ad369
2 files changed
+20
-7
No files matched your search
@@ -46,8 +46,8 @@ android {
|
|||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 36
|
targetSdkVersion 36
|
||||||
|
|
||||||
versionCode 154
|
versionCode 155
|
||||||
versionName "2.14.1"
|
versionName "2.14.2"
|
||||||
|
|
||||||
/* Base URL of the update storage, trailing slash included */
|
/* Base URL of the update storage, trailing slash included */
|
||||||
buildConfigField "String", "UPDATE_BASE_URL", "\"${updateBaseUrl}\""
|
buildConfigField "String", "UPDATE_BASE_URL", "\"${updateBaseUrl}\""
|
||||||
|
|||||||
+18
-5
@@ -544,6 +544,11 @@ class HomeViewModel(app: Application) : AndroidViewModel(app), VpnStateService.V
|
|||||||
{
|
{
|
||||||
val cm = ctx.getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager
|
val cm = ctx.getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager
|
||||||
?: return null to null
|
?: return null to null
|
||||||
|
/* Android keeps the cellular network agent alive in parallel with
|
||||||
|
* Wi-Fi (allNetworks order is unspecified), so Wi-Fi wins if present -
|
||||||
|
* the same precedence NetworkMonitor uses for the trust decision */
|
||||||
|
var wifiCaps: NetworkCapabilities? = null
|
||||||
|
var cellular = false
|
||||||
for (network in cm.allNetworks)
|
for (network in cm.allNetworks)
|
||||||
{
|
{
|
||||||
val caps = try
|
val caps = try
|
||||||
@@ -558,14 +563,22 @@ class HomeViewModel(app: Application) : AndroidViewModel(app), VpnStateService.V
|
|||||||
{
|
{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
|
|
||||||
{
|
|
||||||
return ctx.getString(R.string.network_cellular) to null
|
|
||||||
}
|
|
||||||
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI))
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI))
|
||||||
{
|
{
|
||||||
return ctx.getString(R.string.network_wifi) to SsidReader.from(ctx, caps)
|
wifiCaps = caps
|
||||||
}
|
}
|
||||||
|
else if (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
|
||||||
|
{
|
||||||
|
cellular = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wifiCaps != null)
|
||||||
|
{
|
||||||
|
return ctx.getString(R.string.network_wifi) to SsidReader.from(ctx, wifiCaps)
|
||||||
|
}
|
||||||
|
if (cellular)
|
||||||
|
{
|
||||||
|
return ctx.getString(R.string.network_cellular) to null
|
||||||
}
|
}
|
||||||
return null to null
|
return null to null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user