feat(accessibility): add accessibility mode with stable initialization, permissions, and media handling#5
Open
Repobor wants to merge 6 commits intoLuokavin:masterfrom
Open
feat(accessibility): add accessibility mode with stable initialization, permissions, and media handling#5Repobor wants to merge 6 commits intoLuokavin:masterfrom
Repobor wants to merge 6 commits intoLuokavin:masterfrom
Conversation
…cessibility mode **Problems Fixed:** 1. ComponentManager.reinitializeAgent() did not handle accessibility mode switching 2. initializeAccessibilityComponents() would fail if service wasn't immediately connected 3. No permission check in startTask() when switching modes 4. Missing deviceControllerInstance getter in ComponentManager **Changes:** 1. Modified reinitializeAgent() to properly handle both SHIZUKU and ACCESSIBILITY modes 2. Removed early return in initializeAccessibilityComponents() - now initializes components regardless of immediate service connection 3. Added permission check in startTask() that verifies device controller is ready before execution 4. Added deviceControllerInstance property to ComponentManager for permission checking 5. Modified onServiceConnected() to only initialize Shizuku components when in SHIZUKU mode 6. Added informative toast messages when permissions are not granted **Testing:** Users can now: 1. Switch from Shizuku to Accessibility mode in settings 2. Start tasks once Accessibility Service is enabled 3. Receive clear error messages if permissions are not granted # Conflicts: # app/src/main/java/com/kevinluo/autoglm/ComponentManager.kt # app/src/main/java/com/kevinluo/autoglm/MainActivity.kt
**Problem:** Start button was disabled in accessibility mode because: 1. isServiceConnected only checked userService != null 2. In accessibility mode, userService is never set 3. Components weren't initialized in onCreate() for accessibility mode 4. onResume() couldn't initialize because of circular dependency **Solution:** 1. Modified isServiceConnected to check mode-specific conditions: - SHIZUKU: checks userService != null - ACCESSIBILITY: checks _phoneAgent != null 2. Added initialization in onCreate() for accessibility mode 3. Simplified onResume() logic to always check for config changes 4. Added updateTaskButtonStates() call in onCreate() **Testing:** - Switch to accessibility mode in settings - Enable accessibility service - Start button should now be clickable
…for each mode
**Problem:**
In accessibility mode, ScreenshotService was still trying to use Shizuku's shell
commands instead of using AccessibilityDeviceController's captureScreen() method.
**Root Cause:**
Incorrect ScreenshotService constructor calls in both modes:
1. Accessibility mode:
OLD: ScreenshotService(stubUserService) { FloatingWindowService.getInstance() }
- userService = stubUserService (wrong, should be null)
- screenshotProvider = { FloatingWindowService.getInstance() } (wrong type, should call captureScreen())
- floatingWindowControllerProvider = default (missing)
2. Shizuku mode:
OLD: ScreenshotService(service) { FloatingWindowService.getInstance() }
- userService = service (correct)
- screenshotProvider = { FloatingWindowService.getInstance() } (wrong, should be null)
- floatingWindowControllerProvider = default (missing)
**Solution:**
Use named parameters with correct types:
1. Accessibility mode:
ScreenshotService(
userService = null,
screenshotProvider = { _deviceController!!.captureScreen() },
floatingWindowControllerProvider = { FloatingWindowService.getInstance() }
)
2. Shizuku mode:
ScreenshotService(
userService = service,
screenshotProvider = null,
floatingWindowControllerProvider = { FloatingWindowService.getInstance() }
)
Now:
- Accessibility mode uses AccessibilityDeviceController.captureScreen()
- Shizuku mode uses shell commands via userService
- Both modes properly hide/show floating window
- Improve accessibility screenshot quality for compatibility with lower Android versions - Add notification permission support - Optimize Shizuku mode screenshot handling by directly transferring chunked screenshots instead of writing to files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces Accessibility mode and completes its integration across
agent lifecycle, UI state, permissions, input method, and screenshot handling.
Key changes:
Result: