summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2013-09-09 01:32:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-09 01:32:45 +0000
commitbdd61696c6720faa14ca9fdf180e519138b3d087 (patch)
tree4e46055cd103de4c37dbaf789b688e02ac118f07
parentc59c6dd66b8ec5537c82e330d1c96e9fa424b4fa (diff)
parent4fea0413c160909b35c548325008b9a65b99c412 (diff)
downloadframeworks_base-bdd61696c6720faa14ca9fdf180e519138b3d087.zip
frameworks_base-bdd61696c6720faa14ca9fdf180e519138b3d087.tar.gz
frameworks_base-bdd61696c6720faa14ca9fdf180e519138b3d087.tar.bz2
Merge "Tighten test for warm sim and add more debug." into klp-dev
-rw-r--r--services/java/com/android/server/ConnectivityService.java65
1 files changed, 40 insertions, 25 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index ab0eb23..02a78de 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -3929,39 +3929,41 @@ public class ConnectivityService extends IConnectivityManager.Stub {
/**
* No connection was possible to the network.
+ * This is NOT a warm sim.
*/
- public static final int CMP_RESULT_CODE_NO_CONNECTION = 0;
+ private static final int CMP_RESULT_CODE_NO_CONNECTION = 0;
/**
* A connection was made to the internet, all is well.
+ * This is NOT a warm sim.
*/
- public static final int CMP_RESULT_CODE_CONNECTABLE = 1;
+ private static final int CMP_RESULT_CODE_CONNECTABLE = 1;
/**
- * A connection was made but there was a redirection, we appear to be in walled garden.
- * This is an indication of a warm sim on a mobile network.
+ * A connection was made but no dns server was available to resolve a name to address.
+ * This is NOT a warm sim since provisioning network is supported.
*/
- public static final int CMP_RESULT_CODE_REDIRECTED = 2;
+ private static final int CMP_RESULT_CODE_NO_DNS = 2;
/**
- * A connection was made but no dns server was available to resolve a name to address.
- * This is an indication of a warm sim on a mobile network.
+ * A connection was made but could not open a TCP connection.
+ * This is NOT a warm sim since provisioning network is supported.
*/
- public static final int CMP_RESULT_CODE_NO_DNS = 3;
+ private static final int CMP_RESULT_CODE_NO_TCP_CONNECTION = 3;
/**
- * A connection was made but could not open a TCP connection.
- * This is an indication of a warm sim on a mobile network.
+ * A connection was made but there was a redirection, we appear to be in walled garden.
+ * This is an indication of a warm sim on a mobile network such as T-Mobile.
*/
- public static final int CMP_RESULT_CODE_NO_TCP_CONNECTION = 4;
+ private static final int CMP_RESULT_CODE_REDIRECTED = 4;
/**
* The mobile network is a provisioning network.
- * This is an indication of a warm sim on a mobile network.
+ * This is an indication of a warm sim on a mobile network such as AT&T.
*/
- public static final int CMP_RESULT_CODE_PROVISIONING_NETWORK = 5;
+ private static final int CMP_RESULT_CODE_PROVISIONING_NETWORK = 5;
- AtomicBoolean mIsCheckingMobileProvisioning = new AtomicBoolean(false);
+ private AtomicBoolean mIsCheckingMobileProvisioning = new AtomicBoolean(false);
@Override
public int checkMobileProvisioning(int suggestedTimeOutMs) {
@@ -4036,7 +4038,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mNetTrackers[ConnectivityManager.TYPE_MOBILE_HIPRI].getNetworkInfo();
switch(result) {
case CMP_RESULT_CODE_CONNECTABLE:
- case CMP_RESULT_CODE_NO_CONNECTION: {
+ case CMP_RESULT_CODE_NO_CONNECTION:
+ case CMP_RESULT_CODE_NO_DNS:
+ case CMP_RESULT_CODE_NO_TCP_CONNECTION: {
if (DBG) log("CheckMp.onComplete: ignore, connected or no connection");
break;
}
@@ -4055,8 +4059,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
break;
}
- case CMP_RESULT_CODE_NO_DNS:
- case CMP_RESULT_CODE_NO_TCP_CONNECTION: {
+ case CMP_RESULT_CODE_PROVISIONING_NETWORK: {
String url = getMobileProvisioningUrl();
if (TextUtils.isEmpty(url) == false) {
if (DBG) log("CheckMp.onComplete: warm (no dns/tcp), url=" + url);
@@ -4222,8 +4225,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
MobileDataStateTracker mdst = (MobileDataStateTracker)
mCs.mNetTrackers[ConnectivityManager.TYPE_MOBILE_HIPRI];
if (mdst.isProvisioningNetwork()) {
- if (DBG) log("isMobileOk: isProvisioningNetwork is true, no TCP conn");
- result = CMP_RESULT_CODE_NO_TCP_CONNECTION;
+ if (DBG) log("isMobileOk: isProvisioningNetwork is true");
+ result = CMP_RESULT_CODE_PROVISIONING_NETWORK;
return result;
} else {
if (DBG) log("isMobileOk: isProvisioningNetwork is false, continue");
@@ -4303,25 +4306,37 @@ public class ConnectivityService extends IConnectivityManager.Stub {
urlConn.setAllowUserInteraction(false);
urlConn.setRequestProperty("Connection", "close");
int responseCode = urlConn.getResponseCode();
+
+ // For debug display the headers
+ Map<String, List<String>> headers = urlConn.getHeaderFields();
+ log("isMobileOk: headers=" + headers);
+
+ // Close the connection
+ urlConn.disconnect();
+ urlConn = null;
+
if (responseCode == 204) {
+ // Return
+ log("isMobileOk: expected responseCode=" + responseCode);
result = CMP_RESULT_CODE_CONNECTABLE;
+ return result;
} else {
+ // Retry to be sure this was redirected, we've gotten
+ // occasions where a server returned 200 even though
+ // the device didn't have a "warm" sim.
+ log("isMobileOk: not expected responseCode=" + responseCode);
result = CMP_RESULT_CODE_REDIRECTED;
}
- log("isMobileOk: connected responseCode=" + responseCode);
- urlConn.disconnect();
- urlConn = null;
- return result;
} catch (Exception e) {
log("isMobileOk: HttpURLConnection Exception e=" + e);
+ result = CMP_RESULT_CODE_NO_TCP_CONNECTION;
if (urlConn != null) {
urlConn.disconnect();
urlConn = null;
}
}
}
- result = CMP_RESULT_CODE_NO_TCP_CONNECTION;
- log("isMobileOk: loops|timed out");
+ log("isMobileOk: loops|timed out result=" + result);
return result;
} catch (Exception e) {
log("isMobileOk: Exception e=" + e);