diff options
author | Wink Saville <wink@google.com> | 2013-09-05 12:02:25 -0700 |
---|---|---|
committer | Wink Saville <wink@google.com> | 2013-09-05 12:02:25 -0700 |
commit | 67c382192614dfab821666c4f35f1e2c8b97271b (patch) | |
tree | 59c90941fe6372f94e37bd18c8bb444482551e53 /core/java | |
parent | ce1e37981caec29df2671a6e2909f00da7f24a00 (diff) | |
download | frameworks_base-67c382192614dfab821666c4f35f1e2c8b97271b.zip frameworks_base-67c382192614dfab821666c4f35f1e2c8b97271b.tar.gz frameworks_base-67c382192614dfab821666c4f35f1e2c8b97271b.tar.bz2 |
Do not change NetworkInfo.DetailedState.
I'd changed DetailedState to force ConnectivityService to treat
provisioning apn's specially. In particular so that they wouldn't
be identified they were fully connected until the provisioning
actually started. The problem is that DetailedState is a public enum
that has a CTS test and just changing the CTS to allow for the new
state (CONNECTED_TO_PROVISIONING_NETWORK) was inappropriate.
Instead I've added a new mIsConnectedToProvisioningNetwork variable
and used the DetailedState.SUSPENDED as the intermediate state.
Bug: 10620248
Change-Id: Id4a842398cad67455541ce629959351c27d83639
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/net/MobileDataStateTracker.java | 8 | ||||
-rw-r--r-- | core/java/android/net/NetworkInfo.java | 35 |
2 files changed, 33 insertions, 10 deletions
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index 77b7314..e09254b 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -190,6 +190,8 @@ public class MobileDataStateTracker implements NetworkStateTracker { private class MobileDataStateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + // Assume this isn't a provisioning network. + mNetworkInfo.setIsConnectedToProvisioningNetwork(false); if (intent.getAction().equals(TelephonyIntents. ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN)) { String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY); @@ -205,7 +207,11 @@ public class MobileDataStateTracker implements NetworkStateTracker { // Make us in the connecting state until we make a new TYPE_MOBILE_PROVISIONING mMobileDataState = PhoneConstants.DataState.CONNECTING; updateLinkProperitesAndCapatilities(intent); - setDetailedState(DetailedState.CONNECTED_TO_PROVISIONING_NETWORK, "", apnName); + mNetworkInfo.setIsConnectedToProvisioningNetwork(true); + + // Change state to SUSPENDED so setDetailedState + // sends EVENT_STATE_CHANGED to connectivityService + setDetailedState(DetailedState.SUSPENDED, "", apnName); } else if (intent.getAction().equals(TelephonyIntents. ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY); diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index dabc73a..4d2a70d 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -83,13 +83,7 @@ public class NetworkInfo implements Parcelable { /** Link has poor connectivity. */ 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 + CAPTIVE_PORTAL_CHECK } /** @@ -114,7 +108,6 @@ 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; @@ -127,6 +120,8 @@ public class NetworkInfo implements Parcelable { private String mExtraInfo; private boolean mIsFailover; private boolean mIsRoaming; + private boolean mIsConnectedToProvisioningNetwork; + /** * Indicates whether network connectivity is possible: */ @@ -155,6 +150,7 @@ public class NetworkInfo implements Parcelable { mState = State.UNKNOWN; mIsAvailable = false; // until we're told otherwise, assume unavailable mIsRoaming = false; + mIsConnectedToProvisioningNetwork = false; } /** {@hide} */ @@ -171,6 +167,7 @@ public class NetworkInfo implements Parcelable { mIsFailover = source.mIsFailover; mIsRoaming = source.mIsRoaming; mIsAvailable = source.mIsAvailable; + mIsConnectedToProvisioningNetwork = source.mIsConnectedToProvisioningNetwork; } } @@ -329,6 +326,22 @@ public class NetworkInfo implements Parcelable { } } + /** {@hide} */ + @VisibleForTesting + public boolean isConnectedToProvisioningNetwork() { + synchronized (this) { + return mIsConnectedToProvisioningNetwork; + } + } + + /** {@hide} */ + @VisibleForTesting + public void setIsConnectedToProvisioningNetwork(boolean val) { + synchronized (this) { + mIsConnectedToProvisioningNetwork = val; + } + } + /** * Reports the current coarse-grained state of the network. * @return the coarse-grained state @@ -412,7 +425,9 @@ public class NetworkInfo implements Parcelable { append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo). append(", roaming: ").append(mIsRoaming). append(", failover: ").append(mIsFailover). - append(", isAvailable: ").append(mIsAvailable); + append(", isAvailable: ").append(mIsAvailable). + append(", isConnectedToProvisioningNetwork: "). + append(mIsConnectedToProvisioningNetwork); return builder.toString(); } } @@ -440,6 +455,7 @@ public class NetworkInfo implements Parcelable { dest.writeInt(mIsFailover ? 1 : 0); dest.writeInt(mIsAvailable ? 1 : 0); dest.writeInt(mIsRoaming ? 1 : 0); + dest.writeInt(mIsConnectedToProvisioningNetwork ? 1 : 0); dest.writeString(mReason); dest.writeString(mExtraInfo); } @@ -462,6 +478,7 @@ public class NetworkInfo implements Parcelable { netInfo.mIsFailover = in.readInt() != 0; netInfo.mIsAvailable = in.readInt() != 0; netInfo.mIsRoaming = in.readInt() != 0; + netInfo.mIsConnectedToProvisioningNetwork = in.readInt() != 0; netInfo.mReason = in.readString(); netInfo.mExtraInfo = in.readString(); return netInfo; |