Skip to content

Commit 489820e

Browse files
Fix: Clear command queue in ScreenOperatorAccessibilityService on stop
1 parent 862c9d4 commit 489820e

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

app/src/main/kotlin/com/google/ai/sample/ScreenOperatorAccessibilityService.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
9292
return isAvailable
9393
}
9494

95+
/**
96+
* Clear the command queue and reset the processing flag
97+
*/
98+
fun clearCommandQueue() {
99+
val instance = serviceInstance
100+
if (instance != null) {
101+
instance.commandQueue.clear()
102+
instance.isProcessingQueue.set(false)
103+
Log.d(TAG, "Command queue cleared and processing flag reset.")
104+
} else {
105+
Log.w(TAG, "clearCommandQueue: serviceInstance is null, nothing to clear.")
106+
}
107+
}
108+
95109
/**
96110
* Execute a command using the accessibility service
97111
*/

app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,8 @@ private fun reasonWithMistral(
15281528
stopExecutionFlag.set(true)
15291529
currentReasoningJob?.cancel()
15301530
commandProcessingJob?.cancel()
1531+
// NEU:
1532+
ScreenOperatorAccessibilityService.clearCommandQueue()
15311533

15321534
val messages = _chatState.getAllMessages().toMutableList()
15331535
val lastMessage = messages.lastOrNull()

0 commit comments

Comments
 (0)