|
@@ -86,6 +86,7 @@ public final class WsManager {
|
|
@Override
|
|
@Override
|
|
public void onOpen(@NonNull WebSocket webSocket, @NonNull Response response) {
|
|
public void onOpen(@NonNull WebSocket webSocket, @NonNull Response response) {
|
|
super.onOpen(webSocket, response);
|
|
super.onOpen(webSocket, response);
|
|
|
|
+ XLog.i("连接成功--------------------->" + BuildConfig.WEB_URL + HxUtils.getPhone() + "/");
|
|
Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_14));
|
|
Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_14));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_14));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_14));
|
|
LiveEventBus.get(WEBSOCKET_STATUS_TAG).post(StringUtils.getString(R.string.log_tip_14));
|
|
LiveEventBus.get(WEBSOCKET_STATUS_TAG).post(StringUtils.getString(R.string.log_tip_14));
|
|
@@ -100,16 +101,17 @@ public final class WsManager {
|
|
String value = json.getString("value");
|
|
String value = json.getString("value");
|
|
String content = json.getString("content");
|
|
String content = json.getString("content");
|
|
String packageName = json.getString("packageName");
|
|
String packageName = json.getString("packageName");
|
|
|
|
+ int simSlot = json.getIntValue("simslot");
|
|
int hashCode = json.getIntValue("hashCode");
|
|
int hashCode = json.getIntValue("hashCode");
|
|
int action = json.getIntValue("action");
|
|
int action = json.getIntValue("action");
|
|
JSONArray arguments = json.getJSONArray("arguments");
|
|
JSONArray arguments = json.getJSONArray("arguments");
|
|
XLog.e("[WsManager] onMessage: " + json);
|
|
XLog.e("[WsManager] onMessage: " + json);
|
|
switch (command) {
|
|
switch (command) {
|
|
case "invoke":
|
|
case "invoke":
|
|
- ThreadUtils.runOnUiThread(() -> callOverlay(value, requestId));
|
|
|
|
|
|
+ ThreadUtils.runOnUiThread(() -> callOverlay(value, requestId, simSlot));
|
|
break;
|
|
break;
|
|
case "invoke2":
|
|
case "invoke2":
|
|
- ThreadUtils.runOnUiThread(() -> callOverlay2(value, requestId));
|
|
|
|
|
|
+ ThreadUtils.runOnUiThread(() -> callOverlay2(value, requestId, simSlot));
|
|
break;
|
|
break;
|
|
case "send":
|
|
case "send":
|
|
ThreadUtils.runOnUiThread(() -> sendUssd(requestId, value));
|
|
ThreadUtils.runOnUiThread(() -> sendUssd(requestId, value));
|
|
@@ -188,6 +190,7 @@ public final class WsManager {
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
XLog.e(command + " 没有定义该操作!");
|
|
XLog.e(command + " 没有定义该操作!");
|
|
|
|
+ sendWebSocketMsg(requestId, "exception", command + " 没有定义该操作!");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -196,6 +199,7 @@ public final class WsManager {
|
|
public void onClosing(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
|
public void onClosing(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
|
super.onClosing(webSocket, code, reason);
|
|
super.onClosing(webSocket, code, reason);
|
|
webSocket.close(code, reason);
|
|
webSocket.close(code, reason);
|
|
|
|
+ XLog.i("连接关闭中--------------------->" + BuildConfig.WEB_URL + HxUtils.getPhone() + "/");
|
|
Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_15_s, " "));
|
|
Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_15_s, " "));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_15_s, " "));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_15_s, " "));
|
|
LiveEventBus.get(WEBSOCKET_STATUS_TAG).post(StringUtils.getString(R.string.log_tip_15_s, reason));
|
|
LiveEventBus.get(WEBSOCKET_STATUS_TAG).post(StringUtils.getString(R.string.log_tip_15_s, reason));
|
|
@@ -204,6 +208,8 @@ public final class WsManager {
|
|
@Override
|
|
@Override
|
|
public void onClosed(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
|
public void onClosed(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
|
super.onClosed(webSocket, code, reason);
|
|
super.onClosed(webSocket, code, reason);
|
|
|
|
+ XLog.i("连接关闭--------------------->" + BuildConfig.WEB_URL + HxUtils.getPhone() + "/");
|
|
|
|
+
|
|
reconnectWebSocket();
|
|
reconnectWebSocket();
|
|
Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_16, reason));
|
|
Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_16, reason));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_16, reason));
|
|
XLog.i(StringUtils.getString(R.string.log_tip_16, reason));
|
|
@@ -214,6 +220,7 @@ public final class WsManager {
|
|
@Override
|
|
@Override
|
|
public void onFailure(@NonNull WebSocket webSocket, @NonNull Throwable t, Response response) {
|
|
public void onFailure(@NonNull WebSocket webSocket, @NonNull Throwable t, Response response) {
|
|
super.onFailure(webSocket, t, response);
|
|
super.onFailure(webSocket, t, response);
|
|
|
|
+ XLog.e("连接失败--------------------->" + BuildConfig.WEB_URL + HxUtils.getPhone() + "/", t);
|
|
reconnectWebSocket();
|
|
reconnectWebSocket();
|
|
Log.e(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_18_s, t.getMessage()), t);
|
|
Log.e(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_18_s, t.getMessage()), t);
|
|
XLog.e(StringUtils.getString(R.string.log_tip_18_s, t.getMessage()), t);
|
|
XLog.e(StringUtils.getString(R.string.log_tip_18_s, t.getMessage()), t);
|
|
@@ -222,6 +229,7 @@ public final class WsManager {
|
|
};
|
|
};
|
|
executorServiceUi.execute(() -> {
|
|
executorServiceUi.execute(() -> {
|
|
try {
|
|
try {
|
|
|
|
+ XLog.i("连接中--------------------->" + BuildConfig.WEB_URL + HxUtils.getPhone() + "/");
|
|
OkHttpClient client = new OkHttpClient.Builder().pingInterval(5, TimeUnit.SECONDS).build();
|
|
OkHttpClient client = new OkHttpClient.Builder().pingInterval(5, TimeUnit.SECONDS).build();
|
|
Request request = new Request.Builder().url(BuildConfig.WEB_URL + HxUtils.getPhone() + "/").build();
|
|
Request request = new Request.Builder().url(BuildConfig.WEB_URL + HxUtils.getPhone() + "/").build();
|
|
webSocket = client.newWebSocket(request, webSocketListener);
|
|
webSocket = client.newWebSocket(request, webSocketListener);
|
|
@@ -239,20 +247,34 @@ public final class WsManager {
|
|
try {
|
|
try {
|
|
List<HashMap<String, Object>> data = new ArrayList<>();
|
|
List<HashMap<String, Object>> data = new ArrayList<>();
|
|
ContentResolver contentResolver = Utils.getApp().getContentResolver();
|
|
ContentResolver contentResolver = Utils.getApp().getContentResolver();
|
|
|
|
+ String selection = Telephony.Sms.TYPE + " in (?,?,?,?,?)";
|
|
|
|
+ String[] sArgs = new String[]{String.valueOf(
|
|
|
|
+ Telephony.Sms.MESSAGE_TYPE_DRAFT)
|
|
|
|
+ , String.valueOf(Telephony.Sms.MESSAGE_TYPE_FAILED)
|
|
|
|
+ , String.valueOf(Telephony.Sms.MESSAGE_TYPE_OUTBOX)
|
|
|
|
+ , String.valueOf(Telephony.Sms.MESSAGE_TYPE_QUEUED)
|
|
|
|
+ , String.valueOf(Telephony.Sms.MESSAGE_TYPE_SENT)
|
|
|
|
+ };
|
|
Cursor cursor = contentResolver.query(Telephony.Sms.Sent.CONTENT_URI, null,
|
|
Cursor cursor = contentResolver.query(Telephony.Sms.Sent.CONTENT_URI, null,
|
|
- null, null, "date DESC LIMIT " + number);
|
|
|
|
|
|
+ selection, sArgs, "date DESC LIMIT " + number);
|
|
if (cursor != null && cursor.moveToFirst()) {
|
|
if (cursor != null && cursor.moveToFirst()) {
|
|
do {
|
|
do {
|
|
// 获取短信信息
|
|
// 获取短信信息
|
|
- long id = cursor.getLong(cursor.getColumnIndexOrThrow("_id"));
|
|
|
|
- String address = cursor.getString(cursor.getColumnIndexOrThrow("address"));
|
|
|
|
- String body = cursor.getString(cursor.getColumnIndexOrThrow("body"));
|
|
|
|
- long date = cursor.getLong(cursor.getColumnIndexOrThrow("date"));
|
|
|
|
- int type = cursor.getInt(cursor.getColumnIndexOrThrow("type"));
|
|
|
|
- int read = cursor.getInt(cursor.getColumnIndexOrThrow("read"));
|
|
|
|
- int status = cursor.getInt(cursor.getColumnIndexOrThrow("status"));
|
|
|
|
|
|
+ long id = cursor.getLong(cursor.getColumnIndexOrThrow(Telephony.Sms._ID));
|
|
|
|
+ String address = cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Sms.ADDRESS));
|
|
|
|
+ String body = cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Sms.BODY));
|
|
|
|
+ long date = cursor.getLong(cursor.getColumnIndexOrThrow(Telephony.Sms.DATE));
|
|
|
|
+ int type = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.TYPE));
|
|
|
|
+ int read = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.READ));
|
|
|
|
+ int status = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.STATUS));
|
|
|
|
+ int error_code = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.ERROR_CODE));
|
|
|
|
+ int date_sent = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.DATE_SENT));
|
|
|
|
+ int creator = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.CREATOR));
|
|
|
|
+ int locked = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.LOCKED));
|
|
|
|
+ int person = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.PERSON));
|
|
|
|
+ int protocol = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Sms.PROTOCOL));
|
|
String statusDescribe = "";
|
|
String statusDescribe = "";
|
|
- String serviceCenter = cursor.getString(cursor.getColumnIndexOrThrow("service_center"));
|
|
|
|
|
|
+ String serviceCenter = cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Sms.SERVICE_CENTER));
|
|
switch (status) {
|
|
switch (status) {
|
|
case -1:
|
|
case -1:
|
|
statusDescribe = "STATUS_NONE";
|
|
statusDescribe = "STATUS_NONE";
|
|
@@ -271,7 +293,14 @@ public final class WsManager {
|
|
}
|
|
}
|
|
XLog.i("SMS info", "ID: " + id + ", Address: " + address + ", Body: " + body +
|
|
XLog.i("SMS info", "ID: " + id + ", Address: " + address + ", Body: " + body +
|
|
", Date: " + date + ", Type: " + type + ", Read: " + read +
|
|
", Date: " + date + ", Type: " + type + ", Read: " + read +
|
|
- ", Status: " + status + ", Service Center: " + serviceCenter + ", statusDescribe: " + statusDescribe);
|
|
|
|
|
|
+ ", Status: " + status + ", Service Center: " + serviceCenter + ", statusDescribe: " + statusDescribe
|
|
|
|
+ + ", error_code: " + error_code
|
|
|
|
+ + ", date_sent: " + date_sent
|
|
|
|
+ + ", creator: " + creator
|
|
|
|
+ + ", locked: " + locked
|
|
|
|
+ + ", person: " + person
|
|
|
|
+ + ", protocol: " + protocol
|
|
|
|
+ );
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
map.put("id", id);
|
|
map.put("id", id);
|
|
map.put("address", address);
|
|
map.put("address", address);
|
|
@@ -282,6 +311,12 @@ public final class WsManager {
|
|
map.put("status", status);
|
|
map.put("status", status);
|
|
map.put("statusDescribe", statusDescribe);
|
|
map.put("statusDescribe", statusDescribe);
|
|
map.put("serviceCenter", serviceCenter);
|
|
map.put("serviceCenter", serviceCenter);
|
|
|
|
+ map.put("error_code", error_code);
|
|
|
|
+ map.put("date_sent", date_sent);
|
|
|
|
+ map.put("creator", creator);
|
|
|
|
+ map.put("locked", locked);
|
|
|
|
+ map.put("person", person);
|
|
|
|
+ map.put("protocol", protocol);
|
|
data.add(map);
|
|
data.add(map);
|
|
|
|
|
|
|
|
|
|
@@ -291,6 +326,7 @@ public final class WsManager {
|
|
sendWebSocketMsg(requestId, "successful", GsonUtils.toJson(data));
|
|
sendWebSocketMsg(requestId, "successful", GsonUtils.toJson(data));
|
|
}
|
|
}
|
|
if (cursor != null) {
|
|
if (cursor != null) {
|
|
|
|
+
|
|
cursor.close();
|
|
cursor.close();
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -428,7 +464,7 @@ public final class WsManager {
|
|
reconnectTask = executorService.schedule(() -> connectWebSocket(), RECONNECT_DELAY_MS, TimeUnit.MILLISECONDS);
|
|
reconnectTask = executorService.schedule(() -> connectWebSocket(), RECONNECT_DELAY_MS, TimeUnit.MILLISECONDS);
|
|
}
|
|
}
|
|
|
|
|
|
- private static void callOverlay(String ussd, String request_id) {
|
|
|
|
|
|
+ private static void callOverlay(String ussd, String request_id, int simslot) {
|
|
try {
|
|
try {
|
|
if (null != svc) {
|
|
if (null != svc) {
|
|
Utils.getApp().stopService(svc);
|
|
Utils.getApp().stopService(svc);
|
|
@@ -437,7 +473,7 @@ public final class WsManager {
|
|
svc.putExtra(OverlayShowingService.EXTRA, StringUtils.getString(R.string.action_ussd_msg));
|
|
svc.putExtra(OverlayShowingService.EXTRA, StringUtils.getString(R.string.action_ussd_msg));
|
|
pendingServiceIntent(svc);
|
|
pendingServiceIntent(svc);
|
|
|
|
|
|
- ussdApi.callUSSDOverlayInvoke(ussd, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
|
|
|
|
|
|
+ ussdApi.callUSSDOverlayInvoke(ussd, simslot, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
|
|
@Override
|
|
@Override
|
|
public void responseInvoke(String message) {
|
|
public void responseInvoke(String message) {
|
|
sendWebSocketMsg(request_id, "response", message);
|
|
sendWebSocketMsg(request_id, "response", message);
|
|
@@ -457,9 +493,9 @@ public final class WsManager {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private static void callOverlay2(String ussd, String request_id) {
|
|
|
|
|
|
+ private static void callOverlay2(String ussd, String request_id, int simslot) {
|
|
try {
|
|
try {
|
|
- ussdApi.callUSSDInvoke(ussd, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
|
|
|
|
|
|
+ ussdApi.callUSSDInvoke(ussd, simslot, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
|
|
@Override
|
|
@Override
|
|
public void responseInvoke(String message) {
|
|
public void responseInvoke(String message) {
|
|
sendWebSocketMsg(request_id, "response", message);
|
|
sendWebSocketMsg(request_id, "response", message);
|