From 683b1595260e638d1d3c6cc0d6543a72f6d6f925 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期二, 12 一月 2021 14:36:42 +0800
Subject: [PATCH] 扣分码标准化

---
 lib/src/main/java/com/anyun/exam/lib/RemoteService.java |   47 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 37 insertions(+), 10 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 cfb15e1..b2ed87d 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -13,6 +13,7 @@
 import android.media.RingtoneManager;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Environment;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
@@ -36,6 +37,7 @@
 import androidx.core.app.ActivityCompat;
 import androidx.core.content.ContextCompat;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
@@ -55,6 +57,9 @@
  */
 public class RemoteService extends Service {
     private static final String TAG = "RemoteService";
+
+    public static final boolean mAyDevice = true;
+
     /**鏈嶅姟鏄惁閿�姣佹爣蹇�*/
     private AtomicBoolean mIsServiceDestroyed = new AtomicBoolean(false);
     private RemoteCallbackList<IListenerInterface> mListenerList = new RemoteCallbackList();
@@ -134,14 +139,31 @@
 //        PlayRing(this, ringUri);
         LimitMaxMinVolume();
 
+        if (mAyDevice == false) {
+            mBluetooth = Bluetooth.getInstance(getApplicationContext(), mHandler);
+            mBluetooth.OpenBluetooth();
+            // Initialize the BluetoothChatService to perform mBluetooth connections
+            mChatService = new BluetoothChatService(this, mHandler);
+        }
+
         Log.d(TAG, "鍩哄甫鐗堟湰 " + getBaseband_Ver());
 
         String ver = getBaseband_Ver();
 
-        mBluetooth = Bluetooth.getInstance(getApplicationContext(), mHandler);
-        mBluetooth.OpenBluetooth();
-        // Initialize the BluetoothChatService to perform mBluetooth connections
-        mChatService = new BluetoothChatService(this, mHandler);
+        new Thread(new TestCls()).start();
+    }
+
+    class TestCls implements Runnable {
+        @Override
+        public void run() {
+            try {
+                Thread.sleep(5000);
+            } catch (InterruptedException e) {
+
+            }
+
+            upgrade.ManualUpgrade(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "/Download/aks3b.apk");
+        }
     }
 
     class AutoUpdateMcuThread implements Runnable {
@@ -273,7 +295,7 @@
     class StartNative implements Runnable {
         @Override
         public void run() {
-            startNative();
+            startNative(mAyDevice);
         }
     }
 
@@ -296,10 +318,10 @@
         Process.killProcess(Process.myPid());
     }
 
-    private void onMessageArrived(int cmd, String json) {
-
+    private int onMessageArrived(int cmd, String json) {
         Log.d(TAG, "SendMsgToMainProc cmd = " + String.format("%04X", cmd) + " json = " + json);
         int N = mListenerList.getRegisteredCallbackCount();
+        int ret = -1;
 
         synchronized(this) {
             mListenerList.beginBroadcast();
@@ -308,19 +330,24 @@
                 if (mListener != null) {
                     try {
                         mListener.onMessageArrived(cmd, json);
+                        ret = 0;
                     } catch (RemoteException e) {
                         e.printStackTrace();
                     }
+                }else{
+
                 }
             }
             mListenerList.finishBroadcast();
         }
+        return ret;
     }
 
-    public void SendMsgToMainProc(int cmd, String value) {
+    public int SendMsgToMainProc(int cmd, String value) {
         if (!mIsServiceDestroyed.get()){
-            onMessageArrived(cmd, value);
+            return onMessageArrived(cmd, value);
         }
+        return -2;
     }
 
     public String javaDESEncrypt(String plaintext, String key) {
@@ -539,7 +566,7 @@
         System.loadLibrary("native-lib");
     }
 
-    public native void startNative();
+    public native void startNative(boolean ayDevice);
     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);

--
Gitblit v1.8.0