Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use deprecated wifi method in case WifiInfo is null #3970

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ class NetworkSensorManager : SensorManager {
val connectivityManager = context.applicationContext.getSystemService<ConnectivityManager>()
connectivityManager?.activeNetwork?.let {
val info = connectivityManager.getNetworkCapabilities(it)?.transportInfo
return@let info as? WifiInfo

// If WifiInfo is null default to the deprecated method as a fix for some devices that may return null
@Suppress("DEPRECATION")
return@let info as? WifiInfo ?: context.applicationContext.getSystemService<WifiManager>()?.connectionInfo
}
} else {
@Suppress("DEPRECATION")
Expand Down