fix: 修正自动充电任务检查逻辑
将自动充电的条件从检查任务是否为空改为检查任务是否允许充电 新增 `isAutoRechargeAllowedTask()` 方法,允许 "speech" 任务时也能触发自动充电
This commit is contained in:
@@ -749,7 +749,7 @@ class MainActivity : AppCompatActivity(), OnRobotReadyListener, TtsListener, OnG
|
||||
}
|
||||
|
||||
private fun scheduleAutoRechargeAfterIdleArrival() {
|
||||
if (taskController.currentTask.isNotEmpty()) {
|
||||
if (!isAutoRechargeAllowedTask()) {
|
||||
return
|
||||
}
|
||||
if (robotEventHandler.normalizeLocation(lastArrivalLocation) == "homebase") {
|
||||
@@ -758,7 +758,7 @@ class MainActivity : AppCompatActivity(), OnRobotReadyListener, TtsListener, OnG
|
||||
autoRechargeJob?.cancel()
|
||||
autoRechargeJob = mainScope.launch {
|
||||
delay(10_000L)
|
||||
if (taskController.currentTask.isNotEmpty()) {
|
||||
if (!isAutoRechargeAllowedTask()) {
|
||||
return@launch
|
||||
}
|
||||
if (robotEventHandler.normalizeLocation(lastArrivalLocation) == "homebase") {
|
||||
@@ -769,6 +769,11 @@ class MainActivity : AppCompatActivity(), OnRobotReadyListener, TtsListener, OnG
|
||||
}
|
||||
}
|
||||
|
||||
private fun isAutoRechargeAllowedTask(): Boolean {
|
||||
val task = taskController.currentTask.trim().lowercase()
|
||||
return task.isEmpty() || task == "speech"
|
||||
}
|
||||
|
||||
private fun cancelAutoRecharge(reason: String) {
|
||||
if (autoRechargeJob?.isActive == true) {
|
||||
Log.i("MainActivity", "Auto recharge canceled: $reason")
|
||||
|
||||
Reference in New Issue
Block a user