How TouchFree Works
TouchFree is a free Android 15+ screen touch lock app built on six cooperating components: a WindowManager overlay, an AccessibilityService, a foreground service, a boot receiver, a WorkManager watchdog, and a screen-state receiver for brick safety. This page explains each piece, the permission it needs, and how the whole system stays alive across reboots, screen-offs, and Android version updates.
Architecture at a glance
TouchFree's lock is not a single overlay. It is a defense-in-depth stack where each layer handles one kind of user input:
| Layer | Component | Blocks |
|---|---|---|
| Touch | WindowManager overlay (TYPE_APPLICATION_OVERLAY) | Taps, swipes, gestures on screen |
| Hardware keys | AccessibilityService (onKeyEvent) | Volume up, volume down |
| Navigation | AccessibilityService + transparent LockScreenActivity | Home, back, recent, edge swipe |
| Notifications | TYPE_ACCESSIBILITY_OVERLAY strip + GLOBAL_ACTION_DISMISS | Notification panel pull-down |
| Persistence | Foreground Service + WorkManager (15 min) | Keeps lock alive if OS tries to kill |
| Boot | BroadcastReceiver (BOOT_COMPLETED) | Re-arms lock after reboot |
| Unlock | BiometricPrompt + SHA-256 PIN | Owner-only unlock |
1. The touchscreen overlay
When you tap Lock, TouchFree asks WindowManager to add a full-screen window with flag TYPE_APPLICATION_OVERLAY. The overlay is transparent, draws nothing, and absorbs every MotionEvent. The app underneath — YouTube, Netflix, any game — keeps receiving power and rendering frames normally because TouchFree only consumes input, not CPU or GPU.
This is the mechanism that lets videos keep playing while the touchscreen is locked. Other lock apps often pause the underlying app or force-close it; TouchFree does neither.
Permission: SYSTEM_ALERT_WINDOW (Draw over other apps). Android 15 shows a dedicated settings screen for this; TouchFree guides you there on first run with a step-wizard.
2. AccessibilityService for system inputs
Volume keys, home buttons, and notification-panel dismissal are reserved by Android for apps declared as AccessibilityService. TouchFree declares one — ScreenLockAccessibilityService — that does only input blocking. No content scraping, no text capture, no external communication.
What the AccessibilityService does
- onKeyEvent intercepts
KEYCODE_VOLUME_UPandKEYCODE_VOLUME_DOWNand returnstrueto consume them. - TYPE_ACCESSIBILITY_OVERLAY strip at the top of the screen blocks notification shade pull-down.
GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADEis a fallback for devices that still leak the gesture. - Edge swipe interception uses a transparent
LockScreenActivitylayered under the overlay, withOnBackInvokedCallbackregistered so that Android 15 gesture navigation cannot return to the launcher.
Permission: BIND_ACCESSIBILITY_SERVICE. Granted in system Settings → Accessibility → Installed apps → TouchFree. TouchFree shows a consent dialog explaining why, and you can revoke at any time.
3. Foreground service and watchdog
Android aggressively kills background processes to save battery. To keep the lock reliable, TouchFree runs a Foreground Service with a persistent notification (ForegroundService type: specialUse). A WorkManager watchdog re-checks the service every 15 minutes and relaunches it if the OS killed it.
The persistent notification is silent and shows only minimal text ("TouchFree is ready"). It has no unlock action — lock can only be toggled from the Quick Settings tile, the floating button, or the main app, so notification access cannot bypass PIN security.
4. Brick safety — the most important rule
This is the single rule that sets TouchFree apart from every other touch lock app on Google Play.
The problem. If an overlay app is still consuming input when the screen sleeps and then wakes, the user can be locked out of their own device. This is how users "brick" their phones with touch lock apps, and it is one of the top one-star review causes across the category.
TouchFree solves this at the architecture level, not as an afterthought:
Intent.ACTION_SCREEN_OFF as a runtime BroadcastReceiver.ACTION_SCREEN_OFF, OverlayService.onScreenOff() runs synchronously on the main thread.FLAG_NOT_TOUCHABLE via WindowManager.updateViewLayout().handler.removeCallbacks() so a delayed re-lock cannot fire on a sleeping phone.Outcome: TouchFree has zero reports of device-bricking in the current build. This is a hard invariant enforced by both code review and project rules — it is documented in the project's CLAUDE.md as "절대 규칙 (absolute rule)".
5. PIN and fingerprint unlock
PIN entry is a dedicated overlay window that collects digits, hashes with SHA-256, and compares against the stored hash. The PIN is 4 or 6 digits, set during first-run. Failed attempts shake the input field; after n failures (configurable 3–18) the PIN field auto-resets to prevent brute-forcing by a child pressing keys.
Fingerprint unlock is optional and routes through BiometricPrompt, Android's official API. TouchFree never sees the biometric data — Android OS handles the match internally and returns only success or failure. Fingerprint is a convenience; PIN is the always-available fallback.
6. Boot persistence
A BroadcastReceiver listens for BOOT_COMPLETED and QUICKBOOT_POWERON (the latter is a HTC/Samsung fast-boot extension). On boot, the receiver restarts the foreground service and re-registers the screen-state receiver so TouchFree is ready the instant the home screen appears.
The boot receiver is declared with android:exported="true" and RECEIVER_EXPORTED at runtime registration, because Android 13+ blocks implicit intents to non-exported receivers. This was a live bug in an earlier build, fixed and documented in the project's TASK log.
7. Permission reference
| Permission | Why it is needed |
|---|---|
SYSTEM_ALERT_WINDOW | Draw the touch-blocking overlay over other apps. |
BIND_ACCESSIBILITY_SERVICE | Block volume keys, home/back/recent, edge swipe, notification shade. |
FOREGROUND_SERVICE + specialUse | Keep the lock alive when the app is backgrounded. |
RECEIVE_BOOT_COMPLETED | Re-arm the lock after a reboot. |
POST_NOTIFICATIONS | Show the foreground-service persistent notification (Android 13+ required). |
USE_BIOMETRIC | Offer fingerprint unlock via BiometricPrompt (optional). |
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS | Prevent Doze from killing the service during long video sessions. |
References
- Android —
TYPE_APPLICATION_OVERLAY - Android —
AccessibilityService - AndroidX —
BiometricPrompt - AndroidX —
WorkManager - Android — Foreground services
Back to TouchFree home, the FAQ, or the comparison with other Android touch lock apps.