use of com.android.internal.telephony.DataConnection in project XobotOS by xamarin.
the class GsmDataConnectionTracker method onRadioOffOrNotAvailable.
@Override
protected void onRadioOffOrNotAvailable() {
for (DataConnection dc : mDataConnections.values()) {
dc.resetRetryCount();
}
mReregisterOnReconnectFailure = false;
if (mPhone.getSimulatedRadioControl() != null) {
// Assume data is connected on the simulator
// FIXME this can be improved
log("We're on the simulator; assuming radio off is meaningless");
} else {
if (DBG)
log("onRadioOffOrNotAvailable: is off and clean up all connections");
cleanUpAllConnections(false, Phone.REASON_RADIO_TURNED_OFF);
}
notifyOffApnsOfAvailability(null);
}
use of com.android.internal.telephony.DataConnection in project XobotOS by xamarin.
the class GsmDataConnectionTracker method onDataSetupComplete.
@Override
protected void onDataSetupComplete(AsyncResult ar) {
ApnContext apnContext = null;
if (ar.userObj instanceof ApnContext) {
apnContext = (ApnContext) ar.userObj;
} else {
throw new RuntimeException("onDataSetupComplete: No apnContext");
}
if (isDataSetupCompleteOk(ar)) {
DataConnectionAc dcac = apnContext.getDataConnectionAc();
if (dcac == null) {
throw new RuntimeException("onDataSetupCompete: No dcac");
}
DataConnection dc = apnContext.getDataConnection();
if (DBG) {
log(String.format("onDataSetupComplete: success apn=%s", apnContext.getWaitingApns().get(0).apn));
}
ApnSetting apn = apnContext.getApnSetting();
if (apn.proxy != null && apn.proxy.length() != 0) {
try {
String port = apn.port;
if (TextUtils.isEmpty(port))
port = "8080";
ProxyProperties proxy = new ProxyProperties(apn.proxy, Integer.parseInt(port), null);
dcac.setLinkPropertiesHttpProxySync(proxy);
} catch (NumberFormatException e) {
loge("onDataSetupComplete: NumberFormatException making ProxyProperties (" + apn.port + "): " + e);
}
}
// everything is setup
if (TextUtils.equals(apnContext.getApnType(), Phone.APN_TYPE_DEFAULT)) {
SystemProperties.set("gsm.defaultpdpcontext.active", "true");
if (canSetPreferApn && mPreferredApn == null) {
if (DBG)
log("onDataSetupComplete: PREFERED APN is null");
mPreferredApn = apnContext.getApnSetting();
if (mPreferredApn != null) {
setPreferredApn(mPreferredApn.id);
}
}
} else {
SystemProperties.set("gsm.defaultpdpcontext.active", "false");
}
notifyDefaultData(apnContext);
} else {
String apnString;
DataConnection.FailCause cause;
cause = (DataConnection.FailCause) (ar.result);
if (DBG) {
try {
apnString = apnContext.getWaitingApns().get(0).apn;
} catch (Exception e) {
apnString = "<unknown>";
}
log(String.format("onDataSetupComplete: error apn=%s cause=%s", apnString, cause));
}
if (cause.isEventLoggable()) {
// Log this failure to the Event Logs.
int cid = getCellLocationId();
EventLog.writeEvent(EventLogTags.PDP_SETUP_FAIL, cause.ordinal(), cid, TelephonyManager.getDefault().getNetworkType());
}
// Count permanent failures and remove the APN we just tried
if (cause.isPermanentFail())
apnContext.decWaitingApnsPermFailCount();
apnContext.removeNextWaitingApn();
if (DBG) {
log(String.format("onDataSetupComplete: WaitingApns.size=%d" + " WaitingApnsPermFailureCountDown=%d", apnContext.getWaitingApns().size(), apnContext.getWaitingApnsPermFailCount()));
}
// See if there are more APN's to try
if (apnContext.getWaitingApns().isEmpty()) {
if (apnContext.getWaitingApnsPermFailCount() == 0) {
if (DBG) {
log("onDataSetupComplete: All APN's had permanent failures, stop retrying");
}
apnContext.setState(State.FAILED);
mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType());
apnContext.setDataConnection(null);
apnContext.setDataConnectionAc(null);
if (DBG) {
log("onDataSetupComplete: permanent error apn=%s" + apnString);
}
} else {
if (DBG)
log("onDataSetupComplete: Not all permanent failures, retry");
// check to see if retry should be overridden for this failure.
int retryOverride = -1;
if (ar.exception instanceof DataConnection.CallSetupException) {
retryOverride = ((DataConnection.CallSetupException) ar.exception).getRetryOverride();
}
if (retryOverride == RILConstants.MAX_INT) {
if (DBG)
log("No retry is suggested.");
} else {
startDelayedRetry(cause, apnContext, retryOverride);
}
}
} else {
if (DBG)
log("onDataSetupComplete: Try next APN");
apnContext.setState(State.SCANNING);
// Wait a bit before trying the next APN, so that
// we're not tying up the RIL command channel
startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
}
}
}
use of com.android.internal.telephony.DataConnection in project XobotOS by xamarin.
the class CdmaDataConnectionTracker method cleanUpConnection.
/**
* Cleanup the CDMA data connection (only one is supported)
*
* @param tearDown true if the underlying DataConnection should be disconnected.
* @param reason for the clean up.
*/
private void cleanUpConnection(boolean tearDown, String reason) {
if (DBG)
log("cleanUpConnection: reason: " + reason);
// Clear the reconnect alarm, if set.
if (mReconnectIntent != null) {
AlarmManager am = (AlarmManager) mPhone.getContext().getSystemService(Context.ALARM_SERVICE);
am.cancel(mReconnectIntent);
mReconnectIntent = null;
}
setState(State.DISCONNECTING);
notifyOffApnsOfAvailability(reason);
boolean notificationDeferred = false;
for (DataConnection conn : mDataConnections.values()) {
if (conn != null) {
DataConnectionAc dcac = mDataConnectionAsyncChannels.get(conn.getDataConnectionId());
if (tearDown) {
if (DBG)
log("cleanUpConnection: teardown, call conn.disconnect");
conn.tearDown(reason, obtainMessage(EVENT_DISCONNECT_DONE, conn.getDataConnectionId(), 0, reason));
notificationDeferred = true;
} else {
if (DBG)
log("cleanUpConnection: !tearDown, call conn.resetSynchronously");
if (dcac != null) {
dcac.resetSync();
}
notificationDeferred = false;
}
}
}
stopNetStatPoll();
if (!notificationDeferred) {
if (DBG)
log("cleanupConnection: !notificationDeferred");
gotoIdleAndNotifyDataConnection(reason);
}
}
Aggregations