use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.
the class GsmDataConnectionTracker method trySetupData.
private boolean trySetupData(String reason, String type) {
if (DBG) {
log("trySetupData: " + type + " due to " + (reason == null ? "(unspecified)" : reason) + " isPsRestricted=" + mIsPsRestricted);
}
if (type == null) {
type = Phone.APN_TYPE_DEFAULT;
}
ApnContext apnContext = mApnContexts.get(type);
if (apnContext == null) {
if (DBG)
log("trySetupData new apn context for type:" + type);
apnContext = new ApnContext(type, LOG_TAG);
mApnContexts.put(type, apnContext);
}
apnContext.setReason(reason);
return trySetupData(apnContext);
}
use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.
the class GsmDataConnectionTracker method cleanUpAllConnections.
/**
* If tearDown is true, this only tears down a CONNECTED session. Presently,
* there is no mechanism for abandoning an INITING/CONNECTING session,
* but would likely involve cancelling pending async requests or
* setting a flag or new state to ignore them when they came in
* @param tearDown true if the underlying GsmDataConnection should be
* disconnected.
* @param reason reason for the clean up.
*/
protected void cleanUpAllConnections(boolean tearDown, String reason) {
if (DBG)
log("cleanUpAllConnections: tearDown=" + tearDown + " reason=" + reason);
for (ApnContext apnContext : mApnContexts.values()) {
apnContext.setReason(reason);
cleanUpConnection(tearDown, apnContext);
}
stopNetStatPoll();
// TODO: Do we need mRequestedApnType?
mRequestedApnType = Phone.APN_TYPE_DEFAULT;
}
use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.
the class GsmDataConnectionTracker method cleanUpConnection.
private void cleanUpConnection(boolean tearDown, ApnContext apnContext) {
if (apnContext == null) {
if (DBG)
log("cleanUpConnection: apn context is null");
return;
}
if (DBG) {
log("cleanUpConnection: tearDown=" + tearDown + " reason=" + apnContext.getReason());
}
DataConnectionAc dcac = apnContext.getDataConnectionAc();
if (tearDown) {
if (apnContext.isDisconnected()) {
// The request is tearDown and but ApnContext is not connected.
// If apnContext is not enabled anymore, break the linkage to the DCAC/DC.
apnContext.setState(State.IDLE);
if (!apnContext.isReady()) {
apnContext.setDataConnection(null);
apnContext.setDataConnectionAc(null);
}
} else {
// Connection is still there. Try to clean up.
if (dcac != null) {
if (apnContext.getState() != State.DISCONNECTING) {
if (DBG)
log("cleanUpConnection: tearing down");
Message msg = obtainMessage(EVENT_DISCONNECT_DONE, apnContext);
apnContext.getDataConnection().tearDown(apnContext.getReason(), msg);
apnContext.setState(State.DISCONNECTING);
}
} else {
// apn is connected but no reference to dcac.
// Should not be happen, but reset the state in case.
apnContext.setState(State.IDLE);
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
}
}
} else {
// force clean up the data connection.
if (dcac != null)
dcac.resetSync();
apnContext.setState(State.IDLE);
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
apnContext.setDataConnection(null);
apnContext.setDataConnectionAc(null);
}
// associated to the connection.
if (dcac != null) {
Collection<ApnContext> apnList = dcac.getApnListSync();
if (apnList.isEmpty()) {
cancelReconnectAlarm(dcac);
}
}
}
use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.
the class GsmDataConnectionTracker method isDataPossible.
@Override
protected boolean isDataPossible(String apnType) {
ApnContext apnContext = mApnContexts.get(apnType);
if (apnContext == null) {
return false;
}
boolean apnContextIsEnabled = apnContext.isEnabled();
State apnContextState = apnContext.getState();
boolean apnTypePossible = !(apnContextIsEnabled && (apnContextState == State.FAILED));
boolean dataAllowed = isDataAllowed();
boolean possible = dataAllowed && apnTypePossible;
if (DBG) {
log(String.format("isDataPossible(%s): possible=%b isDataAllowed=%b " + "apnTypePossible=%b apnContextisEnabled=%b apnContextState()=%s", apnType, possible, dataAllowed, apnTypePossible, apnContextIsEnabled, apnContextState));
}
return possible;
}
use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.
the class GsmDataConnectionTracker method setupDataOnReadyApns.
private void setupDataOnReadyApns(String reason) {
// retry. Reset ApnContext state to IDLE.
for (DataConnectionAc dcac : mDataConnectionAsyncChannels.values()) {
if (dcac.getReconnectIntentSync() != null) {
cancelReconnectAlarm(dcac);
}
// ones for the new RAT.
if (dcac.dataConnection != null) {
Collection<ApnContext> apns = dcac.getApnListSync();
boolean hasDefault = false;
for (ApnContext apnContext : apns) {
if (apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) {
hasDefault = true;
break;
}
}
configureRetry(dcac.dataConnection, hasDefault);
}
}
// Only check for default APN state
for (ApnContext apnContext : mApnContexts.values()) {
if (apnContext.getState() == State.FAILED) {
// By this time, alarms for all failed Apns
// should be stopped if any.
// Make sure to set the state back to IDLE
// so that setup data can happen.
apnContext.setState(State.IDLE);
}
if (apnContext.isReady()) {
if (apnContext.getState() == State.IDLE) {
apnContext.setReason(reason);
trySetupData(apnContext);
}
}
}
}
Aggregations