Skip to content

Add accessibility service screen lock method#52

Open
Xitee1 wants to merge 1 commit into
mainfrom
claude/screen-lock-accessibility-options-penku3
Open

Add accessibility service screen lock method#52
Xitee1 wants to merge 1 commit into
mainfrom
claude/screen-lock-accessibility-options-penku3

Conversation

@Xitee1

@Xitee1 Xitee1 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

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 ScreenLockMethod enum (core:data) — replaces the boolean softScreenOff with three explicit lock methods: DeviceAdmin, Accessibility, and Shizuku. Includes migration logic from the legacy softScreenOff preference.

  • LockAccessibilityService (core:service) — a minimal accessibility service that exists solely to perform GLOBAL_ACTION_LOCK_SCREEN when 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):

    • ScreenLockMethodDialog now presents three options: Device Admin, Accessibility (API 28+ only), and Shizuku.
    • New AccessibilityRequiredDialog guides users to enable the service in accessibility settings.
    • Settings screen shows the active lock method and handles the case where the accessibility service is revoked after selection.
  • Timer service logic (core:service) — refactored screen-lock dispatch to use the ScreenLockMethod enum, 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:

    • Registered LockAccessibilityService in AndroidManifest.xml with minimal accessibility config (no event types, no window-content access).
    • Added string resources for the new method in both English and German.

Notable Implementation Details

  • The accessibility service is intentionally minimal and requests no permissions beyond BIND_ACCESSIBILITY_SERVICE (held by the system). It does not monitor any events or access window content.
  • isServiceEnabled() queries Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES rather 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 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.
  • The lock method selection is persisted as a string preference and migrated from the legacy boolean softScreenOff on first read.

https://claude.ai/code/session_01BVJCKavSoLXsSkzQEzSSNf

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants