yy1717
2020-09-29 2cfc22e1ea5140861499ee5b7142766fb8f754f7
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);
}