summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanket Padawe <sanketpadawe@google.com>2015-05-04 20:44:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-04 20:44:52 +0000
commit5c33a2e3ecf3c495e00614029df917e0754d7397 (patch)
tree6c06fae99b967bcd64229dd0b7ff5cb63d815879
parent61bab469a1529ef61cadb870ca4cc533a5510cfb (diff)
parent7094d22022c8e0c6ad71920b101434dded8a276e (diff)
downloadframeworks_base-5c33a2e3ecf3c495e00614029df917e0754d7397.zip
frameworks_base-5c33a2e3ecf3c495e00614029df917e0754d7397.tar.gz
frameworks_base-5c33a2e3ecf3c495e00614029df917e0754d7397.tar.bz2
Merge "Adding "Connected, no Internet" string in Wifi nw summary." into mnc-dev
-rw-r--r--packages/SettingsLib/res/values/strings.xml3
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java25
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java8
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl3
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java13
5 files changed, 51 insertions, 1 deletions
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 6876222..b2c9cd0 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -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 -->
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();
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 1a75b8a..8d1d124 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -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;
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 0e888e8..00cdc71 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -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();
}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 3205351..5e99672 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -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;
+ }
+ }
}