Merge branch 'master' into dev_robo_240612_6.5.0_tmp

This commit is contained in:
yangyakun
2024-07-05 16:34:49 +08:00
82 changed files with 1643 additions and 251 deletions

View File

@@ -380,6 +380,11 @@ class MoGoAutopilotControlProvider :
startAutoPilot(controlParameters, Constants.AUTOPILOT_SOURCE.MO_FANG)
}
}
/**
* 无参数启动自动驾驶,现在的调用方有:魔方
* @param source 数据来源
*/
private fun startAutoPilotWithNoParameter(source: Int) {
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
val invokeResult = AdasManager.getInstance()
@@ -396,6 +401,7 @@ class MoGoAutopilotControlProvider :
}
}
}
private fun startAutoPilot(controlParameters: AutopilotControlParameters, source: Int) {
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
val invokeResult = AdasManager.getInstance()
@@ -440,12 +446,15 @@ class MoGoAutopilotControlProvider :
)
}
override fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine) {
AdasManager.getInstance().sendTrajectoryDownloadReq(autoPilotLine.toAutoPilotLine())
override fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine, routeInfo: MessagePad.RouteInfo?) {
AdasManager.getInstance().sendTrajectoryDownloadReq(autoPilotLine.toAutoPilotLine(),routeInfo)
}
override fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine, downloadType: Int) {
AdasManager.getInstance().sendTrajectoryDownloadReq(autoPilotLine.toAutoPilotLine(), downloadType)
override fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine, downloadType: Int, routeInfo: MessagePad.RouteInfo?) {
AdasManager.getInstance().sendTrajectoryDownloadReq(
autoPilotLine.toAutoPilotLine(),
downloadType,
routeInfo)
}
override fun cancelAutoPilot() {

View File

@@ -6,6 +6,7 @@ import android.content.Context
import android.view.View
import android.view.ViewGroup
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.EnvConfig
@@ -26,6 +27,7 @@ import com.mogo.eagle.core.function.api.devatools.logcat.*
import com.mogo.eagle.core.function.api.devatools.mofang.*
import com.mogo.eagle.core.function.api.devatools.perf.IMoGoCpuUsageProvider
import com.mogo.eagle.core.function.api.lookaround.*
import com.mogo.eagle.core.function.api.map.route.IMapRouteProvider
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
import com.tencent.matrix.Matrix
@@ -112,6 +114,10 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
private val downloadCallbacks by lazy { ConcurrentHashMap<String, ArrayList<(Int) -> Unit>>() }
private val startAutopilotCallbacks by lazy { ConcurrentHashMap<String, ArrayList<(Boolean) -> Unit>>() }
private val mapRouteProvider by lazy {
ARouter.getInstance().build(MogoServicePaths.PATH_MAP_ROUTE_GUIDE).navigation() as? IMapRouteProvider
}
@Volatile
private var lastCanAutopilotStatus: Int? = null
@@ -607,4 +613,8 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
override fun unRegisterStartAutopilotStateListener(tag: String) {
startAutopilotCallbacks.remove(tag)
}
override fun setRouteDynamicColorEnable(enable: Boolean) {
mapRouteProvider?.setRouteDynamicColorEnable(enable)
}
}

View File

@@ -252,5 +252,9 @@ object BindingCarManager : IMoGoAutopilotCarConfigListener, IMoGoCloudListener {
)
}
}
fun getMacAddress(): String? {
return mAddress
}
}

View File

@@ -23,6 +23,7 @@ import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.function.api.devatools.logcat.*
import com.mogo.eagle.core.utilcode.download.DownloadUtils
import com.zhidao.loglib.bean.RemoteLogPushContent
import com.zhjt.mogo_core_function_devatools.BuildConfig
import com.zhjt.mogo_core_function_devatools.logcat.checker.AnrLogChecker
import com.zhjt.mogo_core_function_devatools.logcat.config.LogRecordConfig
import com.zhjt.mogo_core_function_devatools.logcat.uploader.*
@@ -73,6 +74,7 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
itx["应用版本名称"] = AppConfigInfo.appVersionName
itx["应用版本号"] = AppConfigInfo.appVersionCode
itx["渠道"] = AppConfigInfo.flavor
itx["构建类型"] = BuildConfig.BUILD_TYPE
itx["GIT分支"] = AppConfigInfo.workingBranchName
itx["GIT分支HASH"] = AppConfigInfo.workingBranchHash
itx["${divider}-2"] = divider

View File

