private Uri mAPNUri;
private Cursor mCursor;
private boolean mNewApn;
-// private boolean mFirstTime=true;
+ // private boolean mFirstTime=true;
private boolean mIsPreloaded = false; // SPRD: for cmcc case, preloaded apns should not be editable or deleted.
private Resources mRes;
private TelephonyManager mTelephonyManager;
private static final int PRELOAD_INDEX = 22; // SPRD: for cmcc case, preloaded apns should not be editable or deleted.
private static final int EDITABLE_INDEX = 23;
- private static ApnEditor apnEditor=null;
+ private static ApnEditor apnEditor = null;
- public static ApnEditor getApnEditorInstance(Context context){
- if (apnEditor==null && context!=null)
- {
- apnEditor=new ApnEditor(context);
+ public static ApnEditor getApnEditorInstance(Context context) {
+ if (apnEditor == null && context != null) {
+ apnEditor = new ApnEditor(context);
}
return apnEditor;
}
mContext = context;
mRes = context.getResources();
-
mApnTypeArray = mRes.getStringArray(R.array.apn_type_array);
mFullApnTypeArray = mRes.getStringArray(R.array.full_apn_type_array);
mAuthTypeArray = mRes.getStringArray(R.array.apn_auth_values);
-
mProtocolArray = mRes.getStringArray(R.array.apn_protocol_values);
-
mBearerArray = mRes.getStringArray(R.array.bearer_entries);
-
-
mAPNUri = Telephony.Carriers.getContentUri(mPhoneId, null);
mUri = mAPNUri;
-
mTelephonyManager = (TelephonyManager) mContext.getSystemService(TELEPHONY_SERVICE);
}
- public void setSelectedApnKey(String key) {
- //s mSelectedKey = key;
- ContentResolver resolver = mContext.getContentResolver();
+ public void insertSelectedApnKey(String key) {
- ContentValues values = new ContentValues();
- /* SPRD: for multi-sim @{ */
- // values.put(APN_ID, mSelectedKey);
- // resolver.update(PREFERAPN_URI, values, null, null);
- values.put("apn_id", key);
- resolver.update(
- Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
- values, null, null);
- /* @} */
+ try {
+ //s mSelectedKey = key;
+ ContentResolver resolver = mContext.getContentResolver();
+
+ ContentValues values = new ContentValues();
+ // values.put(APN_ID, mSelectedKey);
+ // resolver.update(PREFERAPN_URI, values, null, null);
+ values.put("apn_id", key);
+
+ resolver.insert(Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN), values);
+// resolver.update(
+// Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
+// values, null, null);
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
+ }
}
- public String getSelectedApnKey() {
+ public void setSelectedApnKey(String key) {
+
+ try {
+ //s mSelectedKey = key;
+ ContentResolver resolver = mContext.getContentResolver();
+
+ ContentValues values = new ContentValues();
+ // values.put(APN_ID, mSelectedKey);
+ // resolver.update(PREFERAPN_URI, values, null, null);
+ values.put("apn_id", key);
+ resolver.update(
+ Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
+ values, null, null);
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
+ }
+ }
+
+ public String getSelectedApnKey() {
String key = null;
/* SPRD: for multi-sim @{ */
// null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
Cursor cursor = mContext.getContentResolver().query(
Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
- new String[] {
+ new String[]{
"_id"
},
null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
key = cursor.getString(0);
}
cursor.close();
- ICLogger.d(" get default apnkey "+key);
+ ICLogger.d(" get default apnkey " + key);
return key;
}
- 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);
+
+ public void setDefaultAPN(String apn, String mccmnc) {
+ String apnid = queryApnID(apn, mccmnc);
+ String currentapnid = getSelectedApnKey();
+ 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);
+ currentapnid = getSelectedApnKey();
+ ICLogger.d(apn + " " + mccmnc + " after set APN key " + apnid + " selected APN key " + currentapnid);
}
- public String queryApnID(String apn,String mccmnc) {
+
+ public String queryApnID(String apn, String mccmnc) {
String where;
where = "numeric=\"" + mccmnc + "\"";
where += " and name!='CMCC DM'";
- where += " and apn='"+apn+"'";
+ where += " and type 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()) {
-
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
- while (mCursor.moveToNext()){
- apnsetings+=";";
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
+ String apnsetings = "";
+ if (mCursor != null && mCursor.moveToFirst()) {
+
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
+ while (mCursor.moveToNext()) {
+ apnsetings += ";";
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
}
}
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
- ICLogger.d("get APN "+apnsetings);
+ ICLogger.d("get APN " + apnsetings);
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 type 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()) {
-
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
- while (mCursor.moveToNext()){
- apnsetings+=";";
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
+ String apnsetings = "";
+ if (mCursor != null && mCursor.moveToFirst()) {
+
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
+ while (mCursor.moveToNext()) {
+ apnsetings += ";";
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
}
}
if (mCursor != null) {
}
return apnsetings;
}
- public String queryApn(String mccmnc){
+
+ public String queryApn(String mccmnc) {
String where;
where = "numeric=\"" + mccmnc + "\"";
- where += " and name!='CMCC DM'";
+ where += " and type 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()) {
-
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
- while (mCursor.moveToNext()){
- apnsetings+=";";
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
+ String apnsetings = "";
+ if (mCursor != null && mCursor.moveToFirst()) {
+
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
+ while (mCursor.moveToNext()) {
+ apnsetings += ";";
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
}
}
if (mCursor != null) {
return apnsetings;
}
- public String getCurrentAPN(){
+ public String getCurrentAPN() {
String where;
String mccmnc;
if (TelephonyManager.isMultiSim()) {
- mccmnc = android.os.SystemProperties.get(TelephonyManager.getProperty(
+ mccmnc = SystemProperties.get(TelephonyManager.getProperty(
TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId), "");
// APNs are listed based on the MCC+MNC.
// Get the value from appropriate Telephony Property based on the
where = "numeric=\"" + mccmnc + "\"";
} else {
- mccmnc = android.os.SystemProperties.get(
+ mccmnc = 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);
+ 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()) {
-
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
- while (mCursor.moveToNext()){
- apnsetings+=";";
- fill_apnSettings(mCursor,mApnSetting);
- apnsetings+= mApnSetting.toShortString();
+ String apnsetings = "";
+ if (mCursor != null && mCursor.moveToFirst()) {
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
+ while (mCursor.moveToNext()) {
+ apnsetings += ";";
+ fill_apnSettings(mCursor, mApnSetting);
+ apnsetings += mApnSetting.toShortString();
}
}
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
- return apnsetings;
+ String currentApnid = getSelectedApnKey();
+ return apnsetings + "; Prefer ApnID=" + currentApnid;
}
- public boolean resetAPNtoDefault(){
+ public boolean resetAPNtoDefault() {
// resolver.delete(DEFAULTAPN_URI, null, null);
- int rows = mContext.getContentResolver().delete(Telephony.Carriers.getContentUri(mPhoneId,
- Telephony.Carriers.PATH_RESTORE),null,null);
- return rows>=0;
+ int rows = mContext.getContentResolver().delete(Telephony.Carriers.getContentUri(mPhoneId,
+ Telephony.Carriers.PATH_RESTORE), null, null);
+ return rows >= 0;
}
+
public boolean addVPN(String apnName, String apn, String mcc, String mnc, String user, String passwd) {
// if (mIsdelete) {
- ContentValues contentValues=new ContentValues();
- contentValues.put(Telephony.Carriers.NAME,apnName);
- contentValues.put(Telephony.Carriers.MCC,mcc);
- contentValues.put(Telephony.Carriers.MNC,mnc);
- contentValues.put(Telephony.Carriers.APN,apn);
- mName = apnName;
- mApn = apn;
- mMcc = mcc;
- mMnc = mnc;
- ICLogger.d( "Get mUri again! mAPNUri="+mAPNUri.toString());
- mUri = mContext.getContentResolver().insert(mAPNUri, contentValues);
-
- if (mUri!=null)
- {
- ICLogger.d( "Get mUri again! mUri="+mUri.toString());
- mCursor = mContext.getContentResolver().query(mUri, sProjection, null, null, null);
- mCursor.moveToFirst();
-
- fill_apnSettings(mCursor,mApnSetting);
- mApnSetting.setmNameStr(checkNull(apnName));
- mApnSetting.setmApnStr(checkNull(apn));
- mApnSetting.setmMccStr(checkNull(mcc));
- mApnSetting.setmMncStr(checkNull(mnc));
- mApnSetting.setmUserStr(checkNull(user));
- mApnSetting.setmPasswordStr(checkNull(passwd));
- mIsdelete = false;
-
- }else{
- ICLogger.d( "Get mUri again! mUri=null");
- }
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(Telephony.Carriers.NAME, apnName);
+ contentValues.put(Telephony.Carriers.MCC, mcc);
+ contentValues.put(Telephony.Carriers.MNC, mnc);
+ contentValues.put(Telephony.Carriers.APN, apn);
+ mName = apnName;
+ mApn = apn;
+ mMcc = mcc;
+ mMnc = mnc;
+ ICLogger.d("Get mUri again! mAPNUri=" + mAPNUri.toString());
+ mUri = mContext.getContentResolver().insert(mAPNUri, contentValues);
+
+ if (mUri != null) {
+ ICLogger.d("Get mUri again! mUri=" + mUri.toString());
+ mCursor = mContext.getContentResolver().query(mUri, sProjection, null, null, null);
+ if (mCursor != null && mCursor.moveToFirst()) {
+ fill_apnSettings(mCursor, mApnSetting);
}
+ mApnSetting.setmNameStr(checkNull(apnName));
+ mApnSetting.setmApnStr(checkNull(apn));
+ mApnSetting.setmMccStr(checkNull(mcc));
+ mApnSetting.setmMncStr(checkNull(mnc));
+ mApnSetting.setmUserStr(checkNull(user));
+ mApnSetting.setmPasswordStr(checkNull(passwd));
+ mIsdelete = false;
+
+ } else {
+ ICLogger.d("Get mUri again! mUri=null");
+ }
+ if (mCursor != null) {
+ mCursor.close();
+ mCursor = null;
+ }
// }
}
-
private boolean getApnEditable(Cursor cursor) {
String version = SystemProperties.get(CURRENT_CARRIER, "default");
if ("vodafone".equalsIgnoreCase(version) ||
}
}
- private void fill_apnSettings(Cursor cursor,ApnSetting apnSetting) {
+ private void fill_apnSettings(Cursor cursor, ApnSetting apnSetting) {
// SPRD: for bug 348288: while Cursor is null, return
// mFirstTime = false;
- mID = (cursor.getString(ID_INDEX));
- mName = (cursor.getString(NAME_INDEX));
- mApn = (cursor.getString(APN_INDEX));
- mProxy = (cursor.getString(PROXY_INDEX));
- mPort = (cursor.getString(PORT_INDEX));
- mUser = (cursor.getString(USER_INDEX));
- mServer = (cursor.getString(SERVER_INDEX));
- mPassword = (cursor.getString(PASSWORD_INDEX));
- mMmsProxy = (cursor.getString(MMSPROXY_INDEX));
- mMmsPort = (cursor.getString(MMSPORT_INDEX));
- mMmsc = (cursor.getString(MMSC_INDEX));
- mMcc = (cursor.getString(MCC_INDEX));
- mMnc = (cursor.getString(MNC_INDEX));
-
- String strApnType = cursor.getString(TYPE_INDEX);
- mApnEditable = getApnEditable(cursor);
- ICLogger.i( "fillUi : mApnEditable = " + mApnEditable
- + ", strApnType = " + strApnType);
-
- mApnType = strApnType;
-
- mApnTypeSummary = checkNull(strApnType);
- /* @} */
- // SPRD: for cmcc case, preloaded apns should not be editable or deleted.
- mIsPreloaded = ("1".equals(cursor.getString(PRELOAD_INDEX)));
-
- if (mNewApn) {
- /* SPRD: for multi-sim @{ */
- // String numeric =
- // SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
- String numeric;
- if (TelephonyManager.isMultiSim()) {
- // APNs are automatically added with MCC+MNC.
- // Get the value from appropriate Telephony Property based
- // on the mPhoneId.
- numeric = SystemProperties
- .get(TelephonyManager.getProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId));
-
- } else {
- numeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
- }
- /* @} */
- // MCC is first 3 chars and then in 2 - 3 chars of MNC
- if (numeric != null && numeric.length() > 4) {
- // Country code
- String mcc = numeric.substring(0, 3);
- // Network code
- String mnc = numeric.substring(3);
- // Auto populate MNC and MCC for new entries, based on what SIM reports
- mMcc = (mcc);
- mMnc = (mnc);
- mCurMnc = mnc;
- mCurMcc = mcc;
- }
- }
- int authVal = cursor.getInt(AUTH_TYPE_INDEX);
- if (authVal != -1) {
- mAuthType = String.valueOf(authVal);
+ mID = (cursor.getString(ID_INDEX));
+ mName = (cursor.getString(NAME_INDEX));
+ mApn = (cursor.getString(APN_INDEX));
+ mProxy = (cursor.getString(PROXY_INDEX));
+ mPort = (cursor.getString(PORT_INDEX));
+ mUser = (cursor.getString(USER_INDEX));
+ mServer = (cursor.getString(SERVER_INDEX));
+ mPassword = (cursor.getString(PASSWORD_INDEX));
+ mMmsProxy = (cursor.getString(MMSPROXY_INDEX));
+ mMmsPort = (cursor.getString(MMSPORT_INDEX));
+ mMmsc = (cursor.getString(MMSC_INDEX));
+ mMcc = (cursor.getString(MCC_INDEX));
+ mMnc = (cursor.getString(MNC_INDEX));
+
+ String strApnType = cursor.getString(TYPE_INDEX);
+ mApnEditable = getApnEditable(cursor);
+ ICLogger.i("fillUi : mApnEditable = " + mApnEditable
+ + ", strApnType = " + strApnType);
+
+ mApnType = strApnType;
+
+ mApnTypeSummary = checkNull(strApnType);
+ /* @} */
+ // SPRD: for cmcc case, preloaded apns should not be editable or deleted.
+ mIsPreloaded = ("1".equals(cursor.getString(PRELOAD_INDEX)));
+
+ if (mNewApn) {
+ /* SPRD: for multi-sim @{ */
+ // String numeric =
+ // SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
+ String numeric;
+ if (TelephonyManager.isMultiSim()) {
+ // APNs are automatically added with MCC+MNC.
+ // Get the value from appropriate Telephony Property based
+ // on the mPhoneId.
+ numeric = SystemProperties
+ .get(TelephonyManager.getProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId));
+
} else {
- mAuthType = (null);
+ numeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
}
-
- mProtocol = (cursor.getString(PROTOCOL_INDEX));
- mRoamingProtocol = (cursor.getString(ROAMING_PROTOCOL_INDEX));
- // mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
- mBearer = (cursor.getString(BEARER_INDEX));
- /* SPRD: Bug 645213 don't allow to modify mvno value @{ */
- String mvnoType = checkNull(cursor.getString(MVNO_TYPE_INDEX));
- String mvnoMatchData = checkNull(cursor.getString(MVNO_TYPE_INDEX));
- ICLogger.d( "fillUi mvnoType = " + mvnoType + ",mvnoMatchData = " + mvnoMatchData);
- // if (mvnoType.equals(sNotSet) && mvnoMatchData.equals(sNotSet)) {
- mVirtualOperator = true;
- //}
-
- mMvnoType = (cursor.getString(MVNO_TYPE_INDEX));
- mMvnoMatchData = (cursor.getString(MVNO_MATCH_DATA_INDEX));
-
- if (mNewApn && mMvnoTypeStr != null && mMvnoMatchDataStr != null) {
- mMvnoType = (mMvnoTypeStr);
- mMvnoMatchData = (mMvnoMatchDataStr);
+ /* @} */
+ // MCC is first 3 chars and then in 2 - 3 chars of MNC
+ if (numeric != null && numeric.length() > 4) {
+ // Country code
+ String mcc = numeric.substring(0, 3);
+ // Network code
+ String mnc = numeric.substring(3);
+ // Auto populate MNC and MCC for new entries, based on what SIM reports
+ mMcc = (mcc);
+ mMnc = (mnc);
+ mCurMnc = mnc;
+ mCurMcc = mcc;
}
+ }
+ int authVal = cursor.getInt(AUTH_TYPE_INDEX);
+ if (authVal != -1) {
+ mAuthType = String.valueOf(authVal);
+ } else {
+ mAuthType = (null);
+ }
+ mProtocol = (cursor.getString(PROTOCOL_INDEX));
+ mRoamingProtocol = (cursor.getString(ROAMING_PROTOCOL_INDEX));
+ // mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
+ mBearer = (cursor.getString(BEARER_INDEX));
+ /* SPRD: Bug 645213 don't allow to modify mvno value @{ */
+ String mvnoType = checkNull(cursor.getString(MVNO_TYPE_INDEX));
+ String mvnoMatchData = checkNull(cursor.getString(MVNO_TYPE_INDEX));
+ ICLogger.d("fillUi mvnoType = " + mvnoType + ",mvnoMatchData = " + mvnoMatchData);
+ // if (mvnoType.equals(sNotSet) && mvnoMatchData.equals(sNotSet)) {
+ mVirtualOperator = true;
+ //}
+
+ mMvnoType = (cursor.getString(MVNO_TYPE_INDEX));
+ mMvnoMatchData = (cursor.getString(MVNO_MATCH_DATA_INDEX));
+
+ if (mNewApn && mMvnoTypeStr != null && mMvnoMatchDataStr != null) {
+ mMvnoType = (mMvnoTypeStr);
+ mMvnoMatchData = (mMvnoMatchDataStr);
+ }
if (mNewApn && TextUtils.isEmpty(cursor.getString(TYPE_INDEX))) {
String mnc = checkNotSet(mMnc);
mApnType = mApnTypeArray[0];
if (getErrorMsg() != null && !force) {
- ICLogger.e(getErrorMsg()+" force="+force);
+ ICLogger.e(getErrorMsg() + " force=" + force);
return false;
}
- if (mCursor!=null && !mCursor.moveToFirst()) {
+ if (mCursor != null && !mCursor.moveToFirst()) {
ICLogger.w(
"Could not go to the first row in the Cursor when saving data.");
return false;
// SPRD: FEATURE_APN_CAN_BE_EMTPY
if (force && mNewApn && name.length() < 1 && apn.length() < 1 && !mAllowEmptyApn) {
mContext.getContentResolver().delete(mUri, null, null);
- ICLogger.d( "The mUri has delete!");
+ ICLogger.d("The mUri has delete!");
mIsdelete = true;
return false;
}
mNewApnSetting.setmBearerStr(checkNull(mBearer));
mNewApnSetting.setmMvnoTypeStr(checkNull(mMvnoType));
mNewApnSetting.setmMvnoMatchDataStr(checkNull(mMvnoMatchData));
- // boolean mIsApnChange = !mApnSetting.equals(mNewApnSetting);
+ // boolean mIsApnChange = !mApnSetting.equals(mNewApnSetting);
// if (mIsApnChange) {
- ICLogger.d( "mApnSetting: " + mApnSetting.toString());
- ICLogger.d( "mNewApnSetting: " + mNewApnSetting.toString());
- ContentValues values = new ContentValues();
+ ICLogger.d("mApnSetting: " + mApnSetting.toString());
+ ICLogger.d("mNewApnSetting: " + mNewApnSetting.toString());
+ ContentValues values = new ContentValues();
- // Add a dummy name "Untitled", if the user exits the screen without adding a name but
- // entered other information worth keeping.
- values.put(Telephony.Carriers.NAME,
- name.length() < 1 ? mContext.getResources().getString(R.string.untitled_apn) : name);
- values.put(Telephony.Carriers.APN, apn);
- values.put(Telephony.Carriers.PROXY, checkNotSet(mProxy));
- values.put(Telephony.Carriers.PORT, checkNotSet(mPort));
- values.put(Telephony.Carriers.MMSPROXY, checkNotSet(mMmsProxy));
- values.put(Telephony.Carriers.MMSPORT, checkNotSet(mMmsPort));
- values.put(Telephony.Carriers.USER, checkNotSet(mUser));
- values.put(Telephony.Carriers.SERVER, checkNotSet(mServer));
- values.put(Telephony.Carriers.PASSWORD, checkNotSet(mPassword));
- values.put(Telephony.Carriers.MMSC, checkNotSet(mMmsc));
-
- String authVal = mAuthType;
- if (authVal != null) {
- values.put(Telephony.Carriers.AUTH_TYPE, Integer.parseInt(authVal));
- }
+ // Add a dummy name "Untitled", if the user exits the screen without adding a name but
+ // entered other information worth keeping.
+ values.put(Telephony.Carriers.NAME,
+ name.length() < 1 ? mContext.getResources().getString(R.string.untitled_apn) : name);
+ values.put(Telephony.Carriers.APN, apn);
+ values.put(Telephony.Carriers.PROXY, checkNotSet(mProxy));
+ values.put(Telephony.Carriers.PORT, checkNotSet(mPort));
+ values.put(Telephony.Carriers.MMSPROXY, checkNotSet(mMmsProxy));
+ values.put(Telephony.Carriers.MMSPORT, checkNotSet(mMmsPort));
+ values.put(Telephony.Carriers.USER, checkNotSet(mUser));
+ values.put(Telephony.Carriers.SERVER, checkNotSet(mServer));
+ values.put(Telephony.Carriers.PASSWORD, checkNotSet(mPassword));
+ values.put(Telephony.Carriers.MMSC, checkNotSet(mMmsc));
+
+ String authVal = mAuthType;
+ if (authVal != null) {
+ values.put(Telephony.Carriers.AUTH_TYPE, Integer.parseInt(authVal));
+ }
- values.put(Telephony.Carriers.PROTOCOL, checkNotSet(mProtocol));
- values.put(Telephony.Carriers.ROAMING_PROTOCOL, checkNotSet(mRoamingProtocol));
+ values.put(Telephony.Carriers.PROTOCOL, checkNotSet(mProtocol));
+ values.put(Telephony.Carriers.ROAMING_PROTOCOL, checkNotSet(mRoamingProtocol));
- if (mApnType != null) {
- values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType));
- }
+ if (mApnType != null) {
+ values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType));
+ }
- values.put(Telephony.Carriers.MCC, mcc);
- values.put(Telephony.Carriers.MNC, mnc);
+ values.put(Telephony.Carriers.MCC, mcc);
+ values.put(Telephony.Carriers.MNC, mnc);
- values.put(Telephony.Carriers.NUMERIC, mcc + mnc);
+ values.put(Telephony.Carriers.NUMERIC, mcc + mnc);
- int mDDS = 0;
- try {
- mDDS = Settings.System.getInt(mContext.getContentResolver(), Settings.System.MULTI_SIM_DATA_CALL);
- } catch (Exception e) {
- ICLogger.e( "Exception Reading Dual Sim Data Subscription Value.", e);
- }
+ int mDDS = 0;
+ try {
+ mDDS = Settings.System.getInt(mContext.getContentResolver(), Settings.System.MULTI_SIM_DATA_CALL);
+ } catch (Exception e) {
+ ICLogger.e("Exception Reading Dual Sim Data Subscription Value.", e);
+ }
- if (mCurMnc != null && mCurMcc != null) {
- // SPRD: add by spreadst
- if (mCurMnc.equals(mnc) && mCurMcc.equals(mcc) && mPhoneId == mDDS) {
- values.put(Telephony.Carriers.CURRENT, 1);
- }
+ if (mCurMnc != null && mCurMcc != null) {
+ // SPRD: add by spreadst
+ if (mCurMnc.equals(mnc) && mCurMcc.equals(mcc) && mPhoneId == mDDS) {
+ values.put(Telephony.Carriers.CURRENT, 1);
}
+ }
- String bearerVal = mBearer;
- if (bearerVal != null) {
- values.put(Telephony.Carriers.BEARER, Integer.parseInt(bearerVal));
- }
+ String bearerVal = mBearer;
+ if (bearerVal != null) {
+ values.put(Telephony.Carriers.BEARER, Integer.parseInt(bearerVal));
+ }
- values.put(Telephony.Carriers.MVNO_TYPE, checkNotSet(mMvnoType));
- values.put(Telephony.Carriers.MVNO_MATCH_DATA, checkNotSet(mMvnoMatchData));
+ values.put(Telephony.Carriers.MVNO_TYPE, checkNotSet(mMvnoType));
+ values.put(Telephony.Carriers.MVNO_MATCH_DATA, checkNotSet(mMvnoMatchData));
- mContext.getContentResolver().update(mUri, values, null, null);
- mNewApn=false;
+ mContext.getContentResolver().update(mUri, values, null, null);
+ mNewApn = false;
// }
return true;
}