|
@@ -1,5 +1,8 @@
|
|
|
package com.xplora.xpsettings.Data;
|
|
|
|
|
|
+import static com.xplora.xpsettings.Utils.MetaData.DB_GOPLAY_APN;
|
|
|
+import static com.xplora.xpsettings.Utils.MetaData.DB_GOPLAY_RINGTONES;
|
|
|
+
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.content.ContentResolver;
|
|
|
import android.content.ContentValues;
|
|
@@ -8,6 +11,7 @@ import android.database.Cursor;
|
|
|
import android.net.Uri;
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import com.xplora.xpsettings.Model.ApnModel;
|
|
|
import com.xplora.xpsettings.Model.RingtoneModel;
|
|
|
import com.xplora.xpsettings.Utils.Macros;
|
|
|
import com.xplora.xpsettings.Utils.MetaData;
|
|
@@ -58,7 +62,7 @@ public class DatabaseHelper {
|
|
|
continue;
|
|
|
ContentValues values = new ContentValues();
|
|
|
values.put("status", "1");
|
|
|
- Uri uri = Uri.parse(MetaData.DB_GOPLAY_RINGTONES + "/" + model._id);
|
|
|
+ Uri uri = Uri.parse(DB_GOPLAY_RINGTONES + "/" + model._id);
|
|
|
int row = context.getContentResolver().update(uri, values, null, null);
|
|
|
Log.d(TAG, "modifyRingtoneStatusDownloading: " + row);
|
|
|
}
|
|
@@ -78,9 +82,7 @@ public class DatabaseHelper {
|
|
|
|
|
|
public static int addWatchFace(Context context, String name) {
|
|
|
Log.d(TAG, "addWatchFaceConfig: ");
|
|
|
- String AUTHORITIES_COMMON = "content://com.xplora.WatchCommonProvider";
|
|
|
- String watchFaceDB = AUTHORITIES_COMMON + "/ringtones";
|
|
|
- Uri insertUri = Uri.parse(watchFaceDB);
|
|
|
+ Uri insertUri = Uri.parse(DB_GOPLAY_RINGTONES);
|
|
|
ContentValues values = new ContentValues();
|
|
|
values.put("contentType", "Watchface");
|
|
|
values.put("title", name);
|
|
@@ -102,4 +104,131 @@ public class DatabaseHelper {
|
|
|
return url.substring(url.lastIndexOf("/") + 1);
|
|
|
}
|
|
|
|
|
|
+ public static ArrayList<ApnModel> getApnList(Context context) {
|
|
|
+ if (Macros.DEBUG) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ } else {
|
|
|
+ ArrayList<ApnModel> arrayList = new ArrayList<>();
|
|
|
+ ContentResolver resolver = context.getContentResolver();
|
|
|
+ Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + 0);
|
|
|
+ Cursor cursor = resolver.query(uri, null, null, null, null);
|
|
|
+ if (cursor == null) {
|
|
|
+ Log.d(TAG, "getApnList: cursor == null");
|
|
|
+ return arrayList;
|
|
|
+ }
|
|
|
+ if (!cursor.moveToFirst()) {
|
|
|
+ Log.d(TAG, "getApnList: cursor.moveToFirst() == false");
|
|
|
+ cursor.close();
|
|
|
+ return arrayList;
|
|
|
+ }
|
|
|
+ Log.d(TAG, "getApnList: db ok");
|
|
|
+ do {
|
|
|
+ ApnModel bean = new ApnModel();
|
|
|
+ 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);
|
|
|
+ arrayList.add(bean);
|
|
|
+ } while (cursor.moveToNext());
|
|
|
+ cursor.close();
|
|
|
+ Log.d(TAG, "getApnList: " + arrayList.size());
|
|
|
+ return arrayList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int insertAPN(Context context, ApnModel model) {
|
|
|
+ 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);
|
|
|
+ Uri returnUri = context.getContentResolver().insert(uri, values);
|
|
|
+ Log.d(TAG, "insertAPN: " + returnUri.toString());
|
|
|
+ String s = getLastPart(returnUri.toString());
|
|
|
+ return Integer.parseInt(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void updateAPN(Context context, ApnModel model) {
|
|
|
+ if (Macros.DEBUG) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ new Thread(()->{
|
|
|
+ Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + model.apn_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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void deleteAPN(Context context, String apnId) {
|
|
|
+ if (Macros.DEBUG) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ new Thread(()->{
|
|
|
+ Uri uri = Uri.parse(DB_GOPLAY_APN + "/" + apnId);
|
|
|
+ int row = context.getContentResolver().delete(uri, null, null);
|
|
|
+ Log.d(TAG, "updateAPN: " + row);
|
|
|
+ }).start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|