Merge branch 'dev_robotaxi-d_230912_6.1.0' into base_3.4.0-map-sdk

This commit is contained in:
zhongchao
2023-09-19 12:08:20 +08:00

View File

@@ -50,6 +50,8 @@ class ParallelDriveView @JvmOverloads constructor(
//1:ready, 2:自动驾驶中, 7:平行驾驶中
@Volatile
private var autopilotState: Int = 1
@Volatile
private var isAutoDriving: Boolean = false
// 初始状态为0
private var state: Int = 0
@@ -107,16 +109,25 @@ class ParallelDriveView @JvmOverloads constructor(
when (state) {
7 -> {
if (this.autopilotState != 7) {
isAutoDriving = false
ThreadUtils.runOnUiThread({
updateUI(PARALLEL_DRIVING)
}, ThreadUtils.MODE.QUEUE)
}
}
2 -> {
if (this.autopilotState != state) {
isAutoDriving = true
}
}
else -> {
if (this.autopilotState == 7 && this.autopilotState != state) {
ThreadUtils.runOnUiThread({
checkAvailableAndUpdateUI()
}, ThreadUtils.MODE.QUEUE)
if (this.autopilotState != state) {
isAutoDriving = false
if (this.autopilotState == 7) {
ThreadUtils.runOnUiThread({
checkAvailableAndUpdateUI()
}, ThreadUtils.MODE.QUEUE)
}
}
}
}
@@ -131,8 +142,14 @@ class ParallelDriveView @JvmOverloads constructor(
) {
if (!isParallelDrivingAbility) {
ThreadUtils.runOnUiThread({
state = UNAVAILABLE
updateUI(UNAVAILABLE)
}, ThreadUtils.MODE.QUEUE)
} else {
ThreadUtils.runOnUiThread({
state = 0
updateUI(0)
}, ThreadUtils.MODE.QUEUE)
}
}
@@ -177,16 +194,6 @@ class ParallelDriveView @JvmOverloads constructor(
}
}
private fun isAvailable(unableAutopilotReasons: ArrayList<UnableLaunchReason>?): Boolean {
var unavailable = false
unableAutopilotReasons?.forEach {
if (it.source.ordinal == SourceType.CHASSIS.ordinal) {
unavailable = true
}
}
return !unavailable
}
@SuppressLint("UseCompatLoadingForDrawables")
private fun updateUI(state: Int) {
when (state) {
@@ -330,12 +337,17 @@ class ParallelDriveView @JvmOverloads constructor(
}
private fun checkAvailableAndUpdateUI() {
if (CallerParallelDrivingActionsListenerManager.isParallelDrivingAbility()) {
if (isAutoDriving) {
state = 0
updateUI(0)
} else {
state = UNAVAILABLE
updateUI(UNAVAILABLE)
if (CallerParallelDrivingActionsListenerManager.isParallelDrivingAbility()) {
state = 0
updateUI(0)
} else {
state = UNAVAILABLE
updateUI(UNAVAILABLE)
}
}
}