Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat(wake-word): tell the user to enable accessibility when screen capture is unavailable

Rishabh Bajpai50a450224b15
diff --git a/app/src/main/java/com/gotcha/service/CallSessionController.kt b/app/src/main/java/com/gotcha/service/CallSessionController.kt
index 31495cb..eb088cd 100644
--- a/app/src/main/java/com/gotcha/service/CallSessionController.kt
+++ b/app/src/main/java/com/gotcha/service/CallSessionController.kt
@@ -458,7 +458,8 @@ class CallSessionController(
var screenshot: String? = null
var screenText: String? = null
var blankScreen = false
- if (ScreenSnapshot.isAvailable()) {
+ val captureAvailable = ScreenSnapshot.isAvailable()
+ if (captureAvailable) {
onCaptureChrome(true)
delay(CAPTURE_SETTLE_MS)
screenshot = ScreenSnapshot.captureScreenBase64()
@@ -477,15 +478,7 @@ class CallSessionController(
onScreenReadDone()
}
val userText = buildString {
- when {
- !screenText.isNullOrBlank() -> {
- append("Current screen text:\n")
- append(screenText)
- append("\n\n")
- }
- blankScreen -> append("(The screen was blank or off — no screenshot was sent.)\n\n")
- else -> append("(The current screen could not be captured this turn.)\n\n")
- }
+ append(screenContextNote(captureAvailable, screenText, blankScreen))
append("User said (voice call — reply briefly, it will be read aloud): ")
append(text)
}
@@ -496,6 +489,26 @@ class CallSessionController(
}
}
+ /**
+ * The screen-context prefix for a voice-call user turn. When the Gotcha
+ * accessibility service is off there is nothing to capture, so the model is
+ * told to ask the user to enable it rather than guessing at the screen.
+ */
+ internal fun screenContextNote(
+ captureAvailable: Boolean,
+ screenText: String?,
+ blankScreen: Boolean
+ ): String = when {
+ !screenText.isNullOrBlank() -> "Current screen text:\n$screenText\n\n"
+ blankScreen -> "(The screen was blank or off — no screenshot was sent.)\n\n"
+ !captureAvailable -> {
+ "(I could not see your screen — the Gotcha accessibility " +
+ "service is turned off. Ask the user to enable it in Android Settings → " +
+ "Accessibility → Gotcha.)\n\n"
+ }
+ else -> "(The current screen could not be captured this turn.)\n\n"
+ }
+
// ---- AgentEvents (engine → call UI) ----
override fun onUi(
diff --git a/app/src/test/java/com/gotcha/service/CallSessionControllerTest.kt b/app/src/test/java/com/gotcha/service/CallSessionControllerTest.kt
index 04a3b73..766b207 100644
--- a/app/src/test/java/com/gotcha/service/CallSessionControllerTest.kt
+++ b/app/src/test/java/com/gotcha/service/CallSessionControllerTest.kt
@@ -190,4 +190,42 @@ class CallSessionControllerTest {
assertTrue(errorMessage != null)
assertFalse("The call controller must stay idle on a failed wake-word start", controller.isActive())
}
+
+ @Test
+ fun `screenContextNote asks the user to enable accessibility when capture is unavailable`() {
+ val note = controller.screenContextNote(
+ captureAvailable = false,
+ screenText = null,
+ blankScreen = false
+ )
+ assertTrue(
+ "the accessibility-off note must tell the user to enable the service",
+ note.contains("accessibility service is turned off") &&
+ note.contains("Accessibility → Gotcha")
+ )
+ }
+
+ @Test
+ fun `screenContextNote prefers screen text and the blank-screen note over the generic fallback`() {
+ val withText = controller.screenContextNote(
+ captureAvailable = false,
+ screenText = "Settings → About",
+ blankScreen = false
+ )
+ assertTrue(withText.contains("Current screen text:") && withText.contains("Settings → About"))
+
+ val blank = controller.screenContextNote(
+ captureAvailable = true,
+ screenText = null,
+ blankScreen = true
+ )
+ assertTrue(blank.contains("screen was blank or off"))
+
+ val failed = controller.screenContextNote(
+ captureAvailable = true,
+ screenText = null,
+ blankScreen = false
+ )
+ assertTrue(failed.contains("could not be captured"))
+ }
}