Merge "Mark a disable apn so we don't reconnect." into honeycomb-LTE
This commit is contained in:
committed by
Android (Google) Code Review
commit
2499da83cb
@@ -28,14 +28,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
*/
|
*/
|
||||||
public class ApnContext {
|
public class ApnContext {
|
||||||
|
|
||||||
public static final int PENDING_ACTION_NONE = 1;
|
|
||||||
public static final int PENDING_ACTION_RECONNECT = 2;
|
|
||||||
public static final int PENDING_ACTION_APN_DISABLE = 3;
|
|
||||||
|
|
||||||
public final String LOG_TAG;
|
public final String LOG_TAG;
|
||||||
|
|
||||||
private AtomicInteger mPendingAction;
|
|
||||||
|
|
||||||
protected static final boolean DBG = true;
|
protected static final boolean DBG = true;
|
||||||
|
|
||||||
private final String mApnType;
|
private final String mApnType;
|
||||||
@@ -71,21 +65,12 @@ public class ApnContext {
|
|||||||
mApnType = apnType;
|
mApnType = apnType;
|
||||||
mState = DataConnectionTracker.State.IDLE;
|
mState = DataConnectionTracker.State.IDLE;
|
||||||
setReason(Phone.REASON_DATA_ENABLED);
|
setReason(Phone.REASON_DATA_ENABLED);
|
||||||
mPendingAction = new AtomicInteger(PENDING_ACTION_NONE);
|
|
||||||
mDataEnabled = new AtomicBoolean(false);
|
mDataEnabled = new AtomicBoolean(false);
|
||||||
mDependencyMet = new AtomicBoolean(true);
|
mDependencyMet = new AtomicBoolean(true);
|
||||||
mWaitingApnsPermanentFailureCountDown = new AtomicInteger(0);
|
mWaitingApnsPermanentFailureCountDown = new AtomicInteger(0);
|
||||||
LOG_TAG = logTag;
|
LOG_TAG = logTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPendingAction() {
|
|
||||||
return mPendingAction.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPendingAction(int pa) {
|
|
||||||
mPendingAction.set(pa);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getApnType() {
|
public String getApnType() {
|
||||||
return mApnType;
|
return mApnType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,20 +457,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
// If already active, return
|
// If already active, return
|
||||||
if (DBG) log("enableApnType: " + apnType + " mState(" + apnContext.getState() + ")");
|
if (DBG) log("enableApnType: " + apnType + " mState(" + apnContext.getState() + ")");
|
||||||
|
|
||||||
if (apnContext.getState() == State.INITING) {
|
if (apnContext.getState() == State.CONNECTED) {
|
||||||
if (DBG) log("enableApnType: return APN_REQUEST_STARTED");
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
}
|
|
||||||
else if (apnContext.getState() == State.CONNECTED) {
|
|
||||||
if (DBG) log("enableApnType: return APN_ALREADY_ACTIVE");
|
if (DBG) log("enableApnType: return APN_ALREADY_ACTIVE");
|
||||||
return Phone.APN_ALREADY_ACTIVE;
|
return Phone.APN_ALREADY_ACTIVE;
|
||||||
}
|
}
|
||||||
else if (apnContext.getState() == State.DISCONNECTING) {
|
|
||||||
if (DBG) log("enableApnType: while disconnecting, return APN_REQUEST_STARTED");
|
|
||||||
apnContext.setPendingAction(ApnContext.PENDING_ACTION_RECONNECT);
|
|
||||||
return Phone.APN_REQUEST_STARTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
setEnabled(apnTypeToId(apnType), true);
|
setEnabled(apnTypeToId(apnType), true);
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("enableApnType: new apn request for type " + apnType +
|
log("enableApnType: new apn request for type " + apnType +
|
||||||
@@ -504,21 +494,12 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
ApnContext apnContext = mApnContexts.get(type);
|
ApnContext apnContext = mApnContexts.get(type);
|
||||||
|
|
||||||
if (apnContext != null) {
|
if (apnContext != null) {
|
||||||
|
setEnabled(apnTypeToId(type), false);
|
||||||
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);
|
|
||||||
msg.arg1 = 1; // tearDown is true;
|
|
||||||
// TODO - don't set things on apnContext from public functions.
|
|
||||||
// Maybe pass reason as arg2?
|
|
||||||
apnContext.setReason(Phone.REASON_DATA_DISABLED);
|
|
||||||
msg.obj = apnContext;
|
|
||||||
sendMessage(msg);
|
|
||||||
if (DBG) log("diableApnType: return APN_REQUEST_STARTED");
|
if (DBG) log("diableApnType: return APN_REQUEST_STARTED");
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log("disableApnType: return APN_ALREADY_INACTIVE");
|
if (DBG) log("disableApnType: return APN_ALREADY_INACTIVE");
|
||||||
apnContext.setEnabled(false);
|
|
||||||
apnContext.setDataConnection(null);
|
|
||||||
return Phone.APN_ALREADY_INACTIVE;
|
return Phone.APN_ALREADY_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,10 +546,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDataAllowed(ApnContext apnContext) {
|
private boolean isDataAllowed(ApnContext apnContext) {
|
||||||
if(apnContext.getState() == State.DISCONNECTING
|
|
||||||
&& apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return apnContext.isReady() && isDataAllowed();
|
return apnContext.isReady() && isDataAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1327,7 +1304,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
if (apnContext.getState() == State.FAILED) {
|
if (apnContext.getState() == State.FAILED) {
|
||||||
if (!apnContext.getDataConnection().isRetryNeeded()) {
|
if (!apnContext.getDataConnection().isRetryNeeded()) {
|
||||||
if (!apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) {
|
if (!apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) {
|
||||||
notifyDataConnection(Phone.REASON_APN_FAILED);
|
mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mReregisterOnReconnectFailure) {
|
if (mReregisterOnReconnectFailure) {
|
||||||
@@ -1645,7 +1622,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
log("onDataSetupComplete: All APN's had permanent failures, stop retrying");
|
log("onDataSetupComplete: All APN's had permanent failures, stop retrying");
|
||||||
}
|
}
|
||||||
apnContext.setState(State.FAILED);
|
apnContext.setState(State.FAILED);
|
||||||
notifyDataConnection(Phone.REASON_APN_FAILED);
|
mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType());
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log("onDataSetupComplete: Not all permanent failures, retry");
|
if (DBG) log("onDataSetupComplete: Not all permanent failures, retry");
|
||||||
startDelayedRetry(cause, apnContext);
|
startDelayedRetry(cause, apnContext);
|
||||||
@@ -1684,10 +1661,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
apnContext.setState(State.IDLE);
|
apnContext.setState(State.IDLE);
|
||||||
apnContext.setApnSetting(null);
|
apnContext.setApnSetting(null);
|
||||||
|
|
||||||
// Check if APN disabled.
|
|
||||||
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
|
||||||
apnContext.setPendingAction(ApnContext.PENDING_ACTION_NONE);
|
|
||||||
}
|
|
||||||
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
|
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
|
||||||
|
|
||||||
// if all data connection are gone, check whether Airplane mode request was
|
// if all data connection are gone, check whether Airplane mode request was
|
||||||
@@ -1701,10 +1674,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
|||||||
|
|
||||||
// If APN is still enabled, try to bring it back up automatically
|
// If APN is still enabled, try to bring it back up automatically
|
||||||
if (apnContext.isReady() && retryAfterDisconnected(apnContext.getReason())) {
|
if (apnContext.isReady() && retryAfterDisconnected(apnContext.getReason())) {
|
||||||
SystemProperties.set("gsm.defaultpdpcontext.active", "false");
|
SystemProperties.set("gsm.defaultpdpcontext.active", "false"); // TODO - what the heck? This shoudld go
|
||||||
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_RECONNECT) {
|
|
||||||
apnContext.setPendingAction(ApnContext.PENDING_ACTION_NONE);
|
|
||||||
}
|
|
||||||
// Wait a bit before trying the next APN, so that
|
// Wait a bit before trying the next APN, so that
|
||||||
// we're not tying up the RIL command channel.
|
// we're not tying up the RIL command channel.
|
||||||
// This also helps in any external dependency to turn off the context.
|
// This also helps in any external dependency to turn off the context.
|
||||||
|
|||||||
Reference in New Issue
Block a user