@@ -145,7 +145,6 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
145145 private val handler = Handler (Looper .getMainLooper()) // Instance handler
146146
147147 private var pendingScreenshotDelayMillis: Long = 0L
148- private var sawNonTermuxCommandSinceLastScreenshot: Boolean = false
149148 private var pendingDelayedScreenshotRunnable: Runnable ? = null
150149
151150 // App name to package mapper
@@ -419,35 +418,13 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
419418 }
420419 }
421420 }
422- .also { _ ->
423- if (command !is Command .TakeScreenshot && command !is Command .TermuxCommand ) {
424- sawNonTermuxCommandSinceLastScreenshot = true
425- }
426- }
427421 }
428422
429423 private fun executeTakeScreenshotCommand (): Boolean {
430424 val delayMillis = pendingScreenshotDelayMillis
431425 pendingScreenshotDelayMillis = 0L
432- val onlyTermuxContext = ! sawNonTermuxCommandSinceLastScreenshot
433-
434- if (! isTermuxRunCommandPermissionGranted()) {
435- val denialCount = TermuxFeedbackPreferences .incrementPermissionDenialCount(applicationContext)
436- if (denialCount >= 2 ) {
437- showToast(" Enable Termux permissions in the Android settings" , true )
438- }
439- Log .w(TAG , " Blocking screenshot/AI handoff because Termux RUN_COMMAND permission is not granted." )
440- return false
441- } else {
442- TermuxFeedbackPreferences .resetPermissionDenialCount(applicationContext)
443- }
444-
445426 fun buildScreenInfoPayload (rawScreenInfo : String? ): String? {
446- val termuxOutput = if (onlyTermuxContext) {
447- TermuxOutputPreferences .peekOutput(applicationContext)?.trim().orEmpty()
448- } else {
449- TermuxOutputPreferences .consumeOutput(applicationContext)?.trim().orEmpty()
450- }
427+ val termuxOutput = TermuxOutputPreferences .consumeOutput(applicationContext)?.trim().orEmpty()
451428 if (termuxOutput.isBlank()) {
452429 return rawScreenInfo
453430 }
@@ -457,7 +434,7 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
457434
458435 val captureAndRequestScreenshot = {
459436 val currentModel = GenerativeAiViewModelFactory .getCurrentModel()
460- if (! currentModel.supportsScreenshot || onlyTermuxContext ) {
437+ if (! currentModel.supportsScreenshot) {
461438 Log .d(TAG , " Command.TakeScreenshot: Model has no screenshot support, capturing screen info only." )
462439 showToast(" Capturing screen info..." , false )
463440 val screenInfo = buildScreenInfoPayload(captureScreenInformation())
@@ -467,7 +444,6 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
467444 applicationContext,
468445 screenInfo
469446 )
470- sawNonTermuxCommandSinceLastScreenshot = false
471447 } else {
472448 Log .d(TAG , " Command.TakeScreenshot: Capturing screen info and sending request broadcast to MainActivity." )
473449 showToast(" Preparing screenshot..." , false )
@@ -480,7 +456,6 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
480456 }
481457 applicationContext.sendBroadcast(intent)
482458 Log .d(TAG , " Sent broadcast ACTION_REQUEST_MEDIAPROJECTION_SCREENSHOT to MainActivity with screenInfo." )
483- sawNonTermuxCommandSinceLastScreenshot = false
484459 }
485460 }
486461
@@ -501,10 +476,6 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
501476 return true
502477 }
503478
504- private fun isTermuxRunCommandPermissionGranted (): Boolean {
505- return checkSelfPermission(" com.termux.permission.RUN_COMMAND" ) == PackageManager .PERMISSION_GRANTED
506- }
507-
508479 private fun cancelPendingDelayedScreenshot () {
509480 pendingScreenshotDelayMillis = 0L
510481 pendingDelayedScreenshotRunnable?.let { runnable ->
@@ -622,8 +593,8 @@ class ScreenOperatorAccessibilityService : AccessibilityService() {
622593 putExtra(" com.termux.RUN_COMMAND_PATH" , " /data/data/com.termux/files/usr/bin/bash" )
623594 putExtra(" com.termux.RUN_COMMAND_ARGUMENTS" , arrayOf(" -lc" , trimmedCommand))
624595 putExtra(" com.termux.RUN_COMMAND_WORKDIR" , " /data/data/com.termux/files/home" )
625- putExtra(" com.termux.RUN_COMMAND_BACKGROUND" , false )
626- putExtra(" com.termux.RUN_COMMAND_SESSION_ACTION" , 1 )
596+ putExtra(" com.termux.RUN_COMMAND_BACKGROUND" , true )
597+ putExtra(" com.termux.RUN_COMMAND_SESSION_ACTION" , 0 )
627598 putExtra(" com.termux.RUN_COMMAND_RUNNER" , " app-shell" )
628599 putExtra(" com.termux.RUN_COMMAND_PENDING_INTENT" , pendingResultIntent)
629600 putExtra(" com.termux.RUN_COMMAND_BACKGROUND_CUSTOM_LOG_LEVEL" , 0 )
0 commit comments