Merge change Ie944f08b into eclair

* changes:
  Revert setDataEnabled to setting a master switch.
This commit is contained in:
Android (Google) Code Review
2009-09-30 20:54:37 -04:00
4 changed files with 42 additions and 13 deletions

View File

@@ -100,6 +100,7 @@ public abstract class DataConnectionTracker extends Handler {
public static final int EVENT_CLEAN_UP_CONNECTION = 34;
protected static final int EVENT_CDMA_OTA_PROVISION = 35;
protected static final int EVENT_RESTART_RADIO = 36;
protected static final int EVENT_SET_MASTER_DATA_ENABLE = 37;
/***** Constants *****/
@@ -111,8 +112,11 @@ public abstract class DataConnectionTracker extends Handler {
protected static final int APN_HIPRI_ID = 4;
protected static final int APN_NUM_TYPES = 5;
protected static final int APN_DISABLED = 0;
protected static final int APN_ENABLED = 1;
protected static final int DISABLED = 0;
protected static final int ENABLED = 1;
// responds to the setDataEnabled call - used independently from the APN requests
protected boolean mMasterDataEnabled = true;
protected boolean[] dataEnabled = new boolean[APN_NUM_TYPES];
protected int enabledCount = 0;
@@ -322,6 +326,11 @@ public abstract class DataConnectionTracker extends Handler {
onCleanUpConnection(tearDown, (String)msg.obj);
break;
case EVENT_SET_MASTER_DATA_ENABLE:
boolean enabled = (msg.arg1 == ENABLED) ? true : false;
onSetDataEnabled(enabled);
break;
default:
Log.e("DATA", "Unidentified event = " + msg.what);
break;
@@ -486,7 +495,7 @@ public abstract class DataConnectionTracker extends Handler {
Message msg = obtainMessage(EVENT_ENABLE_NEW_APN);
msg.arg1 = id;
msg.arg2 = (enable ? APN_ENABLED : APN_DISABLED);
msg.arg2 = (enable ? ENABLED : DISABLED);
sendMessage(msg);
}
@@ -497,7 +506,7 @@ public abstract class DataConnectionTracker extends Handler {
", enabledCount = " + enabledCount +
", isApnTypeActive = " + isApnTypeActive(apnIdToType(apnId)));
}
if (enabled == APN_ENABLED) {
if (enabled == ENABLED) {
if (!dataEnabled[apnId]) {
dataEnabled[apnId] = true;
enabledCount++;
@@ -545,8 +554,24 @@ public abstract class DataConnectionTracker extends Handler {
*/
public boolean setDataEnabled(boolean enable) {
if (DBG) Log.d(LOG_TAG, "setDataEnabled(" + enable + ")");
setEnabled(APN_DEFAULT_ID, enable);
Message msg = obtainMessage(EVENT_SET_MASTER_DATA_ENABLE);
msg.arg1 = (enable ? ENABLED : DISABLED);
sendMessage(msg);
return true;
}
protected void onSetDataEnabled(boolean enable) {
if (mMasterDataEnabled != enable) {
mMasterDataEnabled = enable;
if (enable) {
mRetryMgr.resetRetryCount();
onTrySetupData(Phone.REASON_DATA_ENABLED);
} else {
onCleanUpConnection(true, Phone.REASON_DATA_DISABLED);
}
}
}
}

View File

@@ -1039,8 +1039,8 @@ public final class CdmaCallTracker extends CallTracker {
private void disableDataCallInEmergencyCall(String dialString) {
if (PhoneNumberUtils.isEmergencyNumber(dialString)) {
if (Phone.DEBUG_PHONE) log("disableDataCallInEmergencyCall");
phone.disableDataConnectivity();
mIsInEmergencyCall = true;
phone.disableDataConnectivity();
}
}
@@ -1050,15 +1050,16 @@ public final class CdmaCallTracker extends CallTracker {
*/
private void checkAndEnableDataCallAfterEmergencyCallDropped() {
if (mIsInEmergencyCall) {
mIsInEmergencyCall = false;
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
if (Phone.DEBUG_PHONE) {
log("checkAndEnableDataCallAfterEmergencyCallDropped,inEcm=" + inEcm);
}
if (inEcm.compareTo("false") == 0) {
// Re-initiate data connection
// TODO - can this be changed to phone.enableDataConnectivity();
phone.mDataConnection.setDataEnabled(true);
}
mIsInEmergencyCall = false;
}
}

View File

@@ -302,7 +302,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
private boolean isDataAllowed() {
boolean roaming = phone.getServiceState().getRoaming();
return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled());
return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled()) && mMasterDataEnabled;
}
private boolean trySetupData(String reason) {
@@ -347,7 +347,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
" roaming=" + roaming +
" dataOnRoamingEnable=" + getDataOnRoamingEnabled() +
" desiredPowerState=" + desiredPowerState +
" PendingRestartRadio=" + mPendingRestartRadio);
" PendingRestartRadio=" + mPendingRestartRadio +
" MasterDataEnabled=" + mMasterDataEnabled);
}
return false;
}

View File

@@ -391,7 +391,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
private boolean isDataAllowed() {
boolean roaming = phone.getServiceState().getRoaming();
return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled());
return getAnyDataEnabled() && (!roaming || getDataOnRoamingEnabled()) &&
mMasterDataEnabled;
}
//****** Called from ServiceStateTracker
@@ -475,7 +476,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
" roaming=" + phone.getServiceState().getRoaming() +
" dataOnRoamingEnable=" + getDataOnRoamingEnabled() +
" ps restricted=" + mIsPsRestricted +
" desiredPowerState=" + desiredPowerState);
" desiredPowerState=" + desiredPowerState +
" MasterDataEnabled=" + mMasterDataEnabled);
return false;
}
}
@@ -1039,7 +1041,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
if (!mRequestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
// if no more retries on a secondary APN attempt, tell the world and revert.
phone.notifyDataConnection(Phone.REASON_APN_FAILED);
onEnableApn(apnTypeToId(mRequestedApnType), APN_DISABLED);
onEnableApn(apnTypeToId(mRequestedApnType), DISABLED);
return;
}
if (mReregisterOnReconnectFailure) {
@@ -1203,7 +1205,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
notifyNoData(cause);
if (!mRequestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
phone.notifyDataConnection(Phone.REASON_APN_FAILED);
onEnableApn(apnTypeToId(mRequestedApnType), APN_DISABLED);
onEnableApn(apnTypeToId(mRequestedApnType), DISABLED);
}
return;
}