Lock your phone. Lock in your focus.
FocusLock is a minimalist Android "digital lockbox" app. Set a timer, and your phone becomes a black screen with only a countdown — you can't exit, switch apps, or doom-scroll. When the timer ends, it vibrates and unlocks automatically. Perfect for studying, deep work, and breaking phone addiction.
- Hard lock — intercepts Back / Home / Recents / app-switching / recents-gestures during a focus session. Watches window-layer changes (so gesture-nav "swipe up and hold" can't slip through), closes the Overview screen and yanks you back to the focus screen; if you swipe the app away from Recents, it relaunches instantly. Only a reboot gets you out.
- Notification bar stays usable — read and reply to messages while locked. Incoming calls always work.
- 🍅 Pomodoro mode — work → short break → work… auto-looping, with a long break every 4 rounds. Breaks unlock automatically.
- 📊 Stats — a calendar heatmap of daily focus time, a 14-day bar chart, and streaks.
- Whitelist — pick the apps you're still allowed to open (e.g. WeChat).
- Backup & restore — an offline "recovery code" bundles your whitelist, history, settings, and Pro license so you can restore everything after reinstalling or switching devices.
- Pro upgrade — one-time purchase unlocks Pomodoro, full stats, and unlimited whitelist. Device-bound activation code.
- End reminders — multi-burst vibration + sound + notification when a session / stage finishes.
| Feature | Free | Pro |
|---|---|---|
| Black-screen focus lock | ✅ | ✅ |
| Whitelist | up to 3 apps | unlimited |
| 🍅 Pomodoro loops | ❌ | ✅ |
| 📊 Full stats | ❌ | ✅ |
- Kotlin + Jetpack Compose (Material 3)
- 100% offline — no network permission, no data leaves the device
minSdk 26(Android 8.0+) ·targetSdk 35- No third-party runtime dependencies
🇨🇳 中文说明见 README_zh.md
Requirements: JDK 17 + Android SDK (platform 35, build-tools 35).
# clone
git clone https://github.com/<your-name>/focuslock.git
cd focuslock
# build debug APK (no signing config needed)
./gradlew assembleDebug
# build signed release APK — first create keystore.properties in the project root:
# storeFile=keystore/release.keystore
# storePassword=YOUR_PASSWORD
# keyAlias=focuslock
# keyPassword=YOUR_PASSWORD
./gradlew assembleReleaseOutput APKs are under app/build/outputs/apk/.
Android won't let a normal app fully trap the user, so FocusLock stacks four layers:
- Accessibility Service — swallows Back / Recents keys, and watches both
WINDOW_STATE_CHANGEDandWINDOWS_CHANGEDevents. Gesture-nav's "swipe up and hold" opens Overview without a key event, so the window-layer listener is what catches it. - Recents / launcher interception — when the Overview screen appears, the service closes it and relaunches the focus screen; the Launcher (home) is not whitelisted, so pressing Home bounces straight back.
- Task-removal recovery — if you swipe the app away from Recents, the foreground service (
START_STICKY) notices viaonTaskRemovedand pulls the focus screen back immediately. - Screen Pinning (
startLockTask) — with the system's Screen pinning switch on, Android itself disables Home and the recents gesture: the strongest layer. The app shows a warning (and a shortcut) when that system switch is off.
Plus: Foreground Service + WakeLock keeps the countdown accurate with the screen off and fires vibration/sound at the end.
⚠️ Honest limit: rebooting, force-stopping, oradb uninstallcan always bypass any app. A 100%-kiosk lock needs Device Owner mode (a separate provisioning setup).
Settings → Data backup → generate a recovery code (copy it to your notes / cloud). After reinstalling or on a new phone, paste the code to restore your whitelist, history, settings, and Pro license.
See SELLER-GUIDE.md (Chinese) for the full selling guide: pricing, activation-code flow, and buyer-facing scripts.
MIT — free to use, modify, and learn from.



