[672][app][device]升级build gradle版本到3.5.4用于兼容Android11 manifest <queries>标签;添加硬件管理模块用于管理车载已硬件:新老核销、语音模块等;OCH核销依赖下沉;
This commit is contained in:
@@ -64,8 +64,8 @@ dependencies {
|
|||||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||||
implementation rootProject.ext.dependencies.rxandroid
|
implementation rootProject.ext.dependencies.rxandroid
|
||||||
|
|
||||||
// 串口链接
|
// 硬件管理
|
||||||
implementation rootProject.ext.dependencies.serialport
|
implementation project(":libraries:mogo-hardware-devices")
|
||||||
|
|
||||||
implementation rootProject.ext.dependencies.arouter
|
implementation rootProject.ext.dependencies.arouter
|
||||||
kapt rootProject.ext.dependencies.aroutercompiler
|
kapt rootProject.ext.dependencies.aroutercompiler
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.mogo.och.common.module.manager.scnner
|
package com.mogo.och.common.module.manager.scnner
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.mogo.commons.AbsMogoApplication
|
|
||||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||||
@@ -9,17 +8,17 @@ import com.mogo.eagle.core.utilcode.util.GsonUtils
|
|||||||
import com.mogo.eagle.core.utilcode.util.StringUtils
|
import com.mogo.eagle.core.utilcode.util.StringUtils
|
||||||
import com.mogo.och.common.module.biz.lansocket.IOchLanPassengerStatusListener
|
import com.mogo.och.common.module.biz.lansocket.IOchLanPassengerStatusListener
|
||||||
import com.mogo.och.common.module.biz.lansocket.LoginLanPassengerSocket
|
import com.mogo.och.common.module.biz.lansocket.LoginLanPassengerSocket
|
||||||
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDevicesMsg
|
|
||||||
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffMsg
|
|
||||||
import com.mogo.och.common.module.constant.OchCommonConst
|
import com.mogo.och.common.module.constant.OchCommonConst
|
||||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||||
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
|
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
|
||||||
import com.mogo.support.serialport.client.SerialPortManager
|
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDevicesMsg
|
||||||
import com.mogo.support.serialport.client.SerialPortManager.SERVICE_STATE
|
import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffMsg
|
||||||
import com.mogo.support.serialport.client.listener.OnDeviceVerificationListener
|
import com.mogo.support.device.manager.SerialPortManager
|
||||||
import com.mogo.support.serialport.client.listener.OnSerialPortListener
|
import com.mogo.support.device.manager.bean.VerificationData
|
||||||
import com.mogo.support.serialport.common.verification.UnpackStatus
|
import com.mogo.support.serialport.common.core.DeviceType
|
||||||
import com.mogo.support.serialport.common.verification.data.VerificationActiveData
|
import com.mogo.support.device.DevicesManager
|
||||||
|
import com.mogo.support.device.IBindStateChangeListener
|
||||||
|
import com.mogo.support.device.IVerificationAutoListener
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
@@ -28,7 +27,6 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
|
|
||||||
private val TAG = "ScannerManager"
|
private val TAG = "ScannerManager"
|
||||||
|
|
||||||
private var serialPortManager = SerialPortManager()
|
|
||||||
|
|
||||||
private val stateChanageListeners: ConcurrentHashMap<String, StateChangeListener> =
|
private val stateChanageListeners: ConcurrentHashMap<String, StateChangeListener> =
|
||||||
ConcurrentHashMap()
|
ConcurrentHashMap()
|
||||||
@@ -36,8 +34,11 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
private var bindStatus: BindStatus by Delegates.observable(BindStatus.NOTHING) { _, oldV, newV ->
|
private var bindStatus: BindStatus by Delegates.observable(BindStatus.NOTHING) { _, oldV, newV ->
|
||||||
if (oldV != newV) {
|
if (oldV != newV) {
|
||||||
try {
|
try {
|
||||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "扫码枪状态发生变化old:${oldV}_new:${newV}")
|
CallerLogger.d(
|
||||||
if(newV!= BindStatus.BIND_SUCCEED) {
|
SceneConstant.M_OCHCOMMON + TAG,
|
||||||
|
"扫码枪状态发生变化old:${oldV}_new:${newV}"
|
||||||
|
)
|
||||||
|
if (newV != BindStatus.BIND_SUCCEED) {
|
||||||
dispatchMsg(newV)
|
dispatchMsg(newV)
|
||||||
}
|
}
|
||||||
if (stateChanageListeners.size > 0) {
|
if (stateChanageListeners.size > 0) {
|
||||||
@@ -65,41 +66,58 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val onDeviceVerificationListener = object :OnDeviceVerificationListener(){
|
private val onDeviceVerificationListener = object : IVerificationAutoListener {
|
||||||
override fun onSerialPortState(
|
override fun onDeviceState(
|
||||||
path: String?,
|
path: String?,
|
||||||
|
deviceType: Byte,
|
||||||
isOpen: Boolean,
|
isOpen: Boolean,
|
||||||
throwableMessage: String?
|
message: String?
|
||||||
) {
|
) {
|
||||||
CallerLogger.d(
|
super.onDeviceState(path, deviceType, isOpen, message)
|
||||||
M_BUS_P + TAG,
|
var deviceTypeString = "未知"
|
||||||
"path ${path}---isOpen${isOpen}--throwableMessage${throwableMessage}"
|
if (deviceType == DeviceType.VERIFICATION_SK87R) {
|
||||||
|
deviceTypeString = "(SK87R)"
|
||||||
|
} else if (deviceType == DeviceType.VERIFICATION_Q350) {
|
||||||
|
deviceTypeString = "(Q350)"
|
||||||
|
}
|
||||||
|
val msg =
|
||||||
|
"地址:${path} 设备类型:${deviceTypeString} 是否打开:${isOpen} 消息:${message}"
|
||||||
|
CallerLogger.d(M_BUS_P + TAG, msg)
|
||||||
|
OchChainLogManager.writeChainLogScanner(
|
||||||
|
TAG + "onSerialPortState",
|
||||||
|
"扫码枪是否打开:${msg}"
|
||||||
)
|
)
|
||||||
OchChainLogManager.writeChainLogScanner(TAG +"onSerialPortState","扫码枪是否打开:path${path}_isOpen${isOpen}_throwableMessage${throwableMessage}")
|
|
||||||
openStatus = if (isOpen) {
|
openStatus = if (isOpen) {
|
||||||
sendWriteOffDevicesMessage2Driver(true,"扫码枪打开成功")
|
sendWriteOffDevicesMessage2Driver(true, "扫码枪打开成功")
|
||||||
OpenStatus.Open
|
OpenStatus.Open
|
||||||
} else {
|
} else {
|
||||||
sendWriteOffDevicesMessage2Driver(false,"扫码枪打开错误:${throwableMessage}_${path}")
|
sendWriteOffDevicesMessage2Driver(
|
||||||
|
false,
|
||||||
|
"扫码枪打开错误:${msg}_${path}_${deviceTypeString}"
|
||||||
|
)
|
||||||
OpenStatus.Unopen
|
OpenStatus.Unopen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActiveDataReceive(data: VerificationActiveData?) {
|
|
||||||
OchChainLogManager.writeChainLogScanner(TAG +"onActiveDataReceive","扫码结果:data:${data}")
|
override fun onReceive(data: VerificationData?) {
|
||||||
|
OchChainLogManager.writeChainLogScanner(
|
||||||
|
TAG + "onActiveDataReceive",
|
||||||
|
"扫码结果:data:${data}"
|
||||||
|
)
|
||||||
data?.let {
|
data?.let {
|
||||||
if(data.unpackStatus==UnpackStatus.SUCCEED){
|
if (data.unpackStatus.isNullOrEmpty()) {
|
||||||
"数据类型${it.dataType.name}"
|
"数据类型${it.dataType.name}"
|
||||||
CallerLogger.d(M_BUS_P + TAG, "data $it")
|
CallerLogger.d(M_BUS_P + TAG, "data $it")
|
||||||
if(!StringUtils.isEmpty(it.payload)){
|
if (!StringUtils.isEmpty(it.payload)) {
|
||||||
parseParams(it.payload)
|
parseParams(it.payload)
|
||||||
}else{
|
} else {
|
||||||
CallerLogger.d(M_BUS_P + TAG, "数据错误")
|
CallerLogger.d(M_BUS_P + TAG, "数据错误")
|
||||||
sendWriteOffMessage2Driver("扫码数据为空")
|
sendWriteOffMessage2Driver("扫码数据为空")
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
sendWriteOffMessage2Driver("解包失败")
|
sendWriteOffMessage2Driver("解包失败:${data.unpackStatus}")
|
||||||
CallerLogger.d(M_BUS_P + TAG, "解包失败")
|
CallerLogger.d(M_BUS_P + TAG, "解包失败:${data.unpackStatus}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,45 +125,47 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val onSerialPortListener = object :OnSerialPortListener{
|
private val onSerialPortListener = object : IBindStateChangeListener {
|
||||||
override fun onServiceState(serviceState: Int) {
|
override fun onServiceState(state: Int) {
|
||||||
OchChainLogManager.writeChainLogScanner(TAG +"bindStatus","绑定服务结果:serviceState:${serviceState}")
|
OchChainLogManager.writeChainLogScanner(
|
||||||
when (serviceState) {
|
TAG + "bindStatus",
|
||||||
SERVICE_STATE.BIND_SUCCEED -> {
|
"绑定服务结果:serviceState:${state}"
|
||||||
|
)
|
||||||
|
when (state) {
|
||||||
|
SerialPortManager.SERVICE_STATE.BIND_SUCCEED -> {
|
||||||
CallerLogger.d(M_BUS_P + TAG, "服务绑定成功")
|
CallerLogger.d(M_BUS_P + TAG, "服务绑定成功")
|
||||||
bindStatus = BindStatus.BIND_SUCCEED
|
bindStatus = BindStatus.BIND_SUCCEED
|
||||||
serialPortManager.openVerificationDevice(onDeviceVerificationListener)
|
|
||||||
}
|
}
|
||||||
SERVICE_STATE.BIND_FAILURE_UNINSTALLED -> {
|
|
||||||
|
SerialPortManager.SERVICE_STATE.BIND_FAILURE_UNINSTALLED -> {
|
||||||
CallerLogger.d(M_BUS_P + TAG, "服务绑定失败:未安装串口服务端APP")
|
CallerLogger.d(M_BUS_P + TAG, "服务绑定失败:未安装串口服务端APP")
|
||||||
bindStatus = BindStatus.BIND_FAILURE_UNINSTALLED
|
bindStatus = BindStatus.BIND_FAILURE_UNINSTALLED
|
||||||
}
|
}
|
||||||
SERVICE_STATE.BIND_FAILURE_NO_PERMISSION_NOT_FOUND -> {
|
|
||||||
CallerLogger.d(M_BUS_P + TAG, "服务绑定失败:没有绑定权限或找不到服务(如果是此状态,基本上安装后就可以找到,主要就是权限问题)")
|
SerialPortManager.SERVICE_STATE.BIND_FAILURE_NO_PERMISSION_NOT_FOUND -> {
|
||||||
|
CallerLogger.d(
|
||||||
|
M_BUS_P + TAG,
|
||||||
|
"服务绑定失败:没有绑定权限或找不到服务(如果是此状态,基本上安装后就可以找到,主要就是权限问题)"
|
||||||
|
)
|
||||||
bindStatus = BindStatus.BIND_FAILURE_NO_PERMISSION_NOT_FOUND
|
bindStatus = BindStatus.BIND_FAILURE_NO_PERMISSION_NOT_FOUND
|
||||||
}
|
}
|
||||||
SERVICE_STATE.EXCEPTION -> {
|
|
||||||
|
SerialPortManager.SERVICE_STATE.EXCEPTION -> {
|
||||||
CallerLogger.d(M_BUS_P + TAG, "服务被异常销毁")
|
CallerLogger.d(M_BUS_P + TAG, "服务被异常销毁")
|
||||||
bindStatus = BindStatus.EXCEPTION
|
bindStatus = BindStatus.EXCEPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 查询串口
|
|
||||||
override fun onFindSerialPort(paths: Array<out String>?) {
|
|
||||||
CallerLogger.d(M_BUS_P + TAG, "$paths")
|
|
||||||
OchChainLogManager.writeChainLogScanner(TAG +"onFindSerialPort","查询串口:${paths}")
|
|
||||||
if(paths==null) {
|
|
||||||
bindStatus = BindStatus.BIND_FAILURE_NO_PERMISSION_NOT_FOUND
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
//监听司机端消息
|
//监听司机端消息
|
||||||
LoginLanPassengerSocket.addListener(TAG,this)
|
LoginLanPassengerSocket.addListener(TAG, this)
|
||||||
serialPortManager.bindService(AbsMogoApplication.getApp(), onSerialPortListener)//绑定服务
|
DevicesManager.addBindStateChangeListener(TAG, onSerialPortListener)
|
||||||
|
DevicesManager.addVerificationListener(TAG, onDeviceVerificationListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addStateChangeListener(tag: String, listener: StateChangeListener) {
|
fun addStateChangeListener(tag: String, listener: StateChangeListener) {
|
||||||
@@ -157,7 +177,7 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
|
|
||||||
override fun onDriverConnectChangeListener(isConnect: Boolean) {
|
override fun onDriverConnectChangeListener(isConnect: Boolean) {
|
||||||
super.onDriverConnectChangeListener(isConnect)
|
super.onDriverConnectChangeListener(isConnect)
|
||||||
if(isConnect) {
|
if (isConnect) {
|
||||||
sendScannerState()
|
sendScannerState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,17 +188,17 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
val mutableMapOf = mutableMapOf<String, Any>()
|
val mutableMapOf = mutableMapOf<String, Any>()
|
||||||
queryParameterNames.forEach {
|
queryParameterNames.forEach {
|
||||||
val queryParameter = parse.getQueryParameter(it)
|
val queryParameter = parse.getQueryParameter(it)
|
||||||
if(it!=null&&queryParameter!=null){
|
if (it != null && queryParameter != null) {
|
||||||
mutableMapOf[it] = queryParameter
|
mutableMapOf[it] = queryParameter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mutableMapOf.isNotEmpty()){
|
if (mutableMapOf.isNotEmpty()) {
|
||||||
if (stateChanageListeners.size > 0) {
|
if (stateChanageListeners.size > 0) {
|
||||||
stateChanageListeners.forEach {
|
stateChanageListeners.forEach {
|
||||||
it.value.parseData(mutableMapOf,payload)
|
it.value.parseData(mutableMapOf, payload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
sendWriteOffMessage2Driver("扫码参数数据为空:${payload}")
|
sendWriteOffMessage2Driver("扫码参数数据为空:${payload}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +207,7 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
/**
|
/**
|
||||||
* @param isConnectScanner 是否打开设备
|
* @param isConnectScanner 是否打开设备
|
||||||
*/
|
*/
|
||||||
private fun sendWriteOffDevicesMessage2Driver(isConnectScanner:Boolean, message:String){
|
private fun sendWriteOffDevicesMessage2Driver(isConnectScanner: Boolean, message: String) {
|
||||||
val msg = WriteOffDevicesMsg(isConnectScanner, message)
|
val msg = WriteOffDevicesMsg(isConnectScanner, message)
|
||||||
CallerLogger.d(M_BUS_P + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg))
|
CallerLogger.d(M_BUS_P + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg))
|
||||||
LanSocketManager.sendMsgToServer(msg)
|
LanSocketManager.sendMsgToServer(msg)
|
||||||
@@ -196,8 +216,8 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
/**
|
/**
|
||||||
* 打开设备后数据异常
|
* 打开设备后数据异常
|
||||||
*/
|
*/
|
||||||
private fun sendWriteOffMessage2Driver(message:String){
|
private fun sendWriteOffMessage2Driver(message: String) {
|
||||||
val msg = WriteOffMsg(false, "", 0, "", message,"")
|
val msg = WriteOffMsg(false, "", 0, "", message, "")
|
||||||
CallerLogger.d(M_BUS_P + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg))
|
CallerLogger.d(M_BUS_P + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg))
|
||||||
LanSocketManager.sendMsgToServer(msg)
|
LanSocketManager.sendMsgToServer(msg)
|
||||||
}
|
}
|
||||||
@@ -206,12 +226,12 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
* 链接司机屏后向司机屏同步扫码枪状态
|
* 链接司机屏后向司机屏同步扫码枪状态
|
||||||
*/
|
*/
|
||||||
private fun sendScannerState() {
|
private fun sendScannerState() {
|
||||||
if(bindStatus == BindStatus.BIND_SUCCEED && openStatus == OpenStatus.Open){
|
if (bindStatus == BindStatus.BIND_SUCCEED && openStatus == OpenStatus.Open) {
|
||||||
sendWriteOffDevicesMessage2Driver(true,"扫码枪打开状态")
|
sendWriteOffDevicesMessage2Driver(true, "扫码枪打开状态")
|
||||||
}else{
|
} else {
|
||||||
if(bindStatus == BindStatus.BIND_SUCCEED && openStatus == OpenStatus.Unopen){
|
if (bindStatus == BindStatus.BIND_SUCCEED && openStatus == OpenStatus.Unopen) {
|
||||||
sendWriteOffDevicesMessage2Driver(false,"绑定成功、打开失败")
|
sendWriteOffDevicesMessage2Driver(false, "绑定成功、打开失败")
|
||||||
}else{
|
} else {
|
||||||
dispatchMsg(bindStatus)
|
dispatchMsg(bindStatus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,16 +241,19 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
when (newV) {
|
when (newV) {
|
||||||
BindStatus.BIND_FAILURE_UNINSTALLED -> {
|
BindStatus.BIND_FAILURE_UNINSTALLED -> {
|
||||||
// 服务绑定失败:未安装串口服务端APP
|
// 服务绑定失败:未安装串口服务端APP
|
||||||
sendWriteOffDevicesMessage2Driver(false,"服务绑定失败:未安装串口服务端APP")
|
sendWriteOffDevicesMessage2Driver(false, "服务绑定失败:未安装串口服务端APP")
|
||||||
}
|
}
|
||||||
|
|
||||||
BindStatus.BIND_FAILURE_NO_PERMISSION_NOT_FOUND -> {
|
BindStatus.BIND_FAILURE_NO_PERMISSION_NOT_FOUND -> {
|
||||||
// 服务绑定失败:没有绑定权限或找不到服务(如果是此状态,基本上安装后就可以找到,主要就是权限问题)
|
// 服务绑定失败:没有绑定权限或找不到服务(如果是此状态,基本上安装后就可以找到,主要就是权限问题)
|
||||||
sendWriteOffDevicesMessage2Driver(false,"服务绑定失败:没有绑定权限或找不到服务")
|
sendWriteOffDevicesMessage2Driver(false, "服务绑定失败:没有绑定权限或找不到服务")
|
||||||
}
|
}
|
||||||
|
|
||||||
BindStatus.EXCEPTION -> {
|
BindStatus.EXCEPTION -> {
|
||||||
// 扫码枪open错误
|
// 扫码枪open错误
|
||||||
sendWriteOffDevicesMessage2Driver(false,"扫码枪打开错误")
|
sendWriteOffDevicesMessage2Driver(false, "扫码枪打开错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
BindStatus.NOTHING -> {}
|
BindStatus.NOTHING -> {}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
@@ -240,7 +263,7 @@ object ScannerManager : IOchLanPassengerStatusListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum class BindStatus {
|
enum class BindStatus {
|
||||||
BIND_SUCCEED, BIND_FAILURE_UNINSTALLED ,BIND_FAILURE_NO_PERMISSION_NOT_FOUND,EXCEPTION,NOTHING
|
BIND_SUCCEED, BIND_FAILURE_UNINSTALLED, BIND_FAILURE_NO_PERMISSION_NOT_FOUND, EXCEPTION, NOTHING
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class OpenStatus {
|
enum class OpenStatus {
|
||||||
|
|||||||
@@ -216,8 +216,8 @@ ext {
|
|||||||
//========================= autosize ======================
|
//========================= autosize ======================
|
||||||
androidautoSize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1',
|
androidautoSize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1',
|
||||||
|
|
||||||
//========================= 扫码机 ======================
|
//========================= 串口设备 ======================
|
||||||
serialport : 'com.mogo.support.serialport:client:1.0.0-alpha5',
|
serialport : 'com.mogo.support.device.manager:serial_port:2.2.3',
|
||||||
|
|
||||||
thread_opt : "com.mogo.thread.opt:lib:10.10.3",
|
thread_opt : "com.mogo.thread.opt:lib:10.10.3",
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation project(':libraries:mogo-obu')
|
implementation project(':libraries:mogo-obu')
|
||||||
implementation project(':libraries:mogo-adas')
|
implementation project(':libraries:mogo-adas')
|
||||||
|
implementation project(':libraries:mogo-hardware-devices')
|
||||||
implementation rootProject.ext.dependencies.mogoaicloudtelematic
|
implementation rootProject.ext.dependencies.mogoaicloudtelematic
|
||||||
compileOnly project(':core:function-impl:mogo-core-function-map')
|
compileOnly project(':core:function-impl:mogo-core-function-map')
|
||||||
implementation project(':core:mogo-core-function-call')
|
implementation project(':core:mogo-core-function-call')
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import android.content.Context
|
|||||||
import com.alibaba.android.arouter.facade.annotation.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||||
import com.mogo.eagle.core.function.api.datacenter.IDataCenterProvider
|
import com.mogo.eagle.core.function.api.datacenter.IDataCenterProvider
|
||||||
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener
|
|
||||||
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizManager
|
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizManager
|
||||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||||
import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher
|
import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher
|
||||||
import com.mogo.eagle.core.function.datacenter.v2x.SpeedLimitDispatcher
|
import com.mogo.eagle.core.function.datacenter.v2x.SpeedLimitDispatcher
|
||||||
import com.mogo.eagle.core.function.datacenter.v2x.TrafficLightDispatcher
|
import com.mogo.eagle.core.function.datacenter.v2x.TrafficLightDispatcher
|
||||||
|
import com.mogo.eagle.core.function.datacenter.iot.IotInItManager
|
||||||
|
|
||||||
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
|
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
|
||||||
class DataCenterProvider: IDataCenterProvider {
|
class DataCenterProvider : IDataCenterProvider {
|
||||||
|
|
||||||
override val functionName: String
|
override val functionName: String
|
||||||
get() = "DataCenterProvider"
|
get() = "DataCenterProvider"
|
||||||
|
|
||||||
private var mContext:Context? = null
|
private var mContext: Context? = null
|
||||||
|
|
||||||
override fun init(context: Context?) {
|
override fun init(context: Context?) {
|
||||||
MoGoLocationDispatcher.initListener()
|
MoGoLocationDispatcher.initListener()
|
||||||
@@ -27,6 +27,7 @@ class DataCenterProvider: IDataCenterProvider {
|
|||||||
CallerMsgBoxManager.queryAllMessages(it)
|
CallerMsgBoxManager.queryAllMessages(it)
|
||||||
TrafficLightDispatcher.INSTANCE.initServer(it)
|
TrafficLightDispatcher.INSTANCE.initServer(it)
|
||||||
SpeedLimitDispatcher.INSTANCE.initLimit(it)
|
SpeedLimitDispatcher.INSTANCE.initLimit(it)
|
||||||
|
IotInItManager.init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.mogo.eagle.core.function.datacenter.iot
|
||||||
|
|
||||||
|
import com.mogo.commons.AbsMogoApplication
|
||||||
|
import com.mogo.commons.storage.SharedPrefsMgr
|
||||||
|
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
|
||||||
|
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
|
||||||
|
import com.mogo.support.device.DevicesManager
|
||||||
|
|
||||||
|
object IotInItManager : IMoGoCloudListener {
|
||||||
|
private const val TAG = "IotInIt"
|
||||||
|
|
||||||
|
|
||||||
|
fun init() {
|
||||||
|
CallerCloudListenerManager.addListener(TAG, this)
|
||||||
|
hardwareDeviceBind(SharedPrefsMgr.getInstance().sn)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun tokenGot(token: String, sn: String) {
|
||||||
|
super.tokenGot(token, sn)
|
||||||
|
hardwareDeviceBind(sn)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun hardwareDeviceBind(sn: String) {
|
||||||
|
if (sn.isNotEmpty()) {
|
||||||
|
DevicesManager.init(AbsMogoApplication.getApp(), sn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,8 @@ dependencies {
|
|||||||
implementation rootProject.ext.dependencies.preference_ktx
|
implementation rootProject.ext.dependencies.preference_ktx
|
||||||
implementation rootProject.ext.dependencies.amapsearch
|
implementation rootProject.ext.dependencies.amapsearch
|
||||||
|
|
||||||
|
// 硬件管理
|
||||||
|
compileOnly project(":libraries:mogo-hardware-devices")
|
||||||
implementation rootProject.ext.dependencies.thread_opt
|
implementation rootProject.ext.dependencies.thread_opt
|
||||||
api project(':test:crashreport-apmbyte')
|
api project(':test:crashreport-apmbyte')
|
||||||
compileOnly project(':core:function-impl:mogo-core-function-datacenter')
|
compileOnly project(':core:function-impl:mogo-core-function-datacenter')
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.BaseAdapter
|
import android.widget.BaseAdapter
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.widget.ListPopupWindow
|
import androidx.appcompat.widget.ListPopupWindow
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@@ -132,6 +133,8 @@ import com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS
|
|||||||
import com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP
|
import com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP
|
||||||
import com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT
|
import com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT
|
||||||
import com.mogo.tts.base.IMogoTTSCallback
|
import com.mogo.tts.base.IMogoTTSCallback
|
||||||
|
import com.mogo.support.device.DevicesManager
|
||||||
|
import com.mogo.support.device.IBindStateChangeListener
|
||||||
import com.zhjt.mogo.adas.data.AdasConstants
|
import com.zhjt.mogo.adas.data.AdasConstants
|
||||||
import com.zhjt.service.chain.ChainLog
|
import com.zhjt.service.chain.ChainLog
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.appVersionInfoLayout
|
import kotlinx.android.synthetic.main.view_debug_setting.view.appVersionInfoLayout
|
||||||
@@ -272,6 +275,7 @@ import kotlinx.android.synthetic.main.view_debug_setting.view.tvDriverServerStar
|
|||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.tvGearInfo
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvGearInfo
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.tvGitBranchInfo
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvGitBranchInfo
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.tvHDCityCode
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvHDCityCode
|
||||||
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvHardwareDeviceBindState
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.tvIPCMac
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvIPCMac
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.tvIdentifyInfo
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvIdentifyInfo
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.tvIdentifyInfoCopy
|
import kotlinx.android.synthetic.main.view_debug_setting.view.tvIdentifyInfoCopy
|
||||||
@@ -351,7 +355,7 @@ internal class DebugSettingView @JvmOverloads constructor(
|
|||||||
IMoGoChassisStatesListener,
|
IMoGoChassisStatesListener,
|
||||||
IMoGoSweeperFutianCleanSystemListener,
|
IMoGoSweeperFutianCleanSystemListener,
|
||||||
IMoGoObuInfoListener,
|
IMoGoObuInfoListener,
|
||||||
ISopSettingListener, IViewControlListener, IMoGoCloudListener {
|
ISopSettingListener, IViewControlListener, IMoGoCloudListener, IBindStateChangeListener {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "DebugSettingView"
|
private const val TAG = "DebugSettingView"
|
||||||
@@ -474,6 +478,7 @@ internal class DebugSettingView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CallerObuInfoListenerManager.addListener(TAG, this)
|
CallerObuInfoListenerManager.addListener(TAG, this)
|
||||||
|
DevicesManager.addBindStateChangeListener(TAG,this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromWindow() {
|
override fun onDetachedFromWindow() {
|
||||||
@@ -503,7 +508,7 @@ internal class DebugSettingView @JvmOverloads constructor(
|
|||||||
CallerSopSettingManager.removeListener(TAG)
|
CallerSopSettingManager.removeListener(TAG)
|
||||||
|
|
||||||
CallerHmiViewControlListenerManager.removeListener(TAG)
|
CallerHmiViewControlListenerManager.removeListener(TAG)
|
||||||
|
DevicesManager.removeBindStateChangeListener(TAG)
|
||||||
// 移除 业务配置监听
|
// 移除 业务配置监听
|
||||||
CallerDevaToolsFuncConfigListenerManager.unRegisterDevaToolsFuncConfigListener(
|
CallerDevaToolsFuncConfigListenerManager.unRegisterDevaToolsFuncConfigListener(
|
||||||
FuncBizConfig.FOUNDATION,
|
FuncBizConfig.FOUNDATION,
|
||||||
@@ -1323,6 +1328,40 @@ internal class DebugSettingView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
CallerHmiManager.toggleHdMapVisualAngleAdjust(isChecked)
|
CallerHmiManager.toggleHdMapVisualAngleAdjust(isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//硬件服务绑定状态以及版本
|
||||||
|
tvHardwareDeviceBindState.setOnClickListener {
|
||||||
|
val state = when (DevicesManager.getServiceBindState()) {
|
||||||
|
0 -> {
|
||||||
|
"绑定成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
1 -> {
|
||||||
|
"绑定失败:未安装“硬件服务”APP"
|
||||||
|
}
|
||||||
|
|
||||||
|
2 -> {
|
||||||
|
"绑定失败:没有绑定权限或找不到服务"
|
||||||
|
}
|
||||||
|
|
||||||
|
3 -> {
|
||||||
|
"服务被异常销毁"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
"未知"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var msg = "客户端SDK版本:${DevicesManager.getSDKVersion() ?: "未知"}\n"
|
||||||
|
msg += "客户端SDK AIDL版本:${DevicesManager.getSDKAIDLVersion() ?: "未知"}\n"
|
||||||
|
msg += "硬件服务端APP版本:${DevicesManager.getServerVersion() ?: "未知"}\n"
|
||||||
|
msg += "硬件服务端APP AIDL版本:${DevicesManager.getServerAIDLVersion() ?: ""}"
|
||||||
|
AlertDialog.Builder(context)
|
||||||
|
.setTitle("硬件服务绑定状态: $state")
|
||||||
|
.setMessage(msg)
|
||||||
|
.setPositiveButton("确定", null)
|
||||||
|
.create().show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2707,4 +2746,31 @@ internal class DebugSettingView @JvmOverloads constructor(
|
|||||||
private fun invokeCronetResult(json: String) {
|
private fun invokeCronetResult(json: String) {
|
||||||
CallerLogger.d(SceneConstant.M_HMI + "CronetNetwork", json)
|
CallerLogger.d(SceneConstant.M_HMI + "CronetNetwork", json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onServiceState(state: Int) {
|
||||||
|
val stateMsg = when (state) {
|
||||||
|
0 -> {
|
||||||
|
"绑定成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
1 -> {
|
||||||
|
"绑定失败:未安装“硬件服务”APP"
|
||||||
|
}
|
||||||
|
|
||||||
|
2 -> {
|
||||||
|
"绑定失败:没有绑定权限或找不到服务"
|
||||||
|
}
|
||||||
|
|
||||||
|
3 -> {
|
||||||
|
"服务被异常销毁"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
"未知"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UiThreadHandler.post {
|
||||||
|
tvHardwareDeviceBindState.text = "硬件服务绑定状态: $stateMsg"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -681,6 +681,23 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="#F0F0F0" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvHardwareDeviceBindState"
|
||||||
|
style="@style/DebugSettingText"
|
||||||
|
android:text="硬件服务绑定状态: 未知"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="#F0F0F0" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvBackgroundOperation"
|
android:id="@+id/tvBackgroundOperation"
|
||||||
style="@style/DebugSettingText"
|
style="@style/DebugSettingText"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
ext {
|
ext {
|
||||||
gradle_version = '3.5.3'
|
gradle_version = '3.5.4'
|
||||||
kotlin_plugin_version = '1.5.30'
|
kotlin_plugin_version = '1.5.30'
|
||||||
plugin_version = '10.0.10_mogo'
|
plugin_version = '10.0.10_mogo'
|
||||||
service_chain_version = '5.3.14'
|
service_chain_version = '5.3.14'
|
||||||
|
|||||||
1
libraries/mogo-hardware-devices/.gitignore
vendored
Normal file
1
libraries/mogo-hardware-devices/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
4
libraries/mogo-hardware-devices/README.md
Normal file
4
libraries/mogo-hardware-devices/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#### 说明
|
||||||
|
# 硬件设备管理
|
||||||
|
## 目前包含:核销设备(SK87R和Q350)、TTS语音设备、LED屏幕
|
||||||
|
|
||||||
39
libraries/mogo-hardware-devices/build.gradle
Normal file
39
libraries/mogo-hardware-devices/build.gradle
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.android.library'
|
||||||
|
id 'kotlin-android'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
|
versionCode rootProject.versionCode as int
|
||||||
|
versionName rootProject.versionName
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
api rootProject.ext.dependencies.serialport
|
||||||
|
}
|
||||||
0
libraries/mogo-hardware-devices/consumer-rules.pro
Normal file
0
libraries/mogo-hardware-devices/consumer-rules.pro
Normal file
3
libraries/mogo-hardware-devices/gradle.properties
Normal file
3
libraries/mogo-hardware-devices/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.device
|
||||||
|
POM_ARTIFACT_ID=mogo-device
|
||||||
|
VERSION_CODE=1
|
||||||
21
libraries/mogo-hardware-devices/proguard-rules.pro
vendored
Normal file
21
libraries/mogo-hardware-devices/proguard-rules.pro
vendored
Normal file
@@ -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
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<manifest package="com.mogo.support.device"/>
|
||||||
@@ -0,0 +1,369 @@
|
|||||||
|
package com.mogo.support.device
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import com.mogo.support.device.manager.DefaultDevices
|
||||||
|
import com.mogo.support.device.manager.SerialPortManager
|
||||||
|
import com.mogo.support.device.manager.SerialPortManager.SERVICE_STATE
|
||||||
|
import com.mogo.support.device.manager.bean.VerificationData
|
||||||
|
import com.mogo.support.device.manager.listener.OnBindServerListener
|
||||||
|
import com.mogo.support.device.manager.listener.OnDeviceSpeechCx830seListener
|
||||||
|
import com.mogo.support.device.manager.listener.OnDeviceVerificationListener
|
||||||
|
import com.mogo.support.serialport.common.core.Code
|
||||||
|
import com.mogo.support.serialport.common.core.Define
|
||||||
|
import com.mogo.support.serialport.common.core.Device
|
||||||
|
import com.mogo.support.serialport.common.devices.speech.cx830se.data.SwitchingValueData
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
object DevicesManager {
|
||||||
|
private const val TAG = "DevicesManager"
|
||||||
|
private var serviceBindState = -1//-1:未知
|
||||||
|
private val serialPortManager: SerialPortManager by lazy {
|
||||||
|
SerialPortManager() // 初始化 SerialPortManager
|
||||||
|
}
|
||||||
|
|
||||||
|
private val bindStateChangeListeners: ConcurrentHashMap<String, IBindStateChangeListener> =
|
||||||
|
ConcurrentHashMap()
|
||||||
|
private val verificationAutoListeners: ConcurrentHashMap<String, IVerificationAutoListener> =
|
||||||
|
ConcurrentHashMap()
|
||||||
|
private val speechCx830seListeners: ConcurrentHashMap<String, ISpeechCx830seListener> =
|
||||||
|
ConcurrentHashMap()
|
||||||
|
|
||||||
|
fun init(context: Context, sn: String) {
|
||||||
|
serialPortManager.bindService(context, sn, bindStateChangeListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册服务端APP绑定状态
|
||||||
|
*/
|
||||||
|
fun addBindStateChangeListener(tag: String, listener: IBindStateChangeListener) {
|
||||||
|
if (bindStateChangeListeners.containsKey(tag)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bindStateChangeListeners[tag] = listener
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消注册服务端APP绑定状态
|
||||||
|
*/
|
||||||
|
fun removeBindStateChangeListener(tag: String) {
|
||||||
|
if (bindStateChangeListeners.containsKey(tag)) {
|
||||||
|
bindStateChangeListeners.remove(tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册核销设备回调接口 注册时自动连接核销设备
|
||||||
|
*/
|
||||||
|
fun addVerificationListener(tag: String, listener: IVerificationAutoListener) {
|
||||||
|
if (verificationAutoListeners.containsKey(tag)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
verificationAutoListeners[tag] = listener
|
||||||
|
if (verificationAutoListeners.isNotEmpty()) {
|
||||||
|
if (serviceBindState == SERVICE_STATE.BIND_SUCCEED) {
|
||||||
|
serialPortManager.open(DefaultDevices.VERIFICATION, verificationListener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消注册核销设备回调接口
|
||||||
|
*/
|
||||||
|
fun removeVerificationListener(tag: String) {
|
||||||
|
if (verificationAutoListeners.containsKey(tag)) {
|
||||||
|
verificationAutoListeners.remove(tag)
|
||||||
|
}
|
||||||
|
if (verificationAutoListeners.isEmpty()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册语音设备回调接口 注册时自动连接语音设备
|
||||||
|
*/
|
||||||
|
fun addSpeechCx830seListener(tag: String, listener: ISpeechCx830seListener) {
|
||||||
|
if (speechCx830seListeners.containsKey(tag)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
speechCx830seListeners[tag] = listener
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
if (serviceBindState == SERVICE_STATE.BIND_SUCCEED) {
|
||||||
|
serialPortManager.open(DefaultDevices.SPEECH_CX830SE, speechCx830seListener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消注册语音设备回调接口
|
||||||
|
*/
|
||||||
|
fun removeSpeechCx830seListener(tag: String) {
|
||||||
|
if (speechCx830seListeners.containsKey(tag)) {
|
||||||
|
speechCx830seListeners.remove(tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private val bindStateChangeListener = object : OnBindServerListener() {
|
||||||
|
|
||||||
|
override fun onServiceState(serviceState: Int) {
|
||||||
|
serviceBindState = serviceState
|
||||||
|
if (bindStateChangeListeners.isNotEmpty()) {
|
||||||
|
bindStateChangeListeners.forEach {
|
||||||
|
it.value.onServiceState(serviceState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//TODO 链路日志和埋点
|
||||||
|
// OchChainLogManager.writeChainLogScanner(
|
||||||
|
// TAG + "bindStatus",
|
||||||
|
// "绑定服务结果:serviceState:${serviceState}"
|
||||||
|
// )
|
||||||
|
when (serviceState) {
|
||||||
|
SERVICE_STATE.BIND_SUCCEED -> {
|
||||||
|
Log.d(TAG, "服务绑定成功")
|
||||||
|
if (verificationAutoListeners.isNotEmpty()) {
|
||||||
|
serialPortManager.open(DefaultDevices.VERIFICATION, verificationListener)
|
||||||
|
}
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
serialPortManager.open(DefaultDevices.SPEECH_CX830SE, speechCx830seListener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVICE_STATE.BIND_FAILURE_UNINSTALLED -> {
|
||||||
|
Log.d(TAG, "服务绑定失败:未安装串口服务端APP")
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVICE_STATE.BIND_FAILURE_NO_PERMISSION_NOT_FOUND -> {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
"服务绑定失败:没有绑定权限或找不到服务(如果是此状态,基本上安装后就可以找到,主要就是权限问题)"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVICE_STATE.EXCEPTION -> {
|
||||||
|
Log.d(TAG, "服务被异常销毁")
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val verificationListener: OnDeviceVerificationListener =
|
||||||
|
object : OnDeviceVerificationListener() {
|
||||||
|
override fun onDeviceState(
|
||||||
|
path: String?,
|
||||||
|
deviceType: Byte,
|
||||||
|
isOpen: Boolean,
|
||||||
|
message: String?
|
||||||
|
) {
|
||||||
|
if (verificationAutoListeners.isNotEmpty()) {
|
||||||
|
verificationAutoListeners.forEach {
|
||||||
|
it.value.onDeviceState(path, deviceType, isOpen, message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReceive(data: VerificationData) {
|
||||||
|
if (verificationAutoListeners.isNotEmpty()) {
|
||||||
|
verificationAutoListeners.forEach {
|
||||||
|
it.value.onReceive(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private val speechCx830seListener: OnDeviceSpeechCx830seListener =
|
||||||
|
object : OnDeviceSpeechCx830seListener() {
|
||||||
|
override fun onSerialPortState(
|
||||||
|
path: String,
|
||||||
|
isOpen: Boolean,
|
||||||
|
throwableMessage: String?
|
||||||
|
) {
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
speechCx830seListeners.forEach {
|
||||||
|
it.value.onOpenState(path, isOpen, throwableMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (isOpen) {
|
||||||
|
// openBtnEnable(!serialPortManager.isOpen(selectDevice.path))
|
||||||
|
// updateUi(path, true)
|
||||||
|
// if (serialPortManager.getDeviceType(path) == DeviceType.SPEECH_CX830SE) {
|
||||||
|
// val device = serialPortManager.getOpenedSerialPort(path)
|
||||||
|
// serialPortManager.speechCx830seSendCommand(
|
||||||
|
// device,
|
||||||
|
// SpeechCommand.READ_DEVICE_ADDRESS
|
||||||
|
// )
|
||||||
|
// serialPortManager.speechCx830seSendCommand(
|
||||||
|
// device,
|
||||||
|
// SpeechCommand.READ_SWITCHING_VALUE_STATE
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// showOpenFailed(path)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSpeechState(path: String, state: Int) {
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
speechCx830seListeners.forEach {
|
||||||
|
it.value.onSpeechState(path, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val msg = when (state) {
|
||||||
|
Code.SUCCESS -> {
|
||||||
|
"播报内容下发成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.FAILED -> {
|
||||||
|
"播报内容下发失败"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Code.TIMEOUT -> {
|
||||||
|
"播报内容下发超时"
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.SPEECH_CX830SE_SPEECH_BROADCAST_COMPLETE -> {
|
||||||
|
"播报完成"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
Log.d(TAG, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSwitchingValue(path: String, state: Int, data: SwitchingValueData?) {
|
||||||
|
super.onSwitchingValue(path, state, data)
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
speechCx830seListeners.forEach {
|
||||||
|
it.value.onSwitchingValue(path, state, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val msg = when (state) {
|
||||||
|
Code.SUCCESS -> {
|
||||||
|
"开关量读取成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.TIMEOUT -> {
|
||||||
|
"开关量读取超时"
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.PASSIVITY_RECEIVE -> {
|
||||||
|
"设备主动触发"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (!msg.isNullOrEmpty()) {
|
||||||
|
Log.d(TAG, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDeviceAddress(path: String, state: Int, address: Int) {
|
||||||
|
super.onDeviceAddress(path, state, address)
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
speechCx830seListeners.forEach {
|
||||||
|
it.value.onDeviceAddress(path, state, address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val msg = when (state) {
|
||||||
|
Code.SUCCESS -> {
|
||||||
|
"设备地址读取成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.TIMEOUT -> {
|
||||||
|
"设备地址读取超时"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (!msg.isNullOrEmpty()) {
|
||||||
|
Log.d(TAG, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCommandResponse(
|
||||||
|
path: String,
|
||||||
|
mainCommand: Int,
|
||||||
|
subcommand: Int,
|
||||||
|
state: Int
|
||||||
|
) {
|
||||||
|
super.onCommandResponse(path, mainCommand, subcommand, state)
|
||||||
|
if (speechCx830seListeners.isNotEmpty()) {
|
||||||
|
speechCx830seListeners.forEach {
|
||||||
|
it.value.onCommandResponse(path, mainCommand, subcommand, state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// val command = SpeechCommand.getCommandBySign(mainCommand)
|
||||||
|
// var msg = ""
|
||||||
|
// if (state == Code.SUCCESS) {
|
||||||
|
// msg = "执行成功"
|
||||||
|
// } else if (state == Code.TIMEOUT) {
|
||||||
|
// msg = "执行超时"
|
||||||
|
// }
|
||||||
|
Log.i(TAG, "主命令=${mainCommand} 子命令=${subcommand} 命令结果=$state")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语音设备(科星互联 CX-830S-E)语音播报
|
||||||
|
* AIDL调用
|
||||||
|
* @param content 播报内容 打断模式下,输入 null或""可以停止语音播报
|
||||||
|
* @return 是否调用成功 调用成功(不代表命令执行成功):[Code.SUCCESS];命令未识别:[Code.COMMAND_ERROR];
|
||||||
|
*/
|
||||||
|
@Define.Code
|
||||||
|
fun speechCx830seBroadcast(content: String?): Int {
|
||||||
|
return serialPortManager.speechCx830seBroadcastSpeech(
|
||||||
|
DefaultDevices.SPEECH_CX830SE,
|
||||||
|
content
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备是否打开
|
||||||
|
* @param device {@link DefaultDevices#SPEECH_CX830SE}
|
||||||
|
* {@link DefaultDevices#VERIFICATION}
|
||||||
|
* {@link DefaultDevices#VERIFICATION_SK87R}
|
||||||
|
* {@link DefaultDevices#VERIFICATION_Q350}
|
||||||
|
*/
|
||||||
|
fun isDeviceOpen(device: Device): Boolean {
|
||||||
|
if (DefaultDevices.VERIFICATION.equals(device)) {
|
||||||
|
return serialPortManager.isOpen(DefaultDevices.VERIFICATION_SK87R.path) || serialPortManager.isOpen(
|
||||||
|
DefaultDevices.VERIFICATION_Q350.path
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return serialPortManager.isOpen(device.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定状态
|
||||||
|
* -1:未知 其他的状态 [SerialPortManager.SERVICE_STATE]
|
||||||
|
*/
|
||||||
|
fun getServiceBindState(): Int {
|
||||||
|
return serviceBindState
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSDKVersion(): String {
|
||||||
|
return serialPortManager.version
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSDKAIDLVersion(): String {
|
||||||
|
return serialPortManager.aidlVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getServerVersion(): String? {
|
||||||
|
return serialPortManager.serverVersionName
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getServerAIDLVersion(): String? {
|
||||||
|
return serialPortManager.serverAidlVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.mogo.support.device
|
||||||
|
|
||||||
|
//服务绑定状态接口回调
|
||||||
|
interface IBindStateChangeListener {
|
||||||
|
fun onServiceState(state: Int)
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.mogo.support.device;
|
||||||
|
|
||||||
|
import com.mogo.support.serialport.common.core.Define
|
||||||
|
import com.mogo.support.serialport.common.devices.speech.cx830se.data.SwitchingValueData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语音设备(科星互联 CX-830S-E)监听
|
||||||
|
*/
|
||||||
|
interface ISpeechCx830seListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备打开状态
|
||||||
|
*
|
||||||
|
* @param path 串口地址
|
||||||
|
* @param isOpen 是否打开成功
|
||||||
|
* @param throwableMessage 异常消息
|
||||||
|
*/
|
||||||
|
fun onOpenState(path: String, isOpen: Boolean, throwableMessage: String?) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语音播报状态
|
||||||
|
*
|
||||||
|
* @param path 串口
|
||||||
|
* @param state 状态 语音命令下发成功:{@link Code#SUCCESS};语音命令下发失败:{@link Code#FAILED};语音命令下发超时:{@link Code#TIMEOUT};语音播报完成:{@link Code#SPEECH_CX830SE_SPEECH_BROADCAST_COMPLETE};
|
||||||
|
*/
|
||||||
|
fun onSpeechState(path: String, @Define.Code state: Int) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开关量状态
|
||||||
|
* 设备主动触发开关量时 state = Code.PASSIVITY_RECEIVE
|
||||||
|
*
|
||||||
|
* @param path 串口
|
||||||
|
* @param state 状态 查询成功:{@link Code#SUCCESS};查询命令下发失败:{@link Code#FAILED};查询超时:{@link Code#TIMEOUT};设备主动触发开关量:{@link Code#PASSIVITY_RECEIVE};
|
||||||
|
* @param data 开关量数据
|
||||||
|
*/
|
||||||
|
fun onSwitchingValue(path: String, @Define.Code state: Int, data: SwitchingValueData?) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备地址
|
||||||
|
*
|
||||||
|
* @param path 串口
|
||||||
|
* @param state 查询状态 成功:{@link Code#SUCCESS};查询命令下发失败:{@link Code#FAILED};超时:{@link Code#TIMEOUT};
|
||||||
|
* @param address 设备地址 -1:解析失败
|
||||||
|
*/
|
||||||
|
fun onDeviceAddress(path: String, @Define.Code state: Int, address: Int) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 命令下发响应
|
||||||
|
*
|
||||||
|
* @param path 串口
|
||||||
|
* @param mainCommand 命令
|
||||||
|
* @param subcommand mainCommand 中如果存在子流程则表示正在执行的子命令 目前只有存在子流程的命令有:{@link SpeechCommand#INITIALIZE};
|
||||||
|
* @param state 状态 成功:{@link Code#SUCCESS};失败:{@link Code#FAILED};超时:{@link Code#TIMEOUT};
|
||||||
|
* 当 mainCommand == {@link SpeechCommand#INITIALIZE} && subcommand == {@link SpeechCommand#UNKNOWN} 时
|
||||||
|
* state表示整体流程状态
|
||||||
|
* * 初始化开始(整体初始化流程的开始):{@link Code#SPEECH_CX830SE_INITIALIZE_START}
|
||||||
|
* * 初始化完成(整体初始化流程的完成):{@link Code#SPEECH_CX830SE_INITIALIZE_COMPLETE}
|
||||||
|
* <p>
|
||||||
|
* 当 mainCommand == {@link SpeechCommand#INITIALIZE} && subcommand != {@link SpeechCommand#UNKNOWN} 时
|
||||||
|
* state表示子命令执行状态
|
||||||
|
* * 初始化子命令开始执行(初始化流程中的子命令开始下发):{@link Code#SPEECH_CX830SE_INITIALIZE_SUBCOMMAND_START}
|
||||||
|
* * 初始化子命令成功:{@link Code#SUCCESS}
|
||||||
|
* * 初始化子命令失败:{@link Code#FAILED}
|
||||||
|
* * 初始化子命令超时:{@link Code#TIMEOUT}
|
||||||
|
*/
|
||||||
|
fun onCommandResponse(
|
||||||
|
path: String,
|
||||||
|
@Define.CommandSign mainCommand: Int,
|
||||||
|
@Define.CommandSign subcommand: Int,
|
||||||
|
@Define.Code state: Int
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.mogo.support.device
|
||||||
|
|
||||||
|
import com.mogo.support.device.manager.bean.VerificationData
|
||||||
|
|
||||||
|
//核销设备数据回调
|
||||||
|
interface IVerificationAutoListener {
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
*
|
||||||
|
* @param deviceType 设备类型 [com.mogo.support.serialport.common.core.DeviceType.VERIFICATION_Q350] [com.mogo.support.serialport.common.core.DeviceType.VERIFICATION_SK87R]
|
||||||
|
* @param isOpen 是否打开
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
|
fun onDeviceState(path: String?, deviceType: Byte, isOpen: Boolean, message: String?) {}
|
||||||
|
fun onReceive(data: VerificationData?)
|
||||||
|
}
|
||||||
@@ -44,6 +44,7 @@ include ':libraries:mogo-map'
|
|||||||
include ':libraries:mogo-adas'
|
include ':libraries:mogo-adas'
|
||||||
include ':libraries:mogo-adas-data'
|
include ':libraries:mogo-adas-data'
|
||||||
include ':libraries:mogo-obu'
|
include ':libraries:mogo-obu'
|
||||||
|
include ':libraries:mogo-hardware-devices'
|
||||||
//include ':libraries:mapmodule'
|
//include ':libraries:mapmodule'
|
||||||
|
|
||||||
// 语音
|
// 语音
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ dependencies {
|
|||||||
implementation rootProject.ext.dependencies.androidxappcompat
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
|
||||||
implementation rootProject.ext.dependencies.arouter
|
implementation rootProject.ext.dependencies.arouter
|
||||||
implementation "com.android.tools.build:gradle:3.5.3"
|
implementation "com.android.tools.build:gradle:3.5.4"
|
||||||
kapt rootProject.ext.dependencies.aroutercompiler
|
kapt rootProject.ext.dependencies.aroutercompiler
|
||||||
|
|
||||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user