losion.liu@sikey.com.cn 11 月之前
父节点
当前提交
e21b1fc06c

+ 1 - 9
app/src/main/java/com/xplora/xpsettings/Activity/ApnListActivity.java

@@ -35,13 +35,6 @@ public class ApnListActivity extends BaseActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_list);
         moveApn();
-    }
-
-    @Override
-    protected void onStart() {
-        super.onStart();
-        mApnList.clear();
-        mDataList.clear();
         initApn();
         initData();
         initView();
@@ -49,6 +42,7 @@ public class ApnListActivity extends BaseActivity {
 
     private void moveApn() {
         List<ApnModel> apnModelList = DataManager.getApnList();
+        Log.d(TAG, "moveApn: size: " + apnModelList.size());
         if (apnModelList.size() <= 0)
             return;
         for (ApnModel model: apnModelList) {
@@ -194,7 +188,6 @@ public class ApnListActivity extends BaseActivity {
 
     void insertApn(ApnModel apnModel) {
         int _id = ApnManager.insertAPN(getApplicationContext(), apnModel);
-        Log.d(TAG, "insertApn: " + _id);
         if (_id < 0)
             return;
         apnModel.apn_id = String.valueOf(_id);
@@ -209,7 +202,6 @@ public class ApnListActivity extends BaseActivity {
     }
 
     void deleteApn(ApnModel model) {
-        Log.d(TAG, "deleteApn: " + model.apn_id);
         ApnManager.deleteAPN(getApplicationContext(), model.apn_id);
         DatabaseHelper.deleteAPN(this, model._id);
         reloadView();

+ 8 - 8
app/src/main/java/com/xplora/xpsettings/Data/ApnManager.java

@@ -43,10 +43,10 @@ public class ApnManager {
             a.mmsc = getCursorColumnValue(cr,"mmsc");
             a.mmsproxy = getCursorColumnValue(cr,"mmsproxy");
             a.mmsport = getCursorColumnValue(cr,"mmsport");
-            a.auth_type = getCursorColumnValue(cr,"auth_type");
-            a.apn_type = getCursorColumnValue(cr,"apn_type");
-            a.apn_protocol = getCursorColumnValue(cr,"apn_protocol");
-            a.apn_roaming_protocol = getCursorColumnValue(cr,"apn_roaming_protocol");
+            a.auth_type = getCursorColumnValue(cr,"authtype");
+            a.apn_type = getCursorColumnValue(cr,"type");
+            a.apn_protocol = getCursorColumnValue(cr,"protocol");
+            a.apn_roaming_protocol = getCursorColumnValue(cr,"roaming_protocol");
             a.bearer = getCursorColumnValue(cr,"bearer");
             a.mvno_type = getCursorColumnValue(cr,"mvno_type");
             a.mvno_match_data = getCursorColumnValue(cr,"mvno_match_data");
@@ -142,10 +142,10 @@ public class ApnManager {
             a.mmsc = getCursorColumnValue(cr,"mmsc");
             a.mmsproxy = getCursorColumnValue(cr,"mmsproxy");
             a.mmsport = getCursorColumnValue(cr,"mmsport");
-            a.auth_type = getCursorColumnValue(cr,"auth_type");
-            a.apn_type = getCursorColumnValue(cr,"apn_type");
-            a.apn_protocol = getCursorColumnValue(cr,"apn_protocol");
-            a.apn_roaming_protocol = getCursorColumnValue(cr,"apn_roaming_protocol");
+            a.auth_type = getCursorColumnValue(cr,"authtype");
+            a.apn_type = getCursorColumnValue(cr,"type");
+            a.apn_protocol = getCursorColumnValue(cr,"protocol");
+            a.apn_roaming_protocol = getCursorColumnValue(cr,"roaming_protocol");
             a.bearer = getCursorColumnValue(cr,"bearer");
             a.mvno_type = getCursorColumnValue(cr,"mvno_type");
             a.mvno_match_data = getCursorColumnValue(cr,"mvno_match_data");

+ 31 - 33
app/src/main/java/com/xplora/xpsettings/Data/DatabaseHelper.java

@@ -121,7 +121,6 @@ public class DatabaseHelper {
                 cursor.close();
                 return arrayList;
             }
-            Log.d(TAG, "getApnList: db ok");
             do {
                 ApnModel bean = new ApnModel();
                 bean._id = cursor.getString(cursor.getColumnIndex("_id"));
@@ -155,6 +154,7 @@ public class DatabaseHelper {
     }
 
     public static int insertAPN(Context context, ApnModel model) {
+        Log.d(TAG, "====== insertAPN ========: " + model.apn_id);
         if (Macros.DEBUG) {
             return -1;
         } else {
@@ -181,54 +181,52 @@ public class DatabaseHelper {
             values.put("mvno_type", model.mvno_type);
             values.put("mvno_match_data", model.mvno_match_data);
             Uri returnUri = context.getContentResolver().insert(uri, values);
-            Log.d(TAG, "insertAPN: " + returnUri.toString());
+            Log.d(TAG, "insertAPN row: " + returnUri.toString());
             String s = getLastPart(returnUri.toString());
             return Integer.parseInt(s);
         }
     }
 
     public static void updateAPN(Context context, ApnModel model) {
+        Log.d(TAG, "====== updateAPN =======: " + model.apn_id);
         if (Macros.DEBUG) {
 
         } else {
-            new Thread(()->{
-                Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + model._id);
-                ContentValues values = new ContentValues();
-                values.put("apn_id", model.apn_id);
-                values.put("name", model.name);
-                values.put("apn_name", model.apn_name);
-                values.put("user_name", model.user_name);
-                values.put("password", model.password);
-                values.put("mcc", model.mcc);
-                values.put("mnc", model.mnc);
-                values.put("proxy", model.proxy);
-                values.put("port", model.port);
-                values.put("server", model.server);
-                values.put("mmsc", model.mmsc);
-                values.put("mmsproxy", model.mmsproxy);
-                values.put("mmsport", model.mmsport);
-                values.put("auth_type", model.auth_type);
-                values.put("apn_type", model.apn_type);
-                values.put("apn_protocol", model.apn_protocol);
-                values.put("apn_roaming_protocol", model.apn_roaming_protocol);
-                values.put("bearer", model.bearer);
-                values.put("mvno_type", model.mvno_type);
-                values.put("mvno_match_data", model.mvno_match_data);
-                int row = context.getContentResolver().update(uri, values, null, null);
-                Log.d(TAG, "updateAPN: " + row);
-            }).start();
+            Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + model._id);
+            ContentValues values = new ContentValues();
+            values.put("apn_id", model.apn_id);
+            values.put("name", model.name);
+            values.put("apn_name", model.apn_name);
+            values.put("user_name", model.user_name);
+            values.put("password", model.password);
+            values.put("mcc", model.mcc);
+            values.put("mnc", model.mnc);
+            values.put("proxy", model.proxy);
+            values.put("port", model.port);
+            values.put("server", model.server);
+            values.put("mmsc", model.mmsc);
+            values.put("mmsproxy", model.mmsproxy);
+            values.put("mmsport", model.mmsport);
+            values.put("auth_type", model.auth_type);
+            values.put("apn_type", model.apn_type);
+            values.put("apn_protocol", model.apn_protocol);
+            values.put("apn_roaming_protocol", model.apn_roaming_protocol);
+            values.put("bearer", model.bearer);
+            values.put("mvno_type", model.mvno_type);
+            values.put("mvno_match_data", model.mvno_match_data);
+            int row = context.getContentResolver().update(uri, values, null, null);
+            Log.d(TAG, "updateAPN row: " + row);
         }
     }
 
     public static void deleteAPN(Context context, String _id) {
+        Log.d(TAG, "====== deleteAPN =======: " + _id);
         if (Macros.DEBUG) {
 
         } else {
-            new Thread(()->{
-                Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + _id);
-                int row = context.getContentResolver().delete(uri, null, null);
-                Log.d(TAG, "updateAPN: " + row);
-            }).start();
+            Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + _id);
+            int row = context.getContentResolver().delete(uri, null, null);
+            Log.d(TAG, "deleteAPN row: " + row);
         }
     }