From 3ce7d9cbccabf7f94d8203a98796599cd9dd5411 Mon Sep 17 00:00:00 2001
From: fctom1215 <fctom1215@outlook.com>
Date: 星期二, 11 二月 2020 17:14:27 +0800
Subject: [PATCH] 修改了上坡起步。
---
lib/src/main/java/com/anyun/exam/lib/RemoteService.java | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
index 5cd8834..d6ba6fd 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -16,6 +16,7 @@
import androidx.annotation.Nullable;
+import java.io.UnsupportedEncodingException;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -52,8 +53,18 @@
@Override
public void SendCmd(int cmd, String value) throws RemoteException {
- Log.d(TAG, "Process " + Process.myPid() + " Thread " + Thread.currentThread().getId() + " RecvMsgFromMainProc cmd = " + String.format(" %04X ", cmd) + " length " + value.length() + " value " + value.trim());
- MainProcMsgEntry(cmd, value.trim());
+ if (cmd == 0x8100) {
+ try {
+ byte [] file = value.getBytes("ISO-8859-1");
+ Log.d(TAG, byte2hex(file));
+ MainProcBinMsgEntry(cmd, file, file.length);
+ } catch (UnsupportedEncodingException e) {
+ Log.d(TAG, "UnsupportedEncodingException");
+ }
+ } else {
+ Log.d(TAG, "Process " + Process.myPid() + " Thread " + Thread.currentThread().getId() + " RecvMsgFromMainProc cmd = " + String.format(" %04X ", cmd) + " length " + value.length() + " value " + value.trim());
+ MainProcMsgEntry(cmd, value.trim());
+ }
}
};
@Nullable
@@ -108,6 +119,9 @@
if (!mIsServiceDestroyed.get()){
onMessageArrived(cmd, value);
}
+
+
+
Log.d(TAG, "SendMsgToMainProc cmd = " + String.format("%04X", cmd) + " json = " + value);
}
@@ -136,6 +150,23 @@
}
}
+ private String byte2hex(byte [] buffer){
+ StringBuilder h = new StringBuilder();
+
+ Log.d(TAG, "byte buffer length = " + buffer.length);
+
+ for(int i = 0; i < buffer.length; i++){
+ String temp = Integer.toHexString(buffer[i] & 0xFF);
+ if(temp.length() == 1){
+ temp = "0" + temp;
+ }
+ h.append(temp);
+ h.append(" ");
+ }
+
+ return h.toString();
+ }
+
// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("native-lib");
@@ -143,4 +174,5 @@
public native void startNative();
public native void MainProcMsgEntry(int cmd, String value);
+ public native void MainProcBinMsgEntry(int cmd, byte []data, int length);
}
--
Gitblit v1.8.0