Add support for handling mobile provisioning networks.

When a sim is new or it has expired it needs to be provisioned
with the carrier. Basically provisioning is associating a sim with
a user account. When a sim isn't provisioned then operators will
restrict access to the network and only allow certain addresses
or services to be used.

This set of changes allows two types of provisioning networks to be
recognized. The first is a network that causes all DNS lookups to be
redirected to a different address than was intended. This is exemplified
by how T-Mobile works.

The second technique uses a special apn for provisioning. An example is
AT&T where lwaactivate is the provisioning apn and broadband is the
normal apn. We first try broadband and if we are unable to connect we
try lwaactivate. When we see the activate we identify it as special and
the ApnContext.isProvisioningApn will return true.

In the future our plan is to create a new network type that can be added
to the apn list, but for now it identified by name.

Here is a list of significant changes:

 - CaptivePortalTracker now only test WiFi networks instead of all networks
 - checkMobileProvisioning checks for provisioning networks and doesn't
   try to ping.
 - IConnectivityManager.aidl changes:
   * getProvisioningOrActiveNetworkInfo was added to and used by Manage
     mobile plan in WirelessSettings so even when there is no active
     network it will still allow provisioning. Otherwise it would report
     no internet connection.
   * setSignInErrorNotificationVisible is used by both
     CaptiviePortalTracker and checkMobileProvisioning so they use the
     same code for the notifications.
   * checkMobileProvisioning was simplified to have only a timeout as
     returning the result is now harder as we abort simultaneous call
     otherwise we'd could get into loops because we now check every time
     we connect to mobile.
 - Enhanced MDST to handle the provisioning network.
 - Added CONNECTED_TO_PROVISIONING_NETWORK to NetworkInfo to make a new
   state so we don't announce to the world we're connected.
 - TelephonyIntents.ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN
   is sent by the low level data connection code to notify Connectivity
   Service that a provisioning apn has connected. This allows CS to
   handle the connection differently than a normal connection.

Bug: 10328264
Change-Id: I3925004011bb1243793c4c1b963d923dc2b00cb5
This commit is contained in:
Wink Saville
2013-08-29 08:55:16 -07:00
parent d23fa090e9
commit 9a1a7ef57c
4 changed files with 410 additions and 143 deletions

View File

@@ -582,6 +582,29 @@ public class ConnectivityManager {
}
}
/**
* Returns details about the Provisioning or currently active default data network. When
* connected, this network is the default route for outgoing connections.
* You should always check {@link NetworkInfo#isConnected()} before initiating
* network traffic. This may return {@code null} when there is no default
* network.
*
* @return a {@link NetworkInfo} object for the current default network
* or {@code null} if no network default network is currently active
*
* <p>This method requires the call to hold the permission
* {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
*
* {@hide}
*/
public NetworkInfo getProvisioningOrActiveNetworkInfo() {
try {
return mService.getProvisioningOrActiveNetworkInfo();
} catch (RemoteException e) {
return null;
}
}
/**
* Returns the IP information for the current default network.
*
@@ -1316,63 +1339,19 @@ public class ConnectivityManager {
}
/**
* The ResultReceiver resultCode for checkMobileProvisioning (CMP_RESULT_CODE)
*/
/**
* No connection was possible to the network.
* {@hide}
*/
public static final int CMP_RESULT_CODE_NO_CONNECTION = 0;
/**
* A connection was made to the internet, all is well.
* {@hide}
*/
public 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.
* {@hide}
*/
public static final int CMP_RESULT_CODE_REDIRECTED = 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.
* Check mobile provisioning.
*
* {@hide}
*/
public static final int CMP_RESULT_CODE_NO_DNS = 3;
/**
* A connection was made but could not open a TCP connection.
* This is an indication of a warm sim on a mobile network.
* {@hide}
*/
public static final int CMP_RESULT_CODE_NO_TCP_CONNECTION = 4;
/**
* Check mobile provisioning. The resultCode passed to
* onReceiveResult will be one of the CMP_RESULT_CODE_xxxx values above.
* This may take a minute or more to complete.
*
* @param sendNotificaiton, when true a notification will be sent to user.
* @param suggestedTimeOutMs, timeout in milliseconds
* @param resultReceiver needs to be supplied to receive the result
*
* @return time out that will be used, maybe less that suggestedTimeOutMs
* -1 if an error.
*
* {@hide}
*/
public int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs,
ResultReceiver resultReceiver) {
public int checkMobileProvisioning(int suggestedTimeOutMs) {
int timeOutMs = -1;
try {
timeOutMs = mService.checkMobileProvisioning(sendNotification, suggestedTimeOutMs,
resultReceiver);
timeOutMs = mService.checkMobileProvisioning(suggestedTimeOutMs);
} catch (RemoteException e) {
}
return timeOutMs;
@@ -1401,4 +1380,20 @@ public class ConnectivityManager {
}
return null;
}
/**
* Set sign in error notification to visible or in visible
*
* @param visible
* @param networkType
*
* {@hide}
*/
public void setProvisioningNotificationVisible(boolean visible, int networkType,
String extraInfo, String url) {
try {
mService.setProvisioningNotificationVisible(visible, networkType, extraInfo, url);
} catch (RemoteException e) {
}
}
}

View File

@@ -46,6 +46,8 @@ interface IConnectivityManager
NetworkInfo getNetworkInfo(int networkType);
NetworkInfo[] getAllNetworkInfo();
NetworkInfo getProvisioningOrActiveNetworkInfo();
boolean isNetworkSupported(int networkType);
LinkProperties getActiveLinkProperties();
@@ -135,9 +137,11 @@ interface IConnectivityManager
int findConnectionTypeForIface(in String iface);
int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs, in ResultReceiver resultReceiver);
int checkMobileProvisioning(int suggestedTimeOutMs);
String getMobileProvisioningUrl();
String getMobileRedirectedProvisioningUrl();
void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo, in String url);
}

View File

@@ -84,6 +84,12 @@ public class NetworkInfo implements Parcelable {
VERIFYING_POOR_LINK,
/** Checking if network is a captive portal */
CAPTIVE_PORTAL_CHECK,
/**
* Network is connected to provisioning network
* TODO: Probably not needed when we add TYPE_PROVISIONING_NETWORK
* @hide
*/
CONNECTED_TO_PROVISIONING_NETWORK
}
/**
@@ -108,6 +114,7 @@ public class NetworkInfo implements Parcelable {
stateMap.put(DetailedState.DISCONNECTED, State.DISCONNECTED);
stateMap.put(DetailedState.FAILED, State.DISCONNECTED);
stateMap.put(DetailedState.BLOCKED, State.DISCONNECTED);
stateMap.put(DetailedState.CONNECTED_TO_PROVISIONING_NETWORK, State.CONNECTED);
}
private int mNetworkType;