Merge "Display "Sign into network" in settings when on a captive portal." into nyc-mr2-dev

This commit is contained in:
Lorenzo Colitti
2016-12-14 04:48:36 +00:00
committed by Android (Google) Code Review

View File

@@ -790,18 +790,21 @@ public class AccessPoint implements Comparable<AccessPoint> {
if (state == DetailedState.CONNECTED) { if (state == DetailedState.CONNECTED) {
IWifiManager wifiManager = IWifiManager.Stub.asInterface( IWifiManager wifiManager = IWifiManager.Stub.asInterface(
ServiceManager.getService(Context.WIFI_SERVICE)); ServiceManager.getService(Context.WIFI_SERVICE));
Network nw; NetworkCapabilities nc = null;
try { try {
nw = wifiManager.getCurrentNetwork(); nc = cm.getNetworkCapabilities(wifiManager.getCurrentNetwork());
} catch (RemoteException e) { } catch (RemoteException e) {}
nw = null;
} if (nc != null) {
NetworkCapabilities nc = cm.getNetworkCapabilities(nw); if (nc.hasCapability(nc.NET_CAPABILITY_CAPTIVE_PORTAL)) {
if (nc != null && !nc.hasCapability(nc.NET_CAPABILITY_VALIDATED)) { return context.getString(
com.android.internal.R.string.network_available_sign_in);
} else if (!nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
return context.getString(R.string.wifi_connected_no_internet); return context.getString(R.string.wifi_connected_no_internet);
} }
} }
}
if (state == null) { if (state == null) {
Log.w(TAG, "state is null, returning empty summary"); Log.w(TAG, "state is null, returning empty summary");
return ""; return "";