am a1d6a9b4: am fc7a146b: am 50f86448: am 59a9884b: Merge "Do not change NetworkInfo.DetailedState." into jb-mr2-dev

* commit 'a1d6a9b474ba095860838c6ed3e72f8d9f5058cd':
  Do not change NetworkInfo.DetailedState.
This commit is contained in:
Wink Saville
2013-09-06 09:25:32 -07:00
committed by Android Git Automerger
3 changed files with 40 additions and 18 deletions

View File

@@ -209,6 +209,8 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
private class MobileDataStateReceiver extends BroadcastReceiver { private class MobileDataStateReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
// Assume this isn't a provisioning network.
mNetworkInfo.setIsConnectedToProvisioningNetwork(false);
if (intent.getAction().equals(TelephonyIntents. if (intent.getAction().equals(TelephonyIntents.
ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN)) { ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN)) {
String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY); String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY);
@@ -224,7 +226,11 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
// Make us in the connecting state until we make a new TYPE_MOBILE_PROVISIONING // Make us in the connecting state until we make a new TYPE_MOBILE_PROVISIONING
mMobileDataState = PhoneConstants.DataState.CONNECTING; mMobileDataState = PhoneConstants.DataState.CONNECTING;
updateLinkProperitesAndCapatilities(intent); 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. } else if (intent.getAction().equals(TelephonyIntents.
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY); String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY);

View File

@@ -83,13 +83,7 @@ public class NetworkInfo implements Parcelable {
/** Link has poor connectivity. */ /** Link has poor connectivity. */
VERIFYING_POOR_LINK, VERIFYING_POOR_LINK,
/** Checking if network is a captive portal */ /** Checking if network is a captive portal */
CAPTIVE_PORTAL_CHECK, CAPTIVE_PORTAL_CHECK
/**
* Network is connected to provisioning network
* TODO: Probably not needed when we add TYPE_PROVISIONING_NETWORK
* @hide
*/
CONNECTED_TO_PROVISIONING_NETWORK
} }
/** /**
@@ -114,7 +108,6 @@ public class NetworkInfo implements Parcelable {
stateMap.put(DetailedState.DISCONNECTED, State.DISCONNECTED); stateMap.put(DetailedState.DISCONNECTED, State.DISCONNECTED);
stateMap.put(DetailedState.FAILED, State.DISCONNECTED); stateMap.put(DetailedState.FAILED, State.DISCONNECTED);
stateMap.put(DetailedState.BLOCKED, State.DISCONNECTED); stateMap.put(DetailedState.BLOCKED, State.DISCONNECTED);
stateMap.put(DetailedState.CONNECTED_TO_PROVISIONING_NETWORK, State.CONNECTED);
} }
private int mNetworkType; private int mNetworkType;
@@ -127,6 +120,8 @@ public class NetworkInfo implements Parcelable {
private String mExtraInfo; private String mExtraInfo;
private boolean mIsFailover; private boolean mIsFailover;
private boolean mIsRoaming; private boolean mIsRoaming;
private boolean mIsConnectedToProvisioningNetwork;
/** /**
* Indicates whether network connectivity is possible: * Indicates whether network connectivity is possible:
*/ */
@@ -155,6 +150,7 @@ public class NetworkInfo implements Parcelable {
mState = State.UNKNOWN; mState = State.UNKNOWN;
mIsAvailable = false; // until we're told otherwise, assume unavailable mIsAvailable = false; // until we're told otherwise, assume unavailable
mIsRoaming = false; mIsRoaming = false;
mIsConnectedToProvisioningNetwork = false;
} }
/** {@hide} */ /** {@hide} */
@@ -171,6 +167,7 @@ public class NetworkInfo implements Parcelable {
mIsFailover = source.mIsFailover; mIsFailover = source.mIsFailover;
mIsRoaming = source.mIsRoaming; mIsRoaming = source.mIsRoaming;
mIsAvailable = source.mIsAvailable; 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. * Reports the current coarse-grained state of the network.
* @return the coarse-grained state * @return the coarse-grained state
@@ -412,7 +425,9 @@ public class NetworkInfo implements Parcelable {
append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo). append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo).
append(", roaming: ").append(mIsRoaming). append(", roaming: ").append(mIsRoaming).
append(", failover: ").append(mIsFailover). append(", failover: ").append(mIsFailover).
append(", isAvailable: ").append(mIsAvailable); append(", isAvailable: ").append(mIsAvailable).
append(", isConnectedToProvisioningNetwork: ").
append(mIsConnectedToProvisioningNetwork);
return builder.toString(); return builder.toString();
} }
} }
@@ -440,6 +455,7 @@ public class NetworkInfo implements Parcelable {
dest.writeInt(mIsFailover ? 1 : 0); dest.writeInt(mIsFailover ? 1 : 0);
dest.writeInt(mIsAvailable ? 1 : 0); dest.writeInt(mIsAvailable ? 1 : 0);
dest.writeInt(mIsRoaming ? 1 : 0); dest.writeInt(mIsRoaming ? 1 : 0);
dest.writeInt(mIsConnectedToProvisioningNetwork ? 1 : 0);
dest.writeString(mReason); dest.writeString(mReason);
dest.writeString(mExtraInfo); dest.writeString(mExtraInfo);
} }
@@ -462,6 +478,7 @@ public class NetworkInfo implements Parcelable {
netInfo.mIsFailover = in.readInt() != 0; netInfo.mIsFailover = in.readInt() != 0;
netInfo.mIsAvailable = in.readInt() != 0; netInfo.mIsAvailable = in.readInt() != 0;
netInfo.mIsRoaming = in.readInt() != 0; netInfo.mIsRoaming = in.readInt() != 0;
netInfo.mIsConnectedToProvisioningNetwork = in.readInt() != 0;
netInfo.mReason = in.readString(); netInfo.mReason = in.readString();
netInfo.mExtraInfo = in.readString(); netInfo.mExtraInfo = in.readString();
return netInfo; return netInfo;

View File

@@ -965,8 +965,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// Find the first Provisioning Network // Find the first Provisioning Network
NetworkInfo provNi = null; NetworkInfo provNi = null;
for (NetworkInfo ni : getAllNetworkInfo()) { for (NetworkInfo ni : getAllNetworkInfo()) {
if (ni.getDetailedState() if (ni.isConnectedToProvisioningNetwork()) {
== NetworkInfo.DetailedState.CONNECTED_TO_PROVISIONING_NETWORK) {
provNi = ni; provNi = ni;
break; break;
} }
@@ -2919,7 +2918,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
NetworkInfo.State state = info.getState(); NetworkInfo.State state = info.getState();
if (VDBG || (state == NetworkInfo.State.CONNECTED) || if (VDBG || (state == NetworkInfo.State.CONNECTED) ||
(state == NetworkInfo.State.DISCONNECTED)) { (state == NetworkInfo.State.DISCONNECTED) ||
(state == NetworkInfo.State.SUSPENDED)) {
log("ConnectivityChange for " + log("ConnectivityChange for " +
info.getTypeName() + ": " + info.getTypeName() + ": " +
state + "/" + info.getDetailedState()); state + "/" + info.getDetailedState());
@@ -2934,7 +2934,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (ConnectivityManager.isNetworkTypeMobile(info.getType()) if (ConnectivityManager.isNetworkTypeMobile(info.getType())
&& (0 != Settings.Global.getInt(mContext.getContentResolver(), && (0 != Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, 0)) Settings.Global.DEVICE_PROVISIONED, 0))
&& (state == NetworkInfo.State.CONNECTED)) { && ((state == NetworkInfo.State.CONNECTED)
|| info.isConnectedToProvisioningNetwork())) {
checkMobileProvisioning(CheckMp.MAX_TIMEOUT_MS); checkMobileProvisioning(CheckMp.MAX_TIMEOUT_MS);
} }
@@ -2947,8 +2948,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} else if (info.getDetailedState() == } else if (info.getDetailedState() ==
DetailedState.CAPTIVE_PORTAL_CHECK) { DetailedState.CAPTIVE_PORTAL_CHECK) {
handleCaptivePortalTrackerCheck(info); handleCaptivePortalTrackerCheck(info);
} else if (info.getDetailedState() == } else if (info.isConnectedToProvisioningNetwork()) {
DetailedState.CONNECTED_TO_PROVISIONING_NETWORK) {
/** /**
* TODO: Create ConnectivityManager.TYPE_MOBILE_PROVISIONING * TODO: Create ConnectivityManager.TYPE_MOBILE_PROVISIONING
* for now its an in between network, its a network that * for now its an in between network, its a network that
@@ -4418,8 +4418,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// If provisioning network handle as a special case, // If provisioning network handle as a special case,
// otherwise launch browser with the intent directly. // otherwise launch browser with the intent directly.
NetworkInfo ni = getProvisioningNetworkInfo(); NetworkInfo ni = getProvisioningNetworkInfo();
if ((ni != null) && ni.getDetailedState() == if ((ni != null) && ni.isConnectedToProvisioningNetwork()) {
NetworkInfo.DetailedState.CONNECTED_TO_PROVISIONING_NETWORK) {
if (DBG) log("handleMobileProvisioningAction: on provisioning network"); if (DBG) log("handleMobileProvisioningAction: on provisioning network");
MobileDataStateTracker mdst = (MobileDataStateTracker) MobileDataStateTracker mdst = (MobileDataStateTracker)
mNetTrackers[ConnectivityManager.TYPE_MOBILE]; mNetTrackers[ConnectivityManager.TYPE_MOBILE];