Skip to content

Termux RUN_COMMAND direkt anfragen und Senden bis Genehmigung verzögern#111

Closed
Android-PowerUser wants to merge 2 commits into
fix-termux-permission-check-issuefrom
uberspringe-checkselfpermission-fur-termux
Closed

Termux RUN_COMMAND direkt anfragen und Senden bis Genehmigung verzögern#111
Android-PowerUser wants to merge 2 commits into
fix-termux-permission-check-issuefrom
uberspringe-checkselfpermission-fur-termux

Conversation

@Android-PowerUser
Copy link
Copy Markdown
Owner

Motivation

  • MiXplorer überspringt den checkSelfPermission-Vorcheck und ruft requestPermissions direkt auf, weil der Vorcheck auf manchen Geräten fälschlicherweise GRANTED zurückgeben kann und dadurch der Systemdialog nie erscheint; dieser PR richtet Screen Operator nach diesem Verhalten aus.

Description

  • Implementiert in MainActivity die neue Funktion requestTermuxRunCommandPermission(onResult: (Boolean) -> Unit) die ActivityCompat.requestPermissions(...) verwendet und das Ergebnis über onRequestPermissionsResult an den Callback weiterreicht.
  • Fügt die Konstanten TERMUX_RUN_COMMAND_PERMISSION und REQUEST_CODE_TERMUX_RUN_COMMAND_PERMISSION in MainActivity hinzu und behandelt das Ergebnis zentral (kein Vorcheck mehr vor dem Request).
  • Passt PhotoReasoningScreen an, sodass das Senden jetzt immer die direkte Request-API aus MainActivity verwendet und das eigentliche Senden erst dann ausführt, wenn die Permission gewährt wurde (sendCurrentQuestion()); bei Ablehnung bleibt die bestehende Denial-/Settings-Logik erhalten.
  • Deaktiviert den Sende-Button während einer ausstehenden Permission-Anfrage (isTermuxPermissionRequestPending) um doppelte Sends zu vermeiden und entfernt den vorherigen checkSelfPermission-Pfad/Launcher-basierten Vorcheck.

Testing

  • Build-Check: ./gradlew :app:compileDebugKotlin wurde ausgeführt und lief erfolgreich (BUILD SUCCESSFUL) mit nur Compiler-Warnungen; keine Fehler gefunden.
  • Es wurden keine zusätzlichen automatisierten Tests hinzugefügt oder ausgeführt.

Codex Task

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR refactors the Termux RUN_COMMAND permission handling to skip the checkSelfPermission pre-check and always call requestPermissions directly, aligning with MiXplorer's approach to avoid false GRANTED results on some devices.

Critical Issue Found

Logic Error in PhotoReasoningScreen (Line 458-461): The code incorrectly treats a null MainActivity reference as a permission denial, incrementing the denial counter when it's actually a lifecycle issue. This can cause users to be redirected to app settings prematurely without ever denying the permission.

Changes Review

MainActivity.kt: The new requestTermuxRunCommandPermission function correctly implements the direct permission request flow using the deprecated but necessary onRequestPermissionsResult for this use case. The callback handling is clean.

PhotoReasoningScreen.kt: The removal of the local permission checking logic simplifies the code. The addition of isTermuxPermissionRequestPending properly prevents double-sends during permission requests. The button enable/disable logic correctly includes this state.

Please address the critical issue before merging to prevent incorrect denial count increments that could frustrate users.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment on lines +458 to +461
if (mainActivity == null) {
handleTermuxRunCommandPermissionDenied()
return@IconButton
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Calling handleTermuxRunCommandPermissionDenied() when mainActivity is null incorrectly increments the permission denial count. This happens when the activity reference is unavailable (lifecycle issue), not when the user denies the permission. This causes the denial counter to increment incorrectly, potentially leading to premature redirection to app settings after 3 failed send attempts even though the user never denied the permission.

Suggested change
if (mainActivity == null) {
handleTermuxRunCommandPermissionDenied()
return@IconButton
}
if (mainActivity == null) {
Toast.makeText(context, "Activity not available. Please try again.", Toast.LENGTH_SHORT).show()
return@IconButton
}

@Android-PowerUser Android-PowerUser deleted the branch fix-termux-permission-check-issue June 2, 2026 16:11
@Android-PowerUser Android-PowerUser deleted the uberspringe-checkselfpermission-fur-termux branch June 2, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant