From 10e4ece2f9c58fffc4ab9c3c2c5be95941005888 Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期一, 06 一月 2020 11:36:11 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge

---
 lib/src/main/java/com/anyun/exam/lib/RemoteService.java |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 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 af461da..90bab00 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -11,6 +11,7 @@
 
 import com.anyun.exam.lib.util.DESUtil;
 import com.anyun.exam.lib.util.NetUtils;
+import com.anyun.exam.lib.util.Speaker;
 
 import androidx.annotation.Nullable;
 
@@ -30,6 +31,8 @@
     private RemoteCallbackList<IListenerInterface> mListenerList = new RemoteCallbackList();
     private IListenerInterface mListener;
     private int msgId = 0;
+    private Speaker speaker = null;
+
     private IRemoteInterface.Stub iRemoteInterface = new IRemoteInterface.Stub(){
         @Override
         public void registListener(IListenerInterface i) throws RemoteException {
@@ -59,6 +62,8 @@
     public void onCreate() {
         super.onCreate();
         Log.i(TAG,"onCreate()");
+        speaker = new Speaker(getApplicationContext());
+
         startNative();
         new Thread(new Worker()).start();
     }
@@ -69,7 +74,7 @@
         public void run() {
             while (!mIsServiceDestroyed.get()){
                 try {
-                    Thread.sleep(4*1000);
+                    Thread.sleep(1000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
@@ -88,8 +93,12 @@
 
     private void onMessageArrived(String json){
         int N = mListenerList.getRegisteredCallbackCount();
+
+        Log.d(TAG, "getRegisteredCallbackCount = " + N);
+        mListenerList.beginBroadcast();
+
         for (int i = 0; i < N; i++) {
-            mListenerList.beginBroadcast();
+
             mListener  = mListenerList.getBroadcastItem(i);
             if (mListener != null){
                 try {
@@ -98,8 +107,9 @@
                     e.printStackTrace();
                 }
             }
-            mListenerList.finishBroadcast();
+
         }
+        mListenerList.finishBroadcast();
     }
 
     public String javaGetImei() {
@@ -163,9 +173,9 @@
     }
 
     public void TextSpeak(String text) {
-/*        if (speaker != null) {
+        if (speaker != null) {
             speaker.speak(text);
-        }*/
+        }
     }
 
     // Used to load the 'native-lib' library on application startup.

--
Gitblit v1.8.0