diff options
Diffstat (limited to 'packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index 2fde4f9..53e69e3 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -17,9 +17,13 @@ package com.android.settingslib.wifi; import android.content.Context; +import android.net.ConnectivityManager; +import android.net.Network; +import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.net.NetworkInfo.DetailedState; import android.net.NetworkInfo.State; +import android.net.wifi.IWifiManager; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration.KeyMgmt; @@ -27,6 +31,8 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; import android.text.TextUtils; +import android.os.RemoteException; +import android.os.ServiceManager; import android.util.Log; import android.util.LruCache; @@ -700,6 +706,25 @@ public class AccessPoint implements Comparable<AccessPoint> { } } + // Case when there is wifi connected without internet connectivity. + final ConnectivityManager cm = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); + if (state == DetailedState.CONNECTED) { + IWifiManager wifiManager = IWifiManager.Stub.asInterface( + ServiceManager.getService(Context.WIFI_SERVICE)); + Network nw; + + try { + nw = wifiManager.getCurrentNetwork(); + } catch (RemoteException e) { + nw = null; + } + NetworkCapabilities nc = cm.getNetworkCapabilities(nw); + if (nc != null && !nc.hasCapability(nc.NET_CAPABILITY_VALIDATED)) { + return context.getString(R.string.wifi_connected_no_internet); + } + } + String[] formats = context.getResources().getStringArray((ssid == null) ? R.array.wifi_status : R.array.wifi_status_with_ssid); int index = state.ordinal(); |