From 2cfc22e1ea5140861499ee5b7142766fb8f754f7 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期二, 29 九月 2020 15:53:20 +0800
Subject: [PATCH] 坐标

---
 lib/src/main/java/com/anyun/exam/lib/RemoteService.java |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 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 0fd34d3..76ec97f 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -19,14 +19,18 @@
 
 import com.anyun.exam.lib.util.DESUtil;
 import com.anyun.exam.lib.util.NetUtils;
+import com.anyun.exam.lib.util.ProperUtil;
 import com.anyun.exam.lib.util.Speaker;
 import com.anyun.exam.lib.util.SpeakerCallback;
 
 import androidx.annotation.Nullable;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
@@ -77,7 +81,7 @@
                     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());
+                Log.d(TAG, "Process " + Process.myPid() + " Thread " + Thread.currentThread().getId() + " RecvMsgFromMainProc cmd = " + String.format(" %04X ", cmd) + " length " + value.length());
                 MainProcMsgEntry(cmd, value.trim());
             }
         }
@@ -98,6 +102,8 @@
 
         new Thread(new TestThread()).start();
 
+        new Thread(new AutoUpdateMcuThread(this)).start();
+
         upgrade = Upgrade.getInstance(getApplicationContext());
         upgrade.CheckUpgrade();
 
@@ -108,6 +114,44 @@
         Log.d(TAG, "鍩哄甫鐗堟湰 " + getBaseband_Ver());
 
         String ver = getBaseband_Ver();
+    }
+
+    class AutoUpdateMcuThread implements Runnable {
+        private Context context;
+
+        public AutoUpdateMcuThread(Context context) {
+            this.context = context;
+        }
+
+        @Override
+        public void run() {
+            Properties proper = ProperUtil.getProperties(getApplicationContext());
+            if (proper != null) {
+                String assetVer = proper.getProperty("mcuVersion");
+
+                if (assetVer != null) {
+                    try {
+                        InputStream inputStream = context.getAssets().open("dfu.bin");
+
+                        if (inputStream != null) {
+                            int fileLength = inputStream.available();
+                            Log.d(TAG, "AutoUpdateMcu " + fileLength);
+
+                            if (fileLength > 0) {
+                                byte[] temp = new byte[fileLength];
+                                inputStream.read(temp);
+
+                                UpgradeMcu(assetVer, temp);
+                            }
+                            inputStream.close();
+                        }
+                    } catch (IOException e) {
+
+                    }
+                }
+            }
+
+        }
     }
 
     private void LimitMaxMinVolume() {
@@ -326,5 +370,6 @@
     public native void startNative();
     public native void MainProcMsgEntry(int cmd, String value);
     public native void MainProcBinMsgEntry(int cmd, byte []data, int length);
+    public native void UpgradeMcu(String vercode, byte []rom);
     public native void TextSpeakEnd(int id);
 }

--
Gitblit v1.8.0