@@ -1,6 +1,7 @@
package com.zhjt.mogo_core_function_devatools.upgrade
import android.content.*
import android.text.TextUtils
import android.util.*
import android.widget.Toast
import com.mogo.commons.constants.*
@@ -22,8 +23,10 @@ import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.getMisChannelCode
import com.mogo.eagle.core.utilcode.mogo.logger.scene.*
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.eagle.core.utilcode.util.FileUtils
import com.zhjt.mogo_core_function_devatools.binding.BindingCarManager
import kotlinx.coroutines.*
import okhttp3.*
import java.util.TreeMap
@@ -55,9 +58,28 @@ class UpgradeAppNetWorkManager private constructor() {
fun getAppUpgradeInfo(context: Context?, mac: String, screenType: String) {
upgradeJob?.safeCancel()
scope.launch {
val sn = SharedPrefsMgr.getInstance().sn
val macAddress = mac //"48:b0:2d:4d:31:7f"
val type = screenType //"10"
var sn = SharedPrefsMgr.getInstance().sn
var macAddress = mac //"48:b0:2d:4d:31:7f"
var type = screenType //"10"
while (sn == null || TextUtils.isEmpty(sn)) {
Logger.d(TAG, "sn is null or empty.")
MogoAnalyticUtils.track("AppUpgradeParams", HashMap<String, Any>().also { it["sn"] = sn })
delay(TimeUnit.MINUTES.toMillis(1))
sn = SharedPrefsMgr.getInstance().sn
}
while (TextUtils.isEmpty(macAddress)) {
Logger.d(TAG, "mac address is null or empty.")
MogoAnalyticUtils.track("AppUpgradeParams", HashMap<String, Any>().also { it["mac_address"] = macAddress })
delay(TimeUnit.MINUTES.toMillis(1))
macAddress = BindingCarManager.getMacAddress() ?: ""
}
while (type == "0") {
Logger.d(TAG, "type is 0")
delay((TimeUnit.MINUTES.toMillis(1)))
MogoAnalyticUtils.track("AppUpgradeParams", HashMap<String, Any>().also { it["type"] = type })
type = AppIdentityModeUtils.getMisChannelCode(FunctionBuildConfig.appIdentityMode).toString()
}
Logger.d(TAG, "start upgrade request ...")
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.HOST_ADDRESS, HostConst.getHost())
try {
val records = provider?.getUpgradeRecords()?.also {
@@ -67,7 +89,7 @@ class UpgradeAppNetWorkManager private constructor() {
"${ it.first } -> ${ it.second }"
}
}
itx["role"] = AppIdentityModeUtils.getMisChannelCode(FunctionBuildConfig.appIdentityMode)
itx["role"] = type
})
}
Log.d(TAG, "getAppUpgradeInfo: -> records:" + records?.entries?.joinToString(",") { itx -> "key:${itx.key} -> value:[${itx.value.joinToString(",") { "${it.first},${it.second}" } }]"})
@@ -98,7 +120,7 @@ class UpgradeAppNetWorkManager private constructor() {
if (mDownloadRequested) {
mDownloadRequested = false
}
getAppUpgradeInfo(context, mac, screenType)
getAppUpgradeInfo(context, macAddress, type)
}.also {
upgradeJob = it
}

View File

@@ -1380,6 +1380,7 @@ internal class DebugSettingView @JvmOverloads constructor(
tbRouteDynamicEffect.isChecked = HmiBuildConfig.isShowRouteStrategy
tbRouteDynamicEffect.setOnCheckedChangeListener { _, isChecked ->
HmiBuildConfig.isShowRouteStrategy = isChecked
CallerDevaToolsManager.setRouteDynamicColorEnable(isChecked)
}
/**

View File

@@ -419,6 +419,7 @@ internal class SOPSettingView @JvmOverloads constructor(
scRouteDynamicEffect.setOnCheckedChangeListener { _, isChecked ->
hmiAction("SOP 引导线动态效果, ", isChecked)
HmiBuildConfig.isShowRouteStrategy = isChecked
CallerDevaToolsManager.setRouteDynamicColorEnable(isChecked)
}
//点云效果

View File

@@ -84,6 +84,9 @@ class ConnectionProcessView @JvmOverloads constructor(
CallerAutoPilotStatusListenerManager.removeListener(TAG)
//隐藏视图
dismissConnectionView()
//如果已经开始连接倒计时则取消Timer
connectSSMTimer?.cancel()
autopilotReadyTimer?.cancel()
}
}
@@ -212,14 +215,16 @@ class ConnectionProcessView @JvmOverloads constructor(
* 展示域控连接成功视图
*/
private fun showIPCConnectSuccessView(){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(5,3,5,8)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_progress_style)
pbConnectionProgress.progress = 25
tvConnectionStatus.setPadding(0,0,0,10)
tvConnectionStatus.text = "系统启动中..."
clConnectionTip.visibility = View.GONE
if(HmiBuildConfig.isShowConnectionProgressView){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(5,3,5,8)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_progress_style)
pbConnectionProgress.progress = 25
tvConnectionStatus.setPadding(0,0,0,10)
tvConnectionStatus.text = "系统启动中..."
clConnectionTip.visibility = View.GONE
}
}
}
@@ -227,14 +232,16 @@ class ConnectionProcessView @JvmOverloads constructor(
* 展示SSM连接成功视图
*/
private fun showSSMConnectSuccessView(){
ThreadUtils.runOnUiThread{
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(5,3,5,8)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_progress_style)
pbConnectionProgress.progress = 50
tvConnectionStatus.setPadding(0,0,0,10)
tvConnectionStatus.text = "系统启动中..."
clConnectionTip.visibility = View.GONE
if(HmiBuildConfig.isShowConnectionProgressView){
ThreadUtils.runOnUiThread{
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(5,3,5,8)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_progress_style)
pbConnectionProgress.progress = 50
tvConnectionStatus.setPadding(0,0,0,10)
tvConnectionStatus.text = "系统启动中..."
clConnectionTip.visibility = View.GONE
}
}
}
@@ -242,14 +249,16 @@ class ConnectionProcessView @JvmOverloads constructor(
* 展示冷启动成功视图
*/
private fun showAutopilotReadySuccessView(){
ThreadUtils.runOnUiThread{
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_success_style)
pbConnectionProgress.progress = 100
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动成功"
clConnectionTip.visibility = View.GONE
if(HmiBuildConfig.isShowConnectionProgressView){
ThreadUtils.runOnUiThread{
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_success_style)
pbConnectionProgress.progress = 100
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动成功"
clConnectionTip.visibility = View.GONE
}
}
}
@@ -257,16 +266,18 @@ class ConnectionProcessView @JvmOverloads constructor(
* 展示域控连接失败视图
*/
private fun showIPCConnectFailView(){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
pbConnectionProgress.progress = 25
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动异常"
clConnectionTip.visibility = View.VISIBLE
tvConnectionTipTitle.text = "Telematics连接异常"
tvConnectionTipContent.text = "建议重启车辆并上报问题"
if(HmiBuildConfig.isShowConnectionProgressView){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
pbConnectionProgress.progress = 25
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动异常"
clConnectionTip.visibility = View.VISIBLE
tvConnectionTipTitle.text = "Telematics连接异常"
tvConnectionTipContent.text = "建议重启车辆并上报问题"
}
}
}
@@ -274,16 +285,18 @@ class ConnectionProcessView @JvmOverloads constructor(
* 展示SSM连接失败视图
*/
private fun showSSMConnectFailView(){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
pbConnectionProgress.progress = 50
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动异常"
clConnectionTip.visibility = View.VISIBLE
tvConnectionTipTitle.text = "SSM连接异常"
tvConnectionTipContent.text = "建议重启车辆并上报问题"
if(HmiBuildConfig.isShowConnectionProgressView){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
pbConnectionProgress.progress = 50
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动异常"
clConnectionTip.visibility = View.VISIBLE
tvConnectionTipTitle.text = "SSM连接异常"
tvConnectionTipContent.text = "建议重启车辆并上报问题"
}
}
}
@@ -291,16 +304,18 @@ class ConnectionProcessView @JvmOverloads constructor(
* 展示SSM冷启动失败视图
*/
private fun showAutopilotReadyFailView(){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
pbConnectionProgress.progress = 100
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动异常"
clConnectionTip.visibility = View.VISIBLE
tvConnectionTipTitle.text = "系统冷启动异常"
tvConnectionTipContent.text = "建议重启车辆并上报问题"
if(HmiBuildConfig.isShowConnectionProgressView){
ThreadUtils.runOnUiThread {
this.visibility = View.VISIBLE
pbConnectionProgress.setPadding(0,0,0,0)
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
pbConnectionProgress.progress = 100
tvConnectionStatus.setPadding(0,0,0,0)
tvConnectionStatus.text = "系统启动异常"
clConnectionTip.visibility = View.VISIBLE
tvConnectionTipTitle.text = "系统冷启动异常"
tvConnectionTipContent.text = "建议重启车辆并上报问题"
}
}
}
@@ -365,6 +380,7 @@ class ConnectionProcessView @JvmOverloads constructor(
override fun onFinish() {
//将SSM连接状态置为false
ssmConnectStatus = false
autopilotReadyStatus = false
//展示连接SSM失败视图
showSSMConnectFailView()
}
@@ -386,6 +402,7 @@ class ConnectionProcessView @JvmOverloads constructor(
override fun onFinish() {
//将冷启动状态置为false
ssmConnectStatus = false
autopilotReadyStatus = false
if(CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().ssmAutoPilotReady){
//冷启动成功

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -30,7 +31,9 @@
app:layout_constraintLeft_toRightOf="@id/ivAutopilotImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -42,7 +45,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -54,9 +57,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvAutopilotTitle"
app:layout_constraintRight_toRightOf="@id/tvAutopilotTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -30,7 +31,9 @@
app:layout_constraintLeft_toRightOf="@id/ivFSMImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -42,7 +45,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -54,9 +57,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvFSMTitle"
app:layout_constraintRight_toRightOf="@id/tvFSMTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -30,7 +31,9 @@
app:layout_constraintLeft_toRightOf="@id/ivSsmImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -42,7 +45,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -54,9 +57,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvSsmTitle"
app:layout_constraintRight_toRightOf="@id/tvSsmTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -28,7 +29,9 @@
app:layout_constraintLeft_toRightOf="@id/ivV2XImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -40,7 +43,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -52,9 +55,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvV2XTitle"
app:layout_constraintRight_toRightOf="@id/tvV2XTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clAutopilotLayout"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -30,7 +31,9 @@
app:layout_constraintLeft_toRightOf="@id/ivAutopilotImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -42,7 +45,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -54,9 +57,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvAutopilotTitle"
app:layout_constraintRight_toRightOf="@id/tvAutopilotTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clFSMLayout"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -30,7 +31,9 @@
app:layout_constraintLeft_toRightOf="@id/ivFSMImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -42,7 +45,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -54,9 +57,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvFSMTitle"
app:layout_constraintRight_toRightOf="@id/tvFSMTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clSsmLayout"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -30,7 +31,9 @@
app:layout_constraintLeft_toRightOf="@id/ivSsmImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -42,7 +45,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -54,9 +57,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvSsmTitle"
app:layout_constraintRight_toRightOf="@id/tvSsmTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginBottom="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,7 +2,8 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clV2XLayout"
android:layout_width="@dimen/dp_804"
android:layout_height="@dimen/dp_160"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_160"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bg_msg_box_v2x"
android:layout_gravity="center_horizontal"
@@ -28,7 +29,9 @@
app:layout_constraintLeft_toRightOf="@id/ivV2XImage"
android:layout_marginStart="@dimen/dp_15"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/dp_32"
android:textSize="@dimen/sp_32"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
<TextView
@@ -40,7 +43,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="25dp"
android:textColor="#80FFFFFF"
android:textSize="24dp"
android:textSize="@dimen/sp_24"
/>
<TextView
@@ -52,9 +55,9 @@
app:layout_constraintLeft_toLeftOf="@id/tvV2XTitle"
app:layout_constraintRight_toRightOf="@id/tvV2XTime"
android:textColor="#B3FFFFFF"
android:textSize="@dimen/dp_28"
android:maxLines="2"
android:ellipsize="end"
android:textSize="@dimen/sp_28"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -13,6 +13,7 @@ import com.mogo.eagle.core.function.business.ai.RomaManager.Companion.romaManage
import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber
import com.mogo.eagle.core.function.business.roadcross.RoadCrossCameraManager
import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager
import com.mogo.eagle.core.function.business.trajectoryoverlay.MogoTrajectoryOverlayManager
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
import com.mogo.eagle.core.utilcode.util.DeviceUtils
import com.mogo.map.MapDataWrapper
@@ -27,6 +28,7 @@ class MapBizProvider :IMoGoFunctionServerProvider, IMogoRoma {
MapDataWrapper.init()
MapIdentifySubscriber.instance
MogoRouteOverlayManager.getInstance().init()
MogoTrajectoryOverlayManager.getInstance().init()
MapPointCloudSubscriber.instance
RoadCrossCameraManager.instance.init(context)
SpeedLimitDataManager.getInstance().start()

View File

@@ -0,0 +1,16 @@
package com.mogo.eagle.core.function.business.routeoverlay
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.map.route.IMapRouteProvider
@Route(path = MogoServicePaths.PATH_MAP_ROUTE_GUIDE)
class MapRouteProviderImpl: IMapRouteProvider {
override fun setRouteDynamicColorEnable(enable: Boolean) {
RouteStrategy.isEnable = enable
}
override fun init(context: Context?) { }
}

View File

@@ -81,7 +81,7 @@ public class RouteOverlayDrawer {
if (mRenderTask != null) {
mRenderHandler.removeCallbacks(mRenderTask);
}
mogoOverlayManager.removeAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
mogoOverlayManager.hideAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
}
}

View File

@@ -3,13 +3,11 @@ package com.mogo.eagle.core.function.business.routeoverlay
import android.animation.ArgbEvaluator
import android.graphics.Color
import android.view.animation.AccelerateInterpolator
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_BLUE
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_BLUE_DARK
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_RED_DARK
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_TRANSPARENT
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import java.util.*
import kotlin.properties.Delegates
@@ -42,7 +40,7 @@ class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightO
object RouteStrategy {
private var isEnable by Delegates.observable(HmiBuildConfig.isShowRouteStrategy) { _, _, newValue ->
internal var isEnable by Delegates.observable(HmiBuildConfig.isShowRouteStrategy) { _, _, newValue ->
if (!newValue) {
strategy = null
colors.clear()

View File

@@ -0,0 +1,106 @@
package com.mogo.eagle.core.function.business.trajectoryoverlay;
import android.util.Log;
import android.util.Pair;
import androidx.annotation.Nullable;
import com.mogo.commons.utils.MogoAnalyticUtils;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mogo.telematics.pad.MessagePad;
public class MogoTrajectoryOverlayManager implements IMoGoPlanningRottingListener, IMoGoChassisLocationGCJ02Listener {
private static volatile MogoTrajectoryOverlayManager sInstance;
private static final String TAG = "MogoTrajectoryOverlayManager";
private static final String ANALYTICS_KEY = "mogo_map_trajectory_overlay_manager";
private final List<MessagePad.Location> queue = new ArrayList<>();
private MogoTrajectoryOverlayManager() {
}
public void init() {
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 1, this);
}
public static MogoTrajectoryOverlayManager getInstance() {
if (sInstance == null) {
synchronized (MogoTrajectoryOverlayManager.class) {
if (sInstance == null) {
sInstance = new MogoTrajectoryOverlayManager();
//需要先初始化否则第一次调用drawTrajectoryOverlayOnce()会因为mRenderHandler=null实际不会绘制
TrajectoryOverlayDrawer.getInstance();
}
}
}
return sInstance;
}
@Override
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) {
if (globalPathResp != null) {
CallerLogger.i(TAG, "onAutopilotRotting size=" + globalPathResp.getWayPointsList().size());
synchronized (queue) {
queue.clear();
queue.addAll(globalPathResp.getWayPointsList());
}
trackEvent("onAutopilotRotting", "接收到全局轨迹规划, size=" + globalPathResp.getWayPointsList().size());
}
}
@Override
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
}
public Pair<Boolean, String> drawTrajectoryOverlayOnce() {
CallerLogger.i(TAG, "drawTrajectoryOverlayOnce");
trackEvent("drawTrajectoryOverlayOnce", "开始执行");
synchronized (queue) {
if (queue != null && !queue.isEmpty()) {
double heading = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getHeading();
TrajectoryOverlayDrawer.getInstance().drawTrajectoryList(queue, heading);
trackEvent("drawTrajectoryOverlayOnce", "执行结果(result=true, msg=success)");
return new Pair(true, "success");
}
trackEvent("drawTrajectoryOverlayOnce", "执行结果(result=false, msg=全局轨迹未就绪或为空)");
return new Pair(false, "全局轨迹未就绪或为空");
}
}
public void clearTrajectoryOverlay(boolean isClearData) {
CallerLogger.i(TAG, "clearTrajectoryOverlay");
trackEvent("clearTrajectoryOverlay", "开始执行");
TrajectoryOverlayDrawer.getInstance().clearMogoTrajectoryOverlay();
if (isClearData) {
queue.clear();
}
trackEvent("clearTrajectoryOverlay", "success");
}
public void trackEvent(String eventKey, String eventValue) {
ThreadUtils.getIoPool().submit(new Runnable() {
@Override
public void run() {
Log.i(TAG, eventKey + "-->" + eventValue);
Map map = new HashMap();
map.put(eventKey, eventValue);
MogoAnalyticUtils.INSTANCE.track(ANALYTICS_KEY, map);
}
});
}
}

View File

@@ -0,0 +1,43 @@
package com.mogo.eagle.core.function.business.trajectoryoverlay
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.map.trajectory.IMoGoGlobalTrajectoryDrawListener
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import java.util.concurrent.atomic.AtomicReference
@Route(path = MogoServicePaths.PATH_MAP_GLOBAL_TRAJECTORY)
class MogoTrajectoryOverlayProvider : IMoGoGlobalTrajectoryDrawListener {
companion object {
private const val TAG = "MogoTrajectoryOverlayProvider"
}
private var hasDrawn = AtomicReference<Boolean>(false)
override fun init(context: Context?) {
CallerLogger.i(TAG, "---init---")
}
override fun hasDrawnGlobalTrajectory(): Boolean {
val result = hasDrawn.get()
CallerLogger.i(TAG, "hasDrawnGlobalTrajectory --> hasDrawn=$result")
return result
}
override fun drawGlobalTrajectory(): Pair<Boolean, String> {
val result = MogoTrajectoryOverlayManager.getInstance().drawTrajectoryOverlayOnce()
if (result.first) {
hasDrawn.set(result.first)
}
CallerLogger.i(TAG, "drawGlobalTrajectory --> hasDrawn=$hasDrawn, result.first=${result.first}, result.second=${result.second}")
return Pair(result.first, result.second)
}
override fun clearGlobalTrajectory(isClearData: Boolean) {
MogoTrajectoryOverlayManager.getInstance().clearTrajectoryOverlay(isClearData)
hasDrawn.set(false)
CallerLogger.i(TAG, "clearGlobalTrajectory --> hasDrawn=$hasDrawn")
}
}

View File

@@ -0,0 +1,288 @@
package com.mogo.eagle.core.function.business.trajectoryoverlay;
import static com.mogo.map.MogoMap.DEFAULT;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import androidx.core.util.Pools;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
import com.mogo.map.overlay.IMoGoOverlayManager;
import com.mogo.map.overlay.core.Level;
import com.mogo.map.overlay.line.Polyline;
import com.zhidaoauto.map.sdk.open.common.tools.MapTools;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import kotlin.Pair;
import mogo.telematics.pad.MessagePad;
public class TrajectoryOverlayDrawer {
private static final String TAG = "TrajectoryOverlayDrawer";
// 连接线参数
private Handler mRenderHandler;
private final IMoGoOverlayManager mogoOverlayManager;
private static volatile TrajectoryOverlayDrawer sInstance;
private static final byte[] obj = new byte[0];
private Polyline.Options mPolylineOptions;
private static final int COLOR_LIGHT = Color.parseColor("#BAEBF5");
private static final int mPolylineWidth = 50;
//用于taxi乘客屏渐变颜色集合
private static List<Integer> colors = null;
private TrajectoryOverlayDrawer() {
// 渐变色
mogoOverlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
if (mogoOverlayManager != null) {
mPolylineOptions = new Polyline.Options.Builder("trajectory_overlay", Level.TRAJECTORY_LINE)
.setUseGps(true)
.setWidth(mPolylineWidth)
.setIsGradient(true)
.build();
// 线条粗细,渐变,渐变色值
HandlerThread renderTask = new HandlerThread("trajectory_render") {
@Override
protected void onLooperPrepared() {
super.onLooperPrepared();
mRenderHandler = new Handler(getLooper());
}
};
renderTask.start();
}
}
public static TrajectoryOverlayDrawer getInstance() {
if (sInstance == null) {
synchronized (obj) {
if (sInstance == null) {
sInstance = new TrajectoryOverlayDrawer();
}
}
}
return sInstance;
}
public void clearMogoTrajectoryOverlay() {
if (mogoOverlayManager != null) {
if (mRenderTask != null) {
mRenderHandler.removeCallbacks(mRenderTask);
}
mogoOverlayManager.hideAllLinesInLevel(Level.TRAJECTORY_LINE);
}
}
private class RenderTask implements Runnable {
private volatile List<MessagePad.Location> routeList;
private final Pools.Pool<MogoLatLng> pools;
private final LinkedList<MogoLatLng> points;
private double bearing;
public RenderTask() {
this.pools = new Pools.SimplePool<>(500);
this.points = new LinkedList<>();
}
public void setData(List<MessagePad.Location> routeList, double bearing) {
this.routeList = routeList;
this.bearing = bearing;
}
@SuppressLint("LongLogTag")
@Override
public void run() {
IMoGoOverlayManager overlayManager = mogoOverlayManager;
if (overlayManager == null) {
return;
}
LinkedList<MogoLatLng> pps = this.points;
boolean isExcept = false;
int total;
try {
pps.clear();
List<MessagePad.Location> routes = this.routeList;
if (routes == null || (total = routes.size()) < 2) {
isExcept = true;
return;
}
//boolean isColorfulStrategy = !AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode);
//全局轨迹线 没有颜色策略,使用固定颜色
boolean isColorfulStrategy = false;
if (isColorfulStrategy) {
TrajectoryStrategy.INSTANCE.start();
} else {
if (colors == null) {
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
temps.add(new Pair<>(0, 70));
temps.add(new Pair<>(2, 100));
temps.add(new Pair<>(98, 100));
temps.add(new Pair<>(100, 70));
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
if (alphas != null && !alphas.isEmpty()) {
colors = new ArrayList<>();
for (int i : alphas) {
colors.add(Color.argb(i, 48,163,255));
}
}
}
}
for (int i = 0; i < total; i++) {
MessagePad.Location route = null;
try {
route = routes.get(i);
if (route == null) {
continue;
}
} catch (Throwable t) {
Log.d("Trajectory", "render-error:" + t.getMessage());
}
if (route == null) {
//数组越界了,结束循环
break;
}
MogoLatLng acquire = pools.acquire();
double latitude = route.getLatitude();
double longitude = route.getLongitude();
if (acquire == null) {
acquire = new MogoLatLng(latitude, longitude);
} else {
acquire.lon = longitude;
acquire.lat = latitude;
}
pps.add(acquire);
}
// double lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
// double lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
if (points.size() > 0) {
// MogoLatLng top = null;
// while (points.size() != 0) {
// MogoLatLng first = points.peek();
// if (first == null) {
// continue;
// }
// if (first == top) {
// break;
// }
// lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
// lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
// long angle = isPointOnCarFront(lon, lat, bearing, first.lon, first.lat);
// if (angle >= 90) {
// if (isColorfulStrategy) {
// TrajectoryStrategy.INSTANCE.remove(first.acc);
// }
// pools.release(first);
// points.poll();
// }
// top = first;
// }
// if (points.size() == 0) {
// isExcept = true;
// return;
// }
// MogoLatLng self = pools.acquire();
// if (self == null) {
// self = new MogoLatLng(lat, lon);
// } else {
// self.lat = lat;
// self.lon = lon;
// }
// points.addFirst(self);
Polyline.Options.Builder builder;
if (mPolylineOptions == null) {
builder = new Polyline.Options.Builder("trajectory_overlay", Level.TRAJECTORY_LINE)
.setUseGps(true)
.setWidth(mPolylineWidth)
.setIsGradient(false);
} else {
builder = mPolylineOptions.builder();
}
if (isColorfulStrategy) {
TrajectoryStrategy.INSTANCE.end();
Strategy strategy = TrajectoryStrategy.INSTANCE.getStrategy();
List<Integer> colors = strategy.getColors();
boolean isLightOn = strategy instanceof ColorfulStrategy && ((ColorfulStrategy) strategy).isLightOn();
builder.colors(colors);
builder.setLightOn(isLightOn);
//builder.setLightColor(COLOR_LIGHT);
//builder.setLightSpeed(0.3f);
} else {
if (colors != null && !colors.isEmpty()) {
builder.colors(colors);
builder.setIsGradient(true);
builder.setLightOn(false);
//builder.setLightColor(COLOR_LIGHT);
//builder.setLightSpeed(0.3f);
}
}
builder.points(points);
builder.setVisible(true);
Polyline.Options options = builder.build();
if (mPolylineOptions == null) {
mPolylineOptions = options;
}
overlayManager.showOrUpdateLine(options,DEFAULT);
} else {
isExcept = true;
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
if (isExcept) {
setVisible(false);
}
if (points.size() > 0) {
for (int i = 0; i < points.size(); i++) {
MogoLatLng latLng = points.get(i);
if (latLng == null) {
continue;
}
pools.release(latLng);
}
}
}
}
private long isPointOnCarFront(double car_lon, double car_lat, double car_head, double lon, double lat) {
return DrivingDirectionUtils.getDegreeOfCar2Poi2(car_lon, car_lat, lon, lat, car_head);
}
}
private volatile RenderTask mRenderTask;
public void drawTrajectoryList(List<MessagePad.Location> routeList, double bearing) {
if (mogoOverlayManager != null) {
if (mRenderTask == null) {
mRenderTask = new RenderTask();
}
mRenderTask.setData(routeList, bearing);
if (mRenderHandler != null) {
mRenderHandler.removeCallbacks(mRenderTask);
mRenderHandler.post(mRenderTask);
}
}
}
private void setVisible(boolean isVisible) {
if (mogoOverlayManager != null) {
if (isVisible) {
mogoOverlayManager.showAllLinesInLevel(Level.TRAJECTORY_LINE);
} else {
mogoOverlayManager.hideAllLinesInLevel(Level.TRAJECTORY_LINE);
}
}
}
}

View File

@@ -0,0 +1,170 @@
package com.mogo.eagle.core.function.business.trajectoryoverlay
import android.animation.ArgbEvaluator
import android.graphics.Color
import android.view.animation.AccelerateInterpolator
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_BLUE
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_BLUE_DARK
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_RED_DARK
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_TRANSPARENT
import java.util.NavigableMap
import java.util.TreeMap
import kotlin.properties.Delegates
interface IStrategy {
fun getColors(): List<Int>
}
class Colors {
companion object {
val COLOR_BLUE = Color.parseColor("#FF2ABAD9")
val COLOR_BLUE_DARK = Color.parseColor("#FF074EFF")
val COLOR_RED_DARK = Color.parseColor("#FF0FF5F0")
val COLOR_TRANSPARENT = Color.parseColor("#002ABAD9")
}
}
sealed class Strategy : IStrategy
class DefaultStrategy(private val colors: List<Int>? = null) : Strategy() {
override fun getColors(): List<Int> = colors ?: listOf(COLOR_BLUE, COLOR_TRANSPARENT)
}
class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightOn: Boolean) :
Strategy() {
override fun getColors(): List<Int> = colors
}
object TrajectoryStrategy {
private var isEnable by Delegates.observable(HmiBuildConfig.isShowRouteStrategy) { _, _, newValue ->
if (!newValue) {
strategy = null
colors.clear()
}
}
private var strategy: Strategy? = null
private val colors: ArrayList<Int> = ArrayList()
private var index = 0
private val sorted: NavigableMap<Double, Int> by lazy { TreeMap() }
private var endEvaluator: ArgbEvaluator? = null
private var startColor = Int.MAX_VALUE
private var hasLessThan0 = false
fun start() {
if (sorted.isEmpty()) {
fill()
}
strategy = null
index = 0
startColor = Int.MAX_VALUE
colors.clear()
endEvaluator = null
hasLessThan0 = false
}
fun end() {
if (isEnable) {
if (colors.isEmpty()) {
return
}
val first = colors[0]
colors.add(0, first)
strategy = ColorfulStrategy(colors, true)
}
}
fun check(speed: Double, acc: Double, total: Int) {
if (!isEnable) {
return
}
if (sorted.isEmpty()) {
return
}
if (acc < 0) {
hasLessThan0 = true
}
val delta = (total * 0.35).toInt()
val last = total - delta
val entry = sorted.floorEntry(acc)
if (entry != null) {
if (index >= last - 1) {
if (startColor == Int.MAX_VALUE) {
startColor = entry.value
if (endEvaluator == null) {
endEvaluator = ArgbEvaluator()
}
colors += entry.value
} else {
if (endEvaluator != null) {
val fraction = (index - last) * 1.0f / delta
colors += endEvaluator!!.evaluate(
fraction,
startColor,
COLOR_TRANSPARENT
) as Int
}
}
} else {
colors += entry.value
}
}
index++
}
fun remove(acc: Double): List<Int> {
if (!isEnable) {
return emptyList()
}
if (sorted.isEmpty()) {
throw AssertionError("sorted map must not be null.")
}
val entry = sorted.floorEntry(acc)
if (entry != null) {
colors.remove(entry.value)
}
return ArrayList(colors)
}
private fun fill() {
var startValue = -4.0
var endValue = 0.0
val step = 0.01
var current = startValue
val evaluator = ArgbEvaluator()
val interceptor = AccelerateInterpolator()
var total = endValue - startValue
while (current <= endValue) {
val fraction = interceptor.getInterpolation(((current - startValue) / total).toFloat())
val colorValue = evaluator.evaluate(fraction, COLOR_RED_DARK, COLOR_BLUE) as Int
sorted[current] = colorValue
current += step
}
startValue = 0.01
endValue = 3.0
current = startValue
total = endValue - startValue
while (current <= endValue) {
val fraction = (current - startValue) / total
val colorValue =
evaluator.evaluate(fraction.toFloat(), COLOR_BLUE, COLOR_BLUE_DARK) as Int
sorted[current] = colorValue
current += step
}
}
fun getStrategy(): Strategy = if (isEnable) {
(strategy ?: DefaultStrategy())
} else DefaultStrategy()
}