Merge "Data connection attempts/retries for multiple APNs" into honeycomb-LTE
This commit is contained in:
@@ -159,8 +159,8 @@ public interface Phone {
|
|||||||
static final String REASON_ROAMING_OFF = "roamingOff";
|
static final String REASON_ROAMING_OFF = "roamingOff";
|
||||||
static final String REASON_DATA_DISABLED = "dataDisabled";
|
static final String REASON_DATA_DISABLED = "dataDisabled";
|
||||||
static final String REASON_DATA_ENABLED = "dataEnabled";
|
static final String REASON_DATA_ENABLED = "dataEnabled";
|
||||||
static final String REASON_GPRS_ATTACHED = "gprsAttached";
|
static final String REASON_DATA_ATTACHED = "dataAttached";
|
||||||
static final String REASON_GPRS_DETACHED = "gprsDetached";
|
static final String REASON_DATA_DETACHED = "dataDetached";
|
||||||
static final String REASON_CDMA_DATA_ATTACHED = "cdmaDataAttached";
|
static final String REASON_CDMA_DATA_ATTACHED = "cdmaDataAttached";
|
||||||
static final String REASON_CDMA_DATA_DETACHED = "cdmaDataDetached";
|
static final String REASON_CDMA_DATA_DETACHED = "cdmaDataDetached";
|
||||||
static final String REASON_APN_CHANGED = "apnChanged";
|
static final String REASON_APN_CHANGED = "apnChanged";
|
||||||
|
|||||||
@@ -505,9 +505,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
ApnContext apnContext = mApnContexts.get(type);
|
ApnContext apnContext = mApnContexts.get(type);
|
||||||
|
|
||||||
if (apnContext != null) {
|
if (apnContext != null) {
|
||||||
apnContext.setPendingAction(ApnContext.PENDING_ACTION_APN_DISABLE);
|
|
||||||
|
|
||||||
if (apnContext.getState() != State.IDLE && apnContext.getState() != State.FAILED) {
|
if (apnContext.getState() != State.IDLE && apnContext.getState() != State.FAILED) {
|
||||||
|
apnContext.setPendingAction(ApnContext.PENDING_ACTION_APN_DISABLE);
|
||||||
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
Message msg = obtainMessage(EVENT_CLEAN_UP_CONNECTION);
|
||||||
msg.arg1 = 1; // tearDown is true;
|
msg.arg1 = 1; // tearDown is true;
|
||||||
// TODO - don't set things on apnContext from public functions.
|
// TODO - don't set things on apnContext from public functions.
|
||||||
@@ -519,6 +518,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log("return APN_ALREADY_INACTIVE");
|
if (DBG) log("return APN_ALREADY_INACTIVE");
|
||||||
|
apnContext.setEnabled(false);
|
||||||
return Phone.APN_ALREADY_INACTIVE;
|
return Phone.APN_ALREADY_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,26 +582,16 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
* when GPRS detaches, but we should stop the network polling.
|
* when GPRS detaches, but we should stop the network polling.
|
||||||
*/
|
*/
|
||||||
stopNetStatPoll();
|
stopNetStatPoll();
|
||||||
notifyDataConnection(Phone.REASON_GPRS_DETACHED);
|
notifyDataConnection(Phone.REASON_DATA_DETACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDataConnectionAttached() {
|
private void onDataConnectionAttached() {
|
||||||
if (getOverallState() == State.CONNECTED) {
|
if (getOverallState() == State.CONNECTED) {
|
||||||
startNetStatPoll();
|
startNetStatPoll();
|
||||||
notifyDataConnection(Phone.REASON_GPRS_ATTACHED);
|
notifyDataConnection(Phone.REASON_DATA_ATTACHED);
|
||||||
} else {
|
|
||||||
// Only check for default APN state
|
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
|
||||||
if (defaultApnContext != null) {
|
|
||||||
if (defaultApnContext.getState() == State.FAILED) {
|
|
||||||
cleanUpConnection(false, defaultApnContext);
|
|
||||||
if (defaultApnContext.getDataConnection() != null) {
|
|
||||||
defaultApnContext.getDataConnection().resetRetryCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trySetupData(Phone.REASON_GPRS_ATTACHED, Phone.APN_TYPE_DEFAULT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupDataOnReadyApns(Phone.REASON_DATA_ATTACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -610,7 +600,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
|
boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
|
||||||
|
|
||||||
boolean allowed =
|
boolean allowed =
|
||||||
(gprsState == ServiceState.STATE_IN_SERVICE || mAutoAttachOnCreation) &&
|
gprsState == ServiceState.STATE_IN_SERVICE &&
|
||||||
mPhone.mSIMRecords.getRecordsLoaded() &&
|
mPhone.mSIMRecords.getRecordsLoaded() &&
|
||||||
mPhone.getState() == Phone.State.IDLE &&
|
mPhone.getState() == Phone.State.IDLE &&
|
||||||
mInternalDataEnabled &&
|
mInternalDataEnabled &&
|
||||||
@@ -619,7 +609,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
desiredPowerState;
|
desiredPowerState;
|
||||||
if (!allowed && DBG) {
|
if (!allowed && DBG) {
|
||||||
String reason = "";
|
String reason = "";
|
||||||
if (!((gprsState == ServiceState.STATE_IN_SERVICE) || mAutoAttachOnCreation)) {
|
if (!(gprsState == ServiceState.STATE_IN_SERVICE)) {
|
||||||
reason += " - gprs= " + gprsState;
|
reason += " - gprs= " + gprsState;
|
||||||
}
|
}
|
||||||
if (!mPhone.mSIMRecords.getRecordsLoaded()) reason += " - SIM not loaded";
|
if (!mPhone.mSIMRecords.getRecordsLoaded()) reason += " - SIM not loaded";
|
||||||
@@ -637,6 +627,26 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupDataOnReadyApns(String reason) {
|
||||||
|
// Only check for default APN state
|
||||||
|
for (ApnContext apnContext : mApnContexts.values()) {
|
||||||
|
if (apnContext.isReady()) {
|
||||||
|
if (apnContext.getState() == State.FAILED) {
|
||||||
|
cleanUpConnection(false, apnContext);
|
||||||
|
if (apnContext.getDataConnection() != null) {
|
||||||
|
apnContext.getDataConnection().resetRetryCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do not start ApnContext in SCANNING state
|
||||||
|
// FAILED state must be reset to IDLE by now
|
||||||
|
if (apnContext.getState() == State.IDLE) {
|
||||||
|
apnContext.setReason(reason);
|
||||||
|
trySetupData(apnContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean trySetupData(String reason, String type) {
|
private boolean trySetupData(String reason, String type) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("***trySetupData for type:" + type +
|
log("***trySetupData for type:" + type +
|
||||||
@@ -973,10 +983,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
createAllApnList();
|
createAllApnList();
|
||||||
cleanUpAllConnections(isConnected, Phone.REASON_APN_CHANGED);
|
cleanUpAllConnections(isConnected, Phone.REASON_APN_CHANGED);
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
// TODO: Won't work for multiple connections!!!!
|
setupDataOnReadyApns(Phone.REASON_APN_CHANGED);
|
||||||
defaultApnContext.getDataConnection().resetRetryCount();
|
|
||||||
defaultApnContext.setReason(Phone.REASON_APN_CHANGED);
|
|
||||||
trySetupData(defaultApnContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1316,18 +1323,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
private void onRecordsLoaded() {
|
private void onRecordsLoaded() {
|
||||||
if (DBG) log("onRecordsLoaded: createAllApnList");
|
if (DBG) log("onRecordsLoaded: createAllApnList");
|
||||||
createAllApnList();
|
createAllApnList();
|
||||||
for (ApnContext apnContext : mApnContexts.values()) {
|
setupDataOnReadyApns(Phone.REASON_SIM_LOADED);
|
||||||
if (apnContext.isReady()) {
|
|
||||||
apnContext.setReason(Phone.REASON_SIM_LOADED);
|
|
||||||
if (apnContext.getState() == State.FAILED) {
|
|
||||||
if (DBG) {
|
|
||||||
log("onRecordsLoaded clean connection for " + apnContext.getApnType());
|
|
||||||
}
|
|
||||||
cleanUpConnection(false, apnContext);
|
|
||||||
}
|
|
||||||
sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1413,7 +1409,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
@Override
|
@Override
|
||||||
// TODO: We shouldnt need this.
|
// TODO: We shouldnt need this.
|
||||||
protected boolean onTrySetupData(String reason) {
|
protected boolean onTrySetupData(String reason) {
|
||||||
return trySetupData(reason, Phone.APN_TYPE_DEFAULT);
|
setupDataOnReadyApns(reason);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean onTrySetupData(ApnContext apnContext) {
|
protected boolean onTrySetupData(ApnContext apnContext) {
|
||||||
@@ -1421,16 +1418,14 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// TODO: Need to understand if more than DEFAULT is impacted?
|
|
||||||
protected void onRoamingOff() {
|
protected void onRoamingOff() {
|
||||||
trySetupData(Phone.REASON_ROAMING_OFF, Phone.APN_TYPE_DEFAULT);
|
setupDataOnReadyApns(Phone.REASON_ROAMING_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// TODO: Need to understand if more than DEFAULT is impacted?
|
|
||||||
protected void onRoamingOn() {
|
protected void onRoamingOn() {
|
||||||
if (getDataOnRoamingEnabled()) {
|
if (getDataOnRoamingEnabled()) {
|
||||||
trySetupData(Phone.REASON_ROAMING_ON, Phone.APN_TYPE_DEFAULT);
|
setupDataOnReadyApns(Phone.REASON_ROAMING_ON);
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log("Tear down data connection on roaming.");
|
if (DBG) log("Tear down data connection on roaming.");
|
||||||
cleanUpAllConnections(true, Phone.REASON_ROAMING_ON);
|
cleanUpAllConnections(true, Phone.REASON_ROAMING_ON);
|
||||||
@@ -1618,14 +1613,12 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextUtils.equals(apnContext.getApnType(), Phone.APN_TYPE_DEFAULT)
|
// If APN is still enabled, try to bring it back up automatically
|
||||||
&& retryAfterDisconnected(apnContext.getReason())) {
|
if (apnContext.isReady() && retryAfterDisconnected(apnContext.getReason())) {
|
||||||
SystemProperties.set("gsm.defaultpdpcontext.active", "false");
|
SystemProperties.set("gsm.defaultpdpcontext.active", "false");
|
||||||
trySetupData(apnContext);
|
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_RECONNECT) {
|
||||||
}
|
apnContext.setPendingAction(ApnContext.PENDING_ACTION_NONE);
|
||||||
else if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_RECONNECT)
|
}
|
||||||
{
|
|
||||||
apnContext.setPendingAction(ApnContext.PENDING_ACTION_NONE);
|
|
||||||
trySetupData(apnContext);
|
trySetupData(apnContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1658,13 +1651,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// reset reconnect timer
|
// reset reconnect timer
|
||||||
ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
|
setupDataOnReadyApns(Phone.REASON_VOICE_CALL_ENDED);
|
||||||
if (defaultApnContext != null) {
|
|
||||||
defaultApnContext.getDataConnection().resetRetryCount();
|
|
||||||
mReregisterOnReconnectFailure = false;
|
|
||||||
// in case data setup was attempted when we were on a voice call
|
|
||||||
trySetupData(Phone.REASON_VOICE_CALL_ENDED, Phone.APN_TYPE_DEFAULT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user