Merge change 22049 into eclair

* changes:
  Fix various issues found when testing Mms.
This commit is contained in:
Android (Google) Code Review
2009-08-19 23:30:42 -07:00
3 changed files with 30 additions and 16 deletions

View File

@@ -143,8 +143,9 @@ public class MobileDataStateTracker extends NetworkStateTracker {
boolean unavailable = intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY, boolean unavailable = intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
false); false);
if (DBG) Log.d(TAG, mApnType + " Received " + intent.getAction() + if (DBG) Log.d(TAG, mApnType + " Received " + intent.getAction() +
" broadcast - state = " + state + ", unavailable = " + unavailable + " broadcast - state = " + state + ", oldstate = " + mMobileDataState +
", reason = " + (reason == null ? "(unspecified)" : reason)); ", unavailable = " + unavailable + ", reason = " +
(reason == null ? "(unspecified)" : reason));
if (isApnTypeIncluded(apnTypeList)) { if (isApnTypeIncluded(apnTypeList)) {
if (mEnabled == false) { if (mEnabled == false) {
@@ -152,10 +153,12 @@ public class MobileDataStateTracker extends NetworkStateTracker {
// we should record the interface name if one's provided. If the user // we should record the interface name if one's provided. If the user
// turns on this network we will need the interfacename but won't get // turns on this network we will need the interfacename but won't get
// a fresh connected message - TODO fix this.. // a fresh connected message - TODO fix this..
if (mInterfaceName == null && state == Phone.DataState.CONNECTED) { if (state == Phone.DataState.CONNECTED) {
if (DBG) Log.d(TAG, "replacing old mInterfaceName (" +
mInterfaceName + ") with " +
intent.getStringExtra(Phone.DATA_IFACE_NAME_KEY) +
" for " + mApnType);
mInterfaceName = intent.getStringExtra(Phone.DATA_IFACE_NAME_KEY); mInterfaceName = intent.getStringExtra(Phone.DATA_IFACE_NAME_KEY);
} else if (state == Phone.DataState.DISCONNECTED) {
mInterfaceName = null;
} }
if (DBG) Log.d(TAG, " dropped - mEnabled = false"); if (DBG) Log.d(TAG, " dropped - mEnabled = false");
return; return;
@@ -179,6 +182,8 @@ public class MobileDataStateTracker extends NetworkStateTracker {
if (mInterfaceName != null) { if (mInterfaceName != null) {
NetworkUtils.resetConnections(mInterfaceName); NetworkUtils.resetConnections(mInterfaceName);
} }
if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
" as it DISCONNECTED");
mInterfaceName = null; mInterfaceName = null;
mDefaultGatewayAddr = 0; mDefaultGatewayAddr = 0;
break; break;
@@ -301,6 +306,8 @@ public class MobileDataStateTracker extends NetworkStateTracker {
switch (setEnableApn(mApnType, true)) { switch (setEnableApn(mApnType, true)) {
case Phone.APN_ALREADY_ACTIVE: case Phone.APN_ALREADY_ACTIVE:
mEnabled = true; mEnabled = true;
// need to set self to CONNECTING so the below message is handled.
mMobileDataState = Phone.DataState.CONNECTING;
//send out a connected message //send out a connected message
Intent intent = new Intent(TelephonyIntents. Intent intent = new Intent(TelephonyIntents.
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
@@ -412,10 +419,11 @@ public class MobileDataStateTracker extends NetworkStateTracker {
*/ */
@Override @Override
public boolean requestRouteToHost(int hostAddress) { public boolean requestRouteToHost(int hostAddress) {
if (DBG) {
Log.d(TAG, "Requested host route to " + Integer.toHexString(hostAddress) +
" for " + mApnType + "(" + mInterfaceName + ")");
}
if (mInterfaceName != null && hostAddress != -1) { if (mInterfaceName != null && hostAddress != -1) {
if (DBG) {
Log.d(TAG, "Requested host route to " + Integer.toHexString(hostAddress));
}
return NetworkUtils.addHostRoute(mInterfaceName, hostAddress) == 0; return NetworkUtils.addHostRoute(mInterfaceName, hostAddress) == 0;
} else { } else {
return false; return false;

View File

@@ -513,7 +513,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mNetRequestersPids[usedNetworkType].add(currentPid); mNetRequestersPids[usedNetworkType].add(currentPid);
} }
if (ni.isConnectedOrConnecting() == true) { if ((ni.isConnectedOrConnecting() == true) &&
!network.isTeardownRequested()) {
if (ni.isConnected() == true) { if (ni.isConnected() == true) {
// add the pid-specific dns // add the pid-specific dns
handleDnsConfigurationChange(); handleDnsConfigurationChange();
@@ -686,6 +687,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
++numConnectedNets; ++numConnectedNets;
} }
} }
if (DBG) Log.d(TAG, "numConnectedNets returning "+numConnectedNets);
return numConnectedNets; return numConnectedNets;
} }
@@ -792,7 +794,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (newNet.isAvailable()) { if (newNet.isAvailable()) {
NetworkInfo switchTo = newNet.getNetworkInfo(); NetworkInfo switchTo = newNet.getNetworkInfo();
switchTo.setFailover(true); switchTo.setFailover(true);
if (!switchTo.isConnectedOrConnecting()) { if (!switchTo.isConnectedOrConnecting() ||
newNet.isTeardownRequested()) {
newNet.reconnect(); newNet.reconnect();
} }
if (DBG) { if (DBG) {

View File

@@ -456,16 +456,19 @@ public abstract class DataConnectionTracker extends Handler {
if (dataEnabled[id] != enable) { if (dataEnabled[id] != enable) {
dataEnabled[id] = enable; dataEnabled[id] = enable;
// count the total number of enabled APN's
// if we just enabled the first APN, start our Data connection,
// if we disabled the last, stop our data connection
if (enable) { if (enable) {
enabledCount++; enabledCount++;
if (enabledCount == 1) {
setPrivateDataEnabled(true);
}
} else { } else {
enabledCount--; enabledCount--;
} if (enabledCount == 0) {
setPrivateDataEnabled(false);
if (enabledCount == 0) { }
setPrivateDataEnabled(false);
} else if (enabledCount == 1) {
setPrivateDataEnabled(true);
} }
} }
} }