[2.13.0-arch-opt] obu warning v2v and socket toast
This commit is contained in:
@@ -2,7 +2,6 @@ package com.mogo.och.common.module.manager
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.commons.module.status.StatusDescriptor
|
||||
@@ -17,6 +16,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -26,26 +26,40 @@ object AbnormalFactorsLoopManager : IMogoStatusChangedListener {
|
||||
|
||||
const val TAG = "AbnormalFactorsLoopManager"
|
||||
|
||||
private const val LOOP_TIME = 10 *1000L
|
||||
private const val LOOP_TIME = 10 * 1000L
|
||||
private const val LOOP_DELAY = 5 * 1000L
|
||||
private var socketStatus: Boolean = false
|
||||
private var socketStatus by Delegates.observable(false) { _, _, newValue ->
|
||||
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
return@observable
|
||||
}
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
return@observable
|
||||
}
|
||||
if (newValue) {
|
||||
ToastUtils.showLong("长链接状态恢复")
|
||||
} else {
|
||||
ToastUtils.showLong("长链接异常,请开启相应权限或者查看网络")
|
||||
}
|
||||
}
|
||||
|
||||
private var looperDisposable : Disposable? = null
|
||||
private var looperDisposable: Disposable? = null
|
||||
|
||||
fun startLoopAbnormalFactors(context: Context){
|
||||
if (looperDisposable != null && !looperDisposable!!.isDisposed){
|
||||
fun startLoopAbnormalFactors(context: Context) {
|
||||
if (looperDisposable != null && !looperDisposable!!.isDisposed) {
|
||||
return
|
||||
}
|
||||
i(TAG, "startLoopAbnormalFactors()")
|
||||
looperDisposable = Observable.interval(LOOP_DELAY, LOOP_TIME, TimeUnit.MILLISECONDS)
|
||||
.map { aLong -> aLong+1 }
|
||||
.map { aLong -> aLong + 1 }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe{ aLong -> checkAbnormalFactors(context)}
|
||||
.subscribe { aLong -> checkAbnormalFactors(context) }
|
||||
|
||||
//长链接监听
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG,
|
||||
StatusDescriptor.CLOUD_SOCKET,this)
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.CLOUD_SOCKET, this
|
||||
)
|
||||
}
|
||||
|
||||
private fun checkAbnormalFactors(context: Context) {
|
||||
@@ -54,14 +68,15 @@ object AbnormalFactorsLoopManager : IMogoStatusChangedListener {
|
||||
var networkStatus = false
|
||||
|
||||
//定位权限
|
||||
locationStatusPermsStatus = !(!PermissionUtil.isLocServiceEnable(context) || !PermissionUtil.checkPermission(
|
||||
context, *arrayOf(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
)
|
||||
))
|
||||
locationStatusPermsStatus =
|
||||
!(!PermissionUtil.isLocServiceEnable(context) || !PermissionUtil.checkPermission(
|
||||
context, *arrayOf(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
)
|
||||
))
|
||||
|
||||
//网络状态或者网络权限是否打开
|
||||
if (NetworkUtils.isConnected(context)){
|
||||
if (NetworkUtils.isConnected(context)) {
|
||||
networkStatus = true
|
||||
}
|
||||
//长链接状态 socketStatus
|
||||
@@ -70,28 +85,27 @@ object AbnormalFactorsLoopManager : IMogoStatusChangedListener {
|
||||
if (!locationStatusPermsStatus) toastStr += "定位服务异常 "
|
||||
if (!networkStatus) toastStr += " 网络异常 "
|
||||
|
||||
//乘客屏不显示长链接异常
|
||||
if (!socketStatus && !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) toastStr += " 长链接异常 "
|
||||
|
||||
i(TAG, "abnormal_factors_Str = $toastStr")
|
||||
|
||||
if (!FunctionBuildConfig.isDemoMode && toastStr !== ""){
|
||||
if (!FunctionBuildConfig.isDemoMode && toastStr !== "") {
|
||||
ToastUtils.showLong(toastStr + "请开启相应权限或者查看网络")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun stopLoopAbnormalFactors(){
|
||||
fun stopLoopAbnormalFactors() {
|
||||
looperDisposable!!.dispose()
|
||||
looperDisposable == null
|
||||
|
||||
MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG,
|
||||
StatusDescriptor.CLOUD_SOCKET,this)
|
||||
MogoStatusManager.getInstance().unregisterStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.CLOUD_SOCKET, this
|
||||
)
|
||||
}
|
||||
|
||||
override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) {
|
||||
//长链接监听、
|
||||
if (StatusDescriptor.CLOUD_SOCKET == descriptor){
|
||||
if (StatusDescriptor.CLOUD_SOCKET == descriptor) {
|
||||
socketStatus = isTrue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,12 +684,9 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
when (appId) {
|
||||
//前向碰撞预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> {
|
||||
if (FunctionBuildConfig.isObuWarningFusionUnion) {
|
||||
if (FunctionBuildConfig.isObuWarningFusionUnion && level == 3) {
|
||||
alertContent = "前车距离过近"
|
||||
ttsContent = "前车距离过近"
|
||||
CallerObuWarningListenerManager.invokeTrackerFusionData(
|
||||
ObuManager.getInstance().obuRvToTrackedObject(info)
|
||||
)
|
||||
} else {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
|
||||
|
||||
@@ -94,21 +94,6 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateTrackerFusionData(trackObject: TrackedObject?) {
|
||||
super.updateTrackerFusionData(trackObject)
|
||||
try {
|
||||
if (FunctionBuildConfig.isObuWarningFusionUnion) {
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
//todo emArrow
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateTrackerWarningInfo(trafficData: TrafficData) {
|
||||
super.updateTrackerWarningInfo(trafficData)
|
||||
try {
|
||||
|
||||
@@ -96,7 +96,7 @@ object FunctionBuildConfig {
|
||||
*/
|
||||
@Volatile
|
||||
@JvmField
|
||||
var isObuWarningFusionUnion = false
|
||||
var isObuWarningFusionUnion = true
|
||||
|
||||
/**
|
||||
* 当前APP的身份模式
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.eagle.core.function.api.obu
|
||||
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -17,13 +16,6 @@ interface IMoGoObuStatusListener {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* obu Tracker data
|
||||
*/
|
||||
fun updateTrackerFusionData(trackObject: MessagePad.TrackedObject?){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新obu Tracker 预警信息
|
||||
*/
|
||||
|
||||
@@ -20,13 +20,6 @@ object CallerObuWarningListenerManager : CallerBase<IMoGoObuStatusListener>() {
|
||||
}
|
||||
}
|
||||
|
||||
fun invokeTrackerFusionData(trackObject: MessagePad.TrackedObject?){
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.updateTrackerFusionData(trackObject)
|
||||
}
|
||||
}
|
||||
|
||||
fun invokeTrackerWarningInfo(trafficData: TrafficData) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
|
||||
Reference in New Issue
Block a user