use of com.android.internal.telephony.ApnSetting in project XobotOS by xamarin.
the class CdmaDataConnectionTracker method setupData.
private boolean setupData(String reason) {
CdmaDataConnection conn = findFreeDataConnection();
if (conn == null) {
if (DBG)
log("setupData: No free CdmaDataConnection found!");
return false;
}
/** TODO: We probably want the connection being setup to a parameter passed around */
mPendingDataConnection = conn;
String[] types;
int apnId;
if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) {
types = new String[1];
types[0] = Phone.APN_TYPE_DUN;
apnId = DataConnectionTracker.APN_DUN_ID;
} else {
types = mDefaultApnTypes;
apnId = mDefaultApnId;
}
mActiveApn = new ApnSetting(apnId, "", "", "", "", "", "", "", "", "", "", 0, types, "IP", "IP", true, 0);
if (DBG)
log("call conn.bringUp mActiveApn=" + mActiveApn);
Message msg = obtainMessage();
msg.what = EVENT_DATA_SETUP_COMPLETE;
msg.obj = reason;
conn.bringUp(msg, mActiveApn);
setState(State.INITING);
notifyDataConnection(reason);
return true;
}
use of com.android.internal.telephony.ApnSetting in project XobotOS by xamarin.
the class GsmDataConnectionTracker method setupData.
private boolean setupData(ApnContext apnContext) {
if (DBG)
log("setupData: apnContext=" + apnContext);
ApnSetting apn;
GsmDataConnection dc;
int profileId = getApnProfileID(apnContext.getApnType());
apn = apnContext.getNextWaitingApn();
if (apn == null) {
if (DBG)
log("setupData: return for no apn found!");
return false;
}
// First, check to see if ApnContext already has DC.
// This could happen if the retries are currently engaged.
dc = (GsmDataConnection) apnContext.getDataConnection();
if (dc == null) {
dc = (GsmDataConnection) checkForConnectionForApnContext(apnContext);
if (dc == null) {
dc = findReadyDataConnection(apn);
}
if (dc == null) {
if (DBG)
log("setupData: No ready GsmDataConnection found!");
// TODO: When allocating you are mapping type to id. If more than 1 free,
// then could findFreeDataConnection get the wrong one??
dc = findFreeDataConnection();
}
if (dc == null) {
dc = createDataConnection();
}
if (dc == null) {
if (DBG)
log("setupData: No free GsmDataConnection found!");
return false;
}
DataConnectionAc dcac = mDataConnectionAsyncChannels.get(dc.getDataConnectionId());
dc.setProfileId(profileId);
dc.setActiveApnType(apnContext.getApnType());
int refCount = dcac.getRefCountSync();
if (DBG)
log("setupData: init dc and apnContext refCount=" + refCount);
// configure retry count if no other Apn is using the same connection.
if (refCount == 0) {
configureRetry(dc, apn.canHandleType(Phone.APN_TYPE_DEFAULT));
}
apnContext.setDataConnectionAc(dcac);
apnContext.setDataConnection(dc);
}
apnContext.setApnSetting(apn);
apnContext.setState(State.INITING);
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
// fired so that we don't disruppt data retry pattern engaged.
if (apnContext.getDataConnectionAc().getReconnectIntentSync() != null) {
if (DBG)
log("setupData: data reconnection pending");
apnContext.setState(State.FAILED);
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
return true;
}
Message msg = obtainMessage();
msg.what = EVENT_DATA_SETUP_COMPLETE;
msg.obj = apnContext;
dc.bringUp(msg, apn);
if (DBG)
log("setupData: initing!");
return true;
}
use of com.android.internal.telephony.ApnSetting in project XobotOS by xamarin.
the class GsmDataConnectionTracker method getPreferredApn.
private ApnSetting getPreferredApn() {
if (mAllApns.isEmpty()) {
return null;
}
Cursor cursor = mPhone.getContext().getContentResolver().query(PREFERAPN_URI, new String[] { "_id", "name", "apn" }, null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (cursor != null) {
canSetPreferApn = true;
} else {
canSetPreferApn = false;
}
if (canSetPreferApn && cursor.getCount() > 0) {
int pos;
cursor.moveToFirst();
pos = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID));
for (ApnSetting p : mAllApns) {
if (p.id == pos && p.canHandleType(mRequestedApnType)) {
cursor.close();
return p;
}
}
}
if (cursor != null) {
cursor.close();
}
return null;
}
use of com.android.internal.telephony.ApnSetting in project XobotOS by xamarin.
the class GsmDataConnectionTracker method createApnList.
private ArrayList<ApnSetting> createApnList(Cursor cursor) {
ArrayList<ApnSetting> result = new ArrayList<ApnSetting>();
if (cursor.moveToFirst()) {
do {
String[] types = parseTypes(cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE)));
ApnSetting apn = new ApnSetting(cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NAME)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PORT)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSC)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPORT)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)), cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)), types, cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.ROAMING_PROTOCOL)), cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.CARRIER_ENABLED)) == 1, cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER)));
result.add(apn);
} while (cursor.moveToNext());
}
if (DBG)
log("createApnList: X result=" + result);
return result;
}
use of com.android.internal.telephony.ApnSetting in project XobotOS by xamarin.
the class GsmDataConnectionTracker method createAllApnList.
/**
* Based on the sim operator numeric, create a list for all possible
* Data Connections and setup the preferredApn.
*/
private void createAllApnList() {
mAllApns = new ArrayList<ApnSetting>();
String operator = mPhone.mIccRecords.getOperatorNumeric();
if (operator != null) {
String selection = "numeric = '" + operator + "'";
// query only enabled apn.
// carrier_enabled : 1 means enabled apn, 0 disabled apn.
selection += " and carrier_enabled = 1";
if (DBG)
log("createAllApnList: selection=" + selection);
Cursor cursor = mPhone.getContext().getContentResolver().query(Telephony.Carriers.CONTENT_URI, null, selection, null, null);
if (cursor != null) {
if (cursor.getCount() > 0) {
mAllApns = createApnList(cursor);
}
cursor.close();
}
}
if (mAllApns.isEmpty()) {
if (DBG)
log("createAllApnList: No APN found for carrier: " + operator);
mPreferredApn = null;
// TODO: What is the right behaviour?
//notifyNoData(GsmDataConnection.FailCause.MISSING_UNKNOWN_APN);
} else {
mPreferredApn = getPreferredApn();
if (mPreferredApn != null && !mPreferredApn.numeric.equals(operator)) {
mPreferredApn = null;
setPreferredApn(-1);
}
if (DBG)
log("createAllApnList: mPreferredApn=" + mPreferredApn);
}
if (DBG)
log("createAllApnList: X mAllApns=" + mAllApns);
}
Aggregations