Procházet zdrojové kódy

3.0 optimize:优化注册能力callback, 2.ASR语音由后台配置

xwh před 3 týdny
rodič
revize
792b1fa8dc

+ 10 - 2
app/src/main/java/com/hh/arome/activity/MainActivity.java

@@ -6,6 +6,7 @@ import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
 import android.widget.ImageView;
@@ -64,6 +65,7 @@ import com.hh.lib_infrared.InfraredInvoker;
 import com.hh.lib_print.PrinterInvoker;
 import com.hh.lib_qr.QRCodeInvoker;
 import com.hh.lib_record.RecordInvoker;
+import com.hh.lib_record.bean.MicrophoneTypeEnum;
 import com.hh.lib_social_security_card.SSCardInvoker;
 import com.hh.lib_tts.SpeechInvoler;
 import com.hh.lib_tts.voice.MTTSDemo;
@@ -247,8 +249,13 @@ public class MainActivity extends BaseMVPActivity<MainPresenter> implements View
             QRCodeInvoker.getInstance().init();
         }
        // R.color.material_on_background_disabled
-        //初始化实时语音
-        RecordInvoker.getInstance().initRecord();
+        boolean isOpenMicrophone = deviceConfigBean.isOpenMicrophone();
+        int microphoneType = deviceConfigBean.getMicrophoneType();
+        if (isOpenMicrophone &&
+                microphoneType == MicrophoneTypeEnum.NATIVE_AUDI0.getValue()) {
+            //初始化实时语音
+            RecordInvoker.getInstance().initRecord();
+        }
         isOpenPrinter=deviceConfigBean.isOpenPrinter();
         if(isOpenPrinter){
             PrinterInvoker.getInstance().initPrint(deviceConfigBean.getPrinterConfig());
@@ -674,6 +681,7 @@ public class MainActivity extends BaseMVPActivity<MainPresenter> implements View
         if(dataBean==null){
             return;
         }
+        dataBean.setBridgeCallback(bridgeCallback);
        // Log.i("____________123",dataBean.getAction()+"  "+dataBean.getParams());
         //设备能力
         DevicesInvoker.getInstance().onCalled(MainActivity.this,dataBean,bridgeCallback);

+ 2 - 2
config.gradle

@@ -7,8 +7,8 @@ ext {
 //            minSdkVersion    : 24,
             minSdkVersion    : 21,
             targetSdkVersion : 22,
-            versionCode      : 80,
-            versionName      : "3.1.1.241206"
+            versionCode      : 81,
+            versionName      : "3.2.0.241216"
     ]
     //依赖 配置
     dependencies = [

+ 32 - 1
lib_asr/src/main/java/com/hh/lib_asr/ASRInvoker.java

@@ -13,7 +13,9 @@ import com.hh.lib_ampe.utils.AromeInvoker;
 import com.hh.lib_ampe.utils.MyTypeToken;
 import com.hh.lib_asr.bean.AmpeAsrRequestBean;
 import com.hh.lib_base.BaseApplication;
+import com.hh.lib_base.ConfigData;
 import com.hh.lib_base.Constants;
+import com.hh.lib_base.bean.device.DeviceConfigResultBean;
 import com.hh.lib_base.log.UploadLogUtils;
 import com.hh.lib_base.utils.GsonUtils;
 import com.mpaas.asrlibrary.AsrSDK;
@@ -41,7 +43,11 @@ public class ASRInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
+        if(isUnEnabledHardware(dataBean,bridgeCallback)){
+            AromeInvoker.getAromeInvoker()
+                    .hardwareNotEnabled(dataBean, bridgeCallback);
+            return;
+        }
         if (!ACTION_DOASR.equals(dataBean.getAction())) { //TODO 不是ASR语音识别功能,return
             return;
         }
@@ -59,6 +65,31 @@ public class ASRInvoker {
 
     }
 
+    /**
+     *
+     * @author xwh
+     * Time 2024/12/13
+     * Description: 是否未开启该模块
+     * @return true:是该模块的消息并且未启用该模块
+     **/
+    private boolean isUnEnabledHardware(BaseAmpeRequestBean dataBean, AromeServiceInvoker.BridgeCallback bridgeCallback) {
+        DeviceConfigResultBean configResultBean = ConfigData.getDeviceConfigResultBean();
+        boolean isOpenMicrophone = true;
+        if (configResultBean != null) {
+            isOpenMicrophone = configResultBean.isOpenMicrophone();
+        }
+        int microphoneType = configResultBean.getMicrophoneType();
+        String action = dataBean.getAction();
+        if(action != null && Constants.Ampe.ACTION_DOASR.equals(action)){
+            if(!isOpenMicrophone ){
+                return true;
+            }
+            if(microphoneType != 2 ){   //MicrophoneTypeEnum.ASR.getValue() ASR语音) //不是ASR语音也拦截
+                return true;
+            }
+        }
+        return false;
+    }
 
     /**
      *

+ 19 - 0
lib_base/src/main/java/com/hh/lib_base/bean/device/DeviceConfigResultBean.java

@@ -63,6 +63,9 @@ public class DeviceConfigResultBean implements Serializable{
 
     private boolean isOpenPrinter; //是否开启打印机
     private  int  printerConfig=0;//打印机类型
+
+    private boolean isOpenMicrophone; //是否启用麦克风
+    private int  microphoneType;  // 1.原生音频流 2.数科asr
     /**
      * NFC(1, "NFC在线阅读器"),
      * TB(2, "天波阅读器"),
@@ -563,6 +566,22 @@ public class DeviceConfigResultBean implements Serializable{
         this.appletEnterPageUrl = appletEnterPageUrl;
     }
 
+    public boolean isOpenMicrophone() {
+        return isOpenMicrophone;
+    }
+
+    public void setOpenMicrophone(boolean openMicrophone) {
+        isOpenMicrophone = openMicrophone;
+    }
+
+    public int getMicrophoneType() {
+        return microphoneType;
+    }
+
+    public void setMicrophoneType(int microphoneType) {
+        this.microphoneType = microphoneType;
+    }
+
     public static class ManualInIdCardAuthDTO implements Serializable {
         public String  appId;
         public String appKey;

+ 0 - 1
lib_device/src/main/java/com/hh/lib_device/DevicesInvoker.java

@@ -59,7 +59,6 @@ public class DevicesInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()) {
             case Constants.Ampe.ACTION_DEVICE: //TODO 设备信息
                 getDeviceInfo(dataBean.getEvent(),dataBean.getTaskId(),bridgeCallback);

+ 0 - 1
lib_face/src/main/java/com/hh/lib_face/BPaaSApiInvoker.java

@@ -90,7 +90,6 @@ public class BPaaSApiInvoker {
         if (isActionrepeatFilter(dataBean, bridgeCallback)) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         if(isUnEnabledHardware(dataBean,bridgeCallback)){
             return;
         }

+ 0 - 1
lib_idcard/src/main/java/com/hh/lib_idcard/IDCardInvoler.java

@@ -55,7 +55,6 @@ public class IDCardInvoler {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         if(isUnEnabledHardware(dataBean,bridgeCallback)){
             return;
         }

+ 0 - 1
lib_infrared/src/main/java/com/hh/lib_infrared/InfraredInvoker.java

@@ -59,7 +59,6 @@ public class InfraredInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()) {
             case Constants.Ampe.ACTION_START_INFRARED_INDUCTION_LISTENER: //TODO 开启红外线感应
                 startInfraredInductionListener(dataBean, bridgeCallback);

+ 0 - 1
lib_nfc/src/main/java/com/lib_nfc/cpu/CPUCardInvoker.java

@@ -48,7 +48,6 @@ public class CPUCardInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()){
 
             case Constants.Ampe.ACTION_NFC_STARTCPUCARDLOOPREAD:

+ 0 - 1
lib_nfc/src/main/java/com/lib_nfc/m1/M1CardInvoker.java

@@ -46,7 +46,6 @@ public class M1CardInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()){
             case Constants.Ampe.ACTION_DOM1LISTENER:
                 doM1Listener(dataBean);

+ 0 - 1
lib_print/src/main/java/com/hh/lib_print/PrinterInvoker.java

@@ -47,7 +47,6 @@ public class PrinterInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         if(isUnEnabledHardware(dataBean,bridgeCallback)){
             return;
         }

+ 0 - 1
lib_qr/src/main/java/com/hh/lib_qr/QRCodeInvoker.java

@@ -51,7 +51,6 @@ public class QRCodeInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         if(isUnEnabledHardware(dataBean,bridgeCallback)){
             return;
         }

+ 38 - 1
lib_record/src/main/java/com/hh/lib_record/RecordInvoker.java

@@ -3,6 +3,7 @@ package com.hh.lib_record;
 import static com.hh.lib_base.Constants.LogcatValue.WARP;
 
 import android.content.Context;
+import android.util.Log;
 
 import com.alipay.arome.aromecli.AromeServiceInvoker;
 import com.google.gson.JsonObject;
@@ -10,14 +11,17 @@ import com.hh.lib_ampe.bean.BaseAmpeRequestBean;
 import com.hh.lib_ampe.utils.AromeInvoker;
 import com.hh.lib_ampe.utils.MyTypeToken;
 import com.hh.lib_base.BaseApplication;
+import com.hh.lib_base.ConfigData;
 import com.hh.lib_base.Constants;
 import com.hh.lib_base.bean.ampe.BaseAmpeAppletResultBean;
+import com.hh.lib_base.bean.device.DeviceConfigResultBean;
 import com.hh.lib_base.log.AppLogUtils;
 import com.hh.lib_base.log.UploadLogUtils;
 import com.hh.lib_base.utils.GsonUtils;
 import com.hh.lib_base.utils.StringUtils;
 import com.hh.lib_base.utils.device.DeviceUtils;
 import com.hh.lib_record.bean.AmpeRequestRecordBean;
+import com.hh.lib_record.bean.MicrophoneTypeEnum;
 import com.hh.lib_record.microphone.IMicroPhoneSizeCallback;
 import com.hh.lib_record.microphone.ZlwRecordManager;
 import com.hh.lib_record.recorder.RecordService;
@@ -46,7 +50,11 @@ public class RecordInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
+        if(isUnEnabledHardware(dataBean,bridgeCallback)){
+            AromeInvoker.getAromeInvoker()
+                    .hardwareNotEnabled(dataBean, bridgeCallback);
+            return;
+        }
         switch (dataBean.getAction()) {
             case Constants.Ampe.ACTION_START_MICROPHONE_LISTENER:
                 BaseAmpeRequestBean<AmpeRequestRecordBean> newBean= MyTypeToken.
@@ -66,6 +74,35 @@ public class RecordInvoker {
 
     }
 
+    /**
+     *
+     * @author xwh
+     * Time 2024/12/13
+     * Description: 是否未开启该模块
+     * @return true:是该模块的消息并且未启用该模块
+     **/
+    private boolean isUnEnabledHardware(BaseAmpeRequestBean dataBean, AromeServiceInvoker.BridgeCallback bridgeCallback) {
+        DeviceConfigResultBean configResultBean = ConfigData.getDeviceConfigResultBean();
+        boolean isOpenMicrophone = true;
+        if (configResultBean != null) {
+            isOpenMicrophone = configResultBean.isOpenMicrophone();
+        }
+        int microphoneType = configResultBean.getMicrophoneType();
+
+        String action = dataBean.getAction();
+        if(action != null && (Constants.Ampe.ACTION_START_MICROPHONE_LISTENER.equals(action) ||
+                Constants.Ampe.ACTION_STOP_MICROPHONE_LISTENER.equals(action) )){
+            if(!isOpenMicrophone){
+                return true;
+            }
+            if(microphoneType != MicrophoneTypeEnum
+                    .NATIVE_AUDI0.getValue()){  //MicrophoneTypeEnum.NATIVE_AUDI0.getValue() A原生语音) //不是A原生语音也拦截
+                return true;
+            }
+        }
+        return false;
+    }
+
     // 麦克风
     public void initRecord(){
         String deviceModel = DeviceUtils.getDeviceModel();

+ 27 - 0
lib_record/src/main/java/com/hh/lib_record/bean/MicrophoneTypeEnum.java

@@ -0,0 +1,27 @@
+package com.hh.lib_record.bean;
+
+/**
+ * Description: 麦克风类型
+ * @author xwh
+ * time 2024/12/13
+ **/
+public enum MicrophoneTypeEnum {
+    NATIVE_AUDI0(1),ASR(2);
+
+    private int value;
+    MicrophoneTypeEnum(int value){
+        this.value = value;
+    }
+    public int getValue() {
+        return value;
+    }
+
+    public static MicrophoneTypeEnum fromValue(int value) {
+        for (MicrophoneTypeEnum type : MicrophoneTypeEnum.values()) {
+            if (type.getValue() == value) {
+                return type;
+            }
+        }
+        return NATIVE_AUDI0; // 或者抛出一个异常,如果你确定这种情况不应该发生
+    }
+}

+ 0 - 1
lib_social_security_card/src/main/java/com/hh/lib_social_security_card/SSCardInvoker.java

@@ -41,7 +41,6 @@ public class SSCardInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()){
             case Constants.Ampe.ACTION_SOCIALSECURITYCARDINFO:
                 startSSCardReader();

+ 0 - 1
lib_tts/src/main/java/com/hh/lib_tts/SpeechInvoler.java

@@ -42,7 +42,6 @@ public class SpeechInvoler {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()) {
             case Constants.Ampe.ACTION_SPEECH: //TODO 语音播报
                 onCalledSpeech(context,dataBean,bridgeCallback);

+ 0 - 1
secondaryscreen/src/main/java/com/hh/arome/secondaryscreen/SecondaryScreenPageInvoker.java

@@ -41,7 +41,6 @@ public class SecondaryScreenPageInvoker {
         if (dataBean == null) {
             return;
         }
-        dataBean.setBridgeCallback(bridgeCallback);
         switch (dataBean.getAction()) {
             case Constants.Ampe.ACTION_OPENSECONDARYSCREEN:  //开启副屏
                 openSecondaryScreen(dataBean,bridgeCallback);