public void setDefaultAPN(String apn, String mccmnc){
String apnid=queryApnID(apn,mccmnc);
String currentapnid=getSelectedApnKey();
- ICLogger.d("current APN key "+apnid +" selected APN key " + currentapnid);
+ ICLogger.d(apn+" "+mccmnc+ " current APN key "+apnid +" selected APN key " + currentapnid);
setSelectedApnKey(apnid);
currentapnid=getSelectedApnKey();
- ICLogger.d("after set APN key "+apnid +" selected APN key " + currentapnid);
+ ICLogger.d(apn+" "+mccmnc+" after set APN key "+apnid +" selected APN key " + currentapnid);
}
- public void insertDefaultAPN(String apn, String mccmnc){
- String apnid=queryApnID(apn,mccmnc);
- String currentapnid=getSelectedApnKey();
- ICLogger.d("current APN key "+apnid +" selected APN key " + currentapnid);
- insertSelectedApnKey(apnid);
- currentapnid=getSelectedApnKey();
- ICLogger.d("after set APN key "+apnid +" selected APN key " + currentapnid);
- }
public String queryApnID(String apn,String mccmnc) {
String where;
where += " and name!='CMCC DM'";
where += " and apn='"+apn+"'";
- Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
+ Log.d(TAG,"where = " + where );
mCursor = mContext.getContentResolver().query(mAPNUri, sProjection, where, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
String apnsetings="";
- if (mCursor.moveToFirst()) {
+ if (mCursor!=null && mCursor.moveToFirst()) {
fill_apnSettings(mCursor,mApnSetting);
apnsetings+= mApnSetting.toShortString();
return mApnSetting.getID();
}
- public String queryApn(String apn,String mccmnc){
+ public String queryApn(String apn,String mccmnc){
String where;
where = "numeric=\"" + mccmnc + "\"";
where += " and name!='CMCC DM'";
- where += " and apn='"+apn+"'";
+ where += " and like '%default%' and apn='"+apn+"'";
- Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
+ Log.d(TAG,"where = " + where );
mCursor = mContext.getContentResolver().query(mAPNUri, sProjection, where, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
String apnsetings="";
- if (mCursor.moveToFirst()) {
+ if (mCursor!=null && mCursor.moveToFirst()) {
fill_apnSettings(mCursor,mApnSetting);
apnsetings+= mApnSetting.toShortString();
public String queryApn(String mccmnc){
String where;
where = "numeric=\"" + mccmnc + "\"";
- where += " and name!='CMCC DM'";
+ where += " and like '%default%' and name!='CMCC DM'";
- Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
+ Log.d(TAG,"where = " + where );
mCursor = mContext.getContentResolver().query(mAPNUri, sProjection, where, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
String apnsetings="";
- if (mCursor.moveToFirst()) {
+ if (mCursor!=null && mCursor.moveToFirst()) {
fill_apnSettings(mCursor,mApnSetting);
apnsetings+= mApnSetting.toShortString();
mccmnc = android.os.SystemProperties.get(
TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");
where = "numeric=\"" + mccmnc + "\"";
-
}
- where += " and name!='CMCC DM'";
+ where += " and type like '%default%' and name!='CMCC DM'";
- Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc+" , type like 'default'");
+ Log.d(TAG,"where = " + where );
// mCursor = mContext.getContentResolver().query(mAPNUri, new String[] {
// "_id", "name", "apn", "type", "mvno_type", "mvno_match_data" }, where, null,
// Telephony.Carriers.DEFAULT_SORT_ORDER);
mCursor = mContext.getContentResolver().query(mAPNUri, sProjection, where, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
// mCursor = mContext.getContentResolver().query(mAPNUri, sProjection, null, null, null);
String apnsetings="";
- if (mCursor.moveToFirst()) {
-
+ if (mCursor!=null && mCursor.moveToFirst()) {
fill_apnSettings(mCursor,mApnSetting);
apnsetings+= mApnSetting.toShortString();
while (mCursor.moveToNext()){
mCursor = null;
}
String currentApnid=getSelectedApnKey();
- return apnsetings + ";currentApnID=" +currentApnid ;
+ return apnsetings + "; Prefer ApnID=" +currentApnid ;
}
public boolean resetAPNtoDefault(){
{
ICLogger.d( "Get mUri again! mUri="+mUri.toString());
mCursor = mContext.getContentResolver().query(mUri, sProjection, null, null, null);
- mCursor.moveToFirst();
-
- fill_apnSettings(mCursor,mApnSetting);
+ if (mCursor!=null && mCursor.moveToFirst()) {
+ fill_apnSettings(mCursor, mApnSetting);
+ }
mApnSetting.setmNameStr(checkNull(apnName));
mApnSetting.setmApnStr(checkNull(apn));
mApnSetting.setmMccStr(checkNull(mcc));