am 7a80f122: am 5c33a2e3: Merge "Adding "Connected, no Internet" string in Wifi nw summary." into mnc-dev
* commit '7a80f12225808c866e890f1e76e33e96ad7342e6': Adding "Connected, no Internet" string in Wifi nw summary.
This commit is contained in:
@@ -72,6 +72,9 @@
|
||||
<!-- Status message of Wi-Fi when network has matching passpoint credentials. [CHAR LIMIT=NONE] -->
|
||||
<string name="available_via_passpoint">Available via %1$s</string>
|
||||
|
||||
<!-- Summary for Connected wifi network without internet -->
|
||||
<string name="wifi_connected_no_internet">Connected, no Internet</string>
|
||||
|
||||
<!-- Bluetooth settings. Message when a device is disconnected -->
|
||||
<string name="bluetooth_disconnected">Disconnected</string>
|
||||
<!-- Bluetooth settings. Message when disconnecting from a device -->
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1141,7 +1141,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
||||
if (nai != null) {
|
||||
synchronized (nai) {
|
||||
return new NetworkCapabilities(nai.networkCapabilities);
|
||||
NetworkCapabilities nc = new NetworkCapabilities(nai.networkCapabilities);
|
||||
if (nai.lastValidated) {
|
||||
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
||||
} else {
|
||||
nc.removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
||||
}
|
||||
return nc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.net.wifi.WifiChannel;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConnectionStatistics;
|
||||
import android.net.wifi.WifiActivityEnergyInfo;
|
||||
import android.net.Network;
|
||||
|
||||
import android.net.DhcpInfo;
|
||||
|
||||
@@ -168,5 +169,7 @@ interface IWifiManager
|
||||
void disableEphemeralNetwork(String SSID);
|
||||
|
||||
void factoryReset();
|
||||
|
||||
Network getCurrentNetwork();
|
||||
}
|
||||
|
||||
|
||||
@@ -2804,4 +2804,17 @@ public class WifiManager {
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Network object of current wifi network
|
||||
* @return Get Network object of current wifi network
|
||||
* @hide
|
||||
*/
|
||||
public Network getCurrentNetwork() {
|
||||
try {
|
||||
return mService.getCurrentNetwork();
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user