|
@@ -104,7 +104,7 @@ public class DatabaseHelper {
|
|
|
return url.substring(url.lastIndexOf("/") + 1);
|
|
|
}
|
|
|
|
|
|
- public static ArrayList<ApnModel> getApnList(Context context) {
|
|
|
+ public static ArrayList<ApnModel> getCustomApnList(Context context) {
|
|
|
if (Macros.DEBUG) {
|
|
|
return new ArrayList<>();
|
|
|
} else {
|
|
@@ -113,73 +113,35 @@ public class DatabaseHelper {
|
|
|
Uri uri = Uri.parse(DB_GOPLAY_APN);
|
|
|
Cursor cursor = resolver.query(uri, null, null, null, null);
|
|
|
if (cursor == null) {
|
|
|
- Log.d(TAG, "getApnList: cursor == null");
|
|
|
+ Log.d(TAG, "getCustomApnList: cursor == null");
|
|
|
return arrayList;
|
|
|
}
|
|
|
if (!cursor.moveToFirst()) {
|
|
|
- Log.d(TAG, "getApnList: cursor.moveToFirst() == false");
|
|
|
+ Log.d(TAG, "getCustomApnList: cursor.moveToFirst() == false");
|
|
|
cursor.close();
|
|
|
return arrayList;
|
|
|
}
|
|
|
do {
|
|
|
ApnModel bean = new ApnModel();
|
|
|
- bean._id = cursor.getString(cursor.getColumnIndex("_id"));
|
|
|
bean.apn_id = cursor.getString(cursor.getColumnIndex("apn_id"));
|
|
|
- bean.name = cursor.getString(cursor.getColumnIndex("name"));
|
|
|
- bean.apn_name = cursor.getString(cursor.getColumnIndex("apn_name"));
|
|
|
- bean.user_name = cursor.getString(cursor.getColumnIndex("user_name"));
|
|
|
- bean.password = cursor.getString(cursor.getColumnIndex("password"));
|
|
|
- bean.mcc = cursor.getString(cursor.getColumnIndex("mcc"));
|
|
|
- bean.mnc = cursor.getString(cursor.getColumnIndex("mnc"));
|
|
|
- bean.proxy = cursor.getString(cursor.getColumnIndex("proxy"));
|
|
|
- bean.port = cursor.getString(cursor.getColumnIndex("port"));
|
|
|
- bean.server = cursor.getString(cursor.getColumnIndex("server"));
|
|
|
- bean.mmsc = cursor.getString(cursor.getColumnIndex("mmsc"));
|
|
|
- bean.mmsproxy = cursor.getString(cursor.getColumnIndex("mmsproxy"));
|
|
|
- bean.mmsport = cursor.getString(cursor.getColumnIndex("mmsport"));
|
|
|
- bean.auth_type = cursor.getString(cursor.getColumnIndex("auth_type"));
|
|
|
- bean.apn_type = cursor.getString(cursor.getColumnIndex("apn_type"));
|
|
|
- bean.apn_protocol = cursor.getString(cursor.getColumnIndex("apn_protocol"));
|
|
|
- bean.apn_roaming_protocol = cursor.getString(cursor.getColumnIndex("apn_roaming_protocol"));
|
|
|
- bean.bearer = cursor.getString(cursor.getColumnIndex("bearer"));
|
|
|
- bean.mvno_type = cursor.getString(cursor.getColumnIndex("mvno_type"));
|
|
|
- bean.mvno_match_data = cursor.getString(cursor.getColumnIndex("mvno_match_data"));
|
|
|
- Log.d(TAG, "getApnList: apn_id: " + bean.apn_id + " mcc: " + bean.mcc + " mnc:" + bean.mnc);
|
|
|
+ bean._id = cursor.getString(cursor.getColumnIndex("_id"));
|
|
|
+ Log.d(TAG, "getCustomApnList: _id: " + bean._id + " mcc: " + bean.mcc + " mnc:" + bean.mnc);
|
|
|
arrayList.add(bean);
|
|
|
} while (cursor.moveToNext());
|
|
|
cursor.close();
|
|
|
- Log.d(TAG, "getApnList: " + arrayList.size());
|
|
|
+ Log.d(TAG, "getCustomApnList: " + arrayList.size());
|
|
|
return arrayList;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static int insertAPN(Context context, ApnModel model) {
|
|
|
- Log.d(TAG, "====== insertAPN ========: " + model.apn_id);
|
|
|
+ Log.d(TAG, "====== insertAPN ========: " + model._id);
|
|
|
if (Macros.DEBUG) {
|
|
|
return -1;
|
|
|
} else {
|
|
|
Uri uri = Uri.parse(DB_GOPLAY_APN);
|
|
|
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);
|
|
|
+ values.put("_id", model._id);
|
|
|
Uri returnUri = context.getContentResolver().insert(uri, values);
|
|
|
Log.d(TAG, "insertAPN row: " + returnUri.toString());
|
|
|
String s = getLastPart(returnUri.toString());
|
|
@@ -188,46 +150,17 @@ public class DatabaseHelper {
|
|
|
}
|
|
|
|
|
|
public static void updateAPN(Context context, ApnModel model) {
|
|
|
- Log.d(TAG, "====== updateAPN =======: " + model.apn_id);
|
|
|
- if (Macros.DEBUG) {
|
|
|
-
|
|
|
- } else {
|
|
|
- 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);
|
|
|
- }
|
|
|
+ Log.d(TAG, "====== updateAPN =======: " + model._id);
|
|
|
}
|
|
|
|
|
|
- public static void deleteAPN(Context context, String _id) {
|
|
|
- Log.d(TAG, "====== deleteAPN =======: " + _id);
|
|
|
+ public static void deleteAPN(Context context, ApnModel model) {
|
|
|
+ Log.d(TAG, "====== deleteAPN =======: " + model.apn_id);
|
|
|
if (Macros.DEBUG) {
|
|
|
|
|
|
} else {
|
|
|
- Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + _id);
|
|
|
+ Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + model.apn_id);
|
|
|
int row = context.getContentResolver().delete(uri, null, null);
|
|
|
Log.d(TAG, "deleteAPN row: " + row);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|