-package com.enqualcomm.support.utils;\r
-\r
-import android.content.ContentResolver;\r
-import android.content.ContentValues;\r
-import android.content.Context;\r
-import android.database.Cursor;\r
-import android.net.Uri;\r
-import android.telephony.TelephonyManager;\r
-import android.widget.Toast;\r
-\r
-public class APNUtil {\r
-\r
- /**\r
- * 当前连接APN\r
- * */\r
- private static Uri APN_URI_NOW =Uri.parse("content://telephony/carriers/current");\r
- /**\r
- * 所有APN\r
- * */\r
- private static Uri APN_URI = Uri.parse("content://telephony/carriers"); //apn列表uri\r
-\r
- private static Uri CURRENT_APN_URI = Uri.parse("content://telephony/carriers/preferapn"); //主apn的uri\r
-\r
- final String MY_APN = "my apn";\r
-\r
- public static String getCurrentAPN(Context context){\r
- ContentResolver resolver = context.getContentResolver();\r
- Cursor c = resolver.query(APN_URI_NOW, null, null, null, null); //从apn列表中查找apn名称为myapn的apn信息\r
- String APNSTR="";\r
- String Columns="";\r
- for (String column :c.getColumnNames())\r
- {\r
- Columns+=column+",";\r
- }\r
-\r
-// APN不存在 columns=_id,name,numeric,mcc,mnc,apn,user,server,password,proxy,port,mmsproxy,mmsport,mmsc,authtype,type,current,protocol,preload,roaming_protocol,editable,traffic_class,carrier_enabled,bearer,mvno_type,mvno_match_data,\r
- if (c != null && c.moveToNext()) {\r
- int id = c.getShort(c.getColumnIndex("_id")); //获取该apn的id信息\r
- String mcc=c.getString(c.getColumnIndex("mcc"));\r
- String mnc=c.getString(c.getColumnIndex("mnc"));\r
- String name=c.getString(c.getColumnIndex("name"));\r
- String apnname=c.getString(c.getColumnIndex("apn"));\r
- String user=c.getString(c.getColumnIndex("user"));\r
- String pwd=c.getString(c.getColumnIndex("password"));\r
- String _type=c.getString(c.getColumnIndex("type"));\r
- APNSTR="[Current APN name = "+apnname+\r
- ",_id="+id+\r
- ",mcc="+mcc+\r
- ",mnc="+mnc+\r
- ",name="+name+\r
- ",user="+user+\r
- ",password="+pwd+\r
- ",type="+_type+\r
- "]";\r
- ICLogger.i(APNSTR);\r
- } else {\r
- ICLogger.i("APN不存在");\r
- return "APN 不存在";\r
- }\r
- return APNSTR;\r
- }\r
- public static boolean addVPN(String apnName, String apn, String mcc,String mnc , String user,String passwd,Context context) {\r
-\r
- if (checkAPN(mcc,mnc,apn,context)==true){\r
- ICLogger.i("VPN 已经存在,不需要添加!");\r
- return false;\r
- }\r
- //添加新的APN到系统\r
- int id= AddNewApn(apnName,apn,mcc,mnc,user,passwd,context);\r
-\r
- //添加后设置为当前指定APN\r
- SetAPN(id,context);\r
-\r
-\r
- boolean isAddSuccess = checkAPN(mcc,mnc,apn,context);\r
- if (isAddSuccess) {\r
- ICLogger.i("APN 添加成功!");\r
- return true;\r
-// Toast.makeText(NewAPNActivity.this, "新增APN成功", Toast.LENGTH_SHORT).show();\r
- } else {\r
- ICLogger.i("APN 添加失败!");\r
- return false;\r
-// Toast.makeText(NewAPNActivity.this, "新增APN失败", Toast.LENGTH_SHORT).show();\r
- }\r
- }\r
- // 设置接入点\r
- public static void SetAPN(int id,Context context) {\r
- ContentResolver resolver = context.getContentResolver();\r
- ContentValues values = new ContentValues();\r
- values.put("apn_id", id);\r
- resolver.update(CURRENT_APN_URI, values, null, null);\r
- }\r
- public static boolean checkAPN(String mcc,String mnc,String apn,Context context) {\r
- // 检查系统已经写入的APN\r
- Cursor cr = context.getContentResolver().query(APN_URI, null, null, null, null);\r
- while (cr != null && cr.moveToNext()) {\r
- if(cr.getString(cr.getColumnIndex("apn")).equals(apn)\r
- && cr.getString(cr.getColumnIndex("mcc")).equals(mcc)\r
- && cr.getString(cr.getColumnIndex("mnc")).equals(mnc)){\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- public static String checkAPN(String mcc,String mnc,Context context) {\r
- // 检查系统已经写入的APN\r
- Cursor cr = context.getContentResolver().query(APN_URI, null, null, null, null);\r
-\r
-// String Columns="";\r
-// for (String column :cr.getColumnNames())\r
-// {\r
-// Columns+=column+",";\r
-// }\r
-\r
-// APN name = mms,mcc=655,mnc=07,column names :_id,name,numeric,mcc,mnc,apn,user,server,password,proxy,port,mmsproxy,mmsport,mmsc,authtype,type,current,protocol,preload,roaming_protocol,editable,traffic_class,carrier_enabled,bearer,mvno_type,mvno_match_data,\r
-\r
- String found="";\r
-\r
- while (cr != null && cr.moveToNext()) {\r
-\r
-// ",column names :"+Columns);\r
- if(cr.getString(cr.getColumnIndex("mcc")).equals(mcc)\r
- && cr.getString(cr.getColumnIndex("mnc")).equals(mnc)){\r
-\r
- int id = cr.getShort(cr.getColumnIndex("_id")); //获取该apn的id信息\r
- String name=cr.getString(cr.getColumnIndex("name"));\r
- String apnname=cr.getString(cr.getColumnIndex("apn"));\r
- String user=cr.getString(cr.getColumnIndex("user"));\r
- String pwd=cr.getString(cr.getColumnIndex("password"));\r
- String _type=cr.getString(cr.getColumnIndex("type"));\r
- String msg="[APN name = "+apnname+\r
- ",_id="+id+\r
- ",mcc="+mcc+\r
- ",mnc="+mnc+\r
- ",name="+name+\r
- ",user="+user+\r
- ",password="+pwd+\r
- ",type="+_type+\r
- "],";\r
- found +=msg;\r
- }\r
- }\r
- found+=getCurrentAPN(context);\r
- ICLogger.i(found);\r
-\r
- return found;\r
- }\r
-\r
-\r
-\r
-\r
- public static int AddNewApn(String apnName,String apn, String mcc,String mnc , String user,String passwd, Context context) {\r
- ICLogger.i("添加一个新的apn ==> "+apnName+", mcc="+mcc+", mnc="+mnc+", user="+user+", password="+passwd);\r
- int apnId = -1;\r
- ContentResolver resolver = context.getContentResolver();\r
- ContentValues values = new ContentValues();\r
- values.put("name", apnName); //apn中文描述\r
- values.put("apn", apn); //apn名称\r
- values.put("type", "default");\r
- values.put("numeric", mcc+mnc);\r
- values.put("mcc", mcc);\r
- values.put("mnc", mnc);\r
- values.put("proxy", "");\r
- values.put("port", "");\r
- values.put("mmsproxy", "");\r
- values.put("mmsport", "");\r
- values.put("user", user);\r
- values.put("server", "");\r
- values.put("password", passwd);\r
- values.put("mmsc", "");\r
- Cursor c = null;\r
-// 获取新添加的apn的ID\r
- try {\r
- Uri newRow = resolver.insert(APN_URI, values);\r
- if (newRow != null) {\r
- c = resolver.query(newRow, null, null, null, null);\r
- int idindex = c.getColumnIndex("_id");\r
- c.moveToFirst();\r
- apnId = idindex;\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- if (c != null)\r
- c.close();\r
- return apnId;\r
- }\r
-\r
- private boolean hasMyApn(Context context) {\r
- ContentResolver resolver = context.getContentResolver();\r
- Cursor cursor = resolver.query(APN_URI, new String[]{"_id", "name"}, null, null, null);\r
- for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()){\r
- int nameIndex = cursor.getColumnIndex("name");\r
- int idIndex = cursor.getColumnIndex("_id");\r
- String name = cursor.getString(nameIndex);\r
- ICLogger.i( name);\r
- if (MY_APN.equals(name)) {\r
- //myId = cursor.getShort(idIndex);\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
-}\r
+package com.enqualcomm.support.utils;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.telephony.TelephonyManager;
+import android.widget.Toast;
+
+import com.enqualcomm.support.bean.ApnSetting;
+
+public class APNUtil {
+
+ public static String getCurrentAPN(Context context){
+ String APNSTR="";
+ APNSTR=ApnEditor.getApnEditorInstance(context).getCurrentAPN();
+ ICLogger.i("当前APN "+APNSTR);
+ return APNSTR;
+ }
+ public static boolean addVPN(String apnName, String apn, String mcc,String mnc , String user,String passwd,Context context) {
+
+ if (checkAPN(mcc,mnc,apn,context)==true){
+ ICLogger.i("VPN 已经存在,不需要添加!");
+ return false;
+ }
+ //添加新的APN到系统
+ boolean isAddSuccess=AddNewApn(apnName,apn,mcc,mnc,user,passwd,context);
+
+ if (isAddSuccess) {
+ ICLogger.i("APN 添加成功!");
+ return true;
+// Toast.makeText(NewAPNActivity.this, "新增APN成功", Toast.LENGTH_SHORT).show();
+ } else {
+ ICLogger.i("APN 添加失败!");
+ return false;
+// Toast.makeText(NewAPNActivity.this, "新增APN失败", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ public static boolean checkAPN(String mcc,String mnc,String apn,Context context) {
+ // 检查系统已经写入的APN
+ String found="";
+ found+=ApnEditor.getApnEditorInstance(context).queryApn(apn,mcc+mnc);
+ ICLogger.i(found);
+
+ return !found.isEmpty();
+ }
+
+ public static String checkAPN(String mcc,String mnc,Context context) {
+ // 检查系统已经写入的APN
+ String found="";
+ found+=ApnEditor.getApnEditorInstance(context).queryApn(mcc+mnc);
+ ICLogger.i(found);
+ return found;
+ }
+
+
+
+
+ public static boolean AddNewApn(String apnName,String apn, String mcc,String mnc , String user,String passwd, Context context) {
+ ICLogger.i("添加一个新的apn ==> "+apnName+", mcc="+mcc+", mnc="+mnc+", user="+user+", password="+passwd);
+ return ApnEditor.getApnEditorInstance(context).addVPN(apnName,apn,mcc,mnc,user,passwd);
+ }
+
+
+ public static boolean resetAPN(Context context){
+ return ApnEditor.getApnEditorInstance(context).resetAPNtoDefault();
+ }
+
+}
import static android.content.Context.TELEPHONY_SERVICE;
-public class ApnEditor {
+public class ApnEditor {
private final static String TAG = ApnEditor.class.getSimpleName();
- private Context mContext=null;
+ private Context mContext = null;
private final static String SAVED_POS = "pos";
private final static String KEY_AUTH_TYPE = "auth_type";
private final static String KEY_PROTOCOL = "apn_protocol";
private final static String KEY_APN_TYPE = "apn_type";
public final static String APN_EDITABLE = "editable";
- private static final int MENU_DELETE = Menu.FIRST;
- private static final int MENU_SAVE = Menu.FIRST + 1;
- private static final int MENU_CANCEL = Menu.FIRST + 2;
- private static final int ERROR_DIALOG_ID = 0;
private static final String APN_TYPE = "APN_TYPE";
private static final String IS_RELOADED = "IS_PRELOADED";
- /* SPRD: add for bug717733 @{ */
+
private static final String CUCC = "cucc";
private final static String XCAP = ",xcap";
private final static String CURRENT_CARRIER = "ro.operator";
public final static String SPECIAL_CTCC_NUMERIC = "20404";
public final static String CTCC_ICCID = "898603,898611";
- /* @} */
+
private static String sNotSet;
- private EditTextPreference mName;
- private EditTextPreference mApn;
- private EditTextPreference mProxy;
- private EditTextPreference mPort;
- private EditTextPreference mUser;
- private EditTextPreference mServer;
- private EditTextPreference mPassword;
- private EditTextPreference mMmsc;
- private EditTextPreference mMcc;
- private EditTextPreference mMnc;
- private EditTextPreference mMmsProxy;
- private EditTextPreference mMmsPort;
- private ListPreference mAuthType;
- private Preference mApnType;
- private ListPreference mProtocol;
- private ListPreference mRoamingProtocol;
- private CheckBoxPreference mCarrierEnabled;
- private ListPreference mBearer;
- private ListPreference mMvnoType;
- private EditTextPreference mMvnoMatchData;
+ private String mName;
+ private String mApn;
+ private String mProxy;
+ private String mPort;
+ private String mUser;
+ private String mServer;
+ private String mPassword;
+ private String mMmsc;
+ private String mMcc;
+ private String mMnc;
+ private String mMmsProxy;
+ private String mMmsPort;
+
+ private String[] mApnTypeArray;
+ private String[] mFullApnTypeArray;
+ private String mApnType;
+ private String mAuthType;
+ private String[] mAuthTypeArray;
+ private String mProtocol;
+ private String[] mProtocolArray;
+
+ private String mRoamingProtocol;
+
+ private String mBearer;
+ private String[] mBearerArray;
+ private String mMvnoType;
+
+
+ private String mMvnoMatchData;
+ private String mMvnoTypeStr;
+ private String mMvnoMatchDataStr;
+
private String mCurMnc;
private String mCurMcc;
private int mPhoneId = 0; // SPRD: add by spreadst
private Uri mUri;
+ private Uri mAPNUri;
private Cursor mCursor;
private boolean mNewApn;
- private boolean mFirstTime;
+// 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 String mRecordApnType;
- // SPRD: modify for bug271734
+
private String mApnTypeSummary;
private boolean mIsdelete = false;
//compare apn setting values whether change
private ApnSetting mApnSetting = new ApnSetting();
private ApnSetting mNewApnSetting = new ApnSetting();
+
// SPRD: FEATURE_APN_CAN_BE_EMTPY
private boolean mAllowEmptyApn = SystemProperties.get(CURRENT_CARRIER, "default")
.equals("orange");
// SPRD: FEATURE_APN_NOT_EDITABLE
- /* SPRD: add for bug675438 @{ */
- private boolean mApnEditable = true;
- /* @} */
- /* SPRD: Bug 628333 modify for support virtual operator @{ */
- private String mMvnoTypeStr;
- private String mMvnoMatchDataStr;
- /* @} */
+ public boolean mApnEditable = true;
+
// SPRD: Bug 645213 don't allow to modify mvno value
private boolean mVirtualOperator = false;
- /**
- * Standard projection for the interesting columns of a normal note.
- */
- private static final String[] sProjection = new String[] {
+
+ private static final String[] sProjection = new String[]{
Telephony.Carriers._ID, // 0
Telephony.Carriers.NAME, // 1
Telephony.Carriers.APN, // 2
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;
- /* SPRD: add for bug685803 @{ */
-// private FeatureBarHelper mFeatureBarHelper;
-// private TextView mLeftSkView;
-// private TextView mCenterSkView;
-// private TextView mRightSkView;
- /* @} */
+ private static ApnEditor apnEditor=null;
+ public static ApnEditor getApnEditorInstance(Context context){
+ if (apnEditor==null && context!=null)
+ {
+ apnEditor=new ApnEditor(context);
+ }
+ return apnEditor;
+ }
public ApnEditor(Context context) {
- mContext=context;
-// addPreferencesFromResource(R.xml.apn_editor);
-
- /* SPRD: add for bug685803 @{ */
-// mFeatureBarHelper = new FeatureBarHelper(this);
-// mLeftSkView = (TextView) mFeatureBarHelper.getOptionsKeyView();
-// mCenterSkView = (TextView) mFeatureBarHelper.getCenterKeyView();
-// mCenterSkView.setText(R.string.default_feature_bar_center);
-// mRightSkView = (TextView) mFeatureBarHelper.getBackKeyView();
- /* @} */
-
-// sNotSet = getResources().getString(R.string.apn_not_set);
-// mName = (EditTextPreference) findPreference("apn_name");
-// mApn = (EditTextPreference) findPreference("apn_apn");
-// mProxy = (EditTextPreference) findPreference("apn_http_proxy");
-// mPort = (EditTextPreference) findPreference("apn_http_port");
-// mUser = (EditTextPreference) findPreference("apn_user");
-// mServer = (EditTextPreference) findPreference("apn_server");
-// mPassword = (EditTextPreference) findPreference("apn_password");
-// mMmsProxy = (EditTextPreference) findPreference("apn_mms_proxy");
-// mMmsPort = (EditTextPreference) findPreference("apn_mms_port");
-// mMmsc = (EditTextPreference) findPreference("apn_mmsc");
-// mMcc = (EditTextPreference) findPreference("apn_mcc");
-// mMnc = (EditTextPreference) findPreference("apn_mnc");
-// mApnType = (Preference) findPreference(KEY_APN_TYPE);
-//
-// mAuthType = (ListPreference) findPreference(KEY_AUTH_TYPE);
-//
-//
-// mProtocol = (ListPreference) findPreference(KEY_PROTOCOL);
-//
-//
-// mRoamingProtocol = (ListPreference) findPreference(KEY_ROAMING_PROTOCOL);
-//
-// mCarrierEnabled = (CheckBoxPreference) findPreference(KEY_CARRIER_ENABLED);
-//
-//
-// mBearer = (ListPreference) findPreference(KEY_BEARER);
-// mBearer.setOnPreferenceChangeListener(this);
-//
-// mMvnoType = (ListPreference) findPreference(KEY_MVNO_TYPE);
-// mMvnoType.setOnPreferenceChangeListener(this);
-// mMvnoMatchData = (EditTextPreference) findPreference("mvno_match_data");
-
+ mContext = context;
mRes = context.getResources();
-// final Intent intent = getIntent();
-// final String action = intent.getAction();
-
- /* SPRD: for multi-sim @{ */
-// if (TelephonyManager.isMultiSim()) {
-// // Read the mPhoneId received from Phone settings.
-// mPhoneId = intent.getIntExtra(WirelessSettings.SUB_ID, 0);
-// this.setTitle(mRes.getString(R.string.apn_edit_ex, mPhoneId + 1));
-// Log.d(TAG, "ApnEditor onCreate received mPhoneId: " + mPhoneId);
-// } else {
-// this.setTitle(R.string.apn_edit);
-// }
- /* @} */
-
-// mFirstTime = icicle == null;
-// /* SPRD: modify for bug271734 @{ */
-// if(icicle != null){
-// mApnTypeSummary = icicle.getString(APN_TYPE,"");
-// // SPRD: modify for bug271736
-// mIsPreloaded = icicle.getBoolean(IS_RELOADED,false);
-// }
-// /* @} */
-// if (action.equals(Intent.ACTION_EDIT)) {
-// mUri = intent.getData();
-// } else if (action.equals(Intent.ACTION_INSERT)) {
-// if (mFirstTime || icicle.getInt(SAVED_POS) == 0) {
-// mUri = context.getContentResolver().insert(intent.getData(), new ContentValues());
-// } else {
-// /* SPRD: for multi-sim @{ */
-// // mUri =
-// // ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI,
-// // icicle.getInt(SAVED_POS));
-// mUri = ContentUris.withAppendedId(
-// Telephony.Carriers.getContentUri(mPhoneId,null), icicle
-// .getInt(SAVED_POS));
-// /* @} */
-// }
-// mNewApn = true;
-// /* SPRD: Bug 628333 modify for support virtual operator @{ */
-// mMvnoTypeStr = intent.getStringExtra(ApnSettings.MVNO_TYPE);
-// mMvnoMatchDataStr = intent.getStringExtra(ApnSettings.MVNO_MATCH_DATA);
-// /* @} */
-//
-// // If we were unable to create a new note, then just finish
-// // this activity. A RESULT_CANCELED will be sent back to the
-// // original activity if they requested a result.
-// if (mUri == null) {
-// Log.w(TAG, "Failed to insert new telephony provider into "
-// + getIntent().getData());
-//// finish();
-// return;
-// }
-//
-// // The new entry was created, so assume all will end well and
-// // set the result to be returned.
-//// setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));
-//
-// } else {
-//// finish();
-// return;
-// }
+ 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);
- /* SPRD: for bug 297172: Use common query management Cursor @{ */
- // mCursor = managedQuery(mUri, sProjection, null, null);
- mCursor = mContext.getContentResolver().query(mUri, sProjection, null, null,null);
- /* @} */
- mCursor.moveToFirst();
+ mProtocolArray = mRes.getStringArray(R.array.apn_protocol_values);
- mTelephonyManager = (TelephonyManager) mContext.getSystemService(TELEPHONY_SERVICE);
+ mBearerArray = mRes.getStringArray(R.array.bearer_entries);
- fillUi();
- }
+ mAPNUri = Telephony.Carriers.getContentUri(mPhoneId, null);
+ mUri = mAPNUri;
- public void onResume() {
+ mTelephonyManager = (TelephonyManager) mContext.getSystemService(TELEPHONY_SERVICE);
+ }
- /* SPRD: for bug 297172: After hanging up the phone, can not save the new apn normally @{ */
- if(mIsdelete) {
- if(mCursor != null) {
- mCursor.close();
- mCursor = null;
+ public String queryApn(String apn,String mccmnc){
+ String where;
+ where = "numeric=\"" + mccmnc + "\"";
+ where += " and name!='CMCC DM'";
+ where += " and apn='"+apn+"'";
+
+ Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
+ 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();
+ }
+ }
+ if (mCursor != null) {
+ mCursor.close();
+ mCursor = null;
+ }
+ return apnsetings;
+ }
+ public String queryApn(String mccmnc){
+ String where;
+ where = "numeric=\"" + mccmnc + "\"";
+ where += " and name!='CMCC DM'";
+
+ Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
+ 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();
}
- // final Intent intent = getIntent();
- Log.d(TAG, "Get mUri again!");
-// mUri = mContext.getContentResolver().insert(intent.getData(), new ContentValues());
- mCursor = mContext.getContentResolver().query(mUri, sProjection, null, null,null);
- mCursor.moveToFirst();
- mIsdelete = false;
}
- /* @} */
+ if (mCursor != null) {
+ mCursor.close();
+ mCursor = null;
+ }
+ return apnsetings;
+ }
+ public String getCurrentAPN(){
- /* SPRD: for cucc case @{ */
-// PreferenceScreen prefSet = getPreferenceScreen();
-// if (mIsPreloaded && "cucc".equals(SystemProperties.get("ro.operator", ""))) {
-// prefSet.setEnabled(false);
-// } else {
-// prefSet.setEnabled(true);
-// }
- /* @} */
+ String where;
+ String mccmnc;
+ if (TelephonyManager.isMultiSim()) {
+ mccmnc = android.os.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
+ // subscription.
+ where = "numeric=\"" + mccmnc + "\"";
- /* SPRD: FEATURE_APN_NOT_EDITABLE @{ */
-// if (!mNewApn && !mApnEditable) {
-// prefSet.setEnabled(false);
-// }
- /* @} */
+ } else {
+ mccmnc = android.os.SystemProperties.get(
+ TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");
+ where = "numeric=\"" + mccmnc + "\"";
- /* SPRD: Bug 645213 don't allow to modify mvno value @{ */
-// if (!mNewApn && mVirtualOperator) {
-// mMvnoType.setEnabled(false);
-// mMvnoMatchData.setEnabled(false);
-// }
- /* @} */
+ }
+ where += " and name!='CMCC DM'";
+
+ Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
+// 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();
+ }
+ }
+ if (mCursor != null) {
+ mCursor.close();
+ mCursor = null;
+ }
+ return apnsetings;
+ }
-// getPreferenceScreen().getSharedPreferences()
-// .registerOnSharedPreferenceChangeListener(this);
+ 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;
}
+ 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;
+ }
+// }
- public void onPause() {
-// getPreferenceScreen().getSharedPreferences()
-// .unregisterOnSharedPreferenceChangeListener(this);
-// super.onPause();
+ return validateAndSave(false);
+
}
- /* SPRD: for bug 297172: Use common query management Cursor @{ */
- protected void onDestroy() {
- // TODO Auto-generated method stub
-// super.onDestroy();
- if(mCursor != null) {
- mCursor.close();
- mCursor = null;
- }
- }
- /* @} */
+
private boolean getApnEditable(Cursor cursor) {
String version = SystemProperties.get(CURRENT_CARRIER, "default");
}
}
- private void fillUi() {
+ private void fill_apnSettings(Cursor cursor,ApnSetting apnSetting) {
+
// SPRD: for bug 348288: while Cursor is null, return
- if (mFirstTime && mCursor.moveToFirst()) {
- mFirstTime = false;
- // Fill in all the values from the db in both text editor and summary
- mName.setText(mCursor.getString(NAME_INDEX));
- mApn.setText(mCursor.getString(APN_INDEX));
- mProxy.setText(mCursor.getString(PROXY_INDEX));
- mPort.setText(mCursor.getString(PORT_INDEX));
- mUser.setText(mCursor.getString(USER_INDEX));
- mServer.setText(mCursor.getString(SERVER_INDEX));
- mPassword.setText(mCursor.getString(PASSWORD_INDEX));
- mMmsProxy.setText(mCursor.getString(MMSPROXY_INDEX));
- mMmsPort.setText(mCursor.getString(MMSPORT_INDEX));
- mMmsc.setText(mCursor.getString(MMSC_INDEX));
- mMcc.setText(mCursor.getString(MCC_INDEX));
- mMnc.setText(mCursor.getString(MNC_INDEX));
- // SPRD: modify for bug271734
- /* SPRD: add for bug717733 @{ */
- String strApnType = mCursor.getString(TYPE_INDEX);
- mApnEditable = getApnEditable(mCursor);
- Log.i(TAG, "fillUi : mApnEditable = " + mApnEditable
+
+// mFirstTime = false;
+
+ 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(mCursor.getString(PRELOAD_INDEX)));
+ mIsPreloaded = ("1".equals(cursor.getString(PRELOAD_INDEX)));
if (mNewApn) {
/* SPRD: for multi-sim @{ */
// Get the value from appropriate Telephony Property based
// on the mPhoneId.
numeric = SystemProperties
- .get(TelephonyManager.getProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId));
+ .get(TelephonyManager.getProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId));
} else {
numeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
// Network code
String mnc = numeric.substring(3);
// Auto populate MNC and MCC for new entries, based on what SIM reports
- mMcc.setText(mcc);
- mMnc.setText(mnc);
+ mMcc = (mcc);
+ mMnc = (mnc);
mCurMnc = mnc;
mCurMcc = mcc;
}
}
- int authVal = mCursor.getInt(AUTH_TYPE_INDEX);
+ int authVal = cursor.getInt(AUTH_TYPE_INDEX);
if (authVal != -1) {
- mAuthType.setValueIndex(authVal);
+ mAuthType = String.valueOf(authVal);
} else {
- mAuthType.setValue(null);
+ mAuthType = (null);
}
- mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX));
- mRoamingProtocol.setValue(mCursor.getString(ROAMING_PROTOCOL_INDEX));
- mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
- mBearer.setValue(mCursor.getString(BEARER_INDEX));
+ 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(mCursor.getString(MVNO_TYPE_INDEX));
- String mvnoMatchData = checkNull(mCursor.getString(MVNO_TYPE_INDEX));
- Log.d(TAG, "fillUi mvnoType = " + mvnoType + ",mvnoMatchData = " + mvnoMatchData);
- if (mvnoType.equals(sNotSet) && mvnoMatchData.equals(sNotSet)) {
+ 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.setValue(mCursor.getString(MVNO_TYPE_INDEX));
- mMvnoMatchData.setEnabled(false);
- mMvnoMatchData.setText(mCursor.getString(MVNO_MATCH_DATA_INDEX));
- /* SPRD: Bug 628333 modify for support virtual operator @{ */
- if (mNewApn && mMvnoTypeStr != null && mMvnoMatchDataStr != null) {
- mMvnoType.setValue(mMvnoTypeStr);
- mMvnoMatchData.setText(mMvnoMatchDataStr);
- }
- /* @} */
- }
- // SPRD: modify for bug271734
- /* SPRD: add for bug713689 @{ */
- if (mNewApn && TextUtils.isEmpty(mCursor.getString(TYPE_INDEX))) {
- String[] array = mContext.getResources().getStringArray(R.array.apn_type_array);
- mApnTypeSummary = array[0];
- }
- /* @} */
- mApnType.setSummary(mApnTypeSummary);
- mName.setSummary(checkNull(mName.getText()));
- mApn.setSummary(checkNull(mApn.getText()));
- mProxy.setSummary(checkNull(mProxy.getText()));
- mPort.setSummary(checkNull(mPort.getText()));
- mUser.setSummary(checkNull(mUser.getText()));
- mServer.setSummary(checkNull(mServer.getText()));
- mPassword.setSummary(starify(mPassword.getText()));
- mMmsProxy.setSummary(checkNull(mMmsProxy.getText()));
- mMmsPort.setSummary(checkNull(mMmsPort.getText()));
- mMmsc.setSummary(checkNull(mMmsc.getText()));
- mMcc.setSummary(checkNull(mMcc.getText()));
- mMnc.setSummary(checkNull(mMnc.getText()));
-
- String authVal = mAuthType.getValue();
- if (authVal != null) {
- int authValIndex = Integer.parseInt(authVal);
- mAuthType.setValueIndex(authValIndex);
-
- String[]values = mRes.getStringArray(R.array.apn_auth_entries);
- mAuthType.setSummary(values[authValIndex]);
- } else {
- mAuthType.setSummary(sNotSet);
- }
+ //}
- mProtocol.setSummary(
- checkNull(protocolDescription(mProtocol.getValue(), mProtocol)));
- mRoamingProtocol.setSummary(
- checkNull(protocolDescription(mRoamingProtocol.getValue(), mRoamingProtocol)));
- mBearer.setSummary(
- checkNull(bearerDescription(mBearer.getValue())));
-// mMvnoType.setSummary(
-// checkNull(mvnoDescription(mMvnoType.getValue())));
-
- String mvnoMatchDataSummery = mMvnoMatchData.getText();
-// if (isSpecificApnForCdma(mvnoMatchDataSummery)) {
- mvnoMatchDataSummery = sNotSet;
-// }
- mMvnoMatchData.setSummary(checkNull(mvnoMatchDataSummery));
- //mApnSetting
- mApnSetting.setmNameStr(checkNull(mName.getText()));
- mApnSetting.setmApnStr(checkNull(mApn.getText()));
- mApnSetting.setmProxyStr(checkNull(mProxy.getText()));
- mApnSetting.setmPortStr(checkNull(mPort.getText()));
- mApnSetting.setmUserStr(checkNull(mUser.getText()));
- mApnSetting.setmServerStr(checkNull(mServer.getText()));
- mApnSetting.setmPasswordStr(checkNull(mPassword.getText()));
- mApnSetting.setmMmsProxyStr(checkNull(mMmsProxy.getText()));
- mApnSetting.setmMmsPortStr(checkNull(mMmsPort.getText()));
- mApnSetting.setmMmscStr(checkNull(mMmsc.getText()));
- mApnSetting.setmMccStr(checkNull(mMcc.getText()));
- mApnSetting.setmMncStr(checkNull(mMnc.getText()));
- mApnSetting.setmApnTypeStr(mApnTypeSummary);
- mApnSetting.setmAuthTypeStr(checkNull(mAuthType.getValue()));
- mApnSetting.setmProtocolStr(checkNull(mProtocol.getValue()));
- mApnSetting.setmRoamingProtocolStr(checkNull(mRoamingProtocol.getValue()));
- mApnSetting.setmBearerStr(checkNull(mBearer.getValue()));
- mApnSetting.setmMvnoTypeStr(checkNull(mMvnoType.getValue()));
- mApnSetting.setmMvnoMatchDataStr(checkNull(mMvnoMatchData.getText()));
- }
+ mMvnoType = (cursor.getString(MVNO_TYPE_INDEX));
+ mMvnoMatchData = (cursor.getString(MVNO_MATCH_DATA_INDEX));
- /**
- * Returns the UI choice (e.g., "IPv4/IPv6") corresponding to the given
- * raw value of the protocol preference (e.g., "IPV4V6"). If unknown,
- * return null.
- */
- private String protocolDescription(String raw, ListPreference protocol) {
- int protocolIndex = protocol.findIndexOfValue(raw);
- if (protocolIndex == -1) {
- return null;
- } else {
- String[] values = mRes.getStringArray(R.array.apn_protocol_entries);
- try {
- return values[protocolIndex];
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
+ if (mNewApn && mMvnoTypeStr != null && mMvnoMatchDataStr != null) {
+ mMvnoType = (mMvnoTypeStr);
+ mMvnoMatchData = (mMvnoMatchDataStr);
}
- }
- }
- private String bearerDescription(String raw) {
- int mBearerIndex = mBearer.findIndexOfValue(raw);
- if (mBearerIndex == -1) {
- return null;
- } else {
- String[] values = mRes.getStringArray(R.array.bearer_entries);
- try {
- return values[mBearerIndex];
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
- }
- }
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_BACK: {
- if (validateAndSave(false)) {
-// finish();
- }
- return true;
- }
+ if (mNewApn && TextUtils.isEmpty(cursor.getString(TYPE_INDEX))) {
+ mApnTypeSummary = mApnTypeArray[0];
}
- return false;
-// return super.onKeyDown(keyCode, event);
+
+ //mApnSetting
+ apnSetting.setmNameStr(checkNull(mName));
+ apnSetting.setmApnStr(checkNull(mApn));
+ apnSetting.setmProxyStr(checkNull(mProxy));
+ apnSetting.setmPortStr(checkNull(mPort));
+ apnSetting.setmUserStr(checkNull(mUser));
+ apnSetting.setmServerStr(checkNull(mServer));
+ apnSetting.setmPasswordStr(checkNull(mPassword));
+ apnSetting.setmMmsProxyStr(checkNull(mMmsProxy));
+ apnSetting.setmMmsPortStr(checkNull(mMmsPort));
+ apnSetting.setmMmscStr(checkNull(mMmsc));
+ apnSetting.setmMccStr(checkNull(mMcc));
+ apnSetting.setmMncStr(checkNull(mMnc));
+ apnSetting.setmApnTypeStr(mApnTypeSummary);
+ apnSetting.setmAuthTypeStr(checkNull(mAuthType));
+ apnSetting.setmProtocolStr(checkNull(mProtocol));
+ apnSetting.setmRoamingProtocolStr(checkNull(mRoamingProtocol));
+ apnSetting.setmBearerStr(checkNull(mBearer));
+ apnSetting.setmMvnoTypeStr(checkNull(mMvnoType));
+ apnSetting.setmMvnoMatchDataStr(checkNull(mMvnoMatchData));
}
- /**
- * Check the key fields' validity and save if valid.
- * @param force save even if the fields are not valid, if the app is
- * being suspended
- * @return true if the data was saved
- */
private boolean validateAndSave(boolean force) {
- String name = checkNotSet(mName.getText());
- String apn = checkNotSet(mApn.getText());
- String mcc = checkNotSet(mMcc.getText());
- String mnc = checkNotSet(mMnc.getText());
-
+ String name = checkNotSet(mName);
+ String apn = checkNotSet(mApn);
+ String mcc = checkNotSet(mMcc);
+ String mnc = checkNotSet(mMnc);
+ mApnType = mApnTypeArray[0];
if (getErrorMsg() != null && !force) {
-// showDialog(ERROR_DIALOG_ID);
+ ICLogger.e(getErrorMsg()+" force="+force);
return false;
}
-
- if (!mCursor.moveToFirst()) {
- Log.w(TAG,
+ if (mCursor!=null && !mCursor.moveToFirst()) {
+ ICLogger.w(
"Could not go to the first row in the Cursor when saving data.");
return false;
}
-
// If it's a new APN and a name or apn haven't been entered, then erase the entry
// SPRD: FEATURE_APN_CAN_BE_EMTPY
if (force && mNewApn && name.length() < 1 && apn.length() < 1 && !mAllowEmptyApn) {
mContext.getContentResolver().delete(mUri, null, null);
-
- /* SPRD: for bug 297172: After hanging up the phone, can not save the new apn normally @{ */
- Log.d(TAG, "The mUri has delete!");
+ ICLogger.d( "The mUri has delete!");
mIsdelete = true;
- /* @} */
return false;
}
//mNewApnSetting
- mNewApnSetting.setmNameStr(checkNull(mName.getText()));
- mNewApnSetting.setmApnStr(checkNull(mApn.getText()));
- mNewApnSetting.setmProxyStr(checkNull(mProxy.getText()));
- mNewApnSetting.setmPortStr(checkNull(mPort.getText()));
- mNewApnSetting.setmUserStr(checkNull(mUser.getText()));
- mNewApnSetting.setmServerStr(checkNull(mServer.getText()));
- mNewApnSetting.setmPasswordStr(checkNull(mPassword.getText()));
- mNewApnSetting.setmMmsProxyStr(checkNull(mMmsProxy.getText()));
- mNewApnSetting.setmMmsPortStr(checkNull(mMmsPort.getText()));
- mNewApnSetting.setmMmscStr(checkNull(mMmsc.getText()));
- mNewApnSetting.setmMccStr(checkNull(mMcc.getText()));
- mNewApnSetting.setmMncStr(checkNull(mMnc.getText()));
- mNewApnSetting.setmApnTypeStr(checkNull(mApnType.getSummary().toString()));
- mNewApnSetting.setmAuthTypeStr(checkNull(mAuthType.getValue()));
- mNewApnSetting.setmProtocolStr(checkNull(mProtocol.getValue()));
- mNewApnSetting.setmRoamingProtocolStr(checkNull(mRoamingProtocol.getValue()));
- mNewApnSetting.setmBearerStr(checkNull(mBearer.getValue()));
- mNewApnSetting.setmMvnoTypeStr(checkNull(mMvnoType.getValue()));
- mNewApnSetting.setmMvnoMatchDataStr(checkNull(mMvnoMatchData.getText()));
- boolean mIsApnChange = mApnSetting.equals(mNewApnSetting) ;
- if (!mIsApnChange) {
- Log.d(TAG, "mApnSetting: " + mApnSetting.toString());
- Log.d(TAG, "mNewApnSetting: " + mNewApnSetting.toString());
+ mNewApnSetting.setmNameStr(checkNull(mName));
+ mNewApnSetting.setmApnStr(checkNull(mApn));
+ mNewApnSetting.setmProxyStr(checkNull(mProxy));
+ mNewApnSetting.setmPortStr(checkNull(mPort));
+ mNewApnSetting.setmUserStr(checkNull(mUser));
+ mNewApnSetting.setmServerStr(checkNull(mServer));
+ mNewApnSetting.setmPasswordStr(checkNull(mPassword));
+ mNewApnSetting.setmMmsProxyStr(checkNull(mMmsProxy));
+ mNewApnSetting.setmMmsPortStr(checkNull(mMmsPort));
+ mNewApnSetting.setmMmscStr(checkNull(mMmsc));
+ mNewApnSetting.setmMccStr(checkNull(mMcc));
+ mNewApnSetting.setmMncStr(checkNull(mMnc));
+ mNewApnSetting.setmApnTypeStr(checkNull(mApnType));
+ mNewApnSetting.setmAuthTypeStr(checkNull(mAuthType));
+ mNewApnSetting.setmProtocolStr(checkNull(mProtocol));
+ mNewApnSetting.setmRoamingProtocolStr(checkNull(mRoamingProtocol));
+ mNewApnSetting.setmBearerStr(checkNull(mBearer));
+ mNewApnSetting.setmMvnoTypeStr(checkNull(mMvnoType));
+ mNewApnSetting.setmMvnoMatchDataStr(checkNull(mMvnoMatchData));
+ // boolean mIsApnChange = !mApnSetting.equals(mNewApnSetting);
+// if (mIsApnChange) {
+ 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);
+ name.length() < 1 ? mContext.getResources().getString(R.string.untitled_apn) : name);
values.put(Telephony.Carriers.APN, apn);
- values.put(Telephony.Carriers.PROXY, checkNotSet(mProxy.getText()));
- values.put(Telephony.Carriers.PORT, checkNotSet(mPort.getText()));
- values.put(Telephony.Carriers.MMSPROXY, checkNotSet(mMmsProxy.getText()));
- values.put(Telephony.Carriers.MMSPORT, checkNotSet(mMmsPort.getText()));
- values.put(Telephony.Carriers.USER, checkNotSet(mUser.getText()));
- values.put(Telephony.Carriers.SERVER, checkNotSet(mServer.getText()));
- values.put(Telephony.Carriers.PASSWORD, checkNotSet(mPassword.getText()));
- values.put(Telephony.Carriers.MMSC, checkNotSet(mMmsc.getText()));
-
- String authVal = mAuthType.getValue();
+ 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.getValue()));
- values.put(Telephony.Carriers.ROAMING_PROTOCOL, checkNotSet(mRoamingProtocol.getValue()));
+ values.put(Telephony.Carriers.PROTOCOL, checkNotSet(mProtocol));
+ values.put(Telephony.Carriers.ROAMING_PROTOCOL, checkNotSet(mRoamingProtocol));
- if (mApnType.getSummary() != null) {
- values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType.getSummary().toString()));
+ if (mApnType != null) {
+ values.put(Telephony.Carriers.TYPE, checkNotSet(mApnType));
}
values.put(Telephony.Carriers.MCC, mcc);
values.put(Telephony.Carriers.NUMERIC, mcc + mnc);
- /* SPRD: for multi-sim @{ */
int mDDS = 0;
try {
- mDDS = Settings.System
- .getInt(mContext.getContentResolver(), Settings.System.MULTI_SIM_DATA_CALL);
+ mDDS = Settings.System.getInt(mContext.getContentResolver(), Settings.System.MULTI_SIM_DATA_CALL);
} catch (Exception e) {
- Log.e(TAG, "Exception Reading Dual Sim Data Subscription Value.", 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) {
- // if (mCurMnc.equals(mnc) && mCurMcc.equals(mcc)) {
values.put(Telephony.Carriers.CURRENT, 1);
}
}
- String bearerVal = mBearer.getValue();
+ String bearerVal = mBearer;
if (bearerVal != null) {
values.put(Telephony.Carriers.BEARER, Integer.parseInt(bearerVal));
}
-// if (SPECIAL_CTCC_NUMERIC.equals(mcc+mnc) && isSpecificApnForCdma(CTCC_ICCID)) {
-// values.put(Telephony.Carriers.MVNO_TYPE, "iccid");
-// values.put(Telephony.Carriers.MVNO_MATCH_DATA, CTCC_ICCID);
-// } else {
- values.put(Telephony.Carriers.MVNO_TYPE, checkNotSet(mMvnoType.getValue()));
- values.put(Telephony.Carriers.MVNO_MATCH_DATA, checkNotSet(mMvnoMatchData.getText()));
-// }
+
+ 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;
+// }
return true;
}
private String getErrorMsg() {
String errorMsg = null;
- String name = checkNotSet(mName.getText());
- String apn = checkNotSet(mApn.getText());
- String mcc = checkNotSet(mMcc.getText());
- String mnc = checkNotSet(mMnc.getText());
- String apnString = (String) mApnType.getSummary();
- String apnType = checkNotSet(apnString);
+ String name = checkNotSet(mName);
+ String apn = checkNotSet(mApn);
+ String mcc = checkNotSet(mMcc);
+ String mnc = checkNotSet(mMnc);
+
+ String apnType = checkNotSet(mApnType);
if (name.length() < 1) {
errorMsg = mRes.getString(R.string.error_name_empty);
- // SPRD: FEATURE_APN_CAN_BE_EMTPY
+ // SPRD: FEATURE_APN_CAN_BE_EMTPY
} else if (apn.length() < 1 && !mAllowEmptyApn) {
errorMsg = mRes.getString(R.string.error_apn_empty);
} else if (mcc.length() != 3) {
}
-
- private void deleteApn() {
+ public void deleteApn() {
mContext.getContentResolver().delete(mUri, null, null);
-// finish();
- }
-
- private String starify(String value) {
- if (value == null || value.length() == 0) {
- return sNotSet;
- } else {
- char[] password = new char[value.length()];
- for (int i = 0; i < password.length; i++) {
- password[i] = '*';
- }
- return new String(password);
- }
}
private String checkNull(String value) {