Merge branch 'master' into release_robosweeper-d_100-sweeper_220830_1.0.0.1_merge
# Conflicts: # app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java # core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt # core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt # core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt # core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/TrafficDataView.java # core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapPointCloudSubscriber.kt # core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotProvider.kt # gradle.properties # libraries/mogo-adas-data/src/main/proto/message_pad.proto # libraries/mogo-adas-data/src/main/proto/special_vehicle_task_cmd.proto # libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java # libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java # libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java # libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java
@@ -52,9 +52,7 @@ import com.zhidao.support.adas.high.OnMultiDeviceListener
|
||||
import com.zhidao.support.adas.high.common.Constants
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils
|
||||
import com.zhidao.support.adas.high.common.MessageType
|
||||
import com.zhidao.support.adas.high.common.MogoReport
|
||||
import com.zhidao.support.adas.high.subscribe.SubscribeInterfaceOptions
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import io.netty.channel.Channel
|
||||
@@ -91,19 +89,19 @@ class MoGoAutopilotProvider :
|
||||
CallerMapDataCollectorManager.registerOnMapCollectTaskListener(this)
|
||||
|
||||
// 配置默认关闭的连接topic
|
||||
val messageTypes: MutableSet<MessageType> = HashSet()
|
||||
messageTypes.add(MessageType.TYPE_RECEIVE_POINT_CLOUD)
|
||||
val subscribeInterfaceOptions = SubscribeInterfaceOptions.newBuilder()
|
||||
.setRole(Constants.TERMINAL_ROLE.DRIVER)
|
||||
.setType(Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE)
|
||||
.setMessageTypes(messageTypes).build()
|
||||
// val messageTypes: MutableSet<MessageType> = HashSet()
|
||||
// messageTypes.add(MessageType.TYPE_RECEIVE_POINT_CLOUD)
|
||||
// val subscribeInterfaceOptions = SubscribeInterfaceOptions.newBuilder()
|
||||
// .setRole(Constants.TERMINAL_ROLE.DRIVER)
|
||||
// .setType(Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE)
|
||||
// .setMessageTypes(messageTypes).build()
|
||||
|
||||
// "192.168.1.102"
|
||||
val options = AdasOptions.Builder()
|
||||
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
|
||||
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
|
||||
.setClient(false)
|
||||
.setSubscribeInterfaceOptions(subscribeInterfaceOptions)
|
||||
// .setSubscribeInterfaceOptions(subscribeInterfaceOptions)//
|
||||
.build()
|
||||
|
||||
AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl())
|
||||
@@ -380,7 +378,7 @@ class MoGoAutopilotProvider :
|
||||
override fun setDemoMode(isEnable: Boolean) {
|
||||
// 同步给乘客端
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
var byteArray = if (isEnable) byteArrayOf(1) else byteArrayOf(0)
|
||||
val byteArray = if (isEnable) byteArrayOf(1) else byteArrayOf(0)
|
||||
if (NSDNettyManager.getInstance().isServerStart) {
|
||||
NSDNettyManager.getInstance()
|
||||
.sendMsgToAllClients(
|
||||
@@ -396,6 +394,25 @@ class MoGoAutopilotProvider :
|
||||
}
|
||||
}
|
||||
|
||||
override fun setIgnoreConditionDraw(isIgnore: Boolean) {
|
||||
// 同步给乘客端
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
val byteArray = if (isIgnore) byteArrayOf(1) else byteArrayOf(0)
|
||||
if (NSDNettyManager.getInstance().isServerStart) {
|
||||
NSDNettyManager.getInstance()
|
||||
.sendMsgToAllClients(
|
||||
MogoProtocolMsg(
|
||||
11,
|
||||
byteArray.size,
|
||||
byteArray
|
||||
)
|
||||
)
|
||||
} else {
|
||||
CallerLogger.d("$M_ADAS_IMPL$TAG", "同步美化模式状态时司机端Server未启动!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置工控机演示模式(美化模式)开启、关闭
|
||||
* isEnable = true 开启
|
||||
@@ -429,6 +446,38 @@ class MoGoAutopilotProvider :
|
||||
AdasManager.getInstance().sendRecordDataConfigReq()
|
||||
}
|
||||
|
||||
/**
|
||||
* 向左变道
|
||||
*/
|
||||
override fun sendOperatorChangeLaneLeft() {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorChangeLaneLeft -------> ")
|
||||
AdasManager.getInstance().sendOperatorCmdChangeLaneLeft()
|
||||
}
|
||||
|
||||
/**
|
||||
* 向右变道
|
||||
*/
|
||||
override fun sendOperatorChangeLaneRight() {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorChangeLaneRight -------> ")
|
||||
AdasManager.getInstance().sendOperatorCmdChangeLaneRight()
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送设置加速度 acc>0加速 acc<0减速 acc=0复位
|
||||
*/
|
||||
override fun sendOperatorSetAcceleratedSpeed(cc: Double) {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorSetAcceleratedSpeed cc $cc ")
|
||||
AdasManager.getInstance().sendOperatorCmdSetAcceleratedSpeed(cc)
|
||||
}
|
||||
|
||||
/**
|
||||
* 鸣笛 value 1: honk 2: stop honking
|
||||
*/
|
||||
override fun sendOperatorSetHorn(value: Double) {
|
||||
// Log.d("liyz", "MoGoAutopilotProvider sendOperatorSetHorn value $value ")
|
||||
AdasManager.getInstance().sendOperatorCmdSetHorn(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送工控机所有节点重启命令
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.autopilot.adapter
|
||||
|
||||
import chassis.VehicleStateOuterClass
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ARRIVE
|
||||
@@ -13,6 +14,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_C
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_CONFIG
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_ACTIONS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_OBJECTS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_RECT_DATA
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_STATUS_QUERY_RESP
|
||||
@@ -21,6 +23,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LO
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_DATA_TRACKED
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_GNSSINFO
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_OBJECTS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_TRAJECTORY
|
||||
@@ -38,6 +41,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListen
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotIdentifyDataUpdate
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotIdentifyPlanningObj
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotWarnMessage
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningActionsListenerManager.invokePNCActions
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager.invokeAutopilotRotting
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager.invokeAutopilotTrajectory
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPointCloudListenerManager
|
||||
@@ -203,6 +207,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
}
|
||||
AdasManager.getInstance().carConfig?.let {
|
||||
autopilotStatusInfo.dockVersion = it.dockVersion
|
||||
AppConfigInfo.dockerVersion = it.dockVersion
|
||||
}
|
||||
invokeAutoPilotStatus()
|
||||
}
|
||||
@@ -404,7 +409,21 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
/**
|
||||
* planning决策状态, 透传
|
||||
*/
|
||||
override fun onPlanningActionMsg(header: MessagePad.Header?, planningActionMsg: MessagePad.PlanningActionMsg?) {
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_ACTIONS,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onPlanningActionMsg(
|
||||
header: MessagePad.Header?,
|
||||
planningActionMsg: MessagePad.PlanningActionMsg?
|
||||
) {
|
||||
planningActionMsg?.let {
|
||||
invokePNCActions(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.eagle.core.function.autopilot.adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.commons.debug.DebugConfig.*
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
@@ -23,11 +22,9 @@ import com.zhidao.support.adas.high.common.Constants
|
||||
import com.zhidao.support.adas.high.common.Constants.ENVIRONMENT.*
|
||||
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DRIVER
|
||||
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.PASSENGER
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
/**
|
||||
* ADAS-SDK与工控机连接状态回调
|
||||
@@ -44,6 +41,10 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
|
||||
|
||||
private var connectStatus = false
|
||||
|
||||
private val hasUploadTaskLaunched by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val timer = Timer()
|
||||
|
||||
init {
|
||||
CallerCloudListenerManager.registerCloudListener(TAG, this)
|
||||
}
|
||||
@@ -168,15 +169,16 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun updateDriveStatusTask() {
|
||||
CallerLogger.d("$M_ADAS_IMPL$TAG", "updateDriveStatusTask")
|
||||
Flowable.interval(0, 5, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
AdasServiceModel.getInstance()
|
||||
.updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
|
||||
}
|
||||
if (hasUploadTaskLaunched.compareAndSet(false, true)) {
|
||||
timer.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
CallerLogger.d("$M_ADAS_IMPL$TAG", "updateDriveStatusTask")
|
||||
AdasServiceModel.getInstance()
|
||||
.updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
|
||||
}
|
||||
}, 0, 5000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun tokenGot(sn: String) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mogo.eagle.core.function.autopilot.server
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -22,7 +22,7 @@ class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListen
|
||||
}
|
||||
|
||||
fun initServer() {
|
||||
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager.setDemoMode
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager.setIgnoreConditionDraw
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
@@ -60,12 +61,13 @@ class TeleMsgHandler : IMsgHandler {
|
||||
1 -> true
|
||||
else -> false
|
||||
}
|
||||
setDemoMode(FunctionBuildConfig.isDemoMode)
|
||||
invokeNettyConnResult("乘客屏收到的美化模式DemoMode为:${FunctionBuildConfig.isDemoMode}")
|
||||
}
|
||||
MogoProtocolMsg.REQ_MAC_ADDRESS -> {
|
||||
val carConfig = MessagePad.CarConfigResp.parseFrom(msg.body)
|
||||
AppConfigInfo.plateNumber = carConfig.plateNumber
|
||||
AppConfigInfo.iPCMacAddress = carConfig.macAddress
|
||||
AppConfigInfo.dockerVersion = carConfig.dockVersion
|
||||
invokeNettyConnResult(
|
||||
"司机屏发送给乘客屏配置信息为:${
|
||||
TextFormat.printer().escapingNonAscii(false).printToString(carConfig)
|
||||
@@ -77,11 +79,20 @@ class TeleMsgHandler : IMsgHandler {
|
||||
MoGoAiCloudClientConfig.getInstance().sn
|
||||
)
|
||||
}
|
||||
// SN
|
||||
10 -> {
|
||||
val sn = String(it.body)
|
||||
isReceiveSN = true
|
||||
NettyTcpClient.sSERVER_SN = sn
|
||||
}
|
||||
// 美化模式是否忽略条件直接绘制
|
||||
11 -> {
|
||||
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = when (it.body[0].toInt()) {
|
||||
1 -> true
|
||||
else -> false
|
||||
}
|
||||
invokeNettyConnResult("乘客屏收到的美化模式isIgnore为:${FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData}")
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
@@ -139,17 +150,8 @@ class TeleMsgHandler : IMsgHandler {
|
||||
override fun handleClientConn2Server(channel: Channel?) {
|
||||
val socketAddress = channel?.remoteAddress().toString()
|
||||
CallerLogger.d("${SceneConstant.M_ADAS_IMPL}$TAG", "Client ip is:${socketAddress}")
|
||||
val byteArray =
|
||||
if (FunctionBuildConfig.isDemoMode) byteArrayOf(1) else byteArrayOf(0)
|
||||
NSDNettyManager.getInstance().sendMsgToSpecifiedClient(
|
||||
MogoProtocolMsg(
|
||||
MogoProtocolMsg.SYNC_MODE_STATUS,
|
||||
byteArray.size,
|
||||
byteArray
|
||||
), channel
|
||||
) {
|
||||
CallerLogger.d("${SceneConstant.M_ADAS_IMPL}$TAG", "同步美化模式状态是否成功:${it.isSuccess}")
|
||||
}
|
||||
setDemoMode(FunctionBuildConfig.isDemoMode)
|
||||
setIgnoreConditionDraw(FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData)
|
||||
}
|
||||
|
||||
override fun handleClientConnStatus(statusCode: Int, content: String?, channel: Channel) {
|
||||
@@ -162,7 +164,7 @@ class TeleMsgHandler : IMsgHandler {
|
||||
if (isReceiveSN) {
|
||||
isReceiveSN = false
|
||||
}
|
||||
AdasManager.getInstance().startDispatchHandler()
|
||||
// AdasManager.getInstance().startDispatchHandler()
|
||||
ToastUtils.showShort("连接司机屏成功!")
|
||||
invokeNettyConnResult("乘客屏连接司机屏成功")
|
||||
val byteArray = byteArrayOf(0)
|
||||
|
||||
@@ -82,7 +82,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
implementation rootProject.ext.dependencies.flexbox
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.mogo.eagle.core.data.deva.scene.SceneTAG
|
||||
import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchManager
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.MonitorManager
|
||||
import com.zhjt.mogo_core_function_devatools.scene.SceneManager.Companion.sceneManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.*
|
||||
import com.zhjt.mogo_core_function_devatools.trace.TraceManager.Companion.traceManager
|
||||
@@ -110,4 +111,12 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
override fun hideStatusBar() {
|
||||
StatusManager.hide()
|
||||
}
|
||||
|
||||
override fun startMonitor() {
|
||||
mContext?.let { MonitorManager.getInstance(it)?.startMonitor() }
|
||||
}
|
||||
|
||||
override fun stopMonitor() {
|
||||
mContext?.let { MonitorManager.getInstance(it)?.stopMonitor() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
import android.util.Log
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.CpuUtils
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
class CpuMonitor private constructor(var context: Context) {
|
||||
|
||||
var isRunning = false
|
||||
|
||||
private val pid by lazy {
|
||||
Process.myPid()
|
||||
}
|
||||
|
||||
private val cpuInfoList by lazy {
|
||||
ArrayList<CpuInfo>()
|
||||
}
|
||||
|
||||
private val dateFormat by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CpuMonitor"
|
||||
const val INTERVAL_PERF = 1000L
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile
|
||||
private var sInstance: CpuMonitor? = null
|
||||
fun getInstance(context: Context): CpuMonitor? {
|
||||
if (sInstance == null) {
|
||||
synchronized(CpuMonitor::class.java) {
|
||||
if (sInstance == null) {
|
||||
sInstance = CpuMonitor(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请先运行Shizuku的服务
|
||||
*/
|
||||
@Synchronized
|
||||
fun startRun() {
|
||||
if (!isRunning) {
|
||||
Thread(CpuRunnable()).start()
|
||||
isRunning = true
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun isStarted() = isRunning
|
||||
|
||||
@Synchronized
|
||||
fun stop() {
|
||||
isRunning = false
|
||||
}
|
||||
|
||||
fun saveCpuInfos() {
|
||||
synchronized(this) {
|
||||
MonitorDb.getDb(context).monitorDao().saveAllCpuInfos(*cpuInfoList.toTypedArray())
|
||||
cpuInfoList.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCpuValue(): Double {
|
||||
var value = 0.0
|
||||
try {
|
||||
// 应用获取当前进程CPU使用时间,Binder服务端获取系统CPU时间,中间用耗时,不如使用top命令
|
||||
// value = UserServiceManager.getCpuUsage(Process.myPid())
|
||||
value = CpuUtils.getCpuUsageForO()
|
||||
return value
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message ?: "未知异常!")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
inner class CpuRunnable : Runnable {
|
||||
override fun run() {
|
||||
while (isRunning) {
|
||||
val cpu = getCpuValue()
|
||||
if (cpu > 0) {
|
||||
synchronized(this@CpuMonitor) {
|
||||
cpuInfoList.add(
|
||||
CpuInfo(
|
||||
saveTime = dateFormat.format(System.currentTimeMillis()),
|
||||
cpuPercent = cpu
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INTERVAL_PERF)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Process.myPid
|
||||
import android.util.Log
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.HookUtils
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.MemUtils
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
class MemMonitor private constructor(var context: Context) {
|
||||
|
||||
var isRunning = false
|
||||
|
||||
private val memInfoList by lazy {
|
||||
ArrayList<MemInfo>()
|
||||
}
|
||||
|
||||
private val dateFormat by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MemMonitor"
|
||||
const val INTERVAL_PERF = 1000L
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile
|
||||
private var sInstance: MemMonitor? = null
|
||||
fun getInstance(context: Context): MemMonitor? {
|
||||
if (sInstance == null) {
|
||||
synchronized(MemMonitor::class.java) {
|
||||
if (sInstance == null) {
|
||||
sInstance = MemMonitor(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun startRun() {
|
||||
if (!isRunning) {
|
||||
Thread(MemoryRunnable()).start()
|
||||
isRunning = true
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun isStarted() = isRunning
|
||||
|
||||
@Synchronized
|
||||
fun stop() {
|
||||
isRunning = false
|
||||
}
|
||||
|
||||
fun saveMemInfos() {
|
||||
synchronized(this) {
|
||||
MonitorDb.getDb(context).monitorDao().saveAllMemInfos(*memInfoList.toTypedArray())
|
||||
memInfoList.clear()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位MB
|
||||
*/
|
||||
private fun getMemoryValue(): Double {
|
||||
var value = 0.0
|
||||
try {
|
||||
value = MemUtils.getPssMemValue(context, intArrayOf(myPid()))
|
||||
return value
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message ?: "未知异常!")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位MB
|
||||
*/
|
||||
private fun getMemoryArray(): DoubleArray {
|
||||
var value = doubleArrayOf()
|
||||
try {
|
||||
value = MemUtils.getPssArray(context, intArrayOf(myPid()))
|
||||
return value
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message ?: "未知异常!")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
inner class MemoryRunnable : Runnable {
|
||||
override fun run() {
|
||||
while (isRunning) {
|
||||
// 0: 总PSS,1: dalvik总Pss, 2: native总Pss, 3: other总Pss
|
||||
val pssArray = getMemoryArray()
|
||||
if (pssArray[0] > 0) {
|
||||
synchronized(this@MemMonitor) {
|
||||
memInfoList.add(
|
||||
MemInfo(
|
||||
saveTime = dateFormat.format(System.currentTimeMillis()),
|
||||
totalPss = pssArray[0],
|
||||
dalvikPss = pssArray[1],
|
||||
nativePss = pssArray[2],
|
||||
otherPss = pssArray[3]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INTERVAL_PERF)
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import java.util.*
|
||||
|
||||
class MonitorManager private constructor(var context: Context) {
|
||||
|
||||
private var timer: Timer? = null
|
||||
|
||||
private var isStarted = false
|
||||
|
||||
companion object {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile
|
||||
private var sInstance: MonitorManager? = null
|
||||
fun getInstance(context: Context): MonitorManager? {
|
||||
if (sInstance == null) {
|
||||
synchronized(MonitorManager::class.java) {
|
||||
if (sInstance == null) {
|
||||
sInstance = MonitorManager(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 主线程中执行
|
||||
*/
|
||||
fun startMonitor() {
|
||||
if (Thread.currentThread() == Looper.getMainLooper().thread) {
|
||||
if (!isStarted) {
|
||||
CpuMonitor.getInstance(context)?.startRun()
|
||||
MemMonitor.getInstance(context)?.startRun()
|
||||
if (timer == null) {
|
||||
timer = Timer()
|
||||
}
|
||||
timer!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
CpuMonitor.getInstance(context)?.saveCpuInfos()
|
||||
MemMonitor.getInstance(context)?.saveMemInfos()
|
||||
}
|
||||
}, 1000, 60000)
|
||||
isStarted = true
|
||||
ToastUtils.showShort("性能监控启动成功!")
|
||||
} else {
|
||||
ToastUtils.showShort("性能监控已启动,请勿重复启动!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun stopMonitor() {
|
||||
CpuMonitor.getInstance(context)?.stop()
|
||||
MemMonitor.getInstance(context)?.stop()
|
||||
timer?.cancel()
|
||||
timer = null
|
||||
isStarted = false
|
||||
ToastUtils.showShort("性能监控停止成功!")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "t_cpu")
|
||||
data class CpuInfo(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
val uuid: Long = 0,
|
||||
|
||||
@ColumnInfo(name = "save_time")
|
||||
val saveTime: String?,
|
||||
|
||||
@ColumnInfo(name = "cpu_percent")
|
||||
val cpuPercent: Double
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "t_memory")
|
||||
data class MemInfo(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
val uuid: Long = 0,
|
||||
|
||||
@ColumnInfo(name = "save_time")
|
||||
val saveTime: String,
|
||||
|
||||
@ColumnInfo(name = "total_pss")
|
||||
val totalPss: Double,
|
||||
|
||||
@ColumnInfo(name = "dalvik_pss")
|
||||
val dalvikPss: Double,
|
||||
|
||||
@ColumnInfo(name = "native_pss")
|
||||
val nativePss: Double,
|
||||
|
||||
@ColumnInfo(name = "other_pss")
|
||||
val otherPss: Double
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import androidx.room.*
|
||||
|
||||
@Dao
|
||||
interface MonitorDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveCpu(info: CpuInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveAllCpuInfos(vararg cpuInfo: CpuInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveMemory(info: MemInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun saveAllMemInfos(vararg memInfo: MemInfo)
|
||||
|
||||
@Query("SELECT * FROM t_cpu WHERE id =:id")
|
||||
fun getAllCPUById(id: Long): List<CpuInfo>
|
||||
|
||||
@Query("SELECT * FROM t_memory WHERE id =:id")
|
||||
fun getAllMemById(id: Long): List<MemInfo>
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.db
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(entities = [CpuInfo::class, MemInfo::class], version = 1, exportSchema = false)
|
||||
abstract class MonitorDb: RoomDatabase() {
|
||||
abstract fun monitorDao(): MonitorDao
|
||||
|
||||
companion object {
|
||||
const val INTERNAL_DB_NAME = "mogo_monitor.db"
|
||||
|
||||
private var db: MonitorDb? = null
|
||||
|
||||
@JvmStatic
|
||||
fun getDb(context: Context): MonitorDb {
|
||||
if (db == null) {
|
||||
db = Room.databaseBuilder(context.applicationContext, MonitorDb::class.java, INTERNAL_DB_NAME)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
return db!!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.remote;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.RemoteException;
|
||||
|
||||
public interface IUserInterface extends IInterface {
|
||||
|
||||
String DESCRIPTOR = "rikka.shizuku.demo.IUserInterface";
|
||||
|
||||
int TRANSACTION_exec = IBinder.FIRST_CALL_TRANSACTION;
|
||||
int TRANSACTION_getCpuUsage = IBinder.FIRST_CALL_TRANSACTION + 1;
|
||||
|
||||
String exec(String cmd) throws RemoteException;
|
||||
|
||||
double getCpuUsage(int pid) throws RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.remote;
|
||||
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.utils.CpuUtils;
|
||||
|
||||
/**
|
||||
* Server端Binder类
|
||||
*/
|
||||
public class RemoteUserServiceImp extends Binder implements IUserInterface {
|
||||
|
||||
public RemoteUserServiceImp() {
|
||||
attachInterface(this, DESCRIPTOR);
|
||||
}
|
||||
|
||||
public static IUserInterface asInterface(IBinder obj) {
|
||||
if ((obj == null)) {
|
||||
return null;
|
||||
}
|
||||
IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
|
||||
if (iin instanceof IUserInterface) {
|
||||
return ((IUserInterface) iin);
|
||||
}
|
||||
return new Proxy(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exec(String cmd) throws RemoteException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCpuUsage(int pid) throws RemoteException {
|
||||
return CpuUtils.getCpuUsagePercentWithPid(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理Client端请求
|
||||
*
|
||||
* @param code
|
||||
* @param data
|
||||
* @param reply
|
||||
* @param flags
|
||||
* @return
|
||||
* @throws RemoteException
|
||||
*/
|
||||
@Override
|
||||
protected boolean onTransact(int code, @NonNull Parcel data, @Nullable Parcel reply, int flags) throws RemoteException {
|
||||
final String descriptor = DESCRIPTOR;
|
||||
switch (code) {
|
||||
case TRANSACTION_exec:
|
||||
data.enforceInterface(descriptor);
|
||||
String _arg0;
|
||||
_arg0 = data.readString();
|
||||
String _result = this.exec(_arg0);
|
||||
reply.writeNoException();
|
||||
reply.writeString(_result);
|
||||
return true;
|
||||
default:
|
||||
return super.onTransact(code, data, reply, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getInterfaceDescriptor() {
|
||||
return super.getInterfaceDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回给Client端并被封装成BinderProxy
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Proxy implements IUserInterface {
|
||||
private IBinder mRemote;
|
||||
|
||||
public Proxy(IBinder remote) {
|
||||
mRemote = remote;
|
||||
}
|
||||
|
||||
public String getInterfaceDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
// 返回Server端Binder对象
|
||||
return mRemote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exec(String cmd) throws RemoteException {
|
||||
// 参数传递给Server端并挂起当前线程,等待Server端执行完返回结果
|
||||
Parcel _data = Parcel.obtain();
|
||||
Parcel _reply = Parcel.obtain();
|
||||
String _result;
|
||||
try {
|
||||
_data.writeInterfaceToken(DESCRIPTOR);
|
||||
_data.writeString(cmd);
|
||||
mRemote.transact(TRANSACTION_exec, _data, _reply, 0);
|
||||
_reply.readException();
|
||||
_result = _reply.readString();
|
||||
} finally {
|
||||
_reply.recycle();
|
||||
_data.recycle();
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCpuUsage(int pid) throws RemoteException {
|
||||
Parcel _data = Parcel.obtain();
|
||||
Parcel _reply = Parcel.obtain();
|
||||
double _result;
|
||||
try {
|
||||
_data.writeInterfaceToken(DESCRIPTOR);
|
||||
_data.writeInt(pid);
|
||||
mRemote.transact(TRANSACTION_getCpuUsage, _data, _reply, 0);
|
||||
_reply.readException();
|
||||
_result = _reply.readDouble();
|
||||
} finally {
|
||||
_reply.recycle();
|
||||
_data.recycle();
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.remote
|
||||
|
||||
//import rikka.shizuku.Shizuku
|
||||
//import android.content.ServiceConnection
|
||||
//import android.content.ComponentName
|
||||
//import android.os.IBinder
|
||||
//import rikka.shizuku.Shizuku.UserServiceArgs
|
||||
//import android.content.pm.PackageManager
|
||||
//import android.util.Log
|
||||
//import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
//import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
//import rikka.shizuku.Shizuku.OnBinderReceivedListener
|
||||
//import rikka.shizuku.Shizuku.OnBinderDeadListener
|
||||
//import rikka.shizuku.Shizuku.OnRequestPermissionResultListener
|
||||
//import java.lang.StringBuilder
|
||||
|
||||
object UserServiceManager {
|
||||
|
||||
// private const val TAG = "UserServiceManager"
|
||||
// private const val REQUEST_CODE_BIND = 1
|
||||
// private const val REQUEST_CODE_UNBIND = 2
|
||||
//
|
||||
// private var userServiceProxy: IUserInterface? = null
|
||||
// private var isFirst = true
|
||||
//
|
||||
// fun init() {
|
||||
// if (isFirst) {
|
||||
// addListener()
|
||||
// isFirst = false
|
||||
// }
|
||||
// bindUserService()
|
||||
// }
|
||||
//
|
||||
// fun stopService() {
|
||||
// removeListener()
|
||||
// unbindUserService()
|
||||
// }
|
||||
//
|
||||
// fun isServiceActive(): Boolean {
|
||||
// var isActive = false
|
||||
// val service = userServiceProxy
|
||||
// if (service != null && service is IBinder && service.isBinderAlive) {
|
||||
// isActive = true
|
||||
// }
|
||||
// return isActive
|
||||
// }
|
||||
//
|
||||
// private fun addListener() {
|
||||
// Shizuku.addBinderReceivedListenerSticky(BINDER_RECEIVED_LISTENER)
|
||||
// Shizuku.addBinderDeadListener(BINDER_DEAD_LISTENER)
|
||||
// Shizuku.addRequestPermissionResultListener(REQUEST_PERMISSION_RESULT_LISTENER)
|
||||
// }
|
||||
//
|
||||
// private fun removeListener() {
|
||||
// Shizuku.removeBinderReceivedListener(BINDER_RECEIVED_LISTENER)
|
||||
// Shizuku.removeBinderDeadListener(BINDER_DEAD_LISTENER)
|
||||
// Shizuku.removeRequestPermissionResultListener(REQUEST_PERMISSION_RESULT_LISTENER)
|
||||
// }
|
||||
//
|
||||
// private fun bindUserService() {
|
||||
// if (checkPermission(REQUEST_CODE_BIND)) {
|
||||
// val res = StringBuilder()
|
||||
// try {
|
||||
// if (Shizuku.getVersion() < 10) {
|
||||
// res.append("requires Shizuku API 10")
|
||||
// } else {
|
||||
// Shizuku.bindUserService(userServiceArgs, userServiceConnection)
|
||||
// }
|
||||
// } catch (tr: Throwable) {
|
||||
// tr.printStackTrace()
|
||||
// res.append(tr.toString())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun unbindUserService() {
|
||||
// if (checkPermission(REQUEST_CODE_UNBIND)) {
|
||||
// val res = StringBuilder()
|
||||
// try {
|
||||
// if (Shizuku.getVersion() < 10) {
|
||||
// res.append("requires Shizuku API 10")
|
||||
// } else {
|
||||
// Shizuku.unbindUserService(userServiceArgs, userServiceConnection, true)
|
||||
// }
|
||||
// } catch (tr: Throwable) {
|
||||
// tr.printStackTrace()
|
||||
// res.append(tr.toString())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// fun exec(cmd: String): String {
|
||||
// return userServiceProxy?.exec(cmd) ?: ""
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 单位:%,保留1位小数
|
||||
// */
|
||||
// fun getCpuUsage(pid: Int): Double {
|
||||
// return userServiceProxy?.getCpuUsage(pid) ?: -1.0
|
||||
// }
|
||||
//
|
||||
// private val userServiceConnection: ServiceConnection = object : ServiceConnection {
|
||||
// override fun onServiceConnected(componentName: ComponentName, binder: IBinder?) {
|
||||
// if (binder != null && binder.pingBinder()) {
|
||||
// val service = RemoteUserServiceImp.asInterface(binder)
|
||||
// userServiceProxy = service
|
||||
// ToastUtils.showShort("监控权限获取成功!")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onServiceDisconnected(componentName: ComponentName) {}
|
||||
// }
|
||||
//
|
||||
// private val userServiceArgs by lazy {
|
||||
// val appInfo = AppUtils.getAppInfo()
|
||||
// UserServiceArgs(
|
||||
// ComponentName(
|
||||
// appInfo?.packageName ?: "com.mogo.launcher.f",
|
||||
// RemoteUserServiceImp::class.java.name
|
||||
// )
|
||||
// )
|
||||
// .daemon(false)
|
||||
// .processNameSuffix("service")
|
||||
// .debuggable(true)
|
||||
// .version(appInfo?.versionCode ?: 1)
|
||||
// }
|
||||
//
|
||||
// private fun checkPermission(code: Int): Boolean {
|
||||
// if (Shizuku.isPreV11()) {
|
||||
// Log.w(TAG, "Version is preV11!")
|
||||
// return false
|
||||
// }
|
||||
// try {
|
||||
// return if (Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED) {
|
||||
// true
|
||||
// } else if (Shizuku.shouldShowRequestPermissionRationale()) {
|
||||
// Log.e(TAG, "User denied permission (shouldShowRequestPermissionRationale=true)")
|
||||
// false
|
||||
// } else {
|
||||
// Shizuku.requestPermission(code)
|
||||
// false
|
||||
// }
|
||||
// } catch (e: Throwable) {
|
||||
// Log.e(TAG, Log.getStackTraceString(e))
|
||||
// ToastUtils.showLong("请先打开Shizuku并启动它!")
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// private fun onRequestPermissionsResult(requestCode: Int, grantResult: Int) {
|
||||
// if (grantResult == PackageManager.PERMISSION_GRANTED) {
|
||||
// when (requestCode) {
|
||||
// REQUEST_CODE_BIND -> {
|
||||
// bindUserService()
|
||||
// }
|
||||
// REQUEST_CODE_UNBIND -> {
|
||||
// unbindUserService()
|
||||
// }
|
||||
// else -> {}
|
||||
// }
|
||||
// } else {
|
||||
// Log.e(TAG, "User denied permission")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private val BINDER_RECEIVED_LISTENER = OnBinderReceivedListener {
|
||||
// if (Shizuku.isPreV11()) {
|
||||
// Log.w(TAG, "Shizuku pre-v11 is not supported")
|
||||
// } else {
|
||||
// Log.d(TAG, "Binder received")
|
||||
// }
|
||||
// }
|
||||
// private val BINDER_DEAD_LISTENER = OnBinderDeadListener { Log.w(TAG, "Binder dead") }
|
||||
// private val REQUEST_PERMISSION_RESULT_LISTENER =
|
||||
// OnRequestPermissionResultListener { requestCode: Int, grantResult: Int ->
|
||||
// onRequestPermissionsResult(
|
||||
// requestCode,
|
||||
// grantResult
|
||||
// )
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils;
|
||||
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* CPU相关工具类。
|
||||
*/
|
||||
public class CpuUtils {
|
||||
private static boolean initCpu = true;
|
||||
private static double oCpu = 0.0;
|
||||
private static double oIdle = 0.0;
|
||||
|
||||
private static double pJif = 0.0;
|
||||
private static double pCpu = 0.0;
|
||||
private static double aCpu = 0.0;
|
||||
private static double opCpu = 0.0;
|
||||
private static double oaCpu = 0.0;
|
||||
|
||||
/**
|
||||
* 8.0以上获取cpu的方式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static double getCpuUsageForO() {
|
||||
java.lang.Process process = null;
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("top -n 1");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
int cpuIndex = -1;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.trim();
|
||||
if (TextUtils.isEmpty(line)) {
|
||||
continue;
|
||||
}
|
||||
int tempIndex = getCPUIndex(line);
|
||||
if (tempIndex != -1) {
|
||||
cpuIndex = tempIndex;
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(String.valueOf(Process.myPid()))) {
|
||||
if (cpuIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
String[] param = line.split("\\s+");
|
||||
if (param.length <= cpuIndex) {
|
||||
continue;
|
||||
}
|
||||
String cpu = param[cpuIndex];
|
||||
if (cpu.endsWith("%")) {
|
||||
cpu = cpu.substring(0, cpu.lastIndexOf("%"));
|
||||
}
|
||||
return Double.parseDouble(cpu) / Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int getCPUIndex(String line) {
|
||||
if (line.contains("CPU")) {
|
||||
String[] titles = line.split("\\s+");
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
if (titles[i].contains("CPU")) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用的CPU占用率,单位:%,保留1位小数
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public static double getCpuUsagePercentWithPid(int pid) {
|
||||
double usage = 0.0;
|
||||
String[] result1;
|
||||
String[] result2;
|
||||
if (pid >= 0) {
|
||||
result1 = getCpuWithPid(pid);
|
||||
if (null != result1) {
|
||||
pCpu = Double.parseDouble(result1[1])
|
||||
+ Double.parseDouble(result1[2]);
|
||||
}
|
||||
result2 = getSystemCpu();
|
||||
if (null != result2) {
|
||||
aCpu = 0.0;
|
||||
for (int i = 2; i < result2.length; i++) {
|
||||
if (result2[i] != null) {
|
||||
aCpu += Double.parseDouble(result2[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((aCpu - oaCpu) != 0) {
|
||||
usage = DoubleUtils.div(((pCpu - opCpu) * 100.00),
|
||||
(aCpu - oaCpu), 1);
|
||||
if (usage < 0) {
|
||||
usage = 0;
|
||||
}
|
||||
else if (usage > 100)
|
||||
{
|
||||
usage = 100;
|
||||
}
|
||||
|
||||
}
|
||||
opCpu = pCpu;
|
||||
oaCpu = aCpu;
|
||||
}
|
||||
pJif = pCpu;
|
||||
return usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取CPU使用率
|
||||
*
|
||||
* @return CPU使用率,单位:%
|
||||
*/
|
||||
public static double getSysCpuUsagePercent() {
|
||||
double usage = 0.0;
|
||||
if (initCpu) {
|
||||
initCpu = false;
|
||||
RandomAccessFile reader = null;
|
||||
try {
|
||||
reader = new RandomAccessFile("/proc/stat",
|
||||
"r");
|
||||
String load;
|
||||
load = reader.readLine();
|
||||
String[] toks = load.split(" ");
|
||||
oIdle = Double.parseDouble(toks[5]);
|
||||
oCpu = Double.parseDouble(toks[2])
|
||||
+ Double.parseDouble(toks[3])
|
||||
+ Double.parseDouble(toks[4])
|
||||
+ Double.parseDouble(toks[6])
|
||||
+ Double.parseDouble(toks[8])
|
||||
+ Double.parseDouble(toks[7]);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
FileUtil.closeRandomAccessFile(reader);
|
||||
}
|
||||
} else {
|
||||
RandomAccessFile reader = null;
|
||||
try {
|
||||
reader = new RandomAccessFile("/proc/stat", "r");
|
||||
String load;
|
||||
load = reader.readLine();
|
||||
String[] toks = load.split(" ");
|
||||
double cIdle = Double.parseDouble(toks[5]);
|
||||
double cCpu = Double.parseDouble(toks[2])
|
||||
+ Double.parseDouble(toks[3])
|
||||
+ Double.parseDouble(toks[4])
|
||||
+ Double.parseDouble(toks[6])
|
||||
+ Double.parseDouble(toks[8])
|
||||
+ Double.parseDouble(toks[7]);
|
||||
if (0 != ((cCpu + cIdle) - (oCpu + oIdle))) {
|
||||
usage = DoubleUtils.div((100.00 * ((cCpu - oCpu))),
|
||||
((cCpu + cIdle) - (oCpu + oIdle)), 1);
|
||||
if (usage < 0) {
|
||||
usage = 0;
|
||||
}
|
||||
else if (usage > 100)
|
||||
{
|
||||
usage = 100;
|
||||
}
|
||||
}
|
||||
oCpu = cCpu;
|
||||
oIdle = cIdle;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
FileUtil.closeRandomAccessFile(reader);
|
||||
}
|
||||
}
|
||||
return usage;
|
||||
}
|
||||
|
||||
private static String[] getCpuWithPid(int pid) {
|
||||
String cpuPath = "/proc/" + pid + "/stat";
|
||||
String cpu = "";
|
||||
String[] result = new String[3];
|
||||
|
||||
File f = new File(cpuPath);
|
||||
// 部分进程信息无法读取
|
||||
if (!f.exists() || !f.canRead())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
FileReader fr = null;
|
||||
BufferedReader localBufferedReader = null;
|
||||
|
||||
try {
|
||||
fr = new FileReader(f);
|
||||
localBufferedReader = new BufferedReader(fr, 8192);
|
||||
cpu = localBufferedReader.readLine();
|
||||
if (null != cpu) {
|
||||
String[] cpuSplit = cpu.split(" ");
|
||||
result[0] = cpuSplit[1];
|
||||
result[1] = cpuSplit[13];
|
||||
result[2] = cpuSplit[14];
|
||||
}
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FileUtil.closeReader(localBufferedReader);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String[] getSystemCpu() {
|
||||
String cpuPath = "/proc/stat";
|
||||
String cpu = "";
|
||||
String[] result = new String[7];
|
||||
|
||||
File f = new File(cpuPath);
|
||||
if (!f.exists() || !f.canRead())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
FileReader fr = null;
|
||||
BufferedReader localBufferedReader = null;
|
||||
|
||||
try {
|
||||
fr = new FileReader(f);
|
||||
localBufferedReader = new BufferedReader(fr, 8192);
|
||||
cpu = localBufferedReader.readLine();
|
||||
if (null != cpu) {
|
||||
result = cpu.split(" ");
|
||||
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FileUtil.closeReader(localBufferedReader);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getCpuUsageByCmd() {
|
||||
java.lang.Process process;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
String cmd = "dumpsys cpuinfo";
|
||||
try {
|
||||
process = Runtime.getRuntime().exec(
|
||||
new String[] { "sh", "-c", cmd });
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
process.getInputStream()));
|
||||
while (((line = br.readLine()) != null)) {
|
||||
// 去掉空白行数据
|
||||
line = line.trim();
|
||||
if (line.equals("")) {
|
||||
continue;
|
||||
}
|
||||
sb.append(line);
|
||||
sb.append("\r\n");
|
||||
}
|
||||
try {
|
||||
process.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进程的CPU使用时间片
|
||||
*
|
||||
* @return 进程的CPU使用时间片
|
||||
*/
|
||||
public long getJif() {
|
||||
return (long)pJif;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils
|
||||
|
||||
import java.lang.Exception
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
||||
object DoubleUtils {
|
||||
|
||||
fun mul(d1: Double, d2: Double): Double {
|
||||
val bd1 = BigDecimal(d1.toString())
|
||||
val bd2 = BigDecimal(d2.toString())
|
||||
return try {
|
||||
bd1.multiply(bd2).toDouble()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun div(d1: Double, d2: Double, scale: Int): Double {
|
||||
val bd1 = BigDecimal(d1.toString())
|
||||
val bd2 = BigDecimal(d2.toString())
|
||||
return try {
|
||||
// 直接向下取整
|
||||
bd1.divide(bd2, scale, BigDecimal.ROUND_DOWN).toDouble()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 四舍五入
|
||||
* scale:保留多少个小数位
|
||||
*/
|
||||
@JvmStatic
|
||||
fun keepDecimal(v: Double, scale: Int = 1): Double {
|
||||
if (scale < 0) {
|
||||
throw IllegalArgumentException("The scale must be a positive integer or zero")
|
||||
}
|
||||
return BigDecimal(v).setScale(scale, BigDecimal.ROUND_HALF_UP).toDouble()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils
|
||||
|
||||
import android.net.LocalSocket
|
||||
import android.util.Log
|
||||
import java.io.*
|
||||
import java.lang.Exception
|
||||
import java.net.Socket
|
||||
import java.nio.channels.FileChannel
|
||||
|
||||
object FileUtil {
|
||||
private const val TAG = "FileUtil"
|
||||
const val separator = "/"
|
||||
fun isPathStringValid(path: String?): Boolean {
|
||||
if (null == path || path.isEmpty()) {
|
||||
return false
|
||||
}
|
||||
if (path.contains(":") || path.contains("*") || path.contains("?")
|
||||
|| path.contains("\"") || path.contains("<")
|
||||
|| path.contains(">") || path.contains("|")
|
||||
) {
|
||||
Log.w(TAG, "filename can not contains:*:?\"<>|")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isPath(path: String): Boolean {
|
||||
return path.contains(separator) || path.contains("\\")
|
||||
}
|
||||
|
||||
fun getPath(path: String): String {
|
||||
val la = path.lastIndexOf(separator)
|
||||
return path.substring(0, la)
|
||||
}
|
||||
|
||||
fun convertValidFilePath(path: String, defPosfix: String): String {
|
||||
var filePath = path
|
||||
if (path.contains(separator) || path.contains("\\")) {
|
||||
val la = filePath.lastIndexOf(".")
|
||||
if (la < 0) {
|
||||
filePath = path + defPosfix
|
||||
} else {
|
||||
val temp = filePath.substring(la)
|
||||
if (temp.contains(separator) || temp.contains("\\")) {
|
||||
// "."是目录名的一部分而不是后缀名的情况
|
||||
filePath = path + defPosfix
|
||||
}
|
||||
// else fileName = fileName
|
||||
}
|
||||
} else {
|
||||
if (!path.contains(".")) // 没有有后缀
|
||||
{
|
||||
filePath = filePath + defPosfix
|
||||
}
|
||||
}
|
||||
return filePath
|
||||
}
|
||||
|
||||
fun isFileExists(file: String?): Boolean {
|
||||
try {
|
||||
val f = File(file)
|
||||
if (!f.exists()) {
|
||||
return false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isFileValid(f: File): Boolean {
|
||||
if (!f.exists()) {
|
||||
try {
|
||||
f.createNewFile()
|
||||
} catch (e: IOException) {
|
||||
return false
|
||||
}
|
||||
f.delete()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun isFileValid(parent: File?, name: String?): Boolean {
|
||||
val f = File(parent, name)
|
||||
return isFileValid(f)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除存在的文件
|
||||
*
|
||||
* @param filePath
|
||||
*/
|
||||
fun delExistFile(filePath: String?) {
|
||||
val f = File(filePath)
|
||||
if (f.exists()) f.delete()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭bufferReader
|
||||
*
|
||||
* @param br
|
||||
*/
|
||||
@JvmStatic
|
||||
fun closeReader(br: Reader?) {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭Writer
|
||||
*
|
||||
* @param wr
|
||||
*/
|
||||
fun closeWriter(wr: Writer?) {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* flush Writer
|
||||
*
|
||||
* @param wr
|
||||
*/
|
||||
fun flushWriter(wr: Writer?) {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.flush()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入流的关闭
|
||||
*
|
||||
* @param in
|
||||
*/
|
||||
fun closeInputStream(`in`: InputStream?) {
|
||||
if (`in` != null) {
|
||||
try {
|
||||
`in`.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出流的关闭
|
||||
*
|
||||
* @param out
|
||||
*/
|
||||
fun closeOutputStream(out: OutputStream?) {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件管道的关闭
|
||||
*
|
||||
* @param chl
|
||||
*/
|
||||
fun closeFileChannel(chl: FileChannel?) {
|
||||
if (chl != null) {
|
||||
try {
|
||||
chl.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RandomAccessFile的关闭
|
||||
*
|
||||
* @param f RandomAccessFile对象
|
||||
*/
|
||||
@JvmStatic
|
||||
fun closeRandomAccessFile(f: RandomAccessFile?) {
|
||||
if (f != null) {
|
||||
try {
|
||||
f.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Socket的关闭
|
||||
*
|
||||
* @param s Socket对象
|
||||
*/
|
||||
fun colseSocket(s: Socket?) {
|
||||
if (s != null) {
|
||||
try {
|
||||
s.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LocalSocket的关闭
|
||||
*
|
||||
* @param s Socket对象
|
||||
*/
|
||||
fun colseLocalSocket(s: LocalSocket?) {
|
||||
if (s != null) {
|
||||
try {
|
||||
s.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteFile(file: File) {
|
||||
if (file.exists()) { // 判断文件是否存在
|
||||
if (file.isFile) { // 判断是否是文件
|
||||
file.delete() // delete()方法 你应该知道 是删除的意思;
|
||||
} else if (file.isDirectory) { // 否则如果它是一个目录
|
||||
val files = file.listFiles() // 声明目录下所有的文件 files[];
|
||||
for (i in files.indices) { // 遍历目录下所有的文件
|
||||
deleteFile(files[i]) // 把每个文件 用这个方法进行迭代
|
||||
}
|
||||
}
|
||||
file.delete()
|
||||
} else {
|
||||
Log.e(TAG, "文件不存在!" + "n")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文件
|
||||
*
|
||||
* @param s 源文件
|
||||
* @param t 目标文件
|
||||
*/
|
||||
fun copyFile(s: File?, t: File) {
|
||||
var fi: FileInputStream? = null
|
||||
var fo: FileOutputStream? = null
|
||||
var `in`: FileChannel? = null
|
||||
var out: FileChannel? = null
|
||||
try {
|
||||
if (!t.exists()) {
|
||||
t.createNewFile()
|
||||
}
|
||||
fi = FileInputStream(s)
|
||||
fo = FileOutputStream(t)
|
||||
`in` = fi.channel
|
||||
out = fo.channel
|
||||
// 连接两个通道,并且从in通道读取,然后写入out通道
|
||||
`in`.transferTo(0, `in`.size(), out)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
closeOutputStream(fo)
|
||||
closeInputStream(fi)
|
||||
closeFileChannel(`in`)
|
||||
closeFileChannel(out)
|
||||
}
|
||||
}
|
||||
|
||||
fun copyInputToFile(`in`: InputStream?, path: String?) {
|
||||
var bis: BufferedInputStream? = null
|
||||
var fos: FileOutputStream? = null
|
||||
try {
|
||||
val buffer = ByteArray(10 * 1024)
|
||||
bis = BufferedInputStream(`in`)
|
||||
fos = FileOutputStream(path)
|
||||
var a = bis.read(buffer, 0, buffer.size)
|
||||
while (a != -1) {
|
||||
fos.write(buffer, 0, a)
|
||||
fos.flush()
|
||||
a = bis.read(buffer, 0, buffer.size)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
closeOutputStream(fos)
|
||||
closeInputStream(bis)
|
||||
closeInputStream(`in`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils;
|
||||
|
||||
import android.os.Debug;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class HookUtils {
|
||||
private static final String TAG = "HookUtils";
|
||||
|
||||
/**
|
||||
* 单位为MB
|
||||
* 0: 总PSS,1: dalvik总Pss, 2: native总Pss, 3: other总Pss
|
||||
* @param memoryInfo
|
||||
* @return
|
||||
*/
|
||||
public static double[] getPssArray(Debug.MemoryInfo memoryInfo) {
|
||||
double[] pssArray = new double[4];
|
||||
if (memoryInfo != null) {
|
||||
double totalPss = DoubleUtils.keepDecimal(memoryInfo.getTotalPss() / 1024.0, 3);
|
||||
// Log.d(TAG, "===========Hook PSS 开始:===========\n");
|
||||
// Log.d(TAG, "总PSS内存为:" + totalPss);
|
||||
pssArray[0] = totalPss;
|
||||
try {
|
||||
Field dalvikField = memoryInfo.getClass().getField("dalvikSwappedOutPss");
|
||||
double dalvikPss = DoubleUtils.keepDecimal(memoryInfo.dalvikPss / 1024.0, 3);
|
||||
double dalvikSwappedOutPss = DoubleUtils.keepDecimal((int) dalvikField.get(memoryInfo) / 1024.0, 3);
|
||||
pssArray[1] = dalvikPss + dalvikSwappedOutPss;
|
||||
// Log.d(TAG, "dalvikPss is:" + dalvikSwappedOutPss);
|
||||
// Log.d(TAG, "dalvikSwappedOutPss is:" + dalvikPss + "\n\n");
|
||||
|
||||
Field nativeField = memoryInfo.getClass().getField("nativeSwappedOutPss");
|
||||
double nativePss = DoubleUtils.keepDecimal(memoryInfo.nativePss / 1024.0, 3);
|
||||
double nativeSwappedOutPss = DoubleUtils.keepDecimal((int) nativeField.get(memoryInfo) / 1024.0, 3);
|
||||
pssArray[2] = nativePss + nativeSwappedOutPss;
|
||||
// Log.d(TAG, "nativePss is:" + nativePss);
|
||||
// Log.d(TAG, "nativeSwappedOutPss is:" + nativeSwappedOutPss + "\n\n");
|
||||
|
||||
Field otherField = memoryInfo.getClass().getField("otherSwappedOutPss");
|
||||
double otherPss = DoubleUtils.keepDecimal(memoryInfo.otherPss / 1024.0, 3);
|
||||
double otherSwappedOutPss = DoubleUtils.keepDecimal((int) otherField.get(memoryInfo) / 1024.0, 3);
|
||||
pssArray[3] = otherPss + otherSwappedOutPss;
|
||||
// Log.d(TAG, "otherPss is:" + otherPss);
|
||||
// Log.d(TAG, "otherSwappedOutPss is:" + otherSwappedOutPss + "\n\n");
|
||||
//
|
||||
// Log.d(TAG, "===========Hook PSS 结束!===========\n");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
return pssArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.zhjt.mogo_core_function_devatools.monitor.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.os.Debug;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 内存信息工具类。
|
||||
*/
|
||||
public class MemUtils {
|
||||
|
||||
public static double[] getPssArray(Context context, int[] pids) {
|
||||
Debug.MemoryInfo[] memoryArray = getMemoryInfo(context, pids);
|
||||
if (memoryArray.length > 0) {
|
||||
return HookUtils.getPssArray(memoryArray[0]);
|
||||
} else {
|
||||
return new double[4];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位MB
|
||||
*/
|
||||
public static double getPssMemValue(Context context, int[] pids) {
|
||||
double value = 0.0;
|
||||
Debug.MemoryInfo[] memoryArray = getMemoryInfo(context, pids);
|
||||
if (memoryArray.length > 0) {
|
||||
value = DoubleUtils.keepDecimal(memoryArray[0].getTotalPss() / 1024.0, 1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只能获取本应用的PSS内存占系统百分比:单位%,保留1位小数
|
||||
* @return
|
||||
*/
|
||||
public static double getPidMemPercent() {
|
||||
double percent = 0.0;
|
||||
Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
|
||||
Debug.getMemoryInfo(memInfo);
|
||||
int pidTotalPss = memInfo.getTotalPss();
|
||||
long systemTotalMem = getTotalMem();
|
||||
percent = DoubleUtils.keepDecimal(pidTotalPss * 100.0 / systemTotalMem, 1);
|
||||
return percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本应用进程总pss内存,单位MB
|
||||
*/
|
||||
public static double getPssMem() {
|
||||
Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
|
||||
Debug.getMemoryInfo(memInfo);
|
||||
return DoubleUtils.keepDecimal(memInfo.getTotalPss() / 1024.0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统空闲内存占用百分比: 单位%
|
||||
* @return
|
||||
*/
|
||||
public static double getSystemMemPercent() {
|
||||
double percent = 0.0;
|
||||
long[] memInfo = getMemInfo();
|
||||
long free = memInfo[1] + memInfo[2] + memInfo[3];
|
||||
long total = memInfo[0];
|
||||
percent = DoubleUtils.keepDecimal(free * 100.0 / total, 1);
|
||||
return percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取空闲内存
|
||||
*
|
||||
* @return 空闲内存,单位KB
|
||||
*/
|
||||
public static long getFreeMem() {
|
||||
long[] memInfo = getMemInfo();
|
||||
return memInfo[1] + memInfo[2] + memInfo[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总内存
|
||||
*
|
||||
* @return 总内存,单位KB
|
||||
*/
|
||||
public static long getTotalMem() {
|
||||
long[] memInfo = getMemInfo();
|
||||
return memInfo[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存信息:total、free、buffers、cached,单位KB
|
||||
*
|
||||
* @return 内存信息
|
||||
*/
|
||||
public static long[] getMemInfo() {
|
||||
long memInfo[] = new long[4];
|
||||
try {
|
||||
Class<?> procClazz = Class.forName("android.os.Process");
|
||||
Class<?> paramTypes[] = new Class[] { String.class, String[].class,
|
||||
long[].class };
|
||||
Method readProclines = procClazz.getMethod("readProcLines",
|
||||
paramTypes);
|
||||
Object args[] = new Object[3];
|
||||
final String[] memInfoFields = new String[] { "MemTotal:",
|
||||
"MemFree:", "Buffers:", "Cached:" };
|
||||
long[] memInfoSizes = new long[memInfoFields.length];
|
||||
memInfoSizes[0] = 30;
|
||||
memInfoSizes[1] = -30;
|
||||
args[0] = "/proc/meminfo";
|
||||
args[1] = memInfoFields;
|
||||
args[2] = memInfoSizes;
|
||||
if (null != readProclines) {
|
||||
readProclines.invoke(null, args);
|
||||
for (int i = 0; i < memInfoSizes.length; i++) {
|
||||
memInfo[i] = memInfoSizes[i];
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return memInfo;
|
||||
}
|
||||
|
||||
public static long[] getHeapNative() {
|
||||
int Native_HeapSize = 0;
|
||||
int Native_HeapAlloc = 1;
|
||||
long[] value = new long[2];
|
||||
value[Native_HeapSize] = Debug.getNativeHeapSize() >> 10;
|
||||
value[Native_HeapAlloc] = Debug.getNativeHeapAllocatedSize() >> 10;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static long[] getHeapDalvik() {
|
||||
int Total_HeapSize = 0;
|
||||
int Total_HeapAlloc = 1;
|
||||
|
||||
long[] value_total = new long[2];
|
||||
value_total[Total_HeapSize] = Runtime.getRuntime().totalMemory() >> 10;
|
||||
value_total[Total_HeapAlloc] = (Runtime.getRuntime().totalMemory() - Runtime
|
||||
.getRuntime().freeMemory()) >> 10;
|
||||
|
||||
long[] value_native = getHeapNative();
|
||||
|
||||
int Dalvik_HeapSize = 0;
|
||||
int Dalvik_HeapAlloc = 1;
|
||||
long[] value_dalvik = new long[2];
|
||||
value_dalvik[Dalvik_HeapSize] = value_total[Total_HeapSize]
|
||||
- value_native[0];
|
||||
value_dalvik[Dalvik_HeapAlloc] = value_total[Total_HeapAlloc]
|
||||
- value_native[1];
|
||||
|
||||
return value_dalvik;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取堆内存数据,精确到KB Get VM Heap Size by calling:
|
||||
* Runtime.getRuntime().totalMemory(); Get Allocated VM Memory by calling:
|
||||
* Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
|
||||
* Get VM Heap Size Limit by calling: Runtime.getRuntime().maxMemory() Get
|
||||
* Native Allocated Memory by calling: Debug.getNativeHeapAllocatedSize();
|
||||
*/
|
||||
public static long[] getVM() {
|
||||
long[] value = new long[5];
|
||||
value[0] = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
|
||||
.freeMemory()) >> 10;
|
||||
value[1] = Runtime.getRuntime().totalMemory() >> 10;
|
||||
|
||||
value[2] = Debug.getNativeHeapAllocatedSize() >> 10;
|
||||
value[3] = Debug.getNativeHeapSize() >> 10;
|
||||
value[4] = Debug.getGlobalAllocSize() >> 10;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Debug.MemoryInfo[] getMemoryInfo(Context context, int[] pids) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
return am.getProcessMemoryInfo(pids);
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,25 @@ class CanStatus(var enabled: Boolean = false): Status() {
|
||||
*/
|
||||
class TracingStatus(var state: Tracing = UNKNOWN): Status() {
|
||||
|
||||
enum class Tracing(val code: String? = "") {
|
||||
enum class Tracing(val code: String? = "", var extra: Map<String, String>? = null) {
|
||||
|
||||
/**
|
||||
* 类型切换
|
||||
*/
|
||||
MAP_TRA_TYPE("IMAP_TRA_TYPE"),
|
||||
|
||||
|
||||
/**
|
||||
* 地图数据存在
|
||||
*/
|
||||
MAP_DATA_EXIST("IMAP_DATA_EXIST"),
|
||||
|
||||
|
||||
/**
|
||||
* 地图数据不存在
|
||||
*/
|
||||
MAP_DATA_NOT_EXIST("EMAP_DATA_NOT_EXIST"),
|
||||
|
||||
/**
|
||||
* 寻迹-已找到轨迹文件
|
||||
*/
|
||||
@@ -182,12 +200,10 @@ class TracingStatus(var state: Tracing = UNKNOWN): Status() {
|
||||
UNKNOWN;
|
||||
|
||||
fun isException(): Boolean {
|
||||
val c1 = when (this) {
|
||||
TRACK_FINDED, TRACK_NOT_EXIST, TRACK_LOAD_FAIL, ROUTE_FAILED, UNKNOWN -> true
|
||||
else -> false
|
||||
if (this == TRACK_LOADED || this == ROUTE_LOADED) {
|
||||
return false
|
||||
}
|
||||
val c2 = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
|
||||
return c1 and c2
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,14 +228,46 @@ class TracingStatus(var state: Tracing = UNKNOWN): Status() {
|
||||
override fun isException(): Boolean = state.isException()
|
||||
}
|
||||
|
||||
fun String.toState(): Tracing? {
|
||||
fun String.toState(msg: String?): Tracing? {
|
||||
val ss = msg?.split("|")
|
||||
var extra: Map<String, String>? = null
|
||||
if (ss != null && ss.isNotEmpty()) {
|
||||
val sb = StringBuilder()
|
||||
for (element in ss) {
|
||||
sb.append(element)
|
||||
sb.append(",")
|
||||
}
|
||||
if (sb.isNotEmpty()) {
|
||||
sb.setLength(sb.length - 1)
|
||||
}
|
||||
extra = mutableMapOf("extra" to sb.toString())
|
||||
}
|
||||
return when(this) {
|
||||
"IMAP_TRA_EXIST" -> TRACK_FINDED
|
||||
"IMAP_TRA_LOADED" -> TRACK_LOADED
|
||||
"EMAP_TRA_NOT_EXIST" -> TRACK_NOT_EXIST
|
||||
"EMAP_TRA_LOAD_FAILED" -> TRACK_LOAD_FAIL
|
||||
"IMAP_TRA_ROUTING" -> ROUTE_LOADED
|
||||
"IMAP_TRA_EXIST" -> TRACK_FINDED.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"IMAP_TRA_LOADED" -> TRACK_LOADED.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"EMAP_TRA_NOT_EXIST" -> TRACK_NOT_EXIST.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"EMAP_TRA_LOAD_FAILED" -> TRACK_LOAD_FAIL.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"IMAP_TRA_ROUTING" -> ROUTE_LOADED.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"EMAP_HADMAP_ENGINE_NO_ROUTING_INFO" -> ROUTE_FAILED
|
||||
"IMAP_TRA_TYPE" -> MAP_TRA_TYPE.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"MAP_DATA_EXIST" -> MAP_DATA_EXIST.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
"MAP_DATA_NOT_EXIST" -> MAP_DATA_NOT_EXIST.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ internal class CanImpl(ctx: Context): IFlow<CanStatus>(ctx), IMoGoAutopilotVehic
|
||||
|
||||
private fun timeOutCheck() {
|
||||
job?.safeCancel()
|
||||
launch(Dispatchers.Default) {
|
||||
launch(Dispatchers.Unconfined) {
|
||||
delay(4000)
|
||||
send(CanStatus(isCanEnabled()))
|
||||
}.also { job = it }
|
||||
|
||||
@@ -35,21 +35,29 @@ internal class GpsImpl(ctx: Context): IFlow<GpsStatus>(ctx) {
|
||||
}
|
||||
|
||||
private val onClose = {
|
||||
send(false, PermissionUtils.isGranted(Manifest.permission.ACCESS_FINE_LOCATION))
|
||||
send(false, isGrandFineLocation())
|
||||
}
|
||||
|
||||
private val onOpen = {
|
||||
send(true, PermissionUtils.isGranted(Manifest.permission.ACCESS_FINE_LOCATION))
|
||||
send(true, isGrandFineLocation())
|
||||
}
|
||||
|
||||
private fun isGrandFineLocation(): Boolean = try {
|
||||
PermissionUtils.isGranted(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate() {
|
||||
val isGranted = PermissionUtils.isGranted(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
val isGranted = isGrandFineLocation()
|
||||
send(isLocationEnabled(), isGranted)
|
||||
if (!isGranted) {
|
||||
PermissionUtils.requestAccessFineLocation(object : SimpleCallback {
|
||||
override fun onGranted() {
|
||||
Log.d(TAG,"权限: ${Manifest.permission.ACCESS_FINE_LOCATION} 被授予了....")
|
||||
send(enabled = isLocationEnabled(), isGranted = false)
|
||||
send(enabled = isLocationEnabled(), isGranted = true)
|
||||
}
|
||||
|
||||
override fun onDenied() {
|
||||
|
||||
@@ -78,12 +78,21 @@ internal class NetsImpl(ctx: Context): IFlow<NetStatus>(ctx) {
|
||||
private var loopCheckAndSendJob: Job? = null
|
||||
|
||||
private fun checkAndSend() {
|
||||
val connectionInfo = wifiMgr.connectionInfo
|
||||
val enabled = isNetConnected()
|
||||
val name = if (isLocationEnabled()) connectionInfo.ssid?.replace(Regex("[\\W]"), "") else "WI-FI"
|
||||
loopCheckAndSendJob?.safeCancel()
|
||||
launch(Dispatchers.Default) { delay(1000); checkAndSend() }.also { loopCheckAndSendJob = it }
|
||||
send(enabled, name)
|
||||
launch(Dispatchers.Unconfined) {
|
||||
val connectionInfo = wifiMgr.connectionInfo
|
||||
val enabled = isNetConnected()
|
||||
val name =
|
||||
try {
|
||||
if (isLocationEnabled()) connectionInfo.ssid?.replace(Regex("[\\W]"), "") else "WI-FI"
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
"WI-FI"
|
||||
}
|
||||
send(enabled, name)
|
||||
delay(1000);
|
||||
checkAndSend()
|
||||
}.also { loopCheckAndSendJob = it }
|
||||
}
|
||||
|
||||
private fun isLocationEnabled() =
|
||||
|
||||
@@ -44,7 +44,7 @@ internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatu
|
||||
return
|
||||
}
|
||||
check?.takeIf { it.isActive }?.cancel()
|
||||
launch {
|
||||
launch(Dispatchers.Unconfined) {
|
||||
CallerAutoPilotManager.sendStatusQueryReq()
|
||||
delay(5000)
|
||||
isOldVersion.set(true)
|
||||
@@ -82,7 +82,7 @@ internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatu
|
||||
if (isRTKEnabled()) {
|
||||
send(RTKStatus("RTK", 0))
|
||||
timeOutCheck?.takeIf { it.isActive }?.cancel()
|
||||
launch {
|
||||
launch(Dispatchers.Unconfined) {
|
||||
delay(4000)
|
||||
send(RTKStatus("", -1))
|
||||
}.also {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.trace
|
||||
|
||||
import android.content.*
|
||||
import android.util.*
|
||||
import com.mogo.eagle.core.data.autopilot.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener.Companion.STATUS_AUTOPILOT_RUNNING
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.*
|
||||
@@ -20,7 +20,8 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
|
||||
|
||||
override fun onCreate() {
|
||||
val code = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode()
|
||||
val state = code.toState() ?: UNKNOWN
|
||||
val msg = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageContent()
|
||||
val state = code.toState(msg) ?: UNKNOWN
|
||||
old = state
|
||||
send(TracingStatus(state))
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
@@ -30,7 +31,7 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
|
||||
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
|
||||
super.onAutopilotGuardian(guardianInfo)
|
||||
val current = guardianInfo?.code
|
||||
val newState = current?.toState()
|
||||
val newState = current?.toState(guardianInfo.msg)
|
||||
if (newState != null && newState != old) {
|
||||
send(TracingStatus(newState))
|
||||
old = newState
|
||||
@@ -40,17 +41,20 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
if (!CallerAutoPilotManager.isConnected()) {
|
||||
old = UNKNOWN
|
||||
send(TracingStatus(UNKNOWN))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
super.onAutopilotStatusResponse(autoPilotStatusInfo)
|
||||
if (autoPilotStatusInfo.state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
if (autoPilotStatusInfo.state != STATUS_AUTOPILOT_RUNNING) {
|
||||
old = UNKNOWN
|
||||
send(TracingStatus(UNKNOWN))
|
||||
return
|
||||
}
|
||||
if (old.isException() && autoPilotStatusInfo.state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (old.isException()) {
|
||||
old = TRACK_LOADED
|
||||
send(TracingStatus(TRACK_LOADED))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.widget.*
|
||||
import androidx.core.content.*
|
||||
import androidx.recyclerview.widget.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.zhjt.mogo_core_function_devatools.*
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
@@ -19,6 +20,10 @@ import kotlinx.coroutines.*
|
||||
|
||||
internal class StatusAdapter(val ctx: Context, var data: ArrayList<Status>): RecyclerView.Adapter<StatusViewHolder>() {
|
||||
|
||||
companion object {
|
||||
const val TAG = "StatusAdapter"
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StatusViewHolder =
|
||||
StatusViewHolder(LayoutInflater.from(ctx).inflate(R.layout.layout_status_bar_item, parent, false))
|
||||
|
||||
@@ -69,7 +74,7 @@ internal class StatusAdapter(val ctx: Context, var data: ArrayList<Status>): Rec
|
||||
}
|
||||
is TracingStatus -> {
|
||||
when(status.state) {
|
||||
ROUTE_FAILED, TRACK_LOAD_FAIL, TRACK_NOT_EXIST, TRACK_FINDED, UNKNOWN -> {
|
||||
MAP_DATA_NOT_EXIST, MAP_DATA_EXIST, MAP_TRA_TYPE, ROUTE_FAILED, TRACK_LOAD_FAIL, TRACK_NOT_EXIST, TRACK_FINDED, UNKNOWN -> {
|
||||
iv.background = ContextCompat.getDrawable(itemView.context, drawable.icon_dev_status_trace_unkown)
|
||||
}
|
||||
TRACK_LOADED -> {
|
||||
@@ -116,7 +121,26 @@ internal class StatusAdapter(val ctx: Context, var data: ArrayList<Status>): Rec
|
||||
else ->
|
||||
"定位异常"
|
||||
}
|
||||
is TracingStatus -> "轨迹类型:${ if (status.state == TRACK_LOADED) "循迹" else if (status.state == ROUTE_LOADED) "自主算路" else "暂无轨迹" }"
|
||||
is TracingStatus -> {
|
||||
val extra = status.state.extra
|
||||
val extraDesc = if (extra != null && extra.isNotEmpty()) extra.values.joinToString(",") else ""
|
||||
Logger.d(TAG, "traceing_state: $status -> extra: $extraDesc :: extra: $extra")
|
||||
when(status.state) {
|
||||
//"轨迹类型:${ if (status.state == TRACK_LOADED) "循迹" else if (status.state == ROUTE_LOADED) "自主算路" else "暂无轨迹" }"
|
||||
MAP_TRA_TYPE -> {
|
||||
"暂无轨迹"
|
||||
}
|
||||
MAP_DATA_EXIST -> "地图数据存在,正在加载${if (extraDesc.isEmpty()) "" else "[$extraDesc]" }"
|
||||
MAP_DATA_NOT_EXIST -> "地图数据不存在${if (extraDesc.isEmpty()) "" else "[$extraDesc]"}"
|
||||
TRACK_FINDED -> "轨迹类型:循迹[已找到轨迹$extraDesc]"
|
||||
TRACK_LOADED -> "轨迹类型:循迹[加载成功$extraDesc]"
|
||||
TRACK_NOT_EXIST -> "轨迹类型:循迹[不存在$extraDesc]"
|
||||
TRACK_LOAD_FAIL -> "轨迹类型:循迹[加载失败$extraDesc]"
|
||||
ROUTE_LOADED -> "轨迹类型:自主算路[加载成功$extraDesc]"
|
||||
ROUTE_FAILED -> "轨迹类型:自主算路[加载失败$extraDesc]"
|
||||
UNKNOWN -> "暂无轨迹"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,12 @@ class TraceManager : IMoGoCloudListener {
|
||||
FwBuild(false, 30, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_TRAFFIC_LIGHT)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_OBJECTS] =
|
||||
FwBuild(false, 30, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_PLANNING_OBJECTS)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_PLANNING_ACTIONS)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_NATIVE_LEAK] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_RECORD_NATIVE_LEAK)
|
||||
|
||||
|
||||
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS] =
|
||||
ChainLogParam(true, "ADAS连接状态")
|
||||
@@ -70,8 +76,14 @@ class TraceManager : IMoGoCloudListener {
|
||||
ChainLogParam(false, "ADAS车前引导线")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE] =
|
||||
ChainLogParam(false, "ADAS车辆底盘数据")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT] =
|
||||
ChainLogParam(false, "ADAS红绿灯数据")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_OBJECTS] =
|
||||
ChainLogParam(false, "ADAS PLANNING 感知障碍物")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS] =
|
||||
ChainLogParam(true, "ADAS PLANNING 决策行为")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_NATIVE_LEAK] =
|
||||
ChainLogParam(true, "Native Leak Record")
|
||||
|
||||
FileWriteManager.getInstance()
|
||||
.init(context, MoGoAiCloudClientConfig.getInstance().sn, pkgName, fwBuildMap)
|
||||
|
||||
@@ -75,6 +75,8 @@ dependencies {
|
||||
|
||||
implementation rootProject.ext.dependencies.android_start_up
|
||||
implementation rootProject.ext.dependencies.cicle_indicator
|
||||
implementation rootProject.ext.dependencies.koomnative
|
||||
implementation rootProject.ext.dependencies.koomxhook
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
api rootProject.ext.dependencies.mogoaicloudservicesdk
|
||||
api rootProject.ext.dependencies.mogocommons
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.eagle.core.function.hmi">
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.hmi.IMoGoHmiViewProxy
|
||||
import com.mogo.eagle.core.function.api.hmi.IMoGoHmiViewProxy.IViewNotificationProvider
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IOchBusView
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewLimitingVelocity
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewNotification
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight
|
||||
@@ -69,6 +70,7 @@ import com.mogo.eagle.core.function.hmi.ui.setting.IPCReportWindow
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.ReportListFloatWindow
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.AdUpgradeDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.AutoPilotAndCheckView
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.MaskView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
@@ -87,8 +89,11 @@ import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.module.common.enums.*
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import kotlinx.android.synthetic.main.fragment_hmi.*
|
||||
import kotlinx.android.synthetic.main.view_auto_pilot_check.view.*
|
||||
import kotlinx.android.synthetic.main.view_och_bus_operation.view.*
|
||||
import kotlinx.coroutines.*
|
||||
import mogo_msg.MogoReportMsg
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.util.*
|
||||
|
||||
@@ -123,6 +128,9 @@ import java.util.*
|
||||
// 检测、自动驾驶速度设置
|
||||
private var toolsViewFloat: WarningFloat.Builder? = null
|
||||
|
||||
private var maskViewFloat: WarningFloat.Builder? = null
|
||||
private var maskView: MaskView? = null
|
||||
|
||||
private var upgradeTipsView: (() -> View)? = null
|
||||
|
||||
// HMI 视图控件代理
|
||||
@@ -150,6 +158,8 @@ import java.util.*
|
||||
private var showingV2XTip: IReminder? = null
|
||||
private var roadVideoDialog: RoadVideoDialog? = null
|
||||
|
||||
private var busOperationStatus: IOchBusView? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
@@ -172,7 +182,7 @@ import java.util.*
|
||||
}
|
||||
}
|
||||
|
||||
/*ivCameraIcon?.setOnLongClickListener {
|
||||
/**ivCameraIcon?.setOnLongClickListener {
|
||||
activity?.let { it1 -> CarcorderPreviewView.show(it1) }
|
||||
true
|
||||
}*/
|
||||
@@ -235,8 +245,8 @@ import java.util.*
|
||||
return
|
||||
}
|
||||
}
|
||||
//处于非美化模式下弹窗
|
||||
if (!FunctionBuildConfig.isDemoMode && (recordPanel.stat == 100 || recordPanel.stat == 101)) {
|
||||
//处于非美化模式下弹窗;是地图数据采集任务时即type=2时,不弹窗
|
||||
if (!FunctionBuildConfig.isDemoMode && (recordPanel.stat == 100 || recordPanel.stat == 101) && recordPanel.type!=2) {
|
||||
//只在司机屏生效,乘客屏不生效
|
||||
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
activity?.let { CallerDevaToolsManager.onReceiveBadCaseRecord(recordPanel, it) }
|
||||
@@ -327,6 +337,15 @@ import java.util.*
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeBusOperationStatus(isOut: Boolean) {
|
||||
busOperationStatus?.changerOperationStatus(isOut)
|
||||
}
|
||||
|
||||
override fun setBusOperationView(view: IOchBusView) {
|
||||
busOperationStatus = view
|
||||
busOperationStatus?.showBusOperation()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 红绿灯 代理View
|
||||
*/
|
||||
@@ -709,7 +728,9 @@ import java.util.*
|
||||
WarningFloat.dismiss(tag)
|
||||
}
|
||||
Log.d("$M_HMI$TAG", "--- disableWarningV2X ---")
|
||||
showingV2XTip?.takeIf { it.isShowing() }?.also { it.hide() }
|
||||
lifecycleScope.launch {
|
||||
showingV2XTip?.takeIf { it.isShowing() }?.also { it.hide() }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -941,6 +962,66 @@ import java.util.*
|
||||
cameraListView?.showNoSignal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示蒙层
|
||||
*/
|
||||
override fun showMaskView() {
|
||||
if (maskViewFloat == null) {
|
||||
context?.let {
|
||||
if (maskViewFloat == null) {
|
||||
if (maskView == null) {
|
||||
maskView = MaskView(it)
|
||||
}
|
||||
|
||||
maskViewFloat = WarningFloat.with(it)
|
||||
.setTag("MaskViewFloat")
|
||||
.setLayout(maskView!!)
|
||||
.setSidePattern(SidePattern.LEFT)
|
||||
.setGravity(Gravity.CENTER)
|
||||
.setImmersionStatusBar(true)
|
||||
.setWindowHeight(LayoutParams.MATCH_PARENT)
|
||||
.setWindowWidth(LayoutParams.MATCH_PARENT)
|
||||
// .setCountDownTime(6000)
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(
|
||||
view: View,
|
||||
params: LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.enterAnim(view, params, windowManager, sidePattern)
|
||||
?.apply {
|
||||
interpolator = OvershootInterpolator()
|
||||
}
|
||||
|
||||
override fun exitAnim(
|
||||
view: View,
|
||||
params: LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.exitAnim(view, params, windowManager, sidePattern)
|
||||
?.setDuration(200)
|
||||
})
|
||||
.addWarningStatusListener(object : IMoGoWarningStatusListener {
|
||||
override fun onDismiss() {
|
||||
maskViewFloat = null
|
||||
maskView = null
|
||||
// TODO:("")
|
||||
}
|
||||
})
|
||||
.show()
|
||||
} else {
|
||||
maskViewFloat?.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideMaskView() {
|
||||
dismissMaskView()
|
||||
}
|
||||
|
||||
override fun showToolsView() {
|
||||
if (toolsViewFloat == null) {
|
||||
showToolsFloat()
|
||||
@@ -1037,6 +1118,14 @@ import java.util.*
|
||||
}
|
||||
}
|
||||
|
||||
private fun dismissMaskView() {
|
||||
maskViewFloat?.let {
|
||||
WarningFloat.dismiss(it.config.floatTag, false)
|
||||
maskViewFloat = null
|
||||
maskView = null
|
||||
}
|
||||
}
|
||||
|
||||
private var isLeftLight :Boolean = false
|
||||
private var isRightLight :Boolean = false
|
||||
private var isDisappare :Boolean = false
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.pnc
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.autopilot.pnc.PncActionsHelper
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.trafficlight.currentRoadTrafficLight
|
||||
import com.mogo.eagle.core.data.trafficlight.isRed
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener.Companion.STATUS_AUTOPILOT_RUNNING
|
||||
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.view_pnc_actions.view.*
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
class PncActionsView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotPlanningActionsListener,
|
||||
IMoGoTrafficLightListener, IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "PncActionsView"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var mTrafficLightResult: TrafficLightResult? = null
|
||||
|
||||
private var mAutoPilotStatusInfo: AutopilotStatusInfo? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_pnc_actions, this, true)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotPlanningActionsListenerManager.addListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
CallerAutopilotPlanningActionsListenerManager.removeListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
super.onAutopilotStatusResponse(autoPilotStatusInfo)
|
||||
mAutoPilotStatusInfo = autoPilotStatusInfo
|
||||
if (mAutoPilotStatusInfo!!.state != STATUS_AUTOPILOT_RUNNING) {
|
||||
UiThreadHandler.post {
|
||||
this.background = null
|
||||
tvHmiPncActions.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun pncActions(planningActionMsg: MessagePad.PlanningActionMsg) {
|
||||
mAutoPilotStatusInfo?.let {
|
||||
if (it.state == STATUS_AUTOPILOT_RUNNING) {
|
||||
UiThreadHandler.post {
|
||||
var actions: String? = null
|
||||
planningActionMsg.actionMsg?.let {
|
||||
actions = PncActionsHelper.getAction(it.drivingState.number, it.drivingAction.number)
|
||||
|
||||
//如果是存在云端红绿灯数据条件下,设置云端数据
|
||||
if (PncActionsHelper.isWaitingTrafficlight(it.drivingState.number, it.drivingAction.number)
|
||||
&& mTrafficLightResult != null
|
||||
&& getWaitTrafficlightTime().isNotBlank()) {
|
||||
actions += ",预计${getWaitTrafficlightTime()}秒后通过"
|
||||
} else {
|
||||
mTrafficLightResult = null
|
||||
}
|
||||
}
|
||||
// update view
|
||||
if (actions.isNullOrEmpty()) {
|
||||
this.background = null
|
||||
tvHmiPncActions.text = ""
|
||||
} else {
|
||||
this.background = AppCompatResources.getDrawable(context, R.drawable.pnc_actions_bg)
|
||||
tvHmiPncActions.text = actions
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
|
||||
mTrafficLightResult = trafficLightResult
|
||||
}
|
||||
|
||||
private fun getWaitTrafficlightTime(): String {
|
||||
return if (mTrafficLightResult != null
|
||||
&& mTrafficLightResult!!.currentRoadTrafficLight() != null
|
||||
&& mTrafficLightResult!!.currentRoadTrafficLight()!!.isRed()
|
||||
) {
|
||||
mTrafficLightResult!!.currentRoadTrafficLight()!!.remain.toString()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,7 @@ import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.MogoMapUIController
|
||||
import com.mogo.map.uicontroller.VisualAngleMode
|
||||
import com.mogo.map.uicontroller.VisualAngleMode.*
|
||||
import com.mogo.module.service.routeoverlay.*
|
||||
@@ -152,6 +153,8 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
|
||||
}
|
||||
|
||||
private var isStarted = false
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_debug_setting, this, true)
|
||||
initView()
|
||||
@@ -248,6 +251,23 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔戒控制
|
||||
*/
|
||||
tbMojie.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
if (isChecked) {
|
||||
buttonView.setCompoundDrawables(null, null, iconDown, null)
|
||||
btnOpenAllGestures.visibility = View.VISIBLE
|
||||
} else {
|
||||
buttonView.setCompoundDrawables(null, null, iconRight, null)
|
||||
btnOpenAllGestures.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
btnOpenAllGestures.setOnClickListener {
|
||||
MogoMapUIController.getInstance().setAllGesturesEnabled(true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
@@ -554,6 +574,11 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
//只在司机端设置美化模式开关功能
|
||||
if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)){
|
||||
tbIsDemoMode.visibility = View.GONE
|
||||
}
|
||||
|
||||
// 雨天模式,上一次勾选的数据
|
||||
tbIsRainMode.isChecked = FunctionBuildConfig.isRainMode
|
||||
//雨天模式
|
||||
@@ -566,6 +591,15 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
tbIsRainMode.visibility = View.GONE
|
||||
}
|
||||
|
||||
tbBeautyMode.isChecked = FunctionBuildConfig.isBeautyMode
|
||||
//感知优化模式
|
||||
tbBeautyMode.setOnCheckedChangeListener { _, isChecked ->
|
||||
FunctionBuildConfig.isBeautyMode = isChecked
|
||||
if (!FunctionBuildConfig.isBeautyMode) {
|
||||
tbBeautyMode.isChecked = false
|
||||
}
|
||||
}
|
||||
|
||||
//重启工控机所有节点
|
||||
btnIpcReboot.onClick {
|
||||
CallerAutoPilotManager.sendIpcReboot()
|
||||
@@ -616,6 +650,31 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化 tracker感知数据源 数据
|
||||
trackerProvider.check(
|
||||
when (FunctionBuildConfig.debugTrackerProvider) {
|
||||
0 -> {
|
||||
R.id.trackerProviderOrigin
|
||||
}
|
||||
1 -> {
|
||||
R.id.trackerProviderObu
|
||||
}
|
||||
else -> R.id.trackerProviderOrigin
|
||||
}
|
||||
)
|
||||
trackerProvider.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.trackerProviderOrigin -> {
|
||||
FunctionBuildConfig.debugTrackerProvider = 0
|
||||
// update tracker provider view
|
||||
}
|
||||
R.id.trackerProviderObu -> {
|
||||
FunctionBuildConfig.debugTrackerProvider = 1
|
||||
// update tracker provider view
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 初始化 ADAS感知数据是否绘制 选择情况
|
||||
tbIsDrawIdentifyData.isChecked = FunctionBuildConfig.isDrawIdentifyData
|
||||
@@ -802,6 +861,17 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
btnBrakeThreshold.setOnLongClickListener {
|
||||
if (!isStarted) {
|
||||
CallerDevaToolsManager.startMonitor()
|
||||
isStarted = true
|
||||
} else {
|
||||
CallerDevaToolsManager.stopMonitor()
|
||||
isStarted = false
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
//设置连接司机屏IP
|
||||
btnConnectServerIp.setOnClickListener {
|
||||
val ip = etConnectServerIp.text.toString()
|
||||
@@ -1380,6 +1450,19 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ADAS红绿灯数据
|
||||
*/
|
||||
cbAdasTrafficlight.setOnCheckedChangeListener { _, isChecked ->
|
||||
val map = CallerDevaToolsManager.getTraceInfo()
|
||||
val param = map[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT]
|
||||
param?.let {
|
||||
it.record = isChecked
|
||||
map[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT] = param
|
||||
CallerDevaToolsManager.refreshTraceInfo(map)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ADAS PLANNING OBJ 感知障碍物
|
||||
*/
|
||||
@@ -1413,6 +1496,10 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
vehicle?.let {
|
||||
cbAdasVehicle.isChecked = it.record
|
||||
}
|
||||
val trafficlight = traceInfoMap[ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT]
|
||||
trafficlight?.let {
|
||||
cbAdasTrafficlight.isChecked = it.record
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,32 +2,35 @@ package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Process
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.temp.EventBusOperation
|
||||
import com.mogo.eagle.core.data.temp.EventLogout
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.ui.utils.KeyBoardUtil
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.view_auto_pilot_check.view.*
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* @author ChenFufeng
|
||||
@@ -96,6 +99,9 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
ivCloseIcon.setOnClickListener {
|
||||
clickListener?.onClose(it)
|
||||
}
|
||||
rlKillLayout.setOnClickListener {
|
||||
killApp()
|
||||
}
|
||||
viewCheckStatus.setOnClickListener {
|
||||
clickListener?.go2CheckPage()
|
||||
}
|
||||
@@ -142,6 +148,7 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
if (speedLimit > 0) {
|
||||
etInputSpeed.setText((speedLimit * 3.6).toInt().toString())
|
||||
}
|
||||
initOchView()
|
||||
// // 比如需要设置默认速度
|
||||
// val speed = "30"
|
||||
// etInputSpeed.setText(speed)
|
||||
@@ -149,6 +156,35 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
|
||||
}
|
||||
|
||||
private fun initOchView() {
|
||||
actvLoginout.onClick {
|
||||
EventBus.getDefault().post(EventLogout())
|
||||
}
|
||||
|
||||
when (DebugConfig.getProductFlavor()) {
|
||||
"fPadLenovoOchTaxi" -> {
|
||||
actvLoginout.visibility = View.VISIBLE
|
||||
}
|
||||
"fPadLenovoOchBus" ->{
|
||||
CallerHmiManager.setBusOperationView(toolBusOperationView)
|
||||
EventBus.getDefault().post(EventBusOperation(0))
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun killApp() {
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
addCategory(Intent.CATEGORY_HOME)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
context.startActivity(this)
|
||||
Process.killProcess(Process.myPid())
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import com.mogo.eagle.core.data.temp.EventBusOperation
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IOchBusView
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import kotlinx.android.synthetic.main.view_och_bus_operation.view.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/8/23
|
||||
*/
|
||||
class BusOperationView @JvmOverloads constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0)
|
||||
: IOchBusView(context, attrs, defStyleAttr), View.OnClickListener {
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_och_bus_operation,this,true)
|
||||
ochBusOperationStatus.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun showBusOperation() {
|
||||
ochBusOperationStatus.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun changerOperationStatus(isOut: Boolean) {
|
||||
if (isOut){
|
||||
ochBusOperationStatusCTV.text = "收车"
|
||||
}else{
|
||||
ochBusOperationStatusCTV.text = "出车"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
EventBus.getDefault().post(EventBusOperation(1))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* 蒙层view
|
||||
*/
|
||||
class MaskView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
) {
|
||||
|
||||
private val TAG = "MaskView"
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_mask, this, true)
|
||||
initView()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var speedLimit: Double = 0.0
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initView() {
|
||||
// background = ColorDrawable(Color.parseColor("#F0151D41"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import android.content.*
|
||||
import android.util.*
|
||||
import android.view.*
|
||||
import android.widget.*
|
||||
import com.mogo.commons.*
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.map.MogoMapUIController
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.map.uicontroller.VisualAngleMode
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import com.mogo.module.common.constants.DataTypes
|
||||
import com.mogo.eagle.core.function.hmi.R.drawable
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.uicontroller.*
|
||||
import com.mogo.map.uicontroller.VisualAngleMode.MODE_MEDIUM_SIGHT
|
||||
import com.mogo.module.common.constants.*
|
||||
import kotlinx.android.synthetic.main.view_perspective_switch.view.*
|
||||
|
||||
/**
|
||||
@@ -43,6 +42,11 @@ class PerspectiveSwitchView @JvmOverloads constructor(
|
||||
.inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS)
|
||||
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null)
|
||||
textSwitch.setText(R.string.module_map_model_faster)
|
||||
} else {
|
||||
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
|
||||
.visibleAllMarkers()
|
||||
MogoMapUIController.getInstance().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null)
|
||||
textSwitch.setText(R.string.module_map_model_normal)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget;
|
||||
|
||||
import static com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
@@ -15,7 +17,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningActionsListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
@@ -25,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import chassis.Chassis;
|
||||
import chassis.VehicleStateOuterClass;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
@@ -61,7 +64,7 @@ public class TrafficDataView extends ConstraintLayout {
|
||||
accTextView.setText("- " + accStr);
|
||||
}
|
||||
int state = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState();
|
||||
if (state < 2) {
|
||||
if (state < STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mBrake > 0) {
|
||||
brakeStatus.setImageResource(R.drawable.traffic_data_brake);
|
||||
} else if (mThrottle >= 0 && mBrake == 0) {
|
||||
@@ -100,11 +103,7 @@ public class TrafficDataView extends ConstraintLayout {
|
||||
super.onAttachedToWindow();
|
||||
handler.sendEmptyMessageDelayed(MSG_SEND_UPDATE, 1000L);
|
||||
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
|
||||
CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, gnssInfo -> {
|
||||
if (gnssInfo != null) {
|
||||
acceleration = gnssInfo.getAcceleration();
|
||||
}
|
||||
});
|
||||
CallerAutopilotPlanningActionsListenerManager.INSTANCE.addListener(TAG, planningActionMsg -> acceleration = planningActionMsg.getDestinationAcc());
|
||||
}
|
||||
|
||||
private void initView(@NonNull Context context) {
|
||||
@@ -120,7 +119,7 @@ public class TrafficDataView extends ConstraintLayout {
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
CallerAutopilotVehicleStateListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerAutopilotCarStatusListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerAutopilotPlanningActionsListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.eagle.core.function.main;
|
||||
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_RECORD_NATIVE_LEAK;
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LEAK;
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LOG_NATIVE_LEAK;
|
||||
import static com.mogo.eagle.core.function.main.MainPresenter.MOGO_PERMISSION_REQUEST_CODE;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI;
|
||||
|
||||
@@ -19,6 +22,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.kwai.koom.base.MonitorManager;
|
||||
import com.kwai.koom.nativeoom.leakmonitor.LeakMonitor;
|
||||
import com.kwai.koom.nativeoom.leakmonitor.LeakMonitorConfig;
|
||||
import com.kwai.koom.nativeoom.leakmonitor.LeakRecord;
|
||||
import com.mogo.cloud.commons.BuildConfig;
|
||||
import com.mogo.commons.context.ContextHolderUtil;
|
||||
import com.mogo.commons.mvp.BaseFragment;
|
||||
@@ -54,6 +61,8 @@ import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.rousetime.android_startup.StartupManager;
|
||||
import com.rousetime.android_startup.model.LoggerLevel;
|
||||
import com.rousetime.android_startup.model.StartupConfig;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
import com.zhjt.service.chain.TracingConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -274,6 +283,8 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
|
||||
// 启动一些基本的服务:定位等
|
||||
startBaseService();
|
||||
// 启动Native内存泄漏监测
|
||||
startLeakMonitor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,6 +299,38 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
// startService(intentCarcorderService);
|
||||
}
|
||||
|
||||
private void startLeakMonitor() {
|
||||
LeakMonitorConfig leakMonitorConfig = new LeakMonitorConfig.Builder()
|
||||
.setLoopInterval(50000)
|
||||
.setMonitorThreshold(16)
|
||||
.setNativeHeapAllocatedThreshold(0)
|
||||
.setEnableLocalSymbolic(true)
|
||||
.setLeakListener(leaks -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (!leaks.isEmpty()) {
|
||||
for (LeakRecord leakRecord : leaks) {
|
||||
stringBuilder.append(leakRecord.toString());
|
||||
}
|
||||
printLeakMsg(stringBuilder.toString());
|
||||
}
|
||||
})
|
||||
.build();
|
||||
MonitorManager.addMonitorConfig(leakMonitorConfig);
|
||||
LeakMonitor.INSTANCE.start();
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_NATIVE_LEAK,
|
||||
linkCode = CHAIN_LINK_LEAK,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_RECORD_NATIVE_LEAK,
|
||||
paramIndexes = {0},
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
private void printLeakMsg(String leakRecord) {
|
||||
CallerLogger.INSTANCE.d(M_HMI + TAG, "内存泄漏日志如下:\n" + leakRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideCoverUpLayout() {
|
||||
mConnectInfoRV.setVisibility(View.GONE);
|
||||
@@ -388,7 +431,8 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) { }
|
||||
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
@@ -5,11 +5,17 @@ import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_INIT;
|
||||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -19,11 +25,17 @@ import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.function.main.moujie.BluetoothMonitorReceiver;
|
||||
import com.mogo.eagle.core.function.main.moujie.ConnectBluetoothEvent;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.BarUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.rousetime.android_startup.model.CostTimesModel;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
@@ -31,8 +43,15 @@ import com.zhjt.service.chain.TracingConstants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* 针对作为Launcher的情况,做个性化操作
|
||||
@@ -45,12 +64,47 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
private final static Handler handlerV2XEvent = new Handler();
|
||||
private static Runnable runnableV2XEvent;
|
||||
|
||||
private volatile double accelerated;//加速度
|
||||
private Timer timerHorn;
|
||||
private Timer timerAcc;
|
||||
|
||||
private BluetoothMonitorReceiver mBluetoothReceiver = null;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
private List<BluetoothDevice> mAreadlyConnectedList = new ArrayList<>();//已连接设备集合
|
||||
private int numberA = 0;
|
||||
private boolean isLongPressA = false;
|
||||
private int numberB = 0;
|
||||
private boolean isLongPressB = false;
|
||||
private int numberC = 0;
|
||||
private boolean isLongPressC = false;
|
||||
private int numberD = 0;
|
||||
private boolean isLongPressD = false;
|
||||
private int numberE = 0;
|
||||
private boolean isLongPressE = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
DebugConfig.setNeedRequestUserInfo(true);
|
||||
EventBus.getDefault().register(this);
|
||||
CallerLogger.INSTANCE.i(M_HMI + TAG, "onCreate");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
initBluetooth();
|
||||
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (!mBluetoothAdapter.isEnabled()) {
|
||||
mBluetoothAdapter.enable();
|
||||
}
|
||||
mBluetoothAdapter.startDiscovery();
|
||||
|
||||
showBondedDevice(mBluetoothAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,6 +209,188 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { //向上长按 开启自动驾驶
|
||||
long currentTime = System.currentTimeMillis() / (1000);
|
||||
long oldTime = SharedPrefsMgr.getInstance(getContext()).getLong("old_time_up", 0);
|
||||
// Log.d("liyz", "time = " + (currentTime - oldTime));
|
||||
if (currentTime - oldTime > 6) {
|
||||
SharedPrefsMgr.getInstance(getContext()).putLong("old_time_up", System.currentTimeMillis() / 1000);
|
||||
// ToastUtils.showShort("长按 ↑↑↑ 开启自动驾驶");
|
||||
CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { //下和中间键盘长按,减速为-2
|
||||
long currentTime = System.currentTimeMillis() / (1000);
|
||||
long oldTime = SharedPrefsMgr.getInstance(getContext()).getLong("old_time_down", 0);
|
||||
if (currentTime - oldTime > 6) {
|
||||
SharedPrefsMgr.getInstance(getContext()).putLong("old_time_down", System.currentTimeMillis() / 1000);
|
||||
// ToastUtils.showShort("长按 ↓↓↓ 减速 -2 ");
|
||||
sendAcc(true, -2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Log.e("liyz", "onKeyDown keyCode = " + keyCode + "--action = " + event.getAction() + "---" + event);
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
// Log.d("liyz", "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event);
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击向左变道,长按-1
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberA++;
|
||||
if (numberA > 2) {
|
||||
if (!isLongPressA) {
|
||||
// ToastUtils.showShort("方块 长按A -2 ");
|
||||
sendAcc(true, -2);
|
||||
isLongPressA = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberA == 1) {
|
||||
// ToastUtils.showShort("方块 点击A -1 ");
|
||||
sendAcc(true, -1);
|
||||
}
|
||||
numberA = 0;
|
||||
isLongPressA = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_B) { //单击向右变道,长按-2
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberB++;
|
||||
if (numberB > 2) {
|
||||
if (!isLongPressB) {
|
||||
// ToastUtils.showShort("方块 长按B 无操作 ");
|
||||
isLongPressB = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberB == 1) {
|
||||
// ToastUtils.showShort("方块 单击B 复原 ");
|
||||
sendAcc(false, 0.0);
|
||||
}
|
||||
numberB = 0;
|
||||
isLongPressB = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击鸣笛,
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberC++;
|
||||
if (numberC > 2) {
|
||||
if (!isLongPressC) {
|
||||
// ToastUtils.showShort("方块 长按C 无操作");
|
||||
isLongPressC = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberC == 1) {
|
||||
// ToastUtils.showShort("方块 单击C ← 向左变道 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
|
||||
}
|
||||
numberC = 0;
|
||||
isLongPressC = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_D) { //单击开启自动驾驶,
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberD++;
|
||||
if (numberD > 2) {
|
||||
if (!isLongPressD) {
|
||||
// ToastUtils.showShort("方块 长按D 无操作");
|
||||
isLongPressD = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberD == 1) {
|
||||
// ToastUtils.showShort("方块 单击D → 向右变道 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
|
||||
}
|
||||
numberD = 0;
|
||||
isLongPressD = false;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击复原,
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
numberE++;
|
||||
if (numberE > 2) {
|
||||
if (!isLongPressE) {
|
||||
// ToastUtils.showShort("方块 长按E 鸣笛 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
|
||||
if (timerHorn == null) {
|
||||
timerHorn = new Timer();
|
||||
}
|
||||
timerHorn.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
|
||||
timerHorn = null;
|
||||
}
|
||||
}, 500);
|
||||
isLongPressE = true;
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (numberE == 1) {
|
||||
// ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
|
||||
CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
|
||||
}
|
||||
numberE = 0;
|
||||
isLongPressE = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
// Log.d("liyz", "dispatchTouchEvent event.getX() = " + event.getX() + "--event.getY() = " + event.getY() + "--action = " + event.getAction());
|
||||
if (event.getX() == -1469.6875 && event.getY() == 530.0) { //向左变道
|
||||
// ToastUtils.showShort("← 向左变道");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
|
||||
|
||||
return true;
|
||||
} else if (event.getX() == -1096.25 && event.getY() == 132.5) { //鸣笛
|
||||
// ToastUtils.showShort("↑ 鸣笛 ");
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
|
||||
|
||||
if (timerHorn == null) {
|
||||
timerHorn = new Timer();
|
||||
}
|
||||
timerHorn.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
|
||||
timerHorn = null;
|
||||
}
|
||||
}, 500);
|
||||
|
||||
return true;
|
||||
} else if (event.getX() == -863.4375 && event.getY() == 690.0) { //向右变道
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
|
||||
// ToastUtils.showShort("→ 向右变道");
|
||||
return true;
|
||||
} else if (event.getX() == -1096.25 && event.getY() == 1099.0) { // -1减速
|
||||
sendAcc(true, -1);
|
||||
// ToastUtils.showShort("↓ 减速 -1 ");
|
||||
|
||||
return true;
|
||||
} else if (event.getX() == -1096.25 && event.getY() == 690.0) { //复原
|
||||
// ToastUtils.showShort("O 复原 ");
|
||||
sendAcc(false, 0.0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinModeChange(int skinMode) {
|
||||
if (skinMode == 0) {
|
||||
@@ -163,4 +399,117 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
BarUtils.setStatusBarLightMode(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void sendAcc(boolean isSend, double acc) {
|
||||
if (isSend) {
|
||||
accelerated = acc;
|
||||
if (timerAcc == null) {
|
||||
timerAcc = new Timer();
|
||||
timerAcc.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetAcceleratedSpeed(accelerated);
|
||||
}
|
||||
}, 0, 500);
|
||||
}
|
||||
} else {
|
||||
if (timerAcc != null) {
|
||||
timerAcc.cancel();
|
||||
timerAcc = null;
|
||||
}
|
||||
CallerAutoPilotManager.INSTANCE.sendOperatorSetAcceleratedSpeed(acc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化蓝牙广播
|
||||
*/
|
||||
private void initBluetooth() {
|
||||
this.mBluetoothReceiver = new BluetoothMonitorReceiver();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
// 监视蓝牙关闭和打开的状态
|
||||
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
|
||||
// 监视蓝牙设备与APP连接的状态
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
|
||||
// 注册广播
|
||||
registerReceiver(this.mBluetoothReceiver, intentFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找蓝牙连接过的蓝牙设备
|
||||
*
|
||||
* @param bluetoothAdapter
|
||||
*/
|
||||
private void showBondedDevice(BluetoothAdapter bluetoothAdapter) {
|
||||
mAreadlyConnectedList.clear();
|
||||
Set<BluetoothDevice> deviceList = bluetoothAdapter.getBondedDevices();
|
||||
for (BluetoothDevice device : deviceList) {
|
||||
try {
|
||||
//使用反射调用获取设备连接状态方法
|
||||
Method isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null);
|
||||
isConnectedMethod.setAccessible(true);
|
||||
boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
|
||||
// Log.e("liyz", "showBondedDevice Name:" + device.getName() + " Mac:" + device.getAddress() + "---isConnected = " + isConnected);
|
||||
mAreadlyConnectedList.add(device);
|
||||
if (device.getName().equals("JX-05")) { //后面魔戒可能不使用了
|
||||
SharedPrefsMgr.getInstance(getContext()).putString("BT_MAC", device.getAddress());
|
||||
}
|
||||
if (!isConnected) {
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
connectBluetooth(); //主动连接一次
|
||||
}, 4000L);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onAutoConnection(ConnectBluetoothEvent event) {
|
||||
// connectBluetooth();
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动连接最近的一次连接
|
||||
*/
|
||||
private void connectBluetooth() {
|
||||
// Log.d("liyz", "connectBluetooth ----> size() = " + mAreadlyConnectedList.size());
|
||||
if (mAreadlyConnectedList.size() > 0) {
|
||||
try {
|
||||
Method method = BluetoothDevice.class.getMethod("createBond");
|
||||
String macAddress = SharedPrefsMgr.getInstance(getContext()).getString("BT_MAC");
|
||||
int pos = -1;
|
||||
for (int i = 0; i < mAreadlyConnectedList.size(); i++) {
|
||||
if (macAddress.equals(mAreadlyConnectedList.get(i).getAddress())) {
|
||||
pos = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Log.d("liyz", "connectBluetooth macAddress = " + macAddress + "---pos = " + pos);
|
||||
if (mAreadlyConnectedList.size() > pos && (pos >= 0)) {
|
||||
method.invoke(mAreadlyConnectedList.get(pos));
|
||||
}
|
||||
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.os.Process;
|
||||
|
||||
import com.bytedance.boost_multidex.BoostMultiDex;
|
||||
import com.elegant.utils.UiThreadHandler;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.kwai.koom.base.DefaultInitTask;
|
||||
import com.mogo.cloud.socket.SocketBuildConfig;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
@@ -28,8 +28,12 @@ import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.zhidao.support.obu.ami.AmiClientManager;
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo;
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo;
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 默认初始化一些基础服务配置
|
||||
@@ -37,8 +41,6 @@ import java.lang.reflect.Field;
|
||||
public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
|
||||
private static final String TAG = "MogoApplication";
|
||||
// 配置云服务API
|
||||
protected MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance();
|
||||
private long start;
|
||||
|
||||
@Override
|
||||
@@ -56,8 +58,10 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
initTipToast();
|
||||
initModules();
|
||||
|
||||
initKoom();
|
||||
//查询是否有版本的更新
|
||||
queryAppUpgrade();
|
||||
checkMonitorDb();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +79,22 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
},5000);
|
||||
}
|
||||
|
||||
private void checkMonitorDb() {
|
||||
new Thread(() -> {
|
||||
long limitId = 50001;
|
||||
List<CpuInfo> cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId);
|
||||
List<MemInfo> memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId);
|
||||
// 大于5w条清除
|
||||
if (cpuList.size() > 0 || memList.size() > 0) {
|
||||
this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void initKoom() {
|
||||
DefaultInitTask.INSTANCE.init(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化异常采集配置
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mogo.eagle.core.function.main.moujie;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2022/7/29
|
||||
*/
|
||||
public class BluetoothMonitorReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action != null) {
|
||||
switch (action) {
|
||||
case BluetoothAdapter.ACTION_STATE_CHANGED:
|
||||
int blueState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0);
|
||||
switch (blueState) {
|
||||
case BluetoothAdapter.STATE_TURNING_ON:
|
||||
// Toast.makeText(context, "蓝牙正在打开", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case BluetoothAdapter.STATE_ON:
|
||||
// Toast.makeText(context, "蓝牙已经打开", Toast.LENGTH_SHORT).show();
|
||||
EventBus.getDefault().post(new ConnectBluetoothEvent());
|
||||
break;
|
||||
case BluetoothAdapter.STATE_TURNING_OFF:
|
||||
// Toast.makeText(context, "蓝牙正在关闭", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case BluetoothAdapter.STATE_OFF:
|
||||
// Toast.makeText(context, "蓝牙已经关闭", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BluetoothDevice.ACTION_ACL_CONNECTED:
|
||||
// Toast.makeText(context, "蓝牙设备已连接", Toast.LENGTH_SHORT).show();
|
||||
// Log.d("liyz", "蓝牙设备已连接 ----> ");
|
||||
// SharedPrefsMgr.getInstance(context).putBoolean("BLUETOOTH", true);
|
||||
break;
|
||||
|
||||
case BluetoothDevice.ACTION_ACL_DISCONNECTED:
|
||||
// SharedPrefsMgr.getInstance(context).putBoolean("BLUETOOTH", false);
|
||||
// Log.d("liyz", "蓝牙设备已断开 ----> ");
|
||||
// Toast.makeText(context, "蓝牙设备已断开", Toast.LENGTH_SHORT).show();
|
||||
EventBus.getDefault().post(new ConnectBluetoothEvent());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.eagle.core.function.main.moujie;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 连接蓝牙事件
|
||||
* @since 2022/8/16
|
||||
*/
|
||||
public class ConnectBluetoothEvent {
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return START_STICKY;
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
private void initAndStartLocation() {
|
||||
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/bus_autopilot_text_color_normal"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_focused="true" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_focused="false" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_selected="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status" android:state_focused="true" />
|
||||
<item android:drawable="@drawable/icon_bus_operation_status_un" />
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="24px"/>
|
||||
|
||||
<gradient android:startColor="#029DFF" android:endColor="#0056FF"/>
|
||||
|
||||
</shape>
|
||||
@@ -181,6 +181,14 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.pnc.PncActionsView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dp_110"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<!--APP、MAP版本-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.VersionNameView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -107,6 +107,31 @@
|
||||
android:textSize="32px" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlKillLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="142px">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivKillImg"
|
||||
android:layout_width="150px"
|
||||
android:layout_height="150px"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/close_nor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvKillContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="42px"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="23px"
|
||||
android:text="杀死APP"
|
||||
android:textColor="@color/color_FFA7B6F0"
|
||||
android:textSize="32px" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
@@ -252,10 +277,34 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40px"
|
||||
android:layout_marginBottom="40px"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/viewSystemVersion" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.tools.BusOperationView
|
||||
android:id="@+id/toolBusOperationView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/systemVersionView"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/actvLoginout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/systemVersionView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/taxi_loginout_bg"
|
||||
android:layout_marginBottom="40px"
|
||||
android:text="退出登录"
|
||||
android:visibility="gone"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="42px"
|
||||
android:layout_width="790px"
|
||||
android:layout_height="126px"/>
|
||||
|
||||
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.tools.SpeedKeyboardView
|
||||
android:id="@+id/sKeyBoardView"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -232,6 +232,42 @@
|
||||
android:textSize="@dimen/dp_24"
|
||||
android:background="@drawable/radio_button_normal_background_right"/>
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbBeautyMode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/dp_10"
|
||||
android:textColor="#000"
|
||||
android:textOff="开启感知优化模式"
|
||||
android:textOn="关闭感知优化模式"
|
||||
android:textSize="@dimen/dp_24"
|
||||
android:background="@drawable/radio_button_normal_background_right"/>
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbMojie"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/dp_10"
|
||||
android:background="@drawable/radio_button_normal_background_right"
|
||||
android:drawableEnd="@drawable/icon_right"
|
||||
android:padding="@dimen/dp_20"
|
||||
android:textOff="魔戒控制"
|
||||
android:textOn="魔戒控制" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnOpenAllGestures"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:paddingStart="@dimen/dp_20"
|
||||
android:paddingEnd="@dimen/dp_20"
|
||||
android:text="开启手势滑动"
|
||||
android:visibility="gone"
|
||||
android:textSize="@dimen/dp_24"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnIpcReboot"
|
||||
android:layout_width="match_parent"
|
||||
@@ -1718,6 +1754,35 @@
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/trackerProvider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintTop_toBottomOf="@id/rgGpsProvider">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/trackerProviderOrigin"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="@dimen/dp_10"
|
||||
android:text="使用工控感知数据"
|
||||
android:textColor="#000"
|
||||
android:textSize="@dimen/dp_24" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/trackerProviderObu"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="@dimen/dp_10"
|
||||
android:text="使用debugOBU感知数据"
|
||||
android:textColor="#000"
|
||||
android:textSize="@dimen/dp_24" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -2030,6 +2095,16 @@
|
||||
android:textColor="#000"
|
||||
android:textSize="@dimen/dp_24" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbAdasTrafficlight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:padding="@dimen/dp_10"
|
||||
android:text="ADAS红绿灯数据"
|
||||
android:textColor="#000"
|
||||
android:textSize="@dimen/dp_24" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbAdasPlanningObj"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="#00000000"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivWaringIcon"
|
||||
android:layout_width="132px"
|
||||
android:layout_height="132px"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ochBusOperationStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40px"
|
||||
android:paddingBottom="40px"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
tools:ignore="DuplicateIds">
|
||||
|
||||
<View
|
||||
android:id="@+id/bus_operation_view"
|
||||
android:layout_width="14px"
|
||||
android:layout_height="50px"
|
||||
android:layout_marginStart="80px"
|
||||
android:background="@color/color_FF2966EC" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_bus_operation_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="113px"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="4px"
|
||||
android:text="@string/bus_operation_title"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="42px" />
|
||||
|
||||
<CheckedTextView
|
||||
android:id="@+id/ochBusOperationStatusCTV"
|
||||
android:layout_width="@dimen/och_bus_operation_status_bg_width"
|
||||
android:layout_height="@dimen/och_bus_operation_status_bg_height"
|
||||
android:layout_below="@+id/tv_bus_operation_title"
|
||||
android:layout_marginStart="113px"
|
||||
android:layout_marginTop="40px"
|
||||
android:background="@drawable/bus_operation_status_bg_selector1"
|
||||
android:gravity="center"
|
||||
android:text="出车"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/bus_autopilot_text_color_normal"
|
||||
android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_100">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHmiPncActions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingStart="@dimen/dp_68"
|
||||
android:paddingEnd="@dimen/dp_68"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_34"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -8,4 +8,5 @@
|
||||
<color name="notice_dialog_back">#3B4577</color>
|
||||
<color name="acc_default_txt_color">#FF343C63</color>
|
||||
<color name="hmi_check_keyboard_input_field">#FF282F62</color>
|
||||
<color name="bus_autopilot_text_color_normal">#FFFFFF</color>
|
||||
</resources>
|
||||
@@ -15,19 +15,25 @@
|
||||
<dimen name="dp_18">18px</dimen>
|
||||
<dimen name="dp_30">30px</dimen>
|
||||
<dimen name="dp_36">36px</dimen>
|
||||
<dimen name="dp_34">34px</dimen>
|
||||
<dimen name="dp_38">38px</dimen>
|
||||
<dimen name="dp_42">42px</dimen>
|
||||
<dimen name="dp_45">45px</dimen>
|
||||
<dimen name="dp_46">46px</dimen>
|
||||
<dimen name="dp_48">48px</dimen>
|
||||
<dimen name="dp_50">50px</dimen>
|
||||
<dimen name="dp_52">52px</dimen>
|
||||
<dimen name="dp_54">54px</dimen>
|
||||
<dimen name="dp_56">56px</dimen>
|
||||
<dimen name="dp_62">62px</dimen>
|
||||
<dimen name="dp_68">68px</dimen>
|
||||
<dimen name="dp_70">70px</dimen>
|
||||
<dimen name="dp_75">80px</dimen>
|
||||
<dimen name="dp_72">72px</dimen>
|
||||
<dimen name="dp_75">75px</dimen>
|
||||
<dimen name="dp_80">80px</dimen>
|
||||
<dimen name="dp_96">96px</dimen>
|
||||
<dimen name="dp_100">100px</dimen>
|
||||
<dimen name="dp_110">110px</dimen>
|
||||
<dimen name="dp_140">140px</dimen>
|
||||
<dimen name="dp_150">150px</dimen>
|
||||
<dimen name="dp_180">180px</dimen>
|
||||
@@ -54,4 +60,10 @@
|
||||
<dimen name="hmi_traffic_light_time_size">60px</dimen>
|
||||
<dimen name="hmi_traffic_light_source_size">32px</dimen>
|
||||
|
||||
<dimen name="och_bus_operation_status_bg_width">150px</dimen>
|
||||
<dimen name="och_bus_operation_status_bg_height">150px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_size">42px</dimen>
|
||||
<dimen name="module_mogo_och_margin_left">40px</dimen>
|
||||
<dimen name="module_mogo_och_margin_bottom">46px</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -66,4 +66,5 @@
|
||||
<color name="dark_mode_select_txt_color">#FFFFFFFF</color>
|
||||
|
||||
<color name="hmi_check_keyboard_input_field">#FF282F62</color>
|
||||
<color name="bus_autopilot_text_color_normal">#FFFFFF</color>
|
||||
</resources>
|
||||
@@ -60,4 +60,9 @@
|
||||
<dimen name="hmi_traffic_light_time_size">60px</dimen>
|
||||
<dimen name="hmi_traffic_light_source_size">32px</dimen>
|
||||
|
||||
<dimen name="och_bus_operation_status_bg_width">150px</dimen>
|
||||
<dimen name="och_bus_operation_status_bg_height">150px</dimen>
|
||||
<dimen name="module_mogo_och_autopilot_status_text_size">42px</dimen>
|
||||
<dimen name="module_mogo_och_margin_left">40px</dimen>
|
||||
<dimen name="module_mogo_och_margin_bottom">46px</dimen>
|
||||
</resources>
|
||||
@@ -23,6 +23,7 @@
|
||||
<string name="debug_panel">调试面板</string>
|
||||
<string name="debug_panel_fb">录包设置</string>
|
||||
<string name="check_vehicle_speed_setting">车速设置</string>
|
||||
<string name="bus_operation_title">出收车状态</string>
|
||||
<string name="check_system_operation">系统运行</string>
|
||||
<string name="check_system_shut_down">关机</string>
|
||||
<string name="check_system_reboot">重启</string>
|
||||
|
||||
@@ -151,8 +151,9 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
|
||||
override fun onLocationChanged(location: MogoLocation?, from: Int) {
|
||||
location ?: return
|
||||
executor.get()?.updateLocation(
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
location.altitude,
|
||||
location.bearing,
|
||||
location.speed,
|
||||
location.provider == "GPS_RTK")
|
||||
|
||||
@@ -42,7 +42,7 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
|
||||
|
||||
override fun onAutopilotIdentifyDataUpdate(trafficData: List<TrackedObject>?) {
|
||||
try {
|
||||
if (FunctionBuildConfig.isDrawIdentifyData) {
|
||||
if (FunctionBuildConfig.isDrawIdentifyData && FunctionBuildConfig.debugTrackerProvider == 0) {
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
IdentifyFactory.renderAdasRecognizedResult(trafficData)
|
||||
}
|
||||
@@ -56,9 +56,12 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
|
||||
|
||||
override fun onAutopilotIdentifyPlanningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
try {
|
||||
if (FunctionBuildConfig.isDrawIdentifyData) {
|
||||
ThreadUtils.getSinglePool()
|
||||
.execute { IdentifyFactory.renderPlanningWarningObj(planningObjects) }
|
||||
if (FunctionBuildConfig.isDrawIdentifyData && FunctionBuildConfig.debugTrackerProvider == 0) {
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
IdentifyFactory.renderPlanningWarningObj(planningObjects)
|
||||
}
|
||||
} else {
|
||||
IdentifyFactory.clearOldMarker()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.mogo.eagle.core.function.map
|
||||
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPointCloudListener
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoSubscriber
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPointCloudListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import rule_segement.MogoPointCloudOuterClass
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
@@ -17,7 +15,8 @@ import java.math.BigDecimal
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class MapPointCloudSubscriber private constructor() : IMoGoSubscriber, IMoGoAutopilotPointCloudListener {
|
||||
class MapPointCloudSubscriber private constructor()
|
||||
: IMoGoSubscriber, IMoGoAutopilotPointCloudListener {
|
||||
|
||||
private val TAG = "MapPointCloudSubscriber"
|
||||
|
||||
@@ -35,7 +34,6 @@ class MapPointCloudSubscriber private constructor() : IMoGoSubscriber, IMoGoAuto
|
||||
|
||||
override fun onCrate() {
|
||||
CallerAutopilotPointCloudListenerManager.addListener(TAG, this)
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -43,42 +41,81 @@ class MapPointCloudSubscriber private constructor() : IMoGoSubscriber, IMoGoAuto
|
||||
}
|
||||
|
||||
override fun onAutopilotPointCloudDataUpdate(pointCloud: ByteArray?) {
|
||||
// 根据配置动态控制点云是否绘制
|
||||
if (FunctionBuildConfig.isDrawPointCloudData) {
|
||||
if (!isDrawPointCloud) {
|
||||
Logger.d(TAG, "====开启点云渲染====")
|
||||
isDrawPointCloud = true
|
||||
try {// 根据配置动态控制点云是否绘制
|
||||
if (FunctionBuildConfig.isDrawPointCloudData && isDrawCloudPointDockerVersion()) {
|
||||
if (!isDrawPointCloud) {
|
||||
Logger.d(TAG, "====开启点云渲染====")
|
||||
isDrawPointCloud = true
|
||||
PointCloudHelper.setIsDrawPointCloud(true)//打开点云绘制
|
||||
}
|
||||
PointCloudHelper.setIsDrawPointCloud(true)//打开点云绘制
|
||||
}
|
||||
PointCloudHelper.setIsDrawPointCloud(true)//打开点云绘制
|
||||
|
||||
/**
|
||||
* 更新点云数据
|
||||
* @param dataStr 点云数据
|
||||
* @param isTrasformer 是否需要转换坐标
|
||||
* @param isResidual 是否需要差量更新
|
||||
* @param isStrong 是否加粗显示
|
||||
* @return 是否执行
|
||||
*/
|
||||
Logger.d(TAG, "====开始传入地图点云数据====")
|
||||
val result = PointCloudHelper.updatePointCloudDataByPb(pointCloud, true, false, false)
|
||||
Logger.d(TAG, "====结束传入地图点云数据=====$result")
|
||||
} else {
|
||||
if (isDrawPointCloud) {
|
||||
Logger.d(TAG, "====停止点云绘制====")
|
||||
isDrawPointCloud = false
|
||||
PointCloudHelper.setIsDrawPointCloud(false)//停止点云绘制
|
||||
/**
|
||||
* 更新点云数据
|
||||
* @param dataStr 点云数据
|
||||
* @param isTrasformer 是否需要转换坐标
|
||||
* @param isResidual 是否需要差量更新
|
||||
* @param isStrong 是否加粗显示
|
||||
* @return 是否执行
|
||||
*/
|
||||
Logger.d(TAG, "====开始传入地图点云数据====")
|
||||
val result = PointCloudHelper.updatePointCloudDataByPb(pointCloud, true, false, false)
|
||||
Logger.d(TAG, "====结束传入地图点云数据=====$result")
|
||||
} else {
|
||||
if (isDrawPointCloud) {
|
||||
Logger.d(TAG, "====停止点云绘制====")
|
||||
isDrawPointCloud = false
|
||||
PointCloudHelper.setIsDrawPointCloud(false)//停止点云绘制
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotPointCloudDataUpdate(header: MessagePad.Header?, pointCloud: MogoPointCloudOuterClass.MogoPointCloud?) {
|
||||
// Logger.d(TAG, "数据对比:"
|
||||
// + "\n自车定位:自车的 satelliteTime==${getPrettyNumber(CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().satelliteTime.toString())} 经纬度:${CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().locationLat},${CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().locationLon}"
|
||||
// + "\n点云数据:点云的 header?.timestamp==${getPrettyNumber(header?.timestamp.toString())} 经纬度:${pointCloud?.selfLatitude},${pointCloud?.selfLongitude} 点云数量:addDataCount==${pointCloud?.addDataCount} delDataCount===${pointCloud?.delDataCount} "
|
||||
// )
|
||||
/**
|
||||
* 判断是否是260之后但版本
|
||||
*/
|
||||
fun isDrawCloudPointDockerVersion(): Boolean {
|
||||
// 由于Docker命名规则不统一,但核心版本是统一但,采用"."分割,如下
|
||||
// MAP-taxi_RoboTaxi_Default_2.2.0_badcasetest_20220215_dev
|
||||
val dockerVersionName = AppConfigInfo.dockerVersion
|
||||
// "." 分割,取前两位
|
||||
val dockerVersionNameArray = dockerVersionName?.split(".")
|
||||
|
||||
var dockerVersionCode = ""
|
||||
dockerVersionNameArray?.let {
|
||||
if (it.size > 3) {
|
||||
for (index in 0 until 3) {
|
||||
dockerVersionCode +=
|
||||
when (index) {
|
||||
0 -> {
|
||||
it[index].substring(it[index].lastIndex)
|
||||
}
|
||||
it.size - 1 -> {
|
||||
it[index].substring(0, 1)
|
||||
}
|
||||
else -> {
|
||||
it[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val dockerVersion =
|
||||
if (dockerVersionCode.isNotEmpty()) {
|
||||
dockerVersionCode.toInt()
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
if (dockerVersion >= 260) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
fun getPrettyNumber(number: String): String {
|
||||
return BigDecimal.valueOf(number.toDouble())
|
||||
.stripTrailingZeros().toPlainString()
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package com.mogo.eagle.core.function.map.identify
|
||||
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
|
||||
interface Identify {
|
||||
|
||||
fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?){
|
||||
fun renderAdasRecognizedResult(resultList: List<TrackedObject>?)
|
||||
|
||||
fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?)
|
||||
|
||||
fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) {
|
||||
|
||||
}
|
||||
|
||||
fun renderAdasRecognizedResult(resultList: List<TrackedObject>?)
|
||||
|
||||
fun clearOldMarker()
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.map.identify
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
@@ -17,6 +18,14 @@ class IdentifyBeautifyDataDrawer : Identify {
|
||||
private const val TAG = "IdentifyDataDrawer"
|
||||
}
|
||||
|
||||
override fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
TrackManager.getInstance().renderPlanningWarningObj(planningObjects)
|
||||
}
|
||||
|
||||
override fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) {
|
||||
TrackManager.getInstance().renderOBUWarningObj(exist, obuTrafficData)
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
@@ -52,4 +61,5 @@ class IdentifyBeautifyDataDrawer : Identify {
|
||||
TrackManager.getInstance().clearAll()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,17 @@ package com.mogo.eagle.core.function.map.identify
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
|
||||
object IdentifyFactory : Identify {
|
||||
object IdentifyFactory : Identify, IMoGoObuStatusListener {
|
||||
|
||||
private const val TAG = "IdentifyFactory"
|
||||
|
||||
object DriverIdentify {
|
||||
internal val originDataDrawer = IdentifyOriginDataDrawer()
|
||||
}
|
||||
@@ -20,34 +25,60 @@ object IdentifyFactory : Identify {
|
||||
private var identify: Identify? = null
|
||||
|
||||
init {
|
||||
identify = if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
identify = if (FunctionBuildConfig.isBeautyMode) {
|
||||
UserIdentify.beautifyDataDrawer
|
||||
} else {
|
||||
DriverIdentify.originDataDrawer
|
||||
}
|
||||
CallerObuListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private const val MSG_DATA_TRACK = 0
|
||||
private const val MSG_DATA_WARNING = 1
|
||||
private const val MSG_DATA_CLEAR = 2
|
||||
private const val MSG_DATA_OBU_WARNING_UPDATE = 2
|
||||
private const val MSG_DATA_OBU_WARNING_REMOVE = 3
|
||||
private const val MSG_DATA_CLEAR = 4
|
||||
|
||||
// 维护一个线程定时轮询数据进行地图绘制
|
||||
private val mDrawerHandler: Handler =
|
||||
object : Handler(WorkThreadHandler.newInstance("IdentifyFactoryDrawer").looper) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
when(msg.what){
|
||||
if (!FunctionBuildConfig.isBeautyMode) {
|
||||
// 非感知美化优化模式,清除旧数据,使用 DriverIdentify originDataDrawer 原始数据绘制
|
||||
if (identify is IdentifyBeautifyDataDrawer) {
|
||||
identify!!.clearOldMarker()
|
||||
identify = DriverIdentify.originDataDrawer
|
||||
}
|
||||
} else {
|
||||
// 感知优化模式,清除旧数据,使用 UserIdentify beautifyDataDrawer 优化数据
|
||||
if (identify is IdentifyOriginDataDrawer) {
|
||||
identify!!.clearOldMarker()
|
||||
identify = UserIdentify.beautifyDataDrawer
|
||||
}
|
||||
}
|
||||
when (msg.what) {
|
||||
MSG_DATA_TRACK -> {
|
||||
if(msg.obj is List<*>){
|
||||
if (msg.obj is List<*>) {
|
||||
identify!!.renderAdasRecognizedResult(msg.obj as List<TrackedObject>?)
|
||||
}
|
||||
}
|
||||
MSG_DATA_WARNING -> {
|
||||
if(msg.obj is List<*>){
|
||||
if (msg.obj is List<*>) {
|
||||
identify!!.renderPlanningWarningObj(msg.obj as List<MessagePad.PlanningObject>?)
|
||||
}
|
||||
}
|
||||
MSG_DATA_CLEAR ->{
|
||||
MSG_DATA_OBU_WARNING_UPDATE -> {
|
||||
if (msg.obj is TrafficData) {
|
||||
identify!!.renderOBUWarningObj(true, msg.obj as TrafficData)
|
||||
}
|
||||
}
|
||||
MSG_DATA_OBU_WARNING_REMOVE -> {
|
||||
if (msg.obj is TrafficData) {
|
||||
identify!!.renderOBUWarningObj(false, msg.obj as TrafficData)
|
||||
}
|
||||
}
|
||||
MSG_DATA_CLEAR -> {
|
||||
identify!!.clearOldMarker()
|
||||
}
|
||||
}
|
||||
@@ -74,4 +105,19 @@ object IdentifyFactory : Identify {
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun updateTrackerWarningInfo(trafficData: TrafficData) {
|
||||
super.updateTrackerWarningInfo(trafficData)
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_OBU_WARNING_UPDATE
|
||||
message.obj = trafficData
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun removeTrackerWarningInfo(trafficData: TrafficData) {
|
||||
super.removeTrackerWarningInfo(trafficData)
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_OBU_WARNING_REMOVE
|
||||
message.obj = trafficData
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
package com.mogo.eagle.core.function.map.identify
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.text.TextUtils
|
||||
import androidx.collection.ArraySet
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.data.traffic.threatLevelColor
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.mogo.map.MogoMarkerManager
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.telematics.pad.MessagePad.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -49,17 +52,21 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
* 过滤后的数据集合
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
private val mFilterTrafficData = HashMap<String,TrackedObject>()
|
||||
private val mFilterTrafficData = HashMap<String, TrackedObject>()
|
||||
|
||||
/**
|
||||
* planning 感知物预警缓存,用于重置color状态
|
||||
*/
|
||||
private val colorTrafficData = ConcurrentHashMap<String, PlanningTrack>()
|
||||
private val pncWarningTrafficData = ConcurrentHashMap<String, PlanningTrack>()
|
||||
|
||||
/**
|
||||
* obu 感知物预警缓存,用于重置color状态
|
||||
*/
|
||||
private val obuWarningTrafficData = ConcurrentHashMap<String, TrafficData>()
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
colorTrafficData.clear()
|
||||
//处于美化模式或者自动驾驶状态下展示
|
||||
pncWarningTrafficData.clear()
|
||||
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || mAutopilotStatus == 2) {
|
||||
if (planningObjects == null) {
|
||||
return
|
||||
@@ -68,18 +75,18 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
val trackId = planningObj.uuid.toString()
|
||||
if (mMarkersCaches.containsKey(trackId)) {
|
||||
val trackObj = mMarkersCaches[trackId]
|
||||
if(planningObj.type == 0){
|
||||
if (planningObj.type == 0) {
|
||||
//0是leading障碍物,障碍物车身红色提示
|
||||
trackObj?.let {
|
||||
colorTrafficData[trackId] = PlanningTrack(
|
||||
pncWarningTrafficData[trackId] = PlanningTrack(
|
||||
"#D65D5AFF",
|
||||
CallerAutoPilotStatusListenerManager.getCurWgs84SatelliteTime()
|
||||
)
|
||||
}
|
||||
}else if(planningObj.type == 1){
|
||||
} else if (planningObj.type == 1) {
|
||||
//1是避障和择机的障碍物,障碍物车身黄色提示
|
||||
trackObj?.let {
|
||||
colorTrafficData[trackId] = PlanningTrack(
|
||||
pncWarningTrafficData[trackId] = PlanningTrack(
|
||||
"#E4DD94FF",
|
||||
CallerAutoPilotStatusListenerManager.getCurWgs84SatelliteTime()
|
||||
)
|
||||
@@ -90,6 +97,17 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) {
|
||||
if (obuTrafficData.uuid.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
if (exist) {
|
||||
obuWarningTrafficData[obuTrafficData.uuid!!] = obuTrafficData
|
||||
} else {
|
||||
obuWarningTrafficData.remove(obuTrafficData.uuid!!)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
@@ -141,7 +159,8 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
*
|
||||
* @return 过滤后的数据集合
|
||||
*/
|
||||
private fun filterTrafficData(trafficData: List<TrackedObject>): HashMap<String,TrackedObject> {
|
||||
@SuppressLint("NewApi")
|
||||
private fun filterTrafficData(trafficData: List<TrackedObject>): HashMap<String, TrackedObject> {
|
||||
mFilterTrafficData.clear()
|
||||
trafficDataUuidList.clear()
|
||||
for (data in trafficData) {
|
||||
@@ -154,19 +173,38 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
//首次过来的数据不添加,首次未添加的感知物在调用完绘制方法后再塞入cache map
|
||||
val cacheData = mMarkersCaches[uuid]
|
||||
if (cacheData != null) {
|
||||
if (data.speed < 0.5) {
|
||||
temp = data.toBuilder().setHeading(cacheData.heading)
|
||||
.setLongitude(cacheData.longitude)
|
||||
.setLatitude(cacheData.latitude).build()
|
||||
|
||||
//OBU数据颜色标记
|
||||
val first = data.trackedSourceList.stream()
|
||||
.filter { trackedSource: TrackedSource -> trackedSource.source == 4 }
|
||||
.findFirst()
|
||||
if (first.isPresent) {
|
||||
val subFirst = first.get().subSourceList.stream()
|
||||
.filter { subSource: SubSource -> subSource.source == 1 }
|
||||
.findFirst()
|
||||
if (subFirst.isPresent) {
|
||||
val subID = subFirst.get().id
|
||||
if (!TextUtils.isEmpty(subID)) {
|
||||
temp = data.toBuilder().setColor("#36D3FE").build()
|
||||
if (obuWarningTrafficData.containsKey(subID)) {
|
||||
temp = data.toBuilder()
|
||||
.setColor(obuWarningTrafficData[subID]!!.threatLevelColor())
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (colorTrafficData.containsKey(uuid)) {
|
||||
val planningTrack = colorTrafficData[uuid]
|
||||
|
||||
//预警颜色变化
|
||||
if (pncWarningTrafficData.containsKey(uuid)) {
|
||||
val planningTrack = pncWarningTrafficData[uuid]
|
||||
if (!timeOut(planningTrack!!.time)) {
|
||||
temp = data.toBuilder().setColor(planningTrack.color).build()
|
||||
} else {
|
||||
colorTrafficData.remove(uuid)
|
||||
pncWarningTrafficData.remove(uuid)
|
||||
}
|
||||
}
|
||||
|
||||
mFilterTrafficData[uuid] = temp
|
||||
}
|
||||
mMarkersCaches[uuid] = temp
|
||||
@@ -185,6 +223,7 @@ class IdentifyOriginDataDrawer : Identify, IMoGoAutopilotStatusListener {
|
||||
.removeMarker(uuid)
|
||||
}
|
||||
trafficDataUuidList.clear()
|
||||
pncWarningTrafficData.clear()
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
|
||||
@@ -4,11 +4,15 @@ public class ObjQueue {
|
||||
|
||||
private double heading;
|
||||
private double speed;
|
||||
private double lat;
|
||||
private double lon;
|
||||
private int type;
|
||||
|
||||
public ObjQueue(double heading, double speed, int type) {
|
||||
public ObjQueue(double heading, double speed, double lat, double lon, int type) {
|
||||
this.heading = heading;
|
||||
this.speed = speed;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -28,6 +32,22 @@ public class ObjQueue {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -41,6 +61,8 @@ public class ObjQueue {
|
||||
return "ObjQueue{" +
|
||||
"heading=" + heading +
|
||||
", speed=" + speed +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.mogo.eagle.core.function.map.identify;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
@@ -11,6 +11,9 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficDataKt;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.geometry.S2CellId;
|
||||
import com.mogo.eagle.core.utilcode.geometry.S2LatLng;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
@@ -19,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
@@ -35,6 +39,9 @@ public class TrackManager {
|
||||
|
||||
public static double LIMIT_SPEED = 0.45;
|
||||
|
||||
private TrackManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* marker缓存队列
|
||||
*/
|
||||
@@ -57,6 +64,59 @@ public class TrackManager {
|
||||
@SuppressLint("NewApi")
|
||||
private final HashMap<String, MessagePad.TrackedObject> mFilterTrafficData = new HashMap<>();
|
||||
|
||||
//感知物预警各自先以帧数更新保持,不做同一个集合的融合处理(以卫星时间做判断先后,可能会出现不同ip节点间的回溯问题)
|
||||
/**
|
||||
* planning 感知物预警缓存,用于重置color状态
|
||||
*/
|
||||
private final ConcurrentHashMap<String, PlanningTrack> pncWarningTrafficData = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* obu 感知物预警缓存,用于重置color状态
|
||||
*/
|
||||
private final ConcurrentHashMap<String, TrafficData> obuWarningTrafficData = new ConcurrentHashMap<>();
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public synchronized void renderPlanningWarningObj(List<MessagePad.PlanningObject> planningObjects) {
|
||||
pncWarningTrafficData.clear();
|
||||
//处于美化模式或者自动驾驶状态下展示
|
||||
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() == 2) {
|
||||
if (planningObjects == null) {
|
||||
return;
|
||||
}
|
||||
planningObjects.forEach(planningObj -> {
|
||||
String trackId = "" + planningObj.getUuid();
|
||||
if (mMarkersCaches.containsKey(trackId)) {
|
||||
TrackObj trackObj = mMarkersCaches.get(trackId);
|
||||
if (trackObj == null) {
|
||||
return;
|
||||
}
|
||||
if (planningObj.getType() == 0) {
|
||||
pncWarningTrafficData.put(trackId, new PlanningTrack(
|
||||
"#D65D5AFF",
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84SatelliteTime()
|
||||
));
|
||||
} else if (planningObj.getType() == 1) {
|
||||
pncWarningTrafficData.put(trackId, new PlanningTrack(
|
||||
"#E4DD94FF",
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84SatelliteTime()
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void renderOBUWarningObj(boolean exist, TrafficData obuTrafficData) {
|
||||
if (obuTrafficData.getUuid() == null || obuTrafficData.getUuid().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (exist) {
|
||||
obuWarningTrafficData.put(obuTrafficData.getUuid(), obuTrafficData);
|
||||
} else {
|
||||
obuWarningTrafficData.remove(obuTrafficData.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤后的数据集合
|
||||
*/
|
||||
@@ -71,6 +131,35 @@ public class TrackManager {
|
||||
}
|
||||
String uuid = "" + data.getUuid();
|
||||
TrackObj trackObj = mMarkersCaches.get(uuid);
|
||||
|
||||
//OBU数据颜色标记
|
||||
Optional<MessagePad.TrackedSource> first = data.getTrackedSourceList().stream()
|
||||
.filter(trackedSource -> trackedSource.getSource() == 4).findFirst();
|
||||
if (first.isPresent()) {
|
||||
Optional<MessagePad.SubSource> subFirst = first.get().getSubSourceList().stream().filter(subSource -> subSource.getSource() == 1).findFirst();
|
||||
if (subFirst.isPresent()) {
|
||||
String subID = subFirst.get().getId();
|
||||
if (!TextUtils.isEmpty(subID)) {
|
||||
data = data.toBuilder().setColor("#36D3FE").build();
|
||||
if (obuWarningTrafficData.containsKey(subID)) {
|
||||
data = data.toBuilder()
|
||||
.setColor(TrafficDataKt.threatLevelColor(obuWarningTrafficData.get(subID)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断物体是否与预警信息
|
||||
if (pncWarningTrafficData.containsKey(uuid)) {
|
||||
PlanningTrack planningTrack = pncWarningTrafficData.get(uuid);
|
||||
if (planningTrack != null && !timeOut(planningTrack.getTime())) {
|
||||
data = data.toBuilder().setColor(planningTrack.getColor()).build();
|
||||
} else {
|
||||
pncWarningTrafficData.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
if (trackObj != null) {
|
||||
trackObj.updateObj(data);
|
||||
} else {
|
||||
@@ -80,7 +169,6 @@ public class TrackManager {
|
||||
// 融合逻辑 : 判断是否有重合元素
|
||||
if (cellIdCaches.containsValue(pos)) {
|
||||
String findSameValue = cellIdCaches.inverse().get(pos);
|
||||
Log.d("hy uuid : " + findSameValue, " 与新感知物 : " + uuid + "相同");
|
||||
//uuid处理
|
||||
data = data.toBuilder().setUuid(Integer.parseInt(findSameValue)).build();
|
||||
TrackObj cacheTrack = mMarkersCaches.get(findSameValue);
|
||||
@@ -90,6 +178,9 @@ public class TrackManager {
|
||||
if (cache != null) {
|
||||
//相对静止物体并且非obu数据,则不改变,为感知融合同位置物体,使用缓存数据做覆盖
|
||||
if (cacheTrack.relativeStatic()) {
|
||||
if(data.getColor()!= null && !data.getColor().isEmpty()){
|
||||
cache = cache.toBuilder().setColor(data.getColor()).build();
|
||||
}
|
||||
data = cache;
|
||||
}
|
||||
}
|
||||
@@ -143,8 +234,13 @@ public class TrackManager {
|
||||
@SuppressLint("NewApi")
|
||||
public void clearAll() {
|
||||
trafficDataUuid.clear();
|
||||
pncWarningTrafficData.clear();
|
||||
mMarkersCaches.forEach((uuid, trackObj) -> removeKey(uuid));
|
||||
}
|
||||
|
||||
private Boolean timeOut(Double time) {
|
||||
long duration = (long) (CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84SatelliteTime() * 1000) - (long) (time * 1000);
|
||||
return duration >= 500;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@ import static com.mogo.eagle.core.function.map.identify.TrackManager.LIMIT_SPEED
|
||||
import android.annotation.SuppressLint;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.utilcode.geometry.S2CellId;
|
||||
import com.mogo.eagle.core.utilcode.geometry.S2LatLng;
|
||||
import com.mogo.map.utils.PointInterpolatorUtil;
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -21,23 +20,23 @@ import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class TrackObj {
|
||||
|
||||
private final CircleQueue circleQueue = new CircleQueue(10);
|
||||
private final CircleQueue circleQueue = new CircleQueue(6);
|
||||
// private final KalmanFilter kalmanFilter; //卡尔曼结果
|
||||
private S2CellId s2CellId; //s2 id权重
|
||||
private S2LatLng s2LatLng; //s2 经纬度
|
||||
private double recentlyTime; //用于缓存帧数判断,暂定缓存1秒数据,中间如果有物体未出现,1秒后删除
|
||||
private double roadAngle; //道路航向
|
||||
private double headingDelta; //航向角德尔塔
|
||||
// private double headingDelta; //航向角德尔塔
|
||||
private int[] typeArray = new int[3];
|
||||
private int typeWeight; //类型权重
|
||||
private double lat;
|
||||
private double lon;
|
||||
private double speedAverage;
|
||||
private CenterLine centerLineInfo = null;
|
||||
// private CenterLine centerLineInfo = null;
|
||||
|
||||
public TrackObj(MessagePad.TrackedObject data) {
|
||||
// kalmanFilter = new KalmanFilter(data.getLongitude(), data.getLatitude(), 0.0000005);
|
||||
circleQueue.addQueue(new ObjQueue(data.getHeading(), data.getSpeed(), data.getType()));
|
||||
circleQueue.addQueue(new ObjQueue(data.getHeading(), data.getSpeed(), data.getLatitude(), data.getLongitude(), data.getType()));
|
||||
recentlyTime = data.getSatelliteTime();
|
||||
lat = data.getLatitude();
|
||||
lon = data.getLongitude();
|
||||
@@ -47,6 +46,7 @@ public class TrackObj {
|
||||
if (centerLine != null && centerLine.getAngle() != 0) {
|
||||
roadAngle = centerLine.getAngle();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private MessagePad.TrackedObject cacheData;
|
||||
@@ -56,7 +56,7 @@ public class TrackObj {
|
||||
cacheData = data;
|
||||
correct();
|
||||
recentlyTime = data.getSatelliteTime();
|
||||
circleQueue.addQueue(new ObjQueue(cacheData.getHeading(), cacheData.getSpeed(), cacheData.getType()));
|
||||
circleQueue.addQueue(new ObjQueue(cacheData.getHeading(), cacheData.getSpeed(), data.getLatitude(), data.getLongitude(), data.getType()));
|
||||
}
|
||||
|
||||
private void correct() {
|
||||
@@ -102,30 +102,30 @@ public class TrackObj {
|
||||
private void calLoc() {
|
||||
//距离计算,位置修正
|
||||
if (relativeStatic()) {
|
||||
double angle = roadAngle != 0 ? roadAngle : cacheData.getHeading();
|
||||
if (centerLineInfo == null && isFourWheelType()) {
|
||||
try {
|
||||
centerLineInfo = CallerHDMapManager.INSTANCE.getCenterLineInfo(lon, lat, (float) angle);
|
||||
} catch (Exception e) {
|
||||
Log.d("hy uuid : " + cacheData.getUuid(), "道路获取异常");
|
||||
}
|
||||
if (centerLineInfo != null && centerLineInfo.getPoints() != null && !centerLineInfo.getPoints().isEmpty()) {
|
||||
double[] matchedPoint = PointInterpolatorUtil.mergeToRoad(cacheData.getLongitude(), cacheData.getLatitude(), centerLineInfo.getPoints());
|
||||
if (matchedPoint[0] > 0 || matchedPoint[1] > 0) {
|
||||
lon = matchedPoint[0];
|
||||
lat = matchedPoint[1];
|
||||
s2LatLng = S2LatLng.fromDegrees(cacheData.getLatitude(), cacheData.getLongitude());
|
||||
s2CellId = S2CellId.fromLatLng(s2LatLng).parent(22);
|
||||
} else {
|
||||
centerLineInfo = null;
|
||||
}
|
||||
} else {
|
||||
centerLineInfo = null;
|
||||
}
|
||||
}
|
||||
// double angle = roadAngle != 0 ? roadAngle : cacheData.getHeading();
|
||||
// if (centerLineInfo == null && isFourWheelType()) {
|
||||
// try {
|
||||
// centerLineInfo = CallerHDMapManager.INSTANCE.getCenterLineInfo(lon, lat, (float) angle);
|
||||
// } catch (Exception e) {
|
||||
// Log.d("hy uuid : " + cacheData.getUuid(), "道路获取异常");
|
||||
// }
|
||||
// if (centerLineInfo != null && centerLineInfo.getPoints() != null && !centerLineInfo.getPoints().isEmpty()) {
|
||||
// double[] matchedPoint = PointInterpolatorUtil.mergeToRoad(cacheData.getLongitude(), cacheData.getLatitude(), centerLineInfo.getPoints());
|
||||
// if (matchedPoint[0] > 0 || matchedPoint[1] > 0) {
|
||||
// lon = matchedPoint[0];
|
||||
// lat = matchedPoint[1];
|
||||
// s2LatLng = S2LatLng.fromDegrees(cacheData.getLatitude(), cacheData.getLongitude());
|
||||
// s2CellId = S2CellId.fromLatLng(s2LatLng).parent(22);
|
||||
// } else {
|
||||
// centerLineInfo = null;
|
||||
// }
|
||||
// } else {
|
||||
// centerLineInfo = null;
|
||||
// }
|
||||
// }
|
||||
cacheData = cacheData.toBuilder().setLongitude(lon).setLatitude(lat).build();
|
||||
} else {
|
||||
centerLineInfo = null;
|
||||
// centerLineInfo = null;
|
||||
//不在阈值内则更新,代表物体移动,使用卡尔曼滤波经纬度数据
|
||||
//double[] lonLat = kalmanFilter.filter(cacheData.getLongitude(), cacheData.getLatitude());
|
||||
lat = cacheData.getLatitude();
|
||||
@@ -175,7 +175,30 @@ public class TrackObj {
|
||||
}
|
||||
|
||||
public boolean relativeStatic() {
|
||||
return speedAverage < LIMIT_SPEED | cacheData.getSpeed() < LIMIT_SPEED;
|
||||
if (speedAverage < LIMIT_SPEED) {
|
||||
// Log.d("emArrow-Track", "relativeStatic return" + " , uuid : " + cacheData.getUuid());
|
||||
return true;
|
||||
} else {
|
||||
return isInRange();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInRange() {
|
||||
if (circleQueue.size() < 3) {
|
||||
return false;
|
||||
}
|
||||
List<ObjQueue> objQueueList = circleQueue.getPreFrame();
|
||||
double[] center = getCenterPoint(objQueueList);
|
||||
if (center[0] == 0.0 || center[1] == 0.0) {
|
||||
return false;
|
||||
}
|
||||
double dis = CoordinateUtils.calculateLineDistance(center[0], center[1], cacheData.getLongitude(), cacheData.getLatitude());
|
||||
// Log.d("emArrow-Track", "uuid : " + cacheData.getUuid() + " , type : " + cacheData.getType() + " , list size : " + objQueueList.size() + " , dis : " + dis);
|
||||
if (cacheData.getType() == TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS.getType() || cacheData.getType() == TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK.getType()) {
|
||||
return dis <= 0.6;
|
||||
} else {
|
||||
return dis <= 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFourWheelType() {
|
||||
@@ -184,6 +207,35 @@ public class TrackObj {
|
||||
&& typeWeight != TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO.getType();
|
||||
}
|
||||
|
||||
private double[] getCenterPoint(List<ObjQueue> objQueueList) {
|
||||
int total = objQueueList.size();
|
||||
double X = 0, Y = 0, Z = 0;
|
||||
for (int i = 0; i < objQueueList.size() - 1; i++) {
|
||||
ObjQueue objQueue = objQueueList.get(i);
|
||||
if (objQueue != null) {
|
||||
double lat, lon, x, y, z;
|
||||
lat = objQueue.getLat() * Math.PI / 180;
|
||||
lon = objQueue.getLon() * Math.PI / 180;
|
||||
x = Math.cos(lat) * Math.cos(lon);
|
||||
y = Math.cos(lat) * Math.sin(lon);
|
||||
z = Math.sin(lat);
|
||||
X += x;
|
||||
Y += y;
|
||||
Z += z;
|
||||
}
|
||||
}
|
||||
X = X / total;
|
||||
Y = Y / total;
|
||||
Z = Z / total;
|
||||
double Lon = Math.atan2(Y, X);
|
||||
double Hyp = Math.sqrt(X * X + Y * Y);
|
||||
double Lat = Math.atan2(Z, Hyp);
|
||||
double[] d = new double[2];
|
||||
d[0] = Lon * 180 / Math.PI;
|
||||
d[1] = Lat * 180 / Math.PI;
|
||||
return d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackObj{" +
|
||||
|
||||
@@ -359,6 +359,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerObuListenerManager.invokeTrackerWarningInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
@@ -370,9 +371,10 @@ class MogoPrivateObuManager private constructor() {
|
||||
CallerHmiManager.disableWarningV2X((appId + direction.direction).toString())
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerObuListenerManager.removeTrackerWarningInfo(it)
|
||||
// 事件结束,还原车辆颜色
|
||||
it.threatLevel = 0x01
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,7 +470,8 @@ class MogoPrivateObuManager private constructor() {
|
||||
// }
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
CallerObuListenerManager.invokeTrackerWarningInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
@@ -477,6 +480,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerObuListenerManager.removeTrackerWarningInfo(it)
|
||||
// 事件结束,还原交通参与者颜色
|
||||
it.threatLevel = 0x01
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
@@ -880,6 +884,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerObuListenerManager.invokeTrackerWarningInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
@@ -891,6 +896,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
CallerHmiManager.disableWarningV2X((appId + direction.direction).toString())
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerObuListenerManager.removeTrackerWarningInfo(it)
|
||||
it.threatLevel = 0x01
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.flexbox
|
||||
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
// implementation rootProject.ext.dependencies.adasHigh
|
||||
implementation rootProject.ext.dependencies.mogo_v2x
|
||||
implementation rootProject.ext.dependencies.mogoaicloudtrafficlive
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
|
||||
@@ -5,9 +5,8 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_V2X_MODULE
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightManager
|
||||
import com.mogo.eagle.core.function.v2x.events.V2XEventManager
|
||||
import com.mogo.eagle.core.function.v2x.redlightwarning.RedLightWarningManager
|
||||
import com.mogo.eagle.core.function.v2x.speedlimit.SpeedLimitDataManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightDispatcher
|
||||
import com.mogo.eagle.core.function.v2x.vip.VipCarManager
|
||||
@@ -20,7 +19,7 @@ class V2XProvider : IMoGoFunctionServerProvider {
|
||||
get() = "V2XProvider"
|
||||
|
||||
override fun init(context: Context) {
|
||||
CallTrafficLightManager.getTrafficLightProvider().initTrafficLightServer(context)
|
||||
CallerTrafficLightManager.getTrafficLightProvider().initTrafficLightServer(context)
|
||||
VipCarManager.INSTANCE.initServer(context)
|
||||
SpeedLimitDataManager.getInstance().start()
|
||||
TrafficLightDispatcher.INSTANCE.initServer(context)
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings.System
|
||||
import android.util.*
|
||||
import androidx.core.util.Pair
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.cloud.passport.IMoGoTokenCallback
|
||||
@@ -14,8 +15,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.network.ParamsUtil
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
@@ -472,6 +472,14 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
}
|
||||
})
|
||||
}
|
||||
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
|
||||
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
|
||||
extra["polygon"] = old.map { d ->
|
||||
val p = CoordinateUtils.transformWgsToGcj(d.lat, d.lon)
|
||||
Pair(p[0], p[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleWarningTargetEvent(data: V2XWarningTarget) {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
// 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
|
||||
|
||||
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay));
|
||||
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay,markerCardResult.getExtras()));
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,39 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.core.util.Pair;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.v2x.R;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XStatusManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 道路V2X事件的Marker
|
||||
*/
|
||||
public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
|
||||
|
||||
private final List<IMogoMarker> pyramids = new ArrayList<>();
|
||||
|
||||
private IMogoPolyline polyline;
|
||||
|
||||
private IMogoOverlayManager overlayManager;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
try {
|
||||
@@ -17,9 +41,88 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
IMoGoV2XMarkerManager marker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (marker != null) {
|
||||
marker.clearAlarmPOI();
|
||||
|
||||
if (entity != null) {
|
||||
marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
|
||||
if (noveltyInfo != null && noveltyInfo.extras != null && noveltyInfo.extras.containsKey("polygon")) {
|
||||
Object extra = noveltyInfo.extras.get("polygon");
|
||||
if (pyramids.size() > 0) {
|
||||
for (IMogoMarker m : pyramids) {
|
||||
m.remove();
|
||||
}
|
||||
pyramids.clear();
|
||||
}
|
||||
if (polyline != null && polyline.isVisible()) {
|
||||
polyline.remove();
|
||||
}
|
||||
if (extra instanceof List) {
|
||||
List l = (List) extra;
|
||||
if (l.size() > 0) {
|
||||
List<Pair<Double, Double>> polygons = new ArrayList<>();
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
Object o = l.get(i);
|
||||
if (!(o instanceof Pair)) {
|
||||
continue;
|
||||
}
|
||||
Pair p = (Pair) o;
|
||||
Object first = p.first;
|
||||
Object second = p.second;
|
||||
if (first == null || second == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(first instanceof Double) || !(second instanceof Double)) {
|
||||
continue;
|
||||
}
|
||||
polygons.add(Pair.create((Double) first, (Double) second));
|
||||
}
|
||||
|
||||
if (polygons.size() > 0) {
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
Pair<Double, Double> p = polygons.get(i);
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.data(entity)
|
||||
.latitude(p.second)
|
||||
.longitude(p.first);
|
||||
options.anchor(0.5f, 0.5f);
|
||||
options.icon3DRes(R.raw.sanjiaozhui);
|
||||
try {
|
||||
pyramids.add(MogoMarkerManager.getInstance(BridgeApi.INSTANCE.context()).addMarker("road_pyramid_" + entity.getPoiType(), options));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// if (polygons.size() > 1) {
|
||||
// if (overlayManager == null) {
|
||||
// overlayManager = MogoOverlayManager.getInstance();
|
||||
// }
|
||||
// MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
// List<Integer> colors = new ArrayList<>();
|
||||
// colors.add(Color.argb(204, 237, 172, 21));
|
||||
// colors.add(Color.argb(0, 255, 255, 255));
|
||||
// options.colorValues(colors);
|
||||
// List<MogoLatLng> points = new ArrayList<>();
|
||||
// for (int i = 0; i < polygons.size(); i++) {
|
||||
// Pair<Double, Double> p = polygons.get(i);
|
||||
// points.add(new MogoLatLng(p.second, p.first));
|
||||
// }
|
||||
// if (points.size() > 2) {
|
||||
// points.add(points.get(0));
|
||||
// }
|
||||
// options.points(points);
|
||||
// options.useGradient(true);
|
||||
// options.useFacade(true);
|
||||
// options.setGps(false);
|
||||
// options.width(5f);
|
||||
// options.zIndex(75000f);
|
||||
// options.maxIndex(800000f);
|
||||
// polyline = overlayManager.addPolyline(options);
|
||||
// polyline.setVisible(true);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -34,6 +137,19 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
if (polyLineManager != null) {
|
||||
polyLineManager.clearLine();
|
||||
}
|
||||
|
||||
IMoGoV2XStatusManager v2xStatus = BridgeApi.INSTANCE.v2xStatus();
|
||||
if (v2xStatus != null && v2xStatus.isRoadEventPOIShow()) {
|
||||
if (polyline != null) {
|
||||
polyline.remove();
|
||||
}
|
||||
if (pyramids.size() > 0) {
|
||||
for (IMogoMarker marker : pyramids) {
|
||||
marker.remove();
|
||||
}
|
||||
pyramids.clear();
|
||||
}
|
||||
}
|
||||
IMoGoV2XMarkerManager v2xMarker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (v2xMarker != null) {
|
||||
// 移除事件POI
|
||||
|
||||
@@ -33,7 +33,7 @@ fun V2XMarkerUserInfo?.toMarkerUserInfo(): MarkerUserInfo? = if (this == null) n
|
||||
it.setAge(this.age)
|
||||
}
|
||||
|
||||
fun V2XMarkerExploreWay.toMarkExploreWay(): MarkerExploreWay = MarkerExploreWay().also {
|
||||
fun V2XMarkerExploreWay.toMarkExploreWay(extras: Map<String, Any>? = null): MarkerExploreWay = MarkerExploreWay().also {
|
||||
it.items = this.items?.map { itx -> itx.toMarkerExploreWayItem() }
|
||||
it.userInfo = this.userInfo?.toMarkerUserInfo()
|
||||
it.distance = this.distance
|
||||
@@ -51,4 +51,5 @@ fun V2XMarkerExploreWay.toMarkExploreWay(): MarkerExploreWay = MarkerExploreWay(
|
||||
it.isFabulous = this.isFabulous
|
||||
it.uploadType = this.uploadType
|
||||
it.isCanLive = this.canLive != "0"
|
||||
it.extras = extras
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import com.mogo.eagle.core.function.api.vip.IMoGoVipSetListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.vip.VipCarManager
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
@@ -72,12 +71,9 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
}
|
||||
|
||||
fun listenTrafficLight() {
|
||||
CallTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
MogoApisHandler.getInstance().apis.registerCenterApi.registerCarLocationChangedListener(
|
||||
VipCarManager.TAG,
|
||||
this
|
||||
)
|
||||
CallerTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
MogoApisHandler.getInstance().apis.registerCenterApi.registerCarLocationChangedListener(TAG, this)
|
||||
CallVipSetListenerManager.registerVipSetListener(TAG, this)
|
||||
}
|
||||
|
||||
@@ -196,9 +192,9 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
CallTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallVipSetListenerManager.unRegisterVipSetListener(TAG)
|
||||
CallTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
MogoApisHandler.getInstance().apis.registerCenterApi.unregisterCarLocationChangedListener(
|
||||
TAG, this
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.trafficlight.isInRange
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.TrafficLightHMIManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_LOOP_SEARCH_CROSS_ROAD
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_LOOP_SEARCH_TRAFFIC_LIGHT
|
||||
@@ -52,7 +52,7 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
//第一次查询路口时,如果红绿灯显示,则隐藏掉
|
||||
if(firstLoopCrossRoad && TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()){
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
CallerTrafficLightListenerManager.resetTrafficLightData()
|
||||
}
|
||||
firstLoopCrossRoad = false
|
||||
mLocation?.let { it ->
|
||||
@@ -81,7 +81,7 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
it.latitude, it.longitude, it.bearing.toDouble(), road, { result ->
|
||||
trafficLightResult = result
|
||||
// TrafficLightHMIManager.INSTANCE.updateTrafficLight(result)
|
||||
CallTrafficLightListenerManager.invokeTrafficLightStatus(result)
|
||||
CallerTrafficLightListenerManager.invokeTrafficLightStatus(result)
|
||||
},
|
||||
{ errorMsg ->
|
||||
//如果没有获取到正确的红绿灯数据,则取消读灯,继续读路口,防止出现一直读灯的情况
|
||||
@@ -103,9 +103,9 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
}
|
||||
if (TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()) {
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
CallerTrafficLightListenerManager.resetTrafficLightData()
|
||||
}
|
||||
CallTrafficLightListenerManager.invokeTrafficRequestError()
|
||||
CallerTrafficLightListenerManager.invokeTrafficRequestError()
|
||||
|
||||
})
|
||||
}
|
||||
@@ -130,18 +130,18 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
if (trafficLightResult != null && it.isInRange(loc.latitude, loc.longitude)) {
|
||||
inRange = true
|
||||
// CallerLogger.d(M_V2X + TAG, "进入路口")
|
||||
CallTrafficLightListenerManager.invokeEnterCrossRoad(true)
|
||||
CallerTrafficLightListenerManager.invokeEnterCrossRoad(true)
|
||||
return
|
||||
}
|
||||
if (inRange) {
|
||||
// CallerLogger.d(M_V2X + TAG, "离开路口")
|
||||
CallTrafficLightListenerManager.invokeEnterCrossRoad(false)
|
||||
CallerTrafficLightListenerManager.invokeEnterCrossRoad(false)
|
||||
inRange = false
|
||||
trafficLightResult = null
|
||||
firstLoopCrossRoad = true
|
||||
mThreadHandler?.sendEmptyMessage(MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT)
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
CallerTrafficLightListenerManager.resetTrafficLightData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.TrafficLightHMIManager
|
||||
import perception.TrafficLightOuterClass
|
||||
import perception.TrafficLightOuterClass.TrafficLight
|
||||
@@ -34,11 +34,11 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener , IMoGoTrafficLigh
|
||||
fun initServer(context: Context){
|
||||
mContext = context
|
||||
//注册监听AI云获取红绿灯状态
|
||||
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
//注册监听AI云进入路口
|
||||
CallTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
//注册监听红绿灯请求失败
|
||||
CallTrafficLightListenerManager.registerTrafficRequestErrorListener(TAG,this)
|
||||
CallerTrafficLightListenerManager.registerTrafficRequestErrorListener(TAG,this)
|
||||
//注册监听工控机感知红绿灯
|
||||
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
||||
}
|
||||
@@ -80,6 +80,10 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener , IMoGoTrafficLigh
|
||||
CallerHmiManager.showWarningTrafficLight(3,2)
|
||||
CallerHmiManager.changeCountdownGreen(0)
|
||||
}
|
||||
TrafficLightOuterClass.LightState.STATE_OFF -> {
|
||||
//黑灯,隐藏红绿灯显示
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -119,13 +123,13 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener , IMoGoTrafficLigh
|
||||
|
||||
fun destroy(){
|
||||
//取消注册监听AI云获取红绿灯状态
|
||||
CallTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
//取消注册监听工控机感知红绿灯
|
||||
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
|
||||
//取消注册监听红绿灯请求失败
|
||||
CallTrafficLightListenerManager.unRegisterTrafficRequestErrorListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficRequestErrorListener(TAG)
|
||||
//取消注册监听AI云进入路口
|
||||
CallTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.core.function.v2x.vip.network.VipNetWorkModel
|
||||
@@ -183,8 +183,8 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
)
|
||||
CallerHmiManager.vipIdentification(true)
|
||||
CallVipSetListenerManager.invokeVipSetStatus(true)
|
||||
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
CallTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun cancelVip() {
|
||||
@@ -194,8 +194,8 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
}
|
||||
CallerHmiManager.vipIdentification(false)
|
||||
CallVipSetListenerManager.invokeVipSetStatus(false)
|
||||
CallTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
}
|
||||
|
||||
private fun canGetThroughCross(
|
||||
|
||||