Skip to content
Open
Show file tree
Hide file tree
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 @@ -25,7 +25,7 @@ internal class NetworkInfo(
fun getWifiIPAddress(): String? {
var ipAddress: String? = null

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val linkAddresses =
connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)?.linkAddresses

Expand Down Expand Up @@ -80,12 +80,12 @@ internal class NetworkInfo(
}

fun getGatewayIPAddress(): String? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val linkAddresses =
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val linkProperties =
connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)
val dhcpServer = linkAddresses?.dhcpServerAddress?.hostAddress
val defaultRoute = linkProperties?.routes?.firstOrNull { route -> route.isDefaultRoute }

dhcpServer
defaultRoute?.gateway?.hostAddress
} else {
@Suppress("DEPRECATION")
val dhcpInfo = wifiManager.dhcpInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NetworkInfoPlusPlugin : FlutterPlugin {
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager

var connectivityManager: ConnectivityManager? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
connectivityManager = context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}

Expand Down
Loading