Add accessibility service screen lock method#52
Open
Xitee1 wants to merge 1 commit into
Open
Conversation
Extend the screen-lock options so the user can choose between device admin, a new accessibility-based soft lock, and Shizuku: - Replace the softScreenOff boolean with a ScreenLockMethod enum (DeviceAdmin / Accessibility / Shizuku) in UserSettings; the legacy soft_screen_off DataStore key is still read for migration. - Add LockAccessibilityService + AccessibilityLockHelper performing GLOBAL_ACTION_LOCK_SCREEN (API 28+). Like the Shizuku soft lock it behaves like the power button, keeping biometric unlock valid, but without requiring Shizuku. Falls back to the device-admin hard lock if the service is disabled. - Offer the new method in the lock-method dialog (hidden below API 28), guide the user to the system accessibility settings when the service is not yet enabled, and complete the selection on return. - Surface a disabled accessibility service in the settings row description and in the startup permission check. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BVJCKavSoLXsSkzQEzSSNf
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.
Summary
Introduces a new soft screen-lock method via Android's accessibility service (
GLOBAL_ACTION_LOCK_SCREEN), offering an alternative to Shizuku that doesn't require biometric unlock to be disabled. This provides users with a middle ground between the hard device-admin lock (which forces credential entry) and the Shizuku soft lock (which requires Shizuku to be installed and running).Key Changes
New
ScreenLockMethodenum (core:data) — replaces the booleansoftScreenOffwith three explicit lock methods:DeviceAdmin,Accessibility, andShizuku. Includes migration logic from the legacysoftScreenOffpreference.LockAccessibilityService(core:service) — a minimal accessibility service that exists solely to performGLOBAL_ACTION_LOCK_SCREENwhen the timer expires. Requires API 28+ and user opt-in via system accessibility settings.AccessibilityLockHelper(core:service) — queries whether the lock service is enabled in system settings and invokes the lock action. Falls back to device admin if the service is unavailable.Settings UI updates (
feature:timer):ScreenLockMethodDialognow presents three options: Device Admin, Accessibility (API 28+ only), and Shizuku.AccessibilityRequiredDialogguides users to enable the service in accessibility settings.Timer service logic (
core:service) — refactored screen-lock dispatch to use theScreenLockMethodenum, with appropriate fallback behavior (e.g., accessibility → device admin if the service is disabled).Startup permission checks (
feature:timer) — extended to detect missing accessibility service grant and prompt the user at timer start if needed.Manifest & resources:
LockAccessibilityServiceinAndroidManifest.xmlwith minimal accessibility config (no event types, no window-content access).Notable Implementation Details
BIND_ACCESSIBILITY_SERVICE(held by the system). It does not monitor any events or access window content.isServiceEnabled()queriesSettings.Secure.ENABLED_ACCESSIBILITY_SERVICESrather than checking if the instance is bound, because the settings row is the authoritative grant and is queryable immediately after the user returns from settings.ON_RESUME, the settings screen re-queries both device-admin and accessibility-service grants (which can be revoked from system settings without app notification) and completes any pending accessibility-method selection if the user enabled the service while away.softScreenOffon first read.https://claude.ai/code/session_01BVJCKavSoLXsSkzQEzSSNf