2 Commits 00bcd3220b ... 0b693c6aec

Author SHA1 Message Date
  xulh 0b693c6aec 2.7.5 改动ZlwRecordManager未单例,各类判空 6 months ago
  xulh 299a5f80fe 2.7.5 1.D2有时候打印无反应 6 months ago
74 changed files with 2850 additions and 552 deletions
  1. 4 2
      MultiReaderLib/build.gradle
  2. 5 2
      SeriaApp/build.gradle
  3. 1 1
      SeriaApp/src/main/java/com/silencefun/comtest/serialport/SerialPort.java
  4. 28 7
      app/build.gradle
  5. BIN
      app/libs/armeabi-v7a/libBDSpeechDecoder_V1.so
  6. BIN
      app/libs/armeabi-v7a/libbd_etts.so
  7. BIN
      app/libs/armeabi-v7a/libbdtts.so
  8. BIN
      app/libs/armeabi-v7a/libgnustl_shared.so
  9. BIN
      app/libs/com.baidu.tts_2.3.0.jar
  10. BIN
      app/libs/posutil_sdk_20231226.jar
  11. BIN
      app/libs/printlib-debug.aar
  12. BIN
      app/src/main/assets/bd_etts_speech_female.dat
  13. BIN
      app/src/main/assets/bd_etts_speech_male.dat
  14. BIN
      app/src/main/assets/bd_etts_text.dat
  15. 3 0
      app/src/main/assets/voice.properties
  16. 20 9
      app/src/main/java/com/hh/arome/broadcastreceiver/AutoStartBroadReceiver.java
  17. 1 0
      app/src/main/java/com/hh/arome/common/Constants.java
  18. 0 2
      app/src/main/java/com/hh/arome/common/deviceui/BaseDeviceUI.java
  19. 20 0
      app/src/main/java/com/hh/arome/common/deviceui/D2DeviceUI.java
  20. 5 0
      app/src/main/java/com/hh/arome/common/deviceui/IDeviceUI.java
  21. 10 0
      app/src/main/java/com/hh/arome/common/deviceui/K8DeviceUI.java
  22. 10 0
      app/src/main/java/com/hh/arome/common/deviceui/MlaDeviceUI.java
  23. 10 0
      app/src/main/java/com/hh/arome/common/deviceui/NullDeviceUI.java
  24. 10 0
      app/src/main/java/com/hh/arome/common/deviceui/ZpDeviceUI.java
  25. 31 3
      app/src/main/java/com/hh/arome/common/microphone/ZlwRecordManager.java
  26. 146 146
      app/src/main/java/com/hh/arome/common/scan/broadcast/D2Scan.java
  27. 6 6
      app/src/main/java/com/hh/arome/common/scan/broadcast/base/BaseBroadcastScan.java
  28. 265 265
      app/src/main/java/com/hh/arome/common/scan/broadcast/d2/SerialRecvThread.java
  29. 5 1
      app/src/main/java/com/hh/arome/common/scan/idcard/manymodels/XzxIDCardScan.java
  30. 8 2
      app/src/main/java/com/hh/arome/common/scan/idcard/manymodels/er301/ReadCardManagerER301.java
  31. 336 0
      app/src/main/java/com/hh/arome/common/voice/BaiduVoice.java
  32. 6 6
      app/src/main/java/com/hh/arome/common/voice/BaseVoice.java
  33. 0 1
      app/src/main/java/com/hh/arome/services/keeplive/LocalService.kt
  34. 0 1
      app/src/main/java/com/hh/arome/ui/Gridadapter.java
  35. 217 64
      app/src/main/java/com/hh/arome/ui/MainActivity.java
  36. 0 1
      app/src/main/java/com/hh/arome/ui/setting/PushActivity.java
  37. 0 3
      app/src/main/java/com/hh/arome/ui/setting/SettingActivity.java
  38. 0 1
      app/src/main/java/com/hh/arome/ui/setting/SystemConfigActivity.java
  39. 1 1
      app/src/main/java/com/hh/arome/utlis/data/Config.java
  40. 0 7
      app/src/main/java/com/hh/arome/utlis/device/DeviceUtils.java
  41. 1 0
      app/src/main/java/com/hh/arome/utlis/log/AppLogUtils.java
  42. 5 0
      app/src/main/java/com/hh/arome/utlis/log/LogType.java
  43. 0 4
      app/src/main/java/com/hh/arome/utlis/log/PrintToFileUtil.java
  44. 25 0
      app/src/main/res/layout/activity_main.xml
  45. 25 0
      app/src/main/res/layout/activity_main_hp.xml
  46. 2 2
      config.gradle
  47. 11 1
      idCard/build.gradle
  48. 5 1
      idCard/src/main/java/com/synjones/idcardusb_reader/IDCardReaderThread.java
  49. 58 0
      lib_arome/.gitignore
  50. 52 0
      lib_arome/build.gradle
  51. 0 0
      lib_arome/consumer-rules.pro
  52. 21 0
      lib_arome/proguard-rules.pro
  53. 26 0
      lib_arome/src/androidTest/java/com/common/arome/ExampleInstrumentedTest.java
  54. 8 0
      lib_arome/src/main/AndroidManifest.xml
  55. 35 0
      lib_arome/src/main/java/com/common/arome/Constants.java
  56. 157 0
      lib_arome/src/main/java/com/common/arome/DeviceUtils.java
  57. 17 0
      lib_arome/src/test/java/com/common/arome/ExampleUnitTest.java
  58. 4 0
      lib_base/src/main/java/com/common/lib_base/utils/NetworkUtils.java
  59. 43 0
      lib_base/src/main/java/com/common/lib_base/utils/app/AppUtils.java
  60. 24 5
      lib_print/build.gradle
  61. BIN
      lib_print/libs/printlib-debug.aar
  62. BIN
      lib_print/libs/telpo_sdk_20240108_noserial.jar
  63. BIN
      lib_print/libs/telpo_sdk_210726_new.jar
  64. 231 0
      lib_print/src/main/java/com/common/print/BasePrinter.java
  65. 62 0
      lib_print/src/main/java/com/common/print/IPrinter.java
  66. 15 0
      lib_print/src/main/java/com/common/print/callback/PrintInitResultCallback.java
  67. 328 0
      lib_print/src/main/java/com/common/print/many/MlaPrinter.java
  68. 82 0
      lib_print/src/main/java/com/common/print/many/NullPrinter.java
  69. 316 0
      lib_print/src/main/java/com/common/print/many/TbPrinter.java
  70. 135 0
      lib_print/src/main/java/com/common/print/utils/BitmapUtils.java
  71. 1 1
      lib_print/src/main/java/com/common/print/utils/CodeUtils.java
  72. 1 6
      lib_print/src/main/java/com/telpo/tps508/PrintUtile.java
  73. 11 1
      recorderlib/build.gradle
  74. 1 0
      settings.gradle

+ 4 - 2
MultiReaderLib/build.gradle

@@ -1,8 +1,10 @@
 apply plugin: 'com.android.library'
 
 android {
-    compileSdkVersion 23
-    buildToolsVersion '21.1.2'
+//    compileSdkVersion 23
+//    buildToolsVersion '21.1.2'
+    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
+    buildToolsVersion rootProject.ext.android["buildToolsVersion"]
     defaultConfig {
         targetSdkVersion 22
         minSdkVersion 14

+ 5 - 2
SeriaApp/build.gradle

@@ -1,6 +1,8 @@
 apply plugin: 'com.android.library'
 android {
-    compileSdkVersion 25
+//    compileSdkVersion 25
+    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
+    buildToolsVersion rootProject.ext.android["buildToolsVersion"]
     defaultConfig {
         minSdkVersion 19
         targetSdkVersion 25
@@ -12,7 +14,8 @@ android {
             }
             ndk{
                 // 打包生成的 APK 文件指挥包含 ARM 指令集的动态库
-                abiFilters "armeabi-v7a" /*, "arm64-v8a", "x86", "x86_64"*/
+                abiFilters "armeabi-v7a"
+                /*, "arm64-v8a", "x86", "x86_64"*/
             }
         }
     }

+ 1 - 1
SeriaApp/src/main/java/com/silencefun/comtest/serialport/SerialPort.java

@@ -46,9 +46,9 @@ public class SerialPort {
        // mFd = open(device.getAbsolutePath(), baudrate, flags);
 
 //        mFd = open(device.getAbsolutePath(), baudrate,dataBits,stopBits,parity);
-//        mFd = open(device.getAbsolutePath(), baudrate, 1, 8, 0, 0, 0);
 //        mFd = open(device.getAbsolutePath(), baudrate,dataBits,stopBits,parity, 0, 0);
         mFd = open(device.getAbsolutePath(), baudrate, 1, 8, 0, 0, 0);
+//        mFd = open(device.getAbsolutePath(), baudrate, stopBits, dataBits, 0, 0, 0);
         if (mFd == null) {
             Log.e(TAG, "native open returns null");
             throw new IOException();

+ 28 - 7
app/build.gradle

@@ -46,10 +46,15 @@ android {
     }
 
     buildTypes {
+        // 因为支付宝刷脸需要包名一致,所以以后仅使用release版本,不再使用debug版本
         release {
 
             // 服务器地址
+            // 正式
             buildConfigField("String", "BASE_URL", "\"https://tx.hz-hanghui.com:8088/\"")
+            // 测试
+//            buildConfigField("String", "BASE_URL", "\"https://test.hz-hanghui.com:18890/\"")
+
             buildConfigField("String", "BASE_API_URL", "\"hanghui-server-platform/\"")
 
             buildConfigField("String", "BASE_URL_OMC", "\"https://hhomc.hz-hanghui.com:8096/\"")
@@ -113,8 +118,15 @@ android {
         debug {
             applicationIdSuffix ".test"
 
-            buildConfigField("String", "BASE_URL", "\"http://192.168.11.17:8081/\"")
-            buildConfigField("String", "BASE_API_URL", "\"hanghui/outapi/\"")
+//            buildConfigField("String", "BASE_URL", "\"https://tx.hz-hanghui.com:8088/\"")
+//            buildConfigField("String", "BASE_API_URL", "\"hanghui-server-platform/\"")
+//
+//            buildConfigField("String", "BASE_URL_OMC", "\"https://hhomc.hz-hanghui.com:8096/\"")
+
+            buildConfigField("String", "BASE_URL", "\"https://test.hz-hanghui.com:18890/\"")
+            buildConfigField("String", "BASE_API_URL", "\"hanghui-server-platform/\"")
+//            buildConfigField("String", "BASE_URL", "\"http://192.168.11.17:8081/\"")
+//            buildConfigField("String", "BASE_API_URL", "\"hanghui/outapi/\"")
 
             buildConfigField("String", "BASE_URL_OMC", "\"http://192.168.11.9:9086/\"")
 
@@ -123,13 +135,16 @@ android {
 
             resValue "string", "app_name", "开发HHArome"
 
-            minifyEnabled false
+            signingConfig signingConfigs.release
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+
             shrinkResources false
+            minifyEnabled false
+            zipAlignEnabled true
 
-            jniDebuggable true
             debuggable true
-            signingConfig signingConfigs.release
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+            jniDebuggable true
+            testCoverageEnabled false
         }
 
     }
@@ -191,13 +206,17 @@ dependencies {
 
     // 添加base依赖
     implementation project(path: ':lib_base')
+//    implementation project(path: ':lib_print')
     // 打印
+    implementation(name: 'printlib-debug', ext: 'aar')
     implementation project(path: ':lib_print')
     // 身份证
 //    implementation project(path: ':lib_idcard')
     // 微信xlog日志
     implementation 'com.elvishew:xlog:1.10.1'
 
+    // 百度语音
+    implementation files('libs/com.baidu.tts_2.3.0.jar')
 
     // 支付宝刷脸
     implementation(name: 'ABCP-API-5.5.2.4-lite', ext: 'aar')
@@ -206,9 +225,11 @@ dependencies {
     // 金联汇通-在线身份证-usb
     implementation files('libs/IDOCR.PubSdk.Android.SerialPort.Release-1.0.4.jar')
     // 关机
-    implementation files('libs/PosUtil.jar')
+//    implementation files('libs/PosUtil.jar')
     // 马里奥y9——硬件所需
     implementation files('libs/OrbbecSSDK_1.0.0.3_0f2b082_240327.jar')
+    // 天波-D2补光灯
+    implementation files('libs/posutil_sdk_20231226.jar')
 
     // 天波-D2
 //    implementation files('libs/telpo_sdk_210726.jar'){

BIN
app/libs/armeabi-v7a/libBDSpeechDecoder_V1.so


BIN
app/libs/armeabi-v7a/libbd_etts.so


BIN
app/libs/armeabi-v7a/libbdtts.so


BIN
app/libs/armeabi-v7a/libgnustl_shared.so


BIN
app/libs/com.baidu.tts_2.3.0.jar


BIN
app/libs/posutil_sdk_20231226.jar


BIN
app/libs/printlib-debug.aar


BIN
app/src/main/assets/bd_etts_speech_female.dat


BIN
app/src/main/assets/bd_etts_speech_male.dat


BIN
app/src/main/assets/bd_etts_text.dat


+ 3 - 0
app/src/main/assets/voice.properties

@@ -0,0 +1,3 @@
+APPID=73914826
+APIKEY=BLXfCDZGPUd6YIUZEzDcENgl
+APIKEYT=F1Rn2nfsZT7KmmFMjKXG0M9itStdWx7R

+ 20 - 9
app/src/main/java/com/hh/arome/broadcastreceiver/AutoStartBroadReceiver.java

@@ -8,8 +8,10 @@ import android.content.pm.PackageManager;
 import android.os.Handler;
 
 import com.common.lib_base.common.local.AppLocalConfigHandler;
+import com.hh.arome.common.Constants;
 import com.hh.arome.common.IAppLocalConfig;
 import com.hh.arome.ui.MainActivity;
+import com.hh.arome.utlis.device.DeviceUtils;
 import com.hh.arome.utlis.log.AppLogUtils;
 
 public class AutoStartBroadReceiver extends BroadcastReceiver {
@@ -46,16 +48,25 @@ public class AutoStartBroadReceiver extends BroadcastReceiver {
 
         // 会收到多次开机广播
 
-        // 判断MainActivity是否已存在
-        Intent intent = new Intent(context, MainActivity.class);
-        if (intent.resolveActivity(context.getPackageManager()) != null) {
-            // Activity存在
-            AppLogUtils.e("MainActivity存在,return");
-            return;
-        } else {
-            // Activity不存在
-            AppLogUtils.e("MainActivity不存在");
+        String deviceModel = DeviceUtils.getDeviceModel();
+        if(Constants.DeviceModel.D2.contains(deviceModel)){
+            // 判断MainActivity是否已存在
+//        Intent intent = new Intent(context, MainActivity.class);
+            Intent intent = new Intent();
+            intent.setClassName("com.hh.arome", "com.hh.arome.ui.MainActivity");
+
+            if (context.getPackageManager().resolveActivity(intent, 0) != null) {
+//        if (intent.resolveActivity(context.getPackageManager()) != null) {
+                // Activity存在
+                AppLogUtils.e("MainActivity存在,return");
+                return;
+            } else {
+                // Activity不存在
+                AppLogUtils.e("MainActivity不存在");
+            }
         }
+
+
 //        PackageManager packageManager = context.getPackageManager();
 //        try {
 //            packageManager.getActivityInfo(new ComponentName(context, MainActivity.class), PackageManager.GET_META_DATA);

+ 1 - 0
app/src/main/java/com/hh/arome/common/Constants.java

@@ -102,6 +102,7 @@ public class Constants {
         public static final String LOG_NODE_MICROPHONE = "麦克风---";
         public static final String LOG_NODE_AIDL = "aidl---";
         public static final String LOG_NODE_INFRARED_INDUCTION = "红外感应---";
+        public static final String LOG_PRINT = "打印---";
 
 
         // 对应web的日志类型

+ 0 - 2
app/src/main/java/com/hh/arome/common/deviceui/BaseDeviceUI.java

@@ -1,7 +1,5 @@
 package com.hh.arome.common.deviceui;
 
-import android.os.Build;
-
 import com.hh.arome.common.Constants;
 import com.hh.arome.utlis.device.DeviceUtils;
 import com.hh.arome.utlis.log.AppLogUtils;

+ 20 - 0
app/src/main/java/com/hh/arome/common/deviceui/D2DeviceUI.java

@@ -3,6 +3,8 @@ package com.hh.arome.common.deviceui;
 import android.app.Activity;
 import android.content.Intent;
 
+import com.common.face.api.FaceUtil;
+
 /**
  * 天波-D2
  */
@@ -31,6 +33,7 @@ public class D2DeviceUI implements IDeviceUI{
     }
 
 
+    // 显示下拉通知栏
     @Override
     public void showNotification(Activity activity) {
         Intent intent = new Intent();
@@ -39,6 +42,7 @@ public class D2DeviceUI implements IDeviceUI{
         activity.sendBroadcast(intent);
     }
 
+    // 禁止下拉通知栏
     @Override
     public void hideNotification(Activity activity) {
         Intent intent = new Intent();
@@ -47,6 +51,7 @@ public class D2DeviceUI implements IDeviceUI{
         activity.sendBroadcast(intent);
     }
 
+    // 显示底部导航栏
     @Override
     public void showNavigationBar(Activity activity) {
         Intent intent = new Intent();
@@ -55,6 +60,7 @@ public class D2DeviceUI implements IDeviceUI{
         activity.sendBroadcast(intent);
     }
 
+    // 隐藏底部导航栏
     @Override
     public void hideNavigationBar(Activity activity) {
         Intent intent = new Intent();
@@ -62,4 +68,18 @@ public class D2DeviceUI implements IDeviceUI{
         intent.putExtra("navigation_bar", "dismiss");
         activity.sendBroadcast(intent);
     }
+
+    @Override
+    public void showFillLight(Activity activity) {
+        FaceUtil.GPIOSet("rgb_led_en",1);//1开,0关
+        FaceUtil.GPIOSet("ir_led_en",1);//1开,0关
+    }
+
+    @Override
+    public void hideFillLight(Activity activity) {
+        FaceUtil.GPIOSet("rgb_led_en",0);//1开,0关
+        FaceUtil.GPIOSet("ir_led_en",0);//1开,0关
+    }
+
+
 }

+ 5 - 0
app/src/main/java/com/hh/arome/common/deviceui/IDeviceUI.java

@@ -16,6 +16,11 @@ public interface IDeviceUI {
     // 隐藏导航栏
     void hideNavigationBar(Activity activity);
 
+    // 打开补光灯
+    void showFillLight(Activity activity);
+
+    // 关闭补光灯
+    void hideFillLight(Activity activity);
 
 
 }

+ 10 - 0
app/src/main/java/com/hh/arome/common/deviceui/K8DeviceUI.java

@@ -56,4 +56,14 @@ public class K8DeviceUI implements IDeviceUI {
         intent.setAction("com.android.internal.policy.impl.hideNavigationBar");
         activity.sendBroadcast(intent);
     }
+
+    @Override
+    public void showFillLight(Activity activity) {
+
+    }
+
+    @Override
+    public void hideFillLight(Activity activity) {
+
+    }
 }

+ 10 - 0
app/src/main/java/com/hh/arome/common/deviceui/MlaDeviceUI.java

@@ -103,4 +103,14 @@ public class MlaDeviceUI implements IDeviceUI{
             }
         });
     }
+
+    @Override
+    public void showFillLight(Activity activity) {
+
+    }
+
+    @Override
+    public void hideFillLight(Activity activity) {
+
+    }
 }

+ 10 - 0
app/src/main/java/com/hh/arome/common/deviceui/NullDeviceUI.java

@@ -46,4 +46,14 @@ public class NullDeviceUI implements IDeviceUI {
     @Override
     public void hideNavigationBar(Activity activity) {
     }
+
+    @Override
+    public void showFillLight(Activity activity) {
+
+    }
+
+    @Override
+    public void hideFillLight(Activity activity) {
+
+    }
 }

+ 10 - 0
app/src/main/java/com/hh/arome/common/deviceui/ZpDeviceUI.java

@@ -62,4 +62,14 @@ public class ZpDeviceUI implements IDeviceUI{
         intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
         activity.sendBroadcast(intent);
     }
+
+    @Override
+    public void showFillLight(Activity activity) {
+
+    }
+
+    @Override
+    public void hideFillLight(Activity activity) {
+
+    }
 }

+ 31 - 3
app/src/main/java/com/hh/arome/common/microphone/ZlwRecordManager.java

@@ -1,5 +1,6 @@
 package com.hh.arome.common.microphone;
 
+import android.app.Activity;
 import android.content.Context;
 import android.media.AudioFormat;
 import android.media.MediaExtractor;
@@ -12,11 +13,13 @@ import android.os.Looper;
 import android.text.TextUtils;
 
 import androidx.annotation.RequiresApi;
+import androidx.fragment.app.FragmentActivity;
 
 import com.blankj.utilcode.util.FileUtils;
 import com.common.lib_base.utils.StringUtils;
 import com.hh.arome.MyApplication;
 import com.hh.arome.common.scan.idcard.callback.IDCardScanResultCallback;
+import com.hh.arome.common.scan.idcard.manymodels.ZlwRecordManager;
 import com.hh.arome.utlis.log.AppLogUtils;
 import com.hh.arome.utlis.log.LogType;
 import com.zlw.main.recorderlib.RecordManager;
@@ -51,7 +54,32 @@ public class ZlwRecordManager {
 
     RecordManager recordManager = RecordManager.getInstance();
 
-    public ZlwRecordManager() {
+
+    //用volatile关键字确保 instance 在多线程下的可见性
+    private static volatile ZlwRecordManager instance = null;
+
+    //将构造方法私有化,禁止外部通过构造方法创建实例
+
+    //提供一个公共的访问方法,用于获取该类的唯一实例
+    public static ZlwRecordManager getInstance(Context context) {
+        //如果instance为空,就进行实例化
+        if (instance == null) {
+            //保证多线程下只有一个线程进行实例化
+            synchronized (ZlwRecordManager.class) {
+                //第二次判断,避免多线程下创建多个实例
+                if (instance == null) {
+                    instance = new ZlwRecordManager(context);
+                }
+            }
+        }
+        return instance;
+    }
+
+
+    Context mContext;
+
+    public ZlwRecordManager(Context context) {
+        this.mContext = context;
         init();
     }
 
@@ -459,10 +487,10 @@ public class ZlwRecordManager {
         boolean orExistsDir = FileUtils.createOrExistsDir(recordFile);
 
         if (!orExistsDir) {
-            AppLogUtils.e("没有该文件");
+            AppLogUtils.e("没有该录音文件");
             return;
         } else {
-            AppLogUtils.e("有该文件");
+            AppLogUtils.e("有该录音文件");
         }
 
         File file = new File(recordFile);

+ 146 - 146
app/src/main/java/com/hh/arome/common/scan/broadcast/D2Scan.java

@@ -1,146 +1,146 @@
-package com.hh.arome.common.scan.broadcast;
-
-import android.app.Activity;
-import android.content.Context;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-
-import androidx.fragment.app.FragmentActivity;
-
-import com.hh.arome.common.scan.broadcast.abstractscan.IBroadcastScan;
-import com.hh.arome.common.scan.broadcast.callback.IScanResultCallback;
-import com.hh.arome.common.scan.broadcast.d2.SerialDataListener;
-import com.hh.arome.common.scan.broadcast.d2.SerialRecvThread;
-import com.hh.arome.utlis.log.AppLogUtils;
-import com.telpo.tps550.api.qrcode.QrcodePower;
-
-import java.util.HashMap;
-
-public class D2Scan implements IBroadcastScan {
-
-    //用volatile关键字确保 instance 在多线程下的可见性
-    private static volatile D2Scan instance = null;
-
-    //将构造方法私有化,禁止外部通过构造方法创建实例
-    private D2Scan() {}
-
-    //提供一个公共的访问方法,用于获取该类的唯一实例
-    public static D2Scan getInstance(Context context) {
-        //如果instance为空,就进行实例化
-        if (instance == null) {
-            //保证多线程下只有一个线程进行实例化
-            synchronized (D2Scan.class) {
-                //第二次判断,避免多线程下创建多个实例
-                if (instance == null) {
-                    instance = new D2Scan(context);
-                }
-            }
-        }
-        return instance;
-    }
-
-
-    Context mContext;
-    Activity mActivity;
-
-
-    public D2Scan(Context context) {
-        if (context instanceof FragmentActivity) {
-            this.mActivity = (Activity) context;
-        }
-        this.mContext = context;
-        init(context);
-    }
-
-    IScanResultCallback listener;
-
-    public void setListener(IScanResultCallback listener) {
-        this.listener = listener;
-    }
-
-
-    QrcodePower qrcodepower;
-    SerialRecvThread serialRecvThread;
-
-    @Override
-    public void init(Context context) {
-
-        qrcodepower = new QrcodePower();
-        serialRecvThread = new SerialRecvThread(mActivity);
-
-        //初始化上电操作改为如下:
-        //上电读头
-        qrcodepower.open_em();
-        if(waitForBarcodeReaderReady()){
-            //二维码读头连接成功,可以继续业务
-            AppLogUtils.e("二维码读头连接成功,可以继续业务");
-        }else{
-            //二维码读头连接失败
-            AppLogUtils.e("二维码读头连接失败");
-        }
-
-
-        //串口通讯
-        SerialDataListener serialDataListener =  new SerialDataListener() {
-            @Override
-            public void onReadSerialData(final String data) {
-                AppLogUtils.e("串口通讯data——"+data);
-            }
-        };
-        serialRecvThread.setListener(serialDataListener);
-        serialRecvThread.start();
-
-
-    }
-
-    @Override
-    public void destory() {
-        serialRecvThread.stop();
-    }
-
-    @Override
-    public void registerBroadcast() {
-
-    }
-
-    @Override
-    public void unregisterBroadcast() {
-
-    }
-
-
-    /**
-     * 上电后调用此方法等待二维码阅读器连接
-     * @return true,连接上  false 连接失败
-     */
-    private boolean waitForBarcodeReaderReady() {
-        for (int count = 0; count < 50; count++) {
-            if (isBarcodeReaderConnected()) {
-                return true;
-            }
-            try {
-                Thread.sleep(200);
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-        return false;
-    }
-
-
-
-    private boolean isBarcodeReaderConnected() {
-        AppLogUtils.e("isBarcodeReaderConnected");
-        UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
-        HashMap<String, UsbDevice> usbList = usbManager.getDeviceList();
-        for (String key : usbList.keySet()) {
-            UsbDevice usbDevice = usbList.get(key);
-            if (usbDevice != null && usbDevice.getProductId() == 0x1d06 && usbDevice.getVendorId() == 0x1eab) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-
-}
+//package com.hh.arome.common.scan.broadcast;
+//
+//import android.app.Activity;
+//import android.content.Context;
+//import android.hardware.usb.UsbDevice;
+//import android.hardware.usb.UsbManager;
+//
+//import androidx.fragment.app.FragmentActivity;
+//
+//import com.hh.arome.common.scan.broadcast.abstractscan.IBroadcastScan;
+//import com.hh.arome.common.scan.broadcast.callback.IScanResultCallback;
+//import com.hh.arome.common.scan.broadcast.d2.SerialDataListener;
+//import com.hh.arome.common.scan.broadcast.d2.SerialRecvThread;
+//import com.hh.arome.utlis.log.AppLogUtils;
+//import com.telpo.tps550.api.qrcode.QrcodePower;
+//
+//import java.util.HashMap;
+//
+//public class D2Scan implements IBroadcastScan {
+//
+//    //用volatile关键字确保 instance 在多线程下的可见性
+//    private static volatile D2Scan instance = null;
+//
+//    //将构造方法私有化,禁止外部通过构造方法创建实例
+//    private D2Scan() {}
+//
+//    //提供一个公共的访问方法,用于获取该类的唯一实例
+//    public static D2Scan getInstance(Context context) {
+//        //如果instance为空,就进行实例化
+//        if (instance == null) {
+//            //保证多线程下只有一个线程进行实例化
+//            synchronized (D2Scan.class) {
+//                //第二次判断,避免多线程下创建多个实例
+//                if (instance == null) {
+//                    instance = new D2Scan(context);
+//                }
+//            }
+//        }
+//        return instance;
+//    }
+//
+//
+//    Context mContext;
+//    Activity mActivity;
+//
+//
+//    public D2Scan(Context context) {
+//        if (context instanceof FragmentActivity) {
+//            this.mActivity = (Activity) context;
+//        }
+//        this.mContext = context;
+//        init(context);
+//    }
+//
+//    IScanResultCallback listener;
+//
+//    public void setListener(IScanResultCallback listener) {
+//        this.listener = listener;
+//    }
+//
+//
+//    QrcodePower qrcodepower;
+//    SerialRecvThread serialRecvThread;
+//
+//    @Override
+//    public void init(Context context) {
+//
+//        qrcodepower = new QrcodePower();
+//        serialRecvThread = new SerialRecvThread(mActivity);
+//
+//        //初始化上电操作改为如下:
+//        //上电读头
+//        qrcodepower.open_em();
+//        if(waitForBarcodeReaderReady()){
+//            //二维码读头连接成功,可以继续业务
+//            AppLogUtils.e("二维码读头连接成功,可以继续业务");
+//        }else{
+//            //二维码读头连接失败
+//            AppLogUtils.e("二维码读头连接失败");
+//        }
+//
+//
+//        //串口通讯
+//        SerialDataListener serialDataListener =  new SerialDataListener() {
+//            @Override
+//            public void onReadSerialData(final String data) {
+//                AppLogUtils.e("串口通讯data——"+data);
+//            }
+//        };
+//        serialRecvThread.setListener(serialDataListener);
+//        serialRecvThread.start();
+//
+//
+//    }
+//
+//    @Override
+//    public void destory() {
+//        serialRecvThread.stop();
+//    }
+//
+//    @Override
+//    public void registerBroadcast() {
+//
+//    }
+//
+//    @Override
+//    public void unregisterBroadcast() {
+//
+//    }
+//
+//
+//    /**
+//     * 上电后调用此方法等待二维码阅读器连接
+//     * @return true,连接上  false 连接失败
+//     */
+//    private boolean waitForBarcodeReaderReady() {
+//        for (int count = 0; count < 50; count++) {
+//            if (isBarcodeReaderConnected()) {
+//                return true;
+//            }
+//            try {
+//                Thread.sleep(200);
+//            } catch (InterruptedException e) {
+//                e.printStackTrace();
+//            }
+//        }
+//        return false;
+//    }
+//
+//
+//
+//    private boolean isBarcodeReaderConnected() {
+//        AppLogUtils.e("isBarcodeReaderConnected");
+//        UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
+//        HashMap<String, UsbDevice> usbList = usbManager.getDeviceList();
+//        for (String key : usbList.keySet()) {
+//            UsbDevice usbDevice = usbList.get(key);
+//            if (usbDevice != null && usbDevice.getProductId() == 0x1d06 && usbDevice.getVendorId() == 0x1eab) {
+//                return true;
+//            }
+//        }
+//        return false;
+//    }
+//
+//
+//}

+ 6 - 6
app/src/main/java/com/hh/arome/common/scan/broadcast/base/BaseBroadcastScan.java

@@ -4,7 +4,7 @@ import android.content.Context;
 import android.os.Build;
 
 import com.hh.arome.common.Constants;
-import com.hh.arome.common.scan.broadcast.D2Scan;
+//import com.hh.arome.common.scan.broadcast.D2Scan;
 import com.hh.arome.common.scan.broadcast.abstractscan.IBroadcastScan;
 import com.hh.arome.common.scan.broadcast.callback.IScanResultCallback;
 import com.hh.arome.utlis.log.AppLogUtils;
@@ -45,11 +45,11 @@ public class BaseBroadcastScan
 
         String model = Build.MODEL;
         AppLogUtils.e("getBaseBroadcastScan--model:"+model);
-        if (Constants.DeviceModel.D2.equals(model)) {
-            D2Scan d2Scan = new D2Scan(context);
-            d2Scan.setListener(iScanResultCallback);
-            return d2Scan;
-        }
+//        if (Constants.DeviceModel.D2.equals(model)) {
+//            D2Scan d2Scan = new D2Scan(context);
+//            d2Scan.setListener(iScanResultCallback);
+//            return d2Scan;
+//        }
         return null;
     }
 

+ 265 - 265
app/src/main/java/com/hh/arome/common/scan/broadcast/d2/SerialRecvThread.java

@@ -1,267 +1,267 @@
-package com.hh.arome.common.scan.broadcast.d2;
-
-import android.content.Context;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.os.Build;
-import android.util.Log;
-
-import androidx.annotation.RequiresApi;
-
-import com.telpo.tps550.api.qrcode.QrcodePower;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.HashMap;
-
-import android_serialport_api.SerialPort;
-
-
-/**
- * Created by ljj on 2018/12/11
- * 读取485的数据
- */
-public class SerialRecvThread implements SerialData{
-
-    private static final String TAG = "HHArome";
-    private InputStream mInputStream;
-    private static SerialPort mSerialPort;
-    private SerialDataListener mListener;
-    private final int baudrate = 9600;//115200;
-    private final int flags = 0;
-    private ReadThread mReadThread;
-    private String mData = "";
-    QrcodePower qrcodePower;
-    private class ReadThread extends Thread {
-
-        @RequiresApi(api = Build.VERSION_CODES.KITKAT)
-        @Override
-        public void run() {
-            super.run();
-            while(!isInterrupted()) {
-                int size;
-                if(!canRunning){
-                    try {
-                        Thread.sleep(200);
-                    } catch (InterruptedException e) {
-                        e.printStackTrace();
-                    }
-                    return;
-                }
-                try {
-
-                    byte[] buffer = new byte[1024];
-                    if (mInputStream == null) {
-                      initSerialPort();
-                      continue;
-                    }
-//                    Log.e(TAG, "SerialQrReaderFactory1  mInputStream.available():"+mInputStream.available());
-                    if(mInputStream.available() == 0 && !mData.isEmpty()){
-                        Log.e(TAG, "SerialQrReaderFactory1_4 bufferStr:"+mData);
-                        String bufferStr1 = mData;
-                        mData = "";
-                        if(mListener != null){
-                            mListener.onReadSerialData(bufferStr1);
-                        }
-                    }
-
-                    //if(mInputStream.available() > 0 ){
-                    size = mInputStream.read(buffer);
-                    if(size > 0) {
-                        String bufferStr = new String(Arrays.copyOf(buffer, size), StandardCharsets.UTF_8);
-//                        Log.e(TAG, "SerialQrReaderFactory1_1 bufferStr:"+bufferStr);
-                        mData += bufferStr;
-                    }
-                    //}
-
-
-                } catch (IOException e) {
-                    initSerialPort();
-                    e.printStackTrace();
-                    mData = "";
-                    //return;
-                }
-                try {
-                    Thread.sleep(200);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-    Context context;
-    private volatile boolean canRunning = false;
-
-    public SerialRecvThread(){
-
-    }
-
-    public SerialRecvThread(Context context){
-        this.context = context;
-    }
-
-//    String pathname = "/dev/ttyS0";//
-//    String pathname = "/dev/ttyS1";//
-//    String pathname = "/dev/ttyACM0";
-//    String pathname = "/dev/ttyACM1";
-    String pathname = "/dev/ttyHSL0";
-
-    /**
-     * 初始化串口
-     */
-    private void initSerialPort() {
-        boolean iniOk = true;
-        if(Build.MODEL.contains("TPS360")){
-            if(!isBarcodeReaderConnected()) {
-                if (qrcodePower == null) {
-                    qrcodePower = new QrcodePower();
-                }
-                qrcodePower.open_em();
-                return;
-            }
-        }
-
-
-        try {
-            if(mSerialPort != null){
-                mSerialPort.close();
-            }
-//            String pathname = "/dev/ttyS1";//AppOptions.getInstance().getSerialDev();
-//            String pathname = "/dev/ttyS0";//AppOptions.getInstance().getSerialDev();
-//            String pathname = "/dev/ttyACM0";//AppOptions.getInstance().getSerialDev();
-//            String pathname = "/dev/ttyACM1";//AppOptions.getInstance().getSerialDev();
-            mSerialPort = new SerialPort(new File(pathname), baudrate, flags);
-            mInputStream = mSerialPort.getInputStream();
-            Log.e(TAG, "initSerialPort ttyACM0 ok baudrate: " + baudrate + " flags: " + flags);
-        } catch (Exception e) {
-            iniOk = false;
-            if(mInputStream != null) {
-                close(mInputStream);
-            }
-            if(mSerialPort != null){
-                mSerialPort.close();
-            }
-            PowerClose360();
-            //Log.e(TAG, e.getMessage());
-        }
-        try {
-            Thread.sleep(1000);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        if(!iniOk){
-            try {
-                if(mSerialPort != null){
-                    mSerialPort.close();
-                }
-//                String pathname = "/dev/ttyACM1";//AppOptions.getInstance().getSerialDev();
-                mSerialPort = new SerialPort(new File(pathname), baudrate, flags);
-                mInputStream = mSerialPort.getInputStream();
-                Log.e(TAG, "initSerialPort ttyACM1 ok baudrate: " + baudrate + " flags: " + flags);
-            } catch (Exception e) {
-                if(mInputStream != null) {
-                    close(mInputStream);
-                }
-                if(mSerialPort != null){
-                    mSerialPort.close();
-                }
-                PowerClose360();
-            }
-        }
-        try {
-            Thread.sleep(1000);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
-    //360设备确认扫码设备是否正常
-    private boolean isBarcodeReaderConnected() {
-        UsbManager usbManager = (UsbManager) this.context.getSystemService(Context.USB_SERVICE);
-        HashMap<String, UsbDevice> usbList = usbManager.getDeviceList();
-        for (String key : usbList.keySet()) {
-            UsbDevice usbDevice = usbList.get(key);
-            if (usbDevice != null && usbDevice.getProductId() == 0x1d06 && usbDevice.getVendorId() == 0x1eab) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 停止线程
-     */
-    @Override
-    public void stop() {
-        Log.e(TAG, "stop");
-        canRunning = false;
-        if (mReadThread != null)
-            mReadThread.interrupt();
-
-        if(mInputStream != null) {
-            close(mInputStream);
-        }
-        if(mSerialPort != null) {
-            mSerialPort.close();
-        }
-        mSerialPort = null;
-        mListener = null;
-        PowerClose360();
-    }
-
-    private void PowerClose360() {
-//        if(Build.MODEL.contains("TPS360")) {
-//            if (qrcodePower == null) {
-//                qrcodePower = new QrcodePower();
+//package com.hh.arome.common.scan.broadcast.d2;
+//
+//import android.content.Context;
+//import android.hardware.usb.UsbDevice;
+//import android.hardware.usb.UsbManager;
+//import android.os.Build;
+//import android.util.Log;
+//
+//import androidx.annotation.RequiresApi;
+//
+//import com.telpo.tps550.api.qrcode.QrcodePower;
+//
+//import java.io.Closeable;
+//import java.io.File;
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.nio.charset.StandardCharsets;
+//import java.util.Arrays;
+//import java.util.HashMap;
+//
+//import android_serialport_api.SerialPort;
+//
+//
+///**
+// * Created by ljj on 2018/12/11
+// * 读取485的数据
+// */
+//public class SerialRecvThread implements SerialData{
+//
+//    private static final String TAG = "HHArome";
+//    private InputStream mInputStream;
+//    private static SerialPort mSerialPort;
+//    private SerialDataListener mListener;
+//    private final int baudrate = 9600;//115200;
+//    private final int flags = 0;
+//    private ReadThread mReadThread;
+//    private String mData = "";
+//    QrcodePower qrcodePower;
+//    private class ReadThread extends Thread {
+//
+//        @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+//        @Override
+//        public void run() {
+//            super.run();
+//            while(!isInterrupted()) {
+//                int size;
+//                if(!canRunning){
+//                    try {
+//                        Thread.sleep(200);
+//                    } catch (InterruptedException e) {
+//                        e.printStackTrace();
+//                    }
+//                    return;
+//                }
+//                try {
+//
+//                    byte[] buffer = new byte[1024];
+//                    if (mInputStream == null) {
+//                      initSerialPort();
+//                      continue;
+//                    }
+////                    Log.e(TAG, "SerialQrReaderFactory1  mInputStream.available():"+mInputStream.available());
+//                    if(mInputStream.available() == 0 && !mData.isEmpty()){
+//                        Log.e(TAG, "SerialQrReaderFactory1_4 bufferStr:"+mData);
+//                        String bufferStr1 = mData;
+//                        mData = "";
+//                        if(mListener != null){
+//                            mListener.onReadSerialData(bufferStr1);
+//                        }
+//                    }
+//
+//                    //if(mInputStream.available() > 0 ){
+//                    size = mInputStream.read(buffer);
+//                    if(size > 0) {
+//                        String bufferStr = new String(Arrays.copyOf(buffer, size), StandardCharsets.UTF_8);
+////                        Log.e(TAG, "SerialQrReaderFactory1_1 bufferStr:"+bufferStr);
+//                        mData += bufferStr;
+//                    }
+//                    //}
+//
+//
+//                } catch (IOException e) {
+//                    initSerialPort();
+//                    e.printStackTrace();
+//                    mData = "";
+//                    //return;
+//                }
+//                try {
+//                    Thread.sleep(200);
+//                } catch (InterruptedException e) {
+//                    e.printStackTrace();
+//                }
 //            }
-//            qrcodePower.close_em();
 //        }
-    }
-
-    /**
-    * 设置返回数据
-    */
-    @Override
-    public void setListener(SerialDataListener listener) {
-        mListener = listener;
-    }
-
-    /**
-    * 关闭流
-    */
-    private void close(Closeable os){
-        if (os != null) {
-            try {
-                os.close();
-            } catch (IOException e) {
-                Log.e(TAG,e.getMessage());
-            }
-        }
-    }
-
-    /**
-     * 输入串口的数据
-     * @param data
-     */
-    @Override
-    public void send(String data) {
-
-    }
-
-    /**
-     * 打开线程 默认参数
-     */
-    @Override
-    public void start(){
-        Log.e(TAG, "start");
-        canRunning = true;
-        initSerialPort();
-        mReadThread = new ReadThread();
-        mReadThread.start();
-    }
-
-}
+//    }
+//    Context context;
+//    private volatile boolean canRunning = false;
+//
+//    public SerialRecvThread(){
+//
+//    }
+//
+//    public SerialRecvThread(Context context){
+//        this.context = context;
+//    }
+//
+////    String pathname = "/dev/ttyS0";//
+////    String pathname = "/dev/ttyS1";//
+////    String pathname = "/dev/ttyACM0";
+////    String pathname = "/dev/ttyACM1";
+//    String pathname = "/dev/ttyHSL0";
+//
+//    /**
+//     * 初始化串口
+//     */
+//    private void initSerialPort() {
+//        boolean iniOk = true;
+//        if(Build.MODEL.contains("TPS360")){
+//            if(!isBarcodeReaderConnected()) {
+//                if (qrcodePower == null) {
+//                    qrcodePower = new QrcodePower();
+//                }
+//                qrcodePower.open_em();
+//                return;
+//            }
+//        }
+//
+//
+//        try {
+//            if(mSerialPort != null){
+//                mSerialPort.close();
+//            }
+////            String pathname = "/dev/ttyS1";//AppOptions.getInstance().getSerialDev();
+////            String pathname = "/dev/ttyS0";//AppOptions.getInstance().getSerialDev();
+////            String pathname = "/dev/ttyACM0";//AppOptions.getInstance().getSerialDev();
+////            String pathname = "/dev/ttyACM1";//AppOptions.getInstance().getSerialDev();
+//            mSerialPort = new SerialPort(new File(pathname), baudrate, flags);
+//            mInputStream = mSerialPort.getInputStream();
+//            Log.e(TAG, "initSerialPort ttyACM0 ok baudrate: " + baudrate + " flags: " + flags);
+//        } catch (Exception e) {
+//            iniOk = false;
+//            if(mInputStream != null) {
+//                close(mInputStream);
+//            }
+//            if(mSerialPort != null){
+//                mSerialPort.close();
+//            }
+//            PowerClose360();
+//            //Log.e(TAG, e.getMessage());
+//        }
+//        try {
+//            Thread.sleep(1000);
+//        } catch (InterruptedException e) {
+//            e.printStackTrace();
+//        }
+//        if(!iniOk){
+//            try {
+//                if(mSerialPort != null){
+//                    mSerialPort.close();
+//                }
+////                String pathname = "/dev/ttyACM1";//AppOptions.getInstance().getSerialDev();
+//                mSerialPort = new SerialPort(new File(pathname), baudrate, flags);
+//                mInputStream = mSerialPort.getInputStream();
+//                Log.e(TAG, "initSerialPort ttyACM1 ok baudrate: " + baudrate + " flags: " + flags);
+//            } catch (Exception e) {
+//                if(mInputStream != null) {
+//                    close(mInputStream);
+//                }
+//                if(mSerialPort != null){
+//                    mSerialPort.close();
+//                }
+//                PowerClose360();
+//            }
+//        }
+//        try {
+//            Thread.sleep(1000);
+//        } catch (InterruptedException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//    //360设备确认扫码设备是否正常
+//    private boolean isBarcodeReaderConnected() {
+//        UsbManager usbManager = (UsbManager) this.context.getSystemService(Context.USB_SERVICE);
+//        HashMap<String, UsbDevice> usbList = usbManager.getDeviceList();
+//        for (String key : usbList.keySet()) {
+//            UsbDevice usbDevice = usbList.get(key);
+//            if (usbDevice != null && usbDevice.getProductId() == 0x1d06 && usbDevice.getVendorId() == 0x1eab) {
+//                return true;
+//            }
+//        }
+//        return false;
+//    }
+//
+//    /**
+//     * 停止线程
+//     */
+//    @Override
+//    public void stop() {
+//        Log.e(TAG, "stop");
+//        canRunning = false;
+//        if (mReadThread != null)
+//            mReadThread.interrupt();
+//
+//        if(mInputStream != null) {
+//            close(mInputStream);
+//        }
+//        if(mSerialPort != null) {
+//            mSerialPort.close();
+//        }
+//        mSerialPort = null;
+//        mListener = null;
+//        PowerClose360();
+//    }
+//
+//    private void PowerClose360() {
+////        if(Build.MODEL.contains("TPS360")) {
+////            if (qrcodePower == null) {
+////                qrcodePower = new QrcodePower();
+////            }
+////            qrcodePower.close_em();
+////        }
+//    }
+//
+//    /**
+//    * 设置返回数据
+//    */
+//    @Override
+//    public void setListener(SerialDataListener listener) {
+//        mListener = listener;
+//    }
+//
+//    /**
+//    * 关闭流
+//    */
+//    private void close(Closeable os){
+//        if (os != null) {
+//            try {
+//                os.close();
+//            } catch (IOException e) {
+//                Log.e(TAG,e.getMessage());
+//            }
+//        }
+//    }
+//
+//    /**
+//     * 输入串口的数据
+//     * @param data
+//     */
+//    @Override
+//    public void send(String data) {
+//
+//    }
+//
+//    /**
+//     * 打开线程 默认参数
+//     */
+//    @Override
+//    public void start(){
+//        Log.e(TAG, "start");
+//        canRunning = true;
+//        initSerialPort();
+//        mReadThread = new ReadThread();
+//        mReadThread.start();
+//    }
+//
+//}

+ 5 - 1
app/src/main/java/com/hh/arome/common/scan/idcard/manymodels/XzxIDCardScan.java

@@ -416,7 +416,11 @@ public class XzxIDCardScan implements IIDCardScan {
 //                    idCardReaderThread = new IDCardReaderThread();
 //                }
                 if(idCardReaderThread!=null){
-                    idCardReaderThread.read();
+                    try {
+                        idCardReaderThread.read();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
                 }
             }
 //        },time*1000);

+ 8 - 2
app/src/main/java/com/hh/arome/common/scan/idcard/manymodels/er301/ReadCardManagerER301.java

@@ -5,6 +5,7 @@ import android.util.Log;
 import com.eidlink.serial_idocr.bean.EidlinkInitParams;
 import com.eidlink.serial_idocr.sdk.EidLinkSE;
 import com.eidlink.serial_idocr.sdk.EidLinkSEFactory;
+import com.hh.arome.utlis.log.AppLogUtils;
 
 
 public class ReadCardManagerER301 {
@@ -30,8 +31,13 @@ public class ReadCardManagerER301 {
         // 设置环境和port
 //        eid.setIP("es-new.beekey.com.cn");
 
-        eid.setIP("es.eidlink.com");
-        eid.setPort(9699);
+        try {
+            eid.setIP("es.eidlink.com");
+            eid.setPort(9699);
+        } catch (Exception e) {
+            e.printStackTrace();
+            AppLogUtils.e("e:"+e.toString());
+        }
 
     }
 

+ 336 - 0
app/src/main/java/com/hh/arome/common/voice/BaiduVoice.java

@@ -0,0 +1,336 @@
+package com.hh.arome.common.voice;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.os.Environment;
+import android.util.Log;
+
+import com.baidu.tts.auth.AuthInfo;
+import com.baidu.tts.client.SpeechError;
+import com.baidu.tts.client.SpeechSynthesizeBag;
+import com.baidu.tts.client.SpeechSynthesizer;
+import com.baidu.tts.client.SpeechSynthesizerListener;
+import com.baidu.tts.client.TtsMode;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * Created by L470 on 2019/7/10.
+ */
+
+public class BaiduVoice implements SpeechSynthesizerListener {
+
+    Context mContext;
+
+
+
+    public BaiduVoice(Context context) {
+        this.mContext = context;
+    }
+
+    private static volatile BaiduVoice instance = null;
+    public static BaiduVoice getInstance(Context context) {
+        if (instance == null) {
+            synchronized (BaiduVoice.class) {
+                if (instance == null) {
+                    instance = new BaiduVoice(context);
+                    instance.init();
+                }
+            }
+        }
+        return instance;
+    }
+
+    /*public static BaiduVoice getInstance(Context context) {
+        instance = new BaiduVoice(context);
+        instance.init();
+        return instance;
+    }*/
+    
+    public void init() {
+        initBaiduVoice();
+    }
+
+    public void Speak(String text) {
+
+        if(mSpeechSynthesizer!=null){
+//            LogUtils.e("tts--Speak");
+            mSpeechSynthesizer.speak(text);
+        }else {
+            init();
+            Speak(text);
+//            LogUtils.e("tts--Speak--null");
+        }
+
+
+        /*List<SpeechSynthesizeBag> bags = new ArrayList<SpeechSynthesizeBag>();
+        bags.add(getSpeechSynthesizeBag(text, "5"));
+        int result = this.mSpeechSynthesizer.batchSpeak(bags);
+        if (result < 0) {
+        }*/
+
+    }
+
+    public void stop(){
+        if (mSpeechSynthesizer != null) {
+            mSpeechSynthesizer.stop();
+        }else {
+//            LogUtils.e("tts--stop--null");
+        }
+    }
+
+    public void resume() {
+        if (mSpeechSynthesizer != null) {
+            mSpeechSynthesizer.resume();
+        }else {
+//            LogUtils.e("tts--resume--null");
+        }
+    }
+
+    public void pause() {
+        if (mSpeechSynthesizer != null) {
+            mSpeechSynthesizer.pause();
+        }else {
+//            Log.e("tts--pause--null");
+        }
+    }
+
+    public void destory() {
+        if (mSpeechSynthesizer != null) {
+            mSpeechSynthesizer.stop();
+            mSpeechSynthesizer.release();
+            mSpeechSynthesizer = null;
+        }else {
+//            LogUtils.e("tts--destory--null");
+        }
+    }
+
+    private SpeechSynthesizeBag getSpeechSynthesizeBag(String text, String utteranceId) {
+        SpeechSynthesizeBag speechSynthesizeBag = new SpeechSynthesizeBag();
+        //需要合成的文本text的长度不能超过1024个GBK字节。
+        speechSynthesizeBag.setText(text);
+        speechSynthesizeBag.setUtteranceId(utteranceId);
+        return speechSynthesizeBag;
+    }
+
+
+    private SpeechSynthesizer mSpeechSynthesizer;
+    private String mSampleDirPath;
+    private static final String SAMPLE_DIR_NAME = "baiduTTS";
+    private static final String SPEECH_FEMALE_MODEL_NAME = "bd_etts_speech_female.dat";
+    private static final String SPEECH_MALE_MODEL_NAME = "bd_etts_speech_male.dat";
+    private static final String TEXT_MODEL_NAME = "bd_etts_text.dat";
+
+    private static final String ENGLISH_SPEECH_FEMALE_MODEL_NAME = "bd_etts_speech_female_en.dat";
+    private static final String ENGLISH_SPEECH_MALE_MODEL_NAME = "bd_etts_speech_male_en.dat";
+    private static final String ENGLISH_TEXT_MODEL_NAME = "bd_etts_text_en.dat";
+
+
+
+    /*
+     * @param savedInstanceState
+     */
+
+    protected void initBaiduVoice() {
+        initialEnv();
+        initialTts();
+    }
+
+    private void initialEnv() {
+        if (mSampleDirPath == null) {
+            String sdcardPath = Environment.getExternalStorageDirectory().toString();
+            mSampleDirPath = sdcardPath + "/" + SAMPLE_DIR_NAME;
+        }
+        makeDir(mSampleDirPath);
+
+        // android 6.0 以上SD卡可能没有权限
+        File dirPath = new File(mSampleDirPath);
+        if (!dirPath.canWrite()) {
+            // 也可以使用 getApplication().getFilesDir().getAbsolutePath+"/"+SAMPLE_DIR_NAME
+            mSampleDirPath = mContext.getApplicationContext().getExternalFilesDir(SAMPLE_DIR_NAME).getAbsolutePath();
+        }
+        makeDir(mSampleDirPath);
+
+
+        copyFromAssetsToSdcard(false, SPEECH_FEMALE_MODEL_NAME, mSampleDirPath + "/" + SPEECH_FEMALE_MODEL_NAME);
+        copyFromAssetsToSdcard(false, SPEECH_MALE_MODEL_NAME, mSampleDirPath + "/" + SPEECH_MALE_MODEL_NAME);
+        copyFromAssetsToSdcard(false, TEXT_MODEL_NAME, mSampleDirPath + "/" + TEXT_MODEL_NAME);
+        //copyFromAssetsToSdcard(false, LICENSE_FILE_NAME, mSampleDirPath + "/" + LICENSE_FILE_NAME);
+        copyFromAssetsToSdcard(false, "english/" + ENGLISH_SPEECH_FEMALE_MODEL_NAME, mSampleDirPath + "/"
+                + ENGLISH_SPEECH_FEMALE_MODEL_NAME);
+        copyFromAssetsToSdcard(false, "english/" + ENGLISH_SPEECH_MALE_MODEL_NAME, mSampleDirPath + "/"
+                + ENGLISH_SPEECH_MALE_MODEL_NAME);
+        copyFromAssetsToSdcard(false, "english/" + ENGLISH_TEXT_MODEL_NAME, mSampleDirPath + "/"
+                + ENGLISH_TEXT_MODEL_NAME);
+    }
+
+    private void makeDir(String dirPath) {
+        File file = new File(dirPath);
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+    }
+
+    /**
+     * 将sample工程需要的资源文件拷贝到SD卡中使用(授权文件为临时授权文件,请注册正式授权)
+     *
+     * @param isCover 是否覆盖已存在的目标文件
+     * @param source
+     * @param dest
+     */
+    private void copyFromAssetsToSdcard(boolean isCover, String source, String dest) {
+        File file = new File(dest);
+        if (isCover || (!isCover && !file.exists())) {
+            InputStream is = null;
+            FileOutputStream fos = null;
+            try {
+                is = mContext.getResources().getAssets().open(source);
+                String path = dest;
+                fos = new FileOutputStream(path);
+                byte[] buffer = new byte[1024];
+                int size = 0;
+                while ((size = is.read(buffer, 0, 1024)) >= 0) {
+                    fos.write(buffer, 0, size);
+                }
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            } finally {
+                if (fos != null) {
+                    try {
+                        fos.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                try {
+                    if (is != null) {
+                        is.close();
+                    }
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+
+    private void initialTts() {
+        this.mSpeechSynthesizer = SpeechSynthesizer.getInstance();
+        this.mSpeechSynthesizer.setContext(mContext);
+        this.mSpeechSynthesizer.setSpeechSynthesizerListener(this);
+        // 文本模型文件路径 (离线引擎使用)
+        this.mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_TTS_TEXT_MODEL_FILE, mSampleDirPath + "/"
+                + TEXT_MODEL_NAME);
+        // 声学模型文件路径 (离线引擎使用)
+        this.mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_TTS_SPEECH_MODEL_FILE, mSampleDirPath + "/"
+                + SPEECH_FEMALE_MODEL_NAME);
+        // 本地授权文件路径,如未设置将使用默认路径.设置临时授权文件路径,LICENCE_FILE_NAME请替换成临时授权文件的实际路径,仅在使用临时license文件时需要进行设置,如果在[应用管理]中开通了正式离线授权,不需要设置该参数,建议将该行代码删除(离线引擎)
+        // 如果合成结果出现临时授权文件将要到期的提示,说明使用了临时授权文件,请删除临时授权即可。
+        // this.mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_TTS_LICENCE_FILE, mSampleDirPath + "/"
+        //        + LICENSE_FILE_NAME);
+        // 请替换为语音开发者平台上注册应用得到的App ID (离线授权)
+        Properties pro = new Properties();
+        String appid = null, apiKey = null, apiKeyT = null;
+        try {
+            AssetManager assets = mContext.getResources().getAssets();
+            InputStream open = assets.open("voice.properties");
+
+            pro.load(open);
+            appid = pro.getProperty("APPID");
+            apiKey = pro.getProperty("APIKEY");
+            apiKeyT = pro.getProperty("APIKEYT");
+
+            open.close();
+            pro.clear();
+        } catch (IOException e) {
+
+            System.out.println(e);
+            System.out.println(mContext.getFilesDir());
+        }
+
+
+        this.mSpeechSynthesizer.setAppId(appid/*这里只是为了让Demo运行使用的APPID,请替换成自己的id。*/);
+        // 请替换为语音开发者平台注册应用得到的apikey和secretkey (在线授权)
+        this.mSpeechSynthesizer.setApiKey(apiKey, apiKeyT);
+        // 发音人(在线引擎),可用参数为0,1,2,3。。。(服务器端会动态增加,各值含义参考文档,以文档说明为准。0--普通女声,1--普通男声,2--特别男声,3--情感男声。。。)
+        this.mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_SPEAKER, "0");
+        // 设置Mix模式的合成策略
+        this.mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_MIX_MODE, SpeechSynthesizer.MIX_MODE_DEFAULT);
+        // 设置合成的音量,0-15 ,默认 5
+//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_VOLUME, "9");
+        // 设置合成的语速,0-15 ,默认 5
+        this.mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_SPEED, "15");
+        // 设置合成的语调,0-15 ,默认 5
+//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_PITCH, "5");
+
+
+        // 授权检测接口(只是通过AuthInfo进行检验授权是否成功。)
+        // AuthInfo接口用于测试开发者是否成功申请了在线或者离线授权,如果测试授权成功了,可以删除AuthInfo部分的代码(该接口首次验证时比较耗时),不会影响正常使用(合成使用时SDK内部会自动验证授权)
+        AuthInfo authInfo = this.mSpeechSynthesizer.auth(TtsMode.MIX);
+
+        if (authInfo.isSuccess()) {
+        } else {
+            String errorMsg = authInfo.getTtsError().getDetailMessage();
+        }
+
+        // 初始化tts
+        mSpeechSynthesizer.initTts(TtsMode.MIX);
+        // 加载离线英文资源(提供离线英文合成功能)
+//        int result =
+//                mSpeechSynthesizer.loadEnglishModel(mSampleDirPath + "/" + ENGLISH_TEXT_MODEL_NAME, mSampleDirPath
+//                        + "/" + ENGLISH_SPEECH_FEMALE_MODEL_NAME);
+
+        //打印引擎信息和model基本信息
+    }
+
+
+    @Override
+    public void onSynthesizeStart(String s) {
+
+    }
+
+    @Override
+    public void onSynthesizeDataArrived(String s, byte[] bytes, int i) {
+
+    }
+
+    @Override
+    public void onSynthesizeFinish(String s) {
+//        LogUtils.e("onSynthesizeFinish");
+        //不能执行run里的
+//        timeFinish();
+
+    }
+
+    @Override
+    public void onSpeechStart(String s) {
+
+    }
+
+    @Override
+    public void onSpeechProgressChanged(String s, int i) {
+
+    }
+
+    @Override
+    public void onSpeechFinish(String s) {
+//        LogUtils.e("onSpeechFinish");
+    }
+
+    @Override
+    public void onError(String s, SpeechError speechError) {
+
+    }
+
+
+}

+ 6 - 6
app/src/main/java/com/hh/arome/common/voice/BaseVoice.java

@@ -4,7 +4,7 @@ import android.content.Context;
 import android.os.Build;
 
 import com.hh.arome.common.Constants;
-import com.hh.arome.common.scan.broadcast.D2Scan;
+//import com.hh.arome.common.scan.broadcast.D2Scan;
 import com.hh.arome.common.scan.broadcast.abstractscan.IBroadcastScan;
 import com.hh.arome.common.scan.broadcast.callback.IScanResultCallback;
 import com.hh.arome.utlis.log.AppLogUtils;
@@ -45,11 +45,11 @@ public class BaseVoice
 
         String model = Build.MODEL;
         AppLogUtils.e("getBaseBroadcastScan--model:"+model);
-        if (Constants.DeviceModel.D2.equals(model)) {
-            D2Scan d2Scan = new D2Scan(context);
-            d2Scan.setListener(iScanResultCallback);
-            return d2Scan;
-        }
+//        if (Constants.DeviceModel.D2.equals(model)) {
+//            D2Scan d2Scan = new D2Scan(context);
+//            d2Scan.setListener(iScanResultCallback);
+//            return d2Scan;
+//        }
         return null;
     }
 

+ 0 - 1
app/src/main/java/com/hh/arome/services/keeplive/LocalService.kt

@@ -8,7 +8,6 @@ import android.os.Build
 import android.os.IBinder
 import androidx.annotation.Nullable
 import com.hh.arome.R
-import com.hh.arome.ui.MainActivity
 import com.hh.arome.utlis.device.DeviceUtils
 import com.hh.arome.utlis.log.AppLogUtils
 import com.hh.hhomc.WxAidlInterface

+ 0 - 1
app/src/main/java/com/hh/arome/ui/Gridadapter.java

@@ -1,7 +1,6 @@
 package com.hh.arome.ui;
 
 import android.content.Context;
-import android.graphics.Color;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;

File diff suppressed because it is too large
+ 217 - 64
app/src/main/java/com/hh/arome/ui/MainActivity.java


+ 0 - 1
app/src/main/java/com/hh/arome/ui/setting/PushActivity.java

@@ -1,7 +1,6 @@
 package com.hh.arome.ui.setting;
 
 import android.view.View;
-import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.TextView;
 

+ 0 - 3
app/src/main/java/com/hh/arome/ui/setting/SettingActivity.java

@@ -1,6 +1,5 @@
 package com.hh.arome.ui.setting;
 
-import android.content.Intent;
 import android.view.KeyEvent;
 import android.view.View;
 import android.widget.ImageButton;
@@ -11,9 +10,7 @@ import android.widget.TextView;
 import androidx.appcompat.widget.Toolbar;
 
 import com.hh.arome.R;
-import com.hh.arome.common.ConfigData;
 import com.hh.arome.common.Constants;
-import com.hh.arome.ui.MainActivity;
 import com.hh.arome.ui.base.BaseHHActivity;
 import com.hh.arome.utlis.device.DeviceUtils;
 

+ 0 - 1
app/src/main/java/com/hh/arome/ui/setting/SystemConfigActivity.java

@@ -1,6 +1,5 @@
 package com.hh.arome.ui.setting;
 
-import android.os.Handler;
 import android.view.View;
 import android.widget.EditText;
 import android.widget.ImageButton;

+ 1 - 1
app/src/main/java/com/hh/arome/utlis/data/Config.java

@@ -5,7 +5,7 @@
 //
 //
 //import com.hh.arome.bean.AuthenticationBean;
-//import com.hh.arome.utlis.device.DeviceUtils;
+//import com.common.arome.DeviceUtils;
 //import com.hh.arome.utlis.device.FaceScenicUtile;
 //
 //import java.util.ArrayList;

+ 0 - 7
app/src/main/java/com/hh/arome/utlis/device/DeviceUtils.java

@@ -1,6 +1,5 @@
 package com.hh.arome.utlis.device;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
@@ -8,8 +7,6 @@ import android.os.Build;
 import android.text.TextUtils;
 import android.util.Log;
 
-import com.hh.arome.utlis.log.AppLogUtils;
-
 import java.lang.reflect.Method;
 import java.net.Inet4Address;
 import java.net.InetAddress;
@@ -29,10 +26,8 @@ public final class DeviceUtils {
             Method get = c.getMethod("get", String.class);
             if (Build.VERSION.SDK_INT <= 28) {//28 is andoird 9.0 24-7.0 22-5.1
                 serial = (String) get.invoke(c, "ro.serialno");
-                AppLogUtils.i("SDK_INT <= 28--serial:"+serial);
             } else {
                 serial = (String) get.invoke(c, "persist.sys.hrSerial");//vendor.gsm.serial
-                AppLogUtils.i("SDK_INT > 28--serial:"+serial);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -48,7 +43,6 @@ public final class DeviceUtils {
 
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                 serial = Build.getSerial();
-                AppLogUtils.i("SDK_INT >= O--serial:"+serial);
                 if(!TextUtils.isEmpty(serial)&&!serial.equals("unknown")) {
                     // 判断非空和非unknown,则返回
                     return serial;
@@ -59,7 +53,6 @@ public final class DeviceUtils {
 
             if(TextUtils.isEmpty(serial)) {
                 serial = Build.SERIAL;
-                AppLogUtils.i("SDK_INT < O--serial:"+serial);
                 if(!TextUtils.isEmpty(serial)&&!serial.equals("unknown")) {
                     // 判断非空和非unknown,则返回
                     return serial;

+ 1 - 0
app/src/main/java/com/hh/arome/utlis/log/AppLogUtils.java

@@ -109,6 +109,7 @@ public final class AppLogUtils {
     private static final int XML = 0x30;
 
     private static final String FILE_SEP = System.getProperty("file.separator");
+    // 换行符,功能和"\n"是一致的,但是此种写法屏蔽了 Windows和Linux的区别 ,更保险一些
     private static final String LINE_SEP = System.getProperty("line.separator");
     private static final String TOP_CORNER = "┌";
     private static final String MIDDLE_CORNER = "├";

+ 5 - 0
app/src/main/java/com/hh/arome/utlis/log/LogType.java

@@ -14,4 +14,9 @@ public enum LogType {
     public String getType() {
         return type;
     }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
 }

+ 0 - 4
app/src/main/java/com/hh/arome/utlis/log/PrintToFileUtil.java

@@ -1,9 +1,5 @@
 package com.hh.arome.utlis.log;
 
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.os.Build;
-
 
 import com.common.lib_base.CommonApplication;
 import com.hh.arome.utlis.device.DeviceUtils;

+ 25 - 0
app/src/main/res/layout/activity_main.xml

@@ -148,6 +148,20 @@
         android:layout_height="wrap_content"
         android:orientation="vertical">
 
+        <Button
+            android:id="@+id/tv_voice"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dp"
+            android:text="播放语音" />
+
+        <Button
+            android:id="@+id/tv_print"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dp"
+            android:text="打印" />
+
         <Button
             android:id="@+id/tv_record_start"
             android:layout_width="wrap_content"
@@ -223,6 +237,17 @@
             app:layout_constraintTop_toTopOf="parent" />
 
 
+        <TextView
+            android:id="@+id/tv_scan_result"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="刷脸结果"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+
         <Button
             android:id="@+id/tv_idcard"
             android:layout_width="wrap_content"

+ 25 - 0
app/src/main/res/layout/activity_main_hp.xml

@@ -149,6 +149,20 @@
         android:layout_height="wrap_content"
         android:orientation="vertical">
 
+        <Button
+            android:id="@+id/tv_voice"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dp"
+            android:text="播放语音" />
+
+        <Button
+            android:id="@+id/tv_print"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dp"
+            android:text="打印" />
+
         <Button
             android:id="@+id/tv_record_start"
             android:layout_width="wrap_content"
@@ -224,6 +238,17 @@
             app:layout_constraintTop_toTopOf="parent" />
 
 
+        <TextView
+            android:id="@+id/tv_scan_result"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="刷脸结果"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+
         <Button
             android:id="@+id/tv_idcard"
             android:layout_width="wrap_content"

+ 2 - 2
config.gradle

@@ -7,8 +7,8 @@ ext {
 //            minSdkVersion    : 24,
             minSdkVersion    : 21,
             targetSdkVersion : 22,
-            versionCode      : 22,
-            versionName      : "2.7.2"
+            versionCode      : 26,
+            versionName      : "2.7.5"
     ]
     //依赖 配置
     dependencies = [

+ 11 - 1
idCard/build.gradle

@@ -16,7 +16,17 @@ android {
     buildTypes {
         release {
             minifyEnabled false
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+
+        debug {
+            jniDebuggable true
+            debuggable true
+        }
+
+        yufabu {
+            jniDebuggable true
+            debuggable true
         }
     }
 }

+ 5 - 1
idCard/src/main/java/com/synjones/idcardusb_reader/IDCardReaderThread.java

@@ -244,7 +244,11 @@ public class IDCardReaderThread {
 
         public void cancel(){
             stopRead=true;
-            interrupt();
+            try {
+                interrupt();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
             try {
                 join();
             } catch (InterruptedException e) {

+ 58 - 0
lib_arome/.gitignore

@@ -0,0 +1,58 @@
+# Built application files
+*.apk
+*.ap_
+
+#OSX
+*.DS_Store
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+app/
+
+# Local configuration file (sdk path, etc)
+/local.properties
+.local.properties
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+/.idea
+
+# Keystore files
+# *.jks
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json

+ 52 - 0
lib_arome/build.gradle

@@ -0,0 +1,52 @@
+plugins {
+    id 'com.android.library'
+}
+
+android {
+    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
+    buildToolsVersion rootProject.ext.android["buildToolsVersion"]
+    defaultConfig {
+        minSdkVersion rootProject.ext.android["minSdkVersion"]
+        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
+        versionCode rootProject.ext.android["versionCode"]
+        versionName rootProject.ext.android["versionName"]
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        consumerProguardFiles "consumer-rules.pro"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+
+        debug {
+            jniDebuggable true
+            debuggable true
+        }
+
+        yufabu {
+            jniDebuggable true
+            debuggable true
+        }
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+
+    implementation 'androidx.appcompat:appcompat:1.1.0'
+    implementation 'com.google.android.material:material:1.1.0'
+    testImplementation 'junit:junit:4.+'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+
+
+    // 添加base依赖
+    implementation project(path: ':lib_base')
+
+}

+ 0 - 0
lib_arome/consumer-rules.pro


+ 21 - 0
lib_arome/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
lib_arome/src/androidTest/java/com/common/arome/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.common.arome;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+        assertEquals("com.common.arome.test", appContext.getPackageName());
+    }
+}

+ 8 - 0
lib_arome/src/main/AndroidManifest.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.common.arome">
+
+    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
+
+
+</manifest>

+ 35 - 0
lib_arome/src/main/java/com/common/arome/Constants.java

@@ -0,0 +1,35 @@
+package com.common.arome;
+
+
+public class Constants {
+
+
+    public static class DeviceModel {
+
+        public static final String K8 = "K8";
+
+        public static final String F10 = "F10";
+
+        // 紫鹏
+        public static final String ZP = "HYIP1000-EI";
+
+        // 访客机d2
+        public static final String D2 = "D2";
+
+        public static final String ZP_A10 = "A10";
+
+        // 紫鹏-X5 有的是A50R3
+        public static final String ZP_A50 = "A50";
+
+        // 马里奥-Y9
+        public static final String T1YB01 = "T1YB01";
+
+
+    }
+
+
+
+
+
+
+}

+ 157 - 0
lib_arome/src/main/java/com/common/arome/DeviceUtils.java

@@ -0,0 +1,157 @@
+package com.common.arome;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.text.TextUtils;
+import android.util.Log;
+
+
+import java.lang.reflect.Method;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Collections;
+import java.util.List;
+
+public final class DeviceUtils {
+
+
+    //获取设备SN码
+    public static String getDeviceSN() {
+        //如224F010T01400859
+        String serial = null;
+        try {
+            Class<?> c = Class.forName("android.os.SystemProperties");
+            Method get = c.getMethod("get", String.class);
+            if (Build.VERSION.SDK_INT <= 28) {//28 is andoird 9.0 24-7.0 22-5.1
+                serial = (String) get.invoke(c, "ro.serialno");
+            } else {
+                serial = (String) get.invoke(c, "persist.sys.hrSerial");//vendor.gsm.serial
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if (TextUtils.isEmpty(serial)) {
+//            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+//                // 注意清单文件加上READ_PHONE_STATE权限,不然还是会获取失败
+//                serial = Build.getSerial();
+//            }else{
+//                serial = Build.SERIAL;
+//            }
+
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+                serial = Build.getSerial();
+                if(!TextUtils.isEmpty(serial)&&!serial.equals("unknown")) {
+                    // 判断非空和非unknown,则返回
+                    return serial;
+                }else{
+                    serial = "";
+                }
+            }
+
+            if(TextUtils.isEmpty(serial)) {
+                serial = Build.SERIAL;
+                if(!TextUtils.isEmpty(serial)&&!serial.equals("unknown")) {
+                    // 判断非空和非unknown,则返回
+                    return serial;
+                }else{
+                    serial = "";
+                }
+            }
+        }
+
+
+
+
+        if (TextUtils.isEmpty(serial)) {
+            serial = "sn号获取失败";
+        }
+
+        return serial;
+    }
+
+    // 获取版本号
+    public static String getAppVersionName(Context context) {
+        PackageInfo packageInfo = null;
+        try {
+            packageInfo = context.getPackageManager()
+                    .getPackageInfo(context.getPackageName(), 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+        //获取APP版本versionName
+        String versionName = packageInfo.versionName;
+        //获取APP版本versionCode
+        int versionCode = packageInfo.versionCode;
+        return versionName;
+    }
+
+    //获取版本code
+    public static int getAppVersionCode(Context context) {
+        PackageInfo packageInfo = null;
+        try {
+            packageInfo = context.getPackageManager()
+                    .getPackageInfo(context.getPackageName(), 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+        //获取APP版本versionName
+        String versionName = packageInfo.versionName;
+        //获取APP版本versionCode
+        int versionCode = packageInfo.versionCode;
+        return versionCode;
+    }
+
+
+    // 获取包名
+    public static String getAppPackageName(Context context) {
+        return context.getPackageName();
+    }
+
+    // Android版本 7.1.2
+    public static String getAndroidVersion() {
+        // 如7.1.2
+        String androidVersion = Build.VERSION.RELEASE;
+        return androidVersion;
+    }
+
+
+    // 设备型号
+    public static String getDeviceModel() {
+        // 如F10
+        String model = Build.MODEL;
+        return model;
+    }
+
+    // 设备固件号
+    public static String getDeviceDisplay() {
+        // 如 F10_ALL_V1.0.3_202206110108
+        String deviceDisplay = Build.DISPLAY;
+        return deviceDisplay;
+    }
+
+    // 设备IP地址
+    public static String getDeviceIP() {
+        // 如 192.168.1.1
+        try {
+            List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
+            for (NetworkInterface intf : interfaces) {
+                List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
+                for (InetAddress addr : addrs) {
+                    if (!addr.isLoopbackAddress() && addr instanceof Inet4Address) {
+                        return addr.getHostAddress();
+                    }
+                }
+            }
+        } catch (Exception e) {
+            Log.e("getIPAddress", e.toString());
+        }
+        return "";
+    }
+
+
+}

+ 17 - 0
lib_arome/src/test/java/com/common/arome/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package com.common.arome;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 4 - 0
lib_base/src/main/java/com/common/lib_base/utils/NetworkUtils.java

@@ -55,6 +55,10 @@ public class NetworkUtils {
         ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
         NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
 
+        if(activeNetwork == null){
+            return "";
+        }
+
         int type = activeNetwork.getType();
         Log.e(BuildConfig.LOG_TAG,"getNetType--type--"+type);
 

+ 43 - 0
lib_base/src/main/java/com/common/lib_base/utils/app/AppUtils.java

@@ -1,20 +1,28 @@
 package com.common.lib_base.utils.app;
 
+import android.annotation.TargetApi;
+import android.app.ActivityManager;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.net.Uri;
+import android.os.Build;
 import android.text.TextUtils;
+import android.text.format.Formatter;
 import android.util.Base64;
 import android.util.Log;
 
 import com.common.lib_base.utils.LogUtils;
 
+import java.io.BufferedReader;
 import java.io.File;
 import android.content.pm.PackageInfo;
 import android.content.pm.Signature;
+
+import java.io.FileReader;
+import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
@@ -156,5 +164,40 @@ public class AppUtils {
 
 
 
+    public static String getTotalMemory(Context context) {
+        String str1 = "/proc/meminfo";// 系统内存信息文件
+        String str2;
+        String[] arrayOfString;
+        long initial_memory = 0;
+        try {
+            FileReader localFileReader = new FileReader(str1);
+            BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192);
+            str2 = localBufferedReader.readLine();// 读取meminfo第一行,系统总内存大小
+            arrayOfString = str2.split("\\s+");
+            for (String num : arrayOfString) {
+                Log.i(str2, num + "\t");
+            }
+            // 获得系统总内存,单位是KB
+            int i = Integer.valueOf(arrayOfString[1]).intValue();
+            //int值乘以1024转换为long类型
+            initial_memory = new Long((long)i*1024);
+            localBufferedReader.close();
+        } catch (IOException e) {
+        }
+        return Formatter.formatFileSize(context, initial_memory);// Byte转换为KB或者MB,内存大小规格化
+    }
+
+
+    public static String getAvailMemory(Context context) {
+        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
+        am.getMemoryInfo(mi);
+        // mi.availMem; 当前系统的可用内存
+        return Formatter.formatFileSize(context, mi.availMem);// 将获取的内存大小规格化
+    }
+
+
+
+
 
 }

+ 24 - 5
lib_print/build.gradle

@@ -1,8 +1,8 @@
 apply plugin: 'com.android.library'
 
 android {
-    compileSdkVersion 30
-    buildToolsVersion "30.0.0"
+    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
+    buildToolsVersion rootProject.ext.android["buildToolsVersion"]
     defaultConfig {
         minSdkVersion 21
         targetSdkVersion 30
@@ -29,6 +29,11 @@ android {
         }
     }
 
+    repositories {
+        flatDir {
+            dirs 'libs'
+        }
+    }
     sourceSets {
         main {
             jniLibs.srcDirs = ['libs']
@@ -56,9 +61,23 @@ dependencies {
     implementation 'com.caverock:androidsvg:1.4+'
 
 
+
+    api files('libs/telpo_sdk_20240108_noserial.jar')
+
 //    api files('libs/telpo_sdk_210726.jar')
-    api files('libs/telpo_sdk_210726_new.jar')
-//    api files('libs/telpo_sdk_20240108_change.jar')
-//    api files('libs/SerialPort.jar')
+//    api files('libs/telpo_sdk_210726_new.jar')
+//    api files('libs/telpo_sdk_20231208.jar')
+//    api files('libs/posutil_sdk_20231226.jar')
+
+
+    implementation project(':lib_arome')
+
+
+    // y9打印
+    implementation(name: 'printlib-debug', ext: 'aar')
+
+
+    // 添加base依赖
+    implementation project(path: ':lib_base')
 
 }

BIN
lib_print/libs/printlib-debug.aar


BIN
lib_print/libs/telpo_sdk_20240108_noserial.jar


BIN
lib_print/libs/telpo_sdk_210726_new.jar


+ 231 - 0
lib_print/src/main/java/com/common/print/BasePrinter.java

@@ -0,0 +1,231 @@
+package com.common.print;
+
+
+import android.content.Context;
+import android.os.Handler;
+import android.util.Log;
+
+import com.common.arome.Constants;
+import com.common.arome.DeviceUtils;
+import com.common.lib_base.common.async.ThreadPoolManager;
+import com.common.lib_base.utils.StringUtils;
+import com.common.print.callback.PrintInitResultCallback;
+import com.common.print.many.MlaPrinter;
+import com.common.print.many.NullPrinter;
+import com.common.print.many.TbPrinter;
+import com.telpo.tps508.PrintContentBean;
+//import com.telpo.tps550.api.printer.UsbThermalPrinter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BasePrinter {
+
+    // 当前类名
+    public String mTag = getClass().getSimpleName()+"--";
+
+
+    //用volatile关键字确保 instance 在多线程下的可见性
+    private static volatile BasePrinter instance = null;
+
+    //将构造方法私有化,禁止外部通过构造方法创建实例
+    private BasePrinter() {}
+
+    //提供一个公共的访问方法,用于获取该类的唯一实例
+    public static BasePrinter getInstance() {
+        //如果instance为空,就进行实例化
+        if (instance == null) {
+            //保证多线程下只有一个线程进行实例化
+            synchronized (BasePrinter.class) {
+                //第二次判断,避免多线程下创建多个实例
+                if (instance == null) {
+                    instance = new BasePrinter();
+                }
+            }
+        }
+        return instance;
+    }
+
+    IPrinter iPrinter;
+
+
+    public IPrinter getPrinter(Context context) {
+        String model = DeviceUtils.getDeviceModel();
+        Log.e(mTag,"model:"+model);
+
+        if (Constants.DeviceModel.T1YB01.equals(model)) {
+            // y9
+            iPrinter = MlaPrinter.getInstance(context);
+        } else if(Constants.DeviceModel.D2.equals(model)) {
+            // 天波
+            iPrinter = TbPrinter.getInstance(context);
+        }else {
+            //其余设备
+            iPrinter = NullPrinter.getInstance();
+        }
+        return iPrinter;
+    }
+
+
+
+    // 初始化
+    PrintInitResultCallback printInitResultCallback;
+
+    public void initPrint(PrintInitResultCallback printInitResultCallback) {
+
+        this.printInitResultCallback = printInitResultCallback;
+
+        iPrinter.initPrint(printInitResultCallback);
+    }
+
+
+
+    OnPrintBaseListener listener;
+
+    public void setListener(OnPrintBaseListener lister) {
+        listener = lister;
+    }
+    public interface OnPrintBaseListener {
+        void PrintingComplete();
+    }
+
+
+    Handler mHandler = new Handler();
+
+    List<PrintContentBean> printContentList = new ArrayList<>();
+
+    private static final String ALGIN_LEFT = "left";
+    private static final String ALGIN_RIGHT = "right";
+    private static final String ALGIN_CENTER = "center";
+
+
+    // 传入要打印的数据,开始打印
+    public void handleDataAndPrint(List<PrintContentBean> printContentData) {
+
+        if(printContentData == null || printContentData.size() == 0){
+
+            Log.e(mTag,"printContentData == null");
+            return;
+        }
+
+        if(iPrinter == null){
+            Log.e(mTag,"iPrinter == null");
+            return;
+        }
+
+        printContentList.clear();
+        printContentList.addAll(printContentData);
+
+
+        ThreadPoolManager.getInstance().executeIOTask(new Runnable() {
+            @Override
+            public void run() {
+
+                startPrint();
+
+            }
+        });
+
+
+
+
+    }
+
+    private void startPrint() {
+
+
+        Log.e(mTag,"startPrint");
+
+        iPrinter.startPrint();
+
+        int printTotalTime = 0;
+        for (int i = 0; i < printContentList.size(); i++) {
+            PrintContentBean printContentBean = printContentList.get(i);
+
+            String text = printContentBean.getText();
+            String qrCodeText = printContentBean.getQrCodeText();
+            String imageBase64 = printContentBean.getImageBase64();
+
+            int width = printContentBean.getWidth();
+            int height = printContentBean.getHeight();
+
+            if(StringUtils.isNotNull(text)){
+                // 普通文字
+
+                // 设置对齐位置
+                int algin=0;
+                String alginParam = printContentBean.getAlgin();
+                if(ALGIN_LEFT.equalsIgnoreCase(alginParam)){
+                    algin = 0;
+                }else if(ALGIN_CENTER.equalsIgnoreCase(alginParam)){
+                    algin = 1;
+                }else if(ALGIN_RIGHT.equalsIgnoreCase(alginParam)){
+                    algin = 2;
+                }
+
+                // 打印文字
+                iPrinter.printText(text,
+                        algin,
+                        printContentBean.getTextSize(),
+                        printContentBean.isBold());
+
+                // 打印时间累计
+                printTotalTime+=1000;
+
+            }else if(StringUtils.isNotNull(qrCodeText)){
+                // 二维码
+
+                iPrinter.printQrCode(qrCodeText,width,height);
+
+                // 打印时间累计
+                printTotalTime+=2000;
+
+            }else if(StringUtils.isNotNull(imageBase64)){
+                // 图片
+
+                iPrinter.printBitmap(imageBase64,width,height);
+
+                // 打印时间累计
+                printTotalTime+=2000;
+
+            }
+
+        }
+
+        Log.e(mTag,"cutPaper");
+        // 打印完并切纸
+        iPrinter.cutPaper();
+
+
+        // 通知打印完成
+        mHandler.postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                if(listener!=null){
+                    listener.PrintingComplete();
+                }
+            }
+        },printTotalTime);
+    }
+
+
+    public void destory(){
+
+        if(mHandler!=null){
+            mHandler.removeCallbacksAndMessages(null);
+            mHandler = null;
+        }
+
+        if(iPrinter!=null){
+            iPrinter.disconnect();
+            iPrinter = null;
+        }
+
+        instance = null;
+
+    }
+
+
+
+
+}

+ 62 - 0
lib_print/src/main/java/com/common/print/IPrinter.java

@@ -0,0 +1,62 @@
+package com.common.print;
+
+import com.common.print.callback.PrintInitResultCallback;
+
+/**
+ * 打印基本接口
+ */
+public interface IPrinter {
+
+
+    void initPrint(PrintInitResultCallback printInitResultCallback);
+
+    /**
+     * 打印文字
+     * @param text
+     * @param align
+     * @param textSize
+     * @param isBold
+     */
+    void printText(String text,int align,int textSize,boolean isBold);
+
+
+    /**
+     * 打印条形码
+     * @param text
+     */
+    void printBarCode(String text,int width,int height);
+
+    /**
+     * 打印二维码
+     */
+    void printQrCode(String text,int width,int height);
+
+    /**
+     * 打印图片
+     * @param base64
+     */
+    void printBitmap(String base64,int width,int height);
+
+    /**
+     * 走纸
+     * 打印空行
+     */
+    void feed(int line);
+
+    /**
+     * 切纸
+     */
+    void cutPaper();
+
+    /**
+     * 打印机取消连接
+     */
+    void disconnect();
+
+    /**
+     * 开始打印
+     */
+    void startPrint();
+
+
+}

+ 15 - 0
lib_print/src/main/java/com/common/print/callback/PrintInitResultCallback.java

@@ -0,0 +1,15 @@
+package com.common.print.callback;
+
+
+
+/**
+ * Created by L470 on 2020/4/11.
+ * 打印SDK初始化成功失败返回结果的回调接口,给最上调用层的回调
+ */
+public interface PrintInitResultCallback {
+
+    void onPrintInitSuccess();
+
+    void onPrintInitError(String errorCode, String errorMsg);
+
+}

+ 328 - 0
lib_print/src/main/java/com/common/print/many/MlaPrinter.java

@@ -0,0 +1,328 @@
+package com.common.print.many;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.hardware.usb.UsbDevice;
+import android.hardware.usb.UsbManager;
+import android.util.Log;
+
+import com.common.lib_base.common.async.ThreadPoolManager;
+import com.common.print.IPrinter;
+import com.common.print.callback.PrintInitResultCallback;
+import com.common.print.utils.BitmapUtils;
+import com.tx.printlib.Const;
+import com.tx.printlib.UsbPrinter;
+
+import java.util.Map;
+
+/**
+ *
+ * 是乐易的打印机
+ * 适用于以下设备
+ * 马里奥-y9
+ */
+public class MlaPrinter implements IPrinter {
+
+
+    // 当前类名
+    public String mTag = "HHArome--"+getClass().getSimpleName() + "--";
+
+    //用volatile关键字确保 instance 在多线程下的可见性
+    private static volatile MlaPrinter instance = null;
+
+    //将构造方法私有化,禁止外部通过构造方法创建实例
+    private MlaPrinter() {
+    }
+
+    //提供一个公共的访问方法,用于获取该类的唯一实例
+    public static MlaPrinter getInstance(Context context) {
+        //如果instance为空,就进行实例化
+        if (instance == null) {
+            //保证多线程下只有一个线程进行实例化
+            synchronized (MlaPrinter.class) {
+                //第二次判断,避免多线程下创建多个实例
+                if (instance == null) {
+                    instance = new MlaPrinter(context);
+                }
+            }
+        }
+        return instance;
+    }
+
+    private MlaPrinter(Context context) {
+        this.mContext = context;
+    }
+
+
+    Context mContext;
+
+    private UsbPrinter mUsbPrinter;
+    int vidpid[] = new int[]{0, 0};
+
+
+    int retryCount = 0;
+    boolean isInitSuccess;
+
+    public void init(Context context) {
+
+//        VID是,PID是
+
+        if(mUsbPrinter==null){
+            mUsbPrinter = new UsbPrinter(context.getApplicationContext());
+        }
+
+
+//        try{
+//            vidpid=getvidpid("28E9","5812");
+//        }
+//        catch (NumberFormatException e){
+//            Log.e(mTag,"PID或VID不是有效的16进制数");
+//        }
+//
+//        final UsbDevice dev = getCorrectDevice(vidpid[0],vidpid[1]);
+        final UsbDevice dev = getCorrectDevice();
+        if (dev != null && mUsbPrinter.open(dev)) {
+
+            mUsbPrinter.init();
+
+            final long stat1 = mUsbPrinter.getStatus();
+            final long stat2 = mUsbPrinter.getStatus2();
+            Log.e(mTag, "stat1:" + stat1);
+            Log.e(mTag, "stat2:" + stat2);
+            // open()和close()要配对使用
+            mUsbPrinter.close();
+
+            isInitSuccess = true;
+            printInitResultCallback.onPrintInitSuccess();
+
+        } else {
+            Log.e(mTag, "找不到USB打印机");
+            Log.e(mTag, "retryCount:"+retryCount);
+
+            mUsbPrinter.close();
+
+            if(retryCount <= 5){
+                retryCount++;
+                init(mContext);
+            }else{
+                isInitSuccess = false;
+                printInitResultCallback.onPrintInitError("-1","找不到USB打印机,请检查USB线连接");
+            }
+
+
+        }
+
+
+    }
+
+    PrintInitResultCallback printInitResultCallback;
+
+    @Override
+    public void initPrint(PrintInitResultCallback printInitResultCallback) {
+
+        this.printInitResultCallback = printInitResultCallback;
+
+        init(mContext);
+
+    }
+
+    @Override
+    public void printText(String text, int align, int textSize, boolean isBold) {
+
+        Log.e(mTag,"isInitSuccess--"+isInitSuccess);
+
+        // 恢复字体效果(大小、粗体等)为原始状态
+        mUsbPrinter.resetFont();
+        // 文字位置,左中右
+        mUsbPrinter.doFunction(Const.TX_ALIGN, align, 0);
+        // 文字加粗
+        mUsbPrinter.doFunction(Const.TX_FONT_BOLD, isBold ? Const.TX_ON : Const.TX_OFF, 0);
+        // 文字大小
+        if (textSize > 26) {
+            mUsbPrinter.doFunction(Const.TX_FONT_SIZE, Const.TX_SIZE_2X, Const.TX_SIZE_2X);
+        } else {
+            mUsbPrinter.doFunction(Const.TX_FONT_SIZE, Const.TX_SIZE_1X, Const.TX_SIZE_1X);
+        }
+        // 打印文字
+        mUsbPrinter.outputStringLn(text);
+        // 间隔
+        feed(15);
+        // 恢复字体效果(大小、粗体等)为原始状态
+        mUsbPrinter.resetFont();
+
+//        feed(15);
+
+
+    }
+
+    @Override
+    public void printBarCode(String text, int width, int height) {
+        mUsbPrinter.doFunction(Const.TX_BARCODE_HEIGHT, 15, 0);
+        mUsbPrinter.printBarcode(Const.TX_BAR_UPCA, text);
+    }
+
+    @Override
+    public void printQrCode(String text, int width, int height) {
+        // 点大小
+        mUsbPrinter.doFunction(Const.TX_QR_DOTSIZE, 6, 0);
+        // 纠错等级
+        mUsbPrinter.doFunction(Const.TX_QR_ERRLEVEL, Const.TX_QR_ERRLEVEL_M, 0); //27 for TX_QR_ERRLEVEL,0x32
+
+        mUsbPrinter.printQRcode(text);
+    }
+
+    @Override
+    public void printBitmap(final String base64, int width, int height) {
+        //mUsbPrinter.printImage("/storage/sdcard0/a1.png");
+//        mUsbPrinter.printImage(getExternalFilesDir(null).getPath()+"/../../../../a1.png");
+//        mUsbPrinter.doFunction(Const.TX_UNIT_TYPE, Const.TX_UNIT_PIXEL, 0);
+
+
+//        ThreadPoolManager.getInstance().executeIOTask(new Runnable() {
+//            @Override
+//            public void run() {
+
+        feed(10);
+
+                String picturePath = null;
+                try {
+                    picturePath = BitmapUtils.createPictureDirAndFile();
+                    Log.e(mTag,"picturePath:"+picturePath);
+                    Bitmap bitmap = BitmapUtils.stringToBitmap(base64);
+                    BitmapUtils.saveImage(picturePath,bitmap);
+                    Thread.sleep(500);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    Log.e(mTag,"e:"+e.toString());
+                }
+//        String picturePath = "/storage/emulated/0/T1YB01_2024-05-16.png";
+                try {
+                    Log.e(mTag,"开始打印的picturePath:"+picturePath);
+                    mUsbPrinter.doFunction(Const.TX_ALIGN, 1, 0);
+                    mUsbPrinter.printImage(picturePath);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    Log.e(mTag,"e:"+e.toString());
+                }
+
+        feed(30);
+
+//            }
+//        });
+
+
+
+//        mUsbPrinter.printImage(mContext.getExternalFilesDir(null).getPath()+"/../../../../a1.png");
+//        mUsbPrinter.doFunction(Const.TX_UNIT_TYPE, Const.TX_UNIT_PIXEL, 0);
+
+
+
+    }
+
+
+    @Override
+    public void feed(int line) {
+        // 走纸
+        mUsbPrinter.doFunction(Const.TX_FEED, line, 0);
+
+    }
+
+    @Override
+    public void cutPaper() {
+
+        feed(30);
+        mUsbPrinter.doFunction(Const.TX_FEED, 140, 0);
+        mUsbPrinter.doFunction(Const.TX_CUT, Const.TX_PURECUT_FULL, 0);
+
+
+        mUsbPrinter.close();
+
+    }
+
+    @Override
+    public void disconnect() {
+
+        if(mUsbPrinter!=null){
+            mUsbPrinter.close();
+        }
+
+    }
+
+    @Override
+    public void startPrint() {
+
+        // 每一次打印,都需要open下。等切纸时再close
+        final UsbDevice dev = getCorrectDevice();
+        if (dev != null && mUsbPrinter.open(dev)) {
+
+            mUsbPrinter.init();
+
+            final long stat1 = mUsbPrinter.getStatus();
+            final long stat2 = mUsbPrinter.getStatus2();
+            Log.e(mTag, "startPrint--stat1:" + stat1);
+            Log.e(mTag, "startPrint--stat2:" + stat2);
+            // 不再close,等打印完再close
+
+
+        } else {
+            Log.e(mTag, "startPrint--找不到USB打印机");
+
+            mUsbPrinter.close();
+
+            // 再试下
+            final UsbDevice dev2 = getCorrectDevice();
+            if (dev2 != null && mUsbPrinter.open(dev2)) {
+
+                mUsbPrinter.init();
+                final long stat1 = mUsbPrinter.getStatus();
+                final long stat2 = mUsbPrinter.getStatus2();
+                Log.e(mTag, "startPrint--stat1:" + stat1);
+                Log.e(mTag, "startPrint--stat2:" + stat2);
+            }
+
+
+        }
+
+    }
+
+
+    private UsbDevice getCorrectDevice() {
+        final UsbManager usbMgr = (UsbManager) (mContext.getSystemService(Context.USB_SERVICE));
+        final Map<String, UsbDevice> devMap = usbMgr.getDeviceList();
+        for (String name : devMap.keySet()) {
+            Log.e(mTag, "check device: " + name);
+            if (UsbPrinter.checkPrinter(devMap.get(name)))
+                return devMap.get(name);
+        }
+        return null;
+    }
+
+
+    private UsbDevice getCorrectDevice(int vid, int pid) {
+        final UsbManager usbMgr = (UsbManager) (mContext.getSystemService(Context.USB_SERVICE));
+        final Map<String, UsbDevice> devMap = usbMgr.getDeviceList();
+        for (String name : devMap.keySet()) {
+            Log.e(mTag, "check device: " + name);
+            //devMap.get(name).getProductId() devMap.get(name).getVendorId()
+            if (vid != 0 && pid != 0) {
+                if (devMap.get(name).getVendorId() != vid || devMap.get(name).getProductId() != pid) {
+                    continue;
+                }
+            }
+            if (UsbPrinter.checkPrinter(devMap.get(name)))
+                return devMap.get(name);
+        }
+        return null;
+    }
+
+    public static int[] getvidpid(String vidstr, String pidstr) {
+        int vid = 0, pid = 0;
+        if (!vidstr.isEmpty() && !pidstr.isEmpty()) {
+            vid = Integer.parseInt(vidstr, 16);
+            pid = Integer.parseInt(pidstr, 16);
+        }
+        return new int[]{vid, pid};
+    }
+
+
+}

+ 82 - 0
lib_print/src/main/java/com/common/print/many/NullPrinter.java

@@ -0,0 +1,82 @@
+package com.common.print.many;
+
+import com.common.print.IPrinter;
+import com.common.print.callback.PrintInitResultCallback;
+
+/**
+ * 空实现
+ */
+public class NullPrinter implements IPrinter {
+
+
+    //用volatile关键字确保 instance 在多线程下的可见性
+    private static volatile NullPrinter instance = null;
+
+    //将构造方法私有化,禁止外部通过构造方法创建实例
+    private NullPrinter() {}
+
+    //提供一个公共的访问方法,用于获取该类的唯一实例
+    public static NullPrinter getInstance() {
+        //如果instance为空,就进行实例化
+        if (instance == null) {
+            //保证多线程下只有一个线程进行实例化
+            synchronized (NullPrinter.class) {
+                //第二次判断,避免多线程下创建多个实例
+                if (instance == null) {
+                    instance = new NullPrinter();
+                }
+            }
+        }
+        return instance;
+    }
+
+
+    PrintInitResultCallback printInitResultCallback;
+
+    @Override
+    public void initPrint(PrintInitResultCallback printInitResultCallback) {
+        this.printInitResultCallback = printInitResultCallback;
+//        printInitResultCallback.onPrintInitSuccess();
+    }
+
+    @Override
+    public void printText(String text, int align, int textSize, boolean isBold) {
+
+    }
+
+    @Override
+    public void printBarCode(String text, int width, int height) {
+
+    }
+
+    @Override
+    public void printQrCode(String text, int width, int height) {
+
+    }
+
+    @Override
+    public void printBitmap(String base64, int width, int height) {
+
+    }
+
+
+    @Override
+    public void feed(int line) {
+
+    }
+
+    @Override
+    public void cutPaper() {
+
+    }
+
+    @Override
+    public void disconnect() {
+
+    }
+
+    @Override
+    public void startPrint() {
+
+    }
+}

+ 316 - 0
lib_print/src/main/java/com/common/print/many/TbPrinter.java

@@ -0,0 +1,316 @@
+package com.common.print.many;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.os.Handler;
+import android.util.Log;
+
+import com.common.lib_base.common.async.ThreadPoolManager;
+import com.common.print.IPrinter;
+import com.common.print.callback.PrintInitResultCallback;
+import com.common.print.utils.BitmapUtils;
+import com.common.print.utils.CodeUtils;
+import com.telpo.tps550.api.TelpoException;
+import com.telpo.tps550.api.printer.ThermalPrinter;
+import com.telpo.tps550.api.printer.UsbThermalPrinter;
+
+/**
+ * 天波
+ * D2
+ */
+public class TbPrinter implements IPrinter {
+
+    // 当前类名
+    public String mTag = "HHArome--"+getClass().getSimpleName() + "--";
+
+    //用volatile关键字确保 instance 在多线程下的可见性
+    private static volatile TbPrinter instance = null;
+
+    //将构造方法私有化,禁止外部通过构造方法创建实例
+    private TbPrinter() {
+    }
+
+    //提供一个公共的访问方法,用于获取该类的唯一实例
+    public static TbPrinter getInstance(Context context) {
+        //如果instance为空,就进行实例化
+        if (instance == null) {
+            //保证多线程下只有一个线程进行实例化
+            synchronized (TbPrinter.class) {
+                //第二次判断,避免多线程下创建多个实例
+                if (instance == null) {
+                    instance = new TbPrinter(context);
+                }
+            }
+        }
+        return instance;
+    }
+
+    Context mContext;
+
+    private TbPrinter(Context context) {
+        this.mContext = context;
+//        init();
+    }
+
+    private static UsbThermalPrinter tps508Printer;
+
+    private void init() {
+
+
+        tps508Printer = new UsbThermalPrinter(mContext);
+
+        isPowerOn();
+
+
+        try {
+
+            tps508Printer.setGray(5);//设置打印灰度值 level:0-7,默认为1
+
+
+        } catch (TelpoException e) {
+            e.printStackTrace();
+
+            Log.e(mTag, "e:"+e.toString());
+
+//            printInitResultCallback.onPrintInitError("-1","天波打印机,reset出错");
+
+        }
+
+
+    }
+
+    Handler mHandler = new Handler();
+
+    int retryCount = 0;
+    int allRetryCount = 6;
+
+    // 上电
+    public void isPowerOn() {
+        if (tps508Printer == null) {
+            tps508Printer = new UsbThermalPrinter(mContext);
+        }
+
+
+        ThreadPoolManager.getInstance().executeIOTask(new Runnable() {
+            @Override
+            public void run() {
+                try {
+
+                    tps508Printer.start(0);
+                    Thread.sleep(500);
+                    tps508Printer.reset();
+
+
+                    mHandler.postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+
+                            int checkStatus = 0;
+                            try {
+                                checkStatus = ThermalPrinter.checkStatus();
+                            } catch (TelpoException e) {
+                                e.printStackTrace();
+                            }
+
+                            Log.e(mTag, "checkStatus:"+checkStatus);
+                            if(checkStatus == ThermalPrinter.STATUS_OK){
+                                // 打印机就绪
+                                printInitResultCallback.onPrintInitSuccess();
+                            }else if(checkStatus == ThermalPrinter.STATUS_NO_PAPER){
+                                // 打印机缺纸
+                                printInitResultCallback.onPrintInitError(checkStatus+"","天波打印机——打印机缺纸");
+                            }else if(checkStatus == ThermalPrinter.STATUS_OVER_HEAT){
+                                // 打印机机芯过热
+                                printInitResultCallback.onPrintInitError(checkStatus+"","天波打印机——机芯过热");
+                            }else if(checkStatus == ThermalPrinter.STATUS_OVER_FLOW){
+                                // 打印机缓存已满
+                                printInitResultCallback.onPrintInitError(checkStatus+"","天波打印机——缓存已满");
+                            }else if(checkStatus == ThermalPrinter.STATUS_UNKNOWN){
+                                // 打印机状态未知
+                                printInitResultCallback.onPrintInitError(checkStatus+"","天波打印机——状态未知");
+                            }
+
+                        }
+                    },1000);
+
+
+//
+//
+
+
+                } catch (TelpoException | InterruptedException e) {
+                    e.printStackTrace();
+
+                    Log.e(mTag, "e:"+e.toString());
+
+                    if(e.toString().contains("DeviceNotOpenException")){
+                        try {
+                            tps508Printer.start(0);
+                            tps508Printer.reset();
+                        } catch (TelpoException telpoException) {
+                            telpoException.printStackTrace();
+                            Log.e(mTag, "e:"+e.toString());
+                        }
+
+                    }else if(e.toString().contains("DeviceAlreadyOpenException")){
+
+                        printInitResultCallback.onPrintInitSuccess();
+
+                    }else if(retryCount <= allRetryCount){
+                        retryCount++;
+                        Log.e(mTag, "retryCount:"+retryCount);
+                        mHandler.postDelayed(new Runnable() {
+                            @Override
+                            public void run() {
+                                isPowerOn();
+                            }
+                        },1000);
+
+                    }
+//                    else{
+//                        printInitResultCallback.onPrintInitError("-1","天波打印机start、reset出错");
+//                    }
+
+
+                }
+
+            }
+        });
+
+    }
+
+    PrintInitResultCallback printInitResultCallback;
+
+
+    @Override
+    public void initPrint(PrintInitResultCallback printInitResultCallback) {
+        this.printInitResultCallback = printInitResultCallback;
+        init();
+    }
+
+    @Override
+    public void printText(String text, int align, int textSize, boolean isBold) {
+
+        try {
+
+            tps508Printer.setAlgin(align);//设置打印对齐方式
+            tps508Printer.setTextSize(textSize);
+            tps508Printer.addString(text);
+            tps508Printer.setBold(isBold);
+
+        } catch (TelpoException e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+    @Override
+    public void printBarCode(String text, int width, int height) {
+
+    }
+
+    @Override
+    public void printQrCode(String text, int width, int height) {
+
+        Bitmap bitmap = CodeUtils.createQRCodeBitmap(text,
+                800,
+                800,
+                "UTF-8",
+                "M",
+                "1",
+                Color.BLACK, Color
+                        .WHITE
+                , null,
+                0.2F,
+                null);
+
+        if (width == 0) {
+            width = 376;
+        }
+        if (height == 0) {
+            height = 376;
+        }
+        Bitmap bitmap1 = BitmapUtils.zoomImg(bitmap,
+                width,
+                height);
+
+        try {
+            tps508Printer.printLogo(bitmap1, true);
+        } catch (TelpoException e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+    @Override
+    public void printBitmap(String base64, int width, int height) {
+
+
+        Bitmap bitmap = BitmapUtils.stringToBitmap(base64);
+
+        if (width == 0) {
+            width = 376;
+        }
+        if (height == 0) {
+            height = 376;
+        }
+
+        Bitmap bitmap1 = BitmapUtils.zoomImg(bitmap,
+                width,
+                height);
+
+        try {
+            tps508Printer.printLogo(bitmap1, true);
+        } catch (TelpoException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    @Override
+    public void feed(int line) {
+        try {
+            tps508Printer.walkPaper(line);
+        } catch (TelpoException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void cutPaper() {
+
+        // D2这个没有切纸的,要手动撕它。所以不要调用切纸的接口,会报错崩溃
+
+        feed(15);
+
+        try {
+            tps508Printer.printString();//启动打印,打印完不走纸
+        } catch (TelpoException e) {
+            e.printStackTrace();
+        }
+
+
+        feed(15);
+
+    }
+
+    @Override
+    public void disconnect() {
+        tps508Printer.stop();
+    }
+
+    @Override
+    public void startPrint() {
+
+    }
+
+
+
+
+
+
+
+}

+ 135 - 0
lib_print/src/main/java/com/common/print/utils/BitmapUtils.java

@@ -0,0 +1,135 @@
+package com.common.print.utils;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Matrix;
+import android.os.Build;
+import android.util.Base64;
+import android.util.Log;
+
+import com.blankj.utilcode.util.FileIOUtils;
+import com.blankj.utilcode.util.FileUtils;
+import com.blankj.utilcode.util.PathUtils;
+import com.common.lib_base.common.async.ThreadPoolManager;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Locale;
+
+public class BitmapUtils {
+
+
+
+    public static String getLogcatDir() {
+        //获取外存路径
+        String externalStoragePath = PathUtils.getExternalAppFilesPath();//   /storage/emulated/0/Android/data/com.hh.arome/files
+//        String externalStoragePath = PathUtils.getExternalStoragePath(); // /storage/emulated/0
+        Log.e("HHArome","externalStoragePath:"+externalStoragePath);
+        //命名存储目录
+        String logPath = externalStoragePath + File.separator + "picture";
+//        String logPath = externalStoragePath;
+        //判断目录是否存在,不存在则判断是否建立成功
+        FileUtils.createOrExistsDir(logPath);
+        return logPath;
+    }
+
+    public static String createFileName() {
+        String fileName = "";
+        String pattern = "yyyy-MM-dd";
+        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.CHINA);
+
+        Calendar calendar = Calendar.getInstance();
+        int hour = calendar.get(Calendar.HOUR_OF_DAY);
+
+        String curDate = dateFormat.format(calendar.getTime());
+        //品牌+时间
+        String model = Build.MODEL;
+        fileName = model + "_" + curDate+"_"+ hour + ".png";
+
+//        fileName = "a1.png";
+
+        return fileName;
+    }
+
+
+
+    public static String createPictureDirAndFile() {
+
+        String logcatDir = getLogcatDir();
+        String fileName = createFileName();
+        String filePath = logcatDir + File.separator + fileName;
+
+        return filePath;
+    }
+
+
+    /**
+     * 字符串转换成Bitmap类型
+     * @param string
+     * @return
+     */
+    public static Bitmap stringToBitmap(String string) {
+
+        Bitmap bitmap = null;
+        try {
+            byte[] bitmapArray;
+            bitmapArray = Base64.decode(string, Base64.DEFAULT);
+            bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
+                    bitmapArray.length);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return bitmap;
+    }
+
+
+    /**
+     * 将Bitmap转成本地图片
+     * @param path 保存为本地图片的地址
+     * @param bitmap 要转化的Bitmap
+     */
+    public static void saveImage(String path, Bitmap bitmap){
+
+        try {
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(path));
+            bitmap.compress(Bitmap.CompressFormat.JPEG,80,bos);
+            bos.flush();
+            bos.close();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    public static Bitmap zoomImg(Bitmap bm, int newWidth, int newHeight) {
+        Bitmap newbm = null;
+        if (bm != null) {
+            // 获得图片的宽高
+            int width = bm.getWidth();
+            int height = bm.getHeight();
+            // 计算缩放比例
+            float scaleWidth = ((float) newWidth) / width;
+            float scaleHeight = ((float) newHeight) / height;
+            // 取得想要缩放的matrix参数
+            Matrix matrix = new Matrix();
+            matrix.postScale(scaleWidth, scaleHeight);
+            // 得到新的图片
+            newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);
+        }
+        return newbm;
+    }
+
+
+
+}

+ 1 - 1
lib_print/src/main/java/com/telpo/tps508/base/CodeUtils.java → lib_print/src/main/java/com/common/print/utils/CodeUtils.java

@@ -1,4 +1,4 @@
-package com.telpo.tps508.base;
+package com.common.print.utils;
 
 import android.graphics.Bitmap;
 import android.graphics.Canvas;

+ 1 - 6
lib_print/src/main/java/com/telpo/tps508/PrintUtile.java

@@ -7,7 +7,6 @@ import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Matrix;
-import android.os.Build;
 import android.os.Handler;
 import android.os.Looper;
 import android.util.Base64;
@@ -17,15 +16,11 @@ import androidx.fragment.app.FragmentActivity;
 
 import com.caverock.androidsvg.SVG;
 import com.caverock.androidsvg.SVGParseException;
-import com.google.zxing.qrcode.encoder.QRCode;
-import com.telpo.tps508.base.CodeUtils;
-import com.telpo.tps508.base.IPrintBase;
+import com.common.print.utils.CodeUtils;
 import com.telpo.tps550.api.TelpoException;
 import com.telpo.tps550.api.printer.UsbThermalPrinter;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;

+ 11 - 1
recorderlib/build.gradle

@@ -21,7 +21,17 @@ android {
     buildTypes {
         release {
             minifyEnabled false
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+
+        debug {
+            jniDebuggable true
+            debuggable true
+        }
+
+        yufabu {
+            jniDebuggable true
+            debuggable true
         }
     }
     sourceSets.main {

+ 1 - 0
settings.gradle

@@ -1,3 +1,4 @@
+include ':lib_arome'
 include ':MultiReaderLib',':idCard',":recorderlib"
 include ':app', ':lib_base','SeriaApp',':lib_print'
 rootProject.name = "HHContainer"

Some files were not shown because too many files changed in this diff