Bawn is a high-performance, privacy fortress for Android, built with modern security protocols and Jetpack Compose. It serves as a secure overlay "fortress," intercepting unauthorized access to your selected applications with biometric or PIN verification.
"Bawn" (noun): A defensive wall or fortified enclosure.
- โก Zero-Latency Locking: Optimized overlay engine (
windowAnimationStyle="@null",taskAffinity="") ensures the lock screen appears almost instantly, minimizing the "flicker" common in Accessibility-based lockers. - ๐ Secure PIN & Biometrics:
- Database-Backed Security: PINs are hashed (SHA-256) and stored securely in a local Room Database.
- Biometric Auth: Native integration with Android's
BiometricPromptAPI (Fingerprint, Face Unlock). - Intelligent Routing: The app automatically detects fresh installs and forces users to establish a master PIN before accessing the dashboard.
- ๐ Smart Session Management: "Unlock once, stay unlocked." The intelligent session manager keeps an app unlocked until the device screen turns off, preventing annoying repetitive lock screens.
- ๐ Sideload Protection (Android 13+): Includes a sophisticated detection system for "Restricted Settings," guiding users through the complex permissions flow required for manually installed (sideloaded) accessibility tools on modern Android.
- ๐จ Modern UI: Built 100% with Jetpack Compose, featuring a dark-themed, neon-accented aesthetic (Basalt Grey & Neon Moss).
- ๐ต๏ธ Privacy First:
- Offline-only architecture (No internet permission).
FLAG_SECUREenabled on lock screens to prevent screenshots or Recents screen peeking.- Strict privacy: No data leaves the device.
Bawn is built using Clean Architecture principles and the MVVM (Model-View-ViewModel) pattern.
- Language: Kotlin
- UI Framework: Jetpack Compose (Material3)
- Database: Room (SQLite abstraction)
- Asynchronicity: Coroutines & Flow
- Security:
androidx.biometric, SHA-256 Hashing - Dependency Injection: Manual DI (via
ViewModelFactoryfor lightweight efficiency).
-
BawnAccessibilityService(The Watchman):- The heart of the app. It listens for
TYPE_WINDOW_STATE_CHANGEDevents. - Checks the foreground package against the
LockedAppDao. - Triggers the
LockScreenActivityif a match is found and no active session exists.
- The heart of the app. It listens for
-
BawnApplication(The Overseer):- Manages app-wide lifecycle events.
- Enforces a "Self-Lock" mechanism: If the user leaves Bawn for more than 30 seconds, they must re-authenticate.
-
LockScreenActivity(The Shield):- A specialized
FragmentActivity(required for Biometrics). - Configured with
launchMode="singleInstance"andtaskAffinity=""to detach it from the main app stack for speed. - Disables screenshotting via
FLAG_SECURE.
- A specialized
- Android Studio Ladybug (or newer) recommended.
- Min SDK: 26 (Android 8.0)
- Target SDK: 36 (Android 16)
- Install & Open: Upon first launch, Bawn detects that no PIN is set.
- Auto-Routing: You are immediately redirected to the Set PIN screen.
- Setup: Create and confirm a 4-digit PIN.
- Dashboard: Once secured, the app allows access to the main dashboard.
If you install the app via USB Debugging (Android Studio), Android considers it a "Test" installation and will not trigger the "Restricted Setting" block.
To test the Sideload Protection flow:
- Generate a Signed Release APK (
Build > Generate Signed Bundle / APK). - Uninstall the debug version from your phone.
- Transfer the
app-release.apkto your phone. - Install it manually via your File Manager.
- You will now see the Red "Restricted" card in the app.
Accessibility Services are reactive. The OS launches the target app first, then tells Bawn "App X just opened." Bawn then launches the lock screen on top.
- Optimization: We mitigate this by removing window animations (
@null) and usingFLAG_ACTIVITY_NO_ANIMATION. - Alternative: "Window Manager" overlays are faster (20ms vs 200ms) but suffer from severe keyboard handling issues and back-stack bugs. The Activity-based approach is chosen for stability.
The app uses two different image assets:
- Launcher Icon: An Adaptive Icon (
mipmap/ic_launcher) complying with Android standards (background + foreground layers). - In-App Logo: A standalone PNG (
drawable/logo_bawn_gold.png) used in the Compose UI, aspainterResourcecannot render adaptive XML icons directly.
Crucial: The LockScreenActivity must inherit from FragmentActivity, not ComponentActivity. The androidx.biometric library relies on Fragment support managers to display the system-level fingerprint dialog.
app/src/main/java/app/bawn/
โ
โโโ ๐ data/
โ โโโ AppDatabase.kt โ Room Database instance
โ โโโ LockedAppDao.kt โ Data Access Object for locked apps
โ โโโ LockedAppEntity.kt โ Database table schema
โ โโโ UserSecurityDao.kt โ DAO for PIN/Auth data
โ โโโ UserSecurityEntity.kt โ Schema for PIN hash storage
โ
โโโ โ๏ธ service/
โ โโโ BawnAccessibilityService.kt โ Core event listener (The Watchman)
โ โโโ SessionManager.kt โ Unlock state management
โ
โโโ ๐จ ui/
โ โโโ theme/
โ โ โโโ Color.kt โ Basalt Grey & Neon Moss palette
โ โ โโโ Theme.kt โ Material3 theme configuration
โ โ โโโ Type.kt โ Typography definitions
โ โ
โ โโโ AppListViewModel.kt โ State management for app list
โ โโโ LockScreenActivity.kt โ PIN/Biometric lock screen
โ โโโ LockScreenContent.kt โ Reusable lock UI components
โ โโโ MainActivity.kt โ Dashboard & configuration
โ โโโ SetPinActivity.kt โ Initial PIN setup flow
โ โโโ RestrictedHelpDialog.kt โ Android 13+ permission guide
โ
โโโ ๐ ๏ธ util/
โโโ RestrictionHelper.kt โ Android 13+ restriction detection
โโโ SecurityUtils.kt โ PIN hashing & validation (SHA-256)
- Intruder Selfie: Capture a photo using the front camera after 3 failed PIN attempts
- Break-in Alerts: Email/notification when someone fails authentication multiple times
- Fake Crash Screen: Show a "Force Close" dialog instead of lock screen to deceive intruders
- Decoy Mode: Show fake empty app content instead of lock screen
- Panic Button: Quick gesture to instantly lock all apps and clear recent sessions
- Stealth Mode: Hide Bawn from app drawer and launcher
- Pattern Lock: Add 3x3 or 4x4 pattern grid as alternative to PIN
- Custom Themes: Multiple color schemes (Gold, Neon Blue, Red, Purple, Minimal White)
- Lock Screen Customization: Custom messages, wallpapers, or branding on lock screen
- Widget Support: Quick lock/unlock widget for home screen
- Dark/Light Mode: Toggle between dark and light theme variations
- Usage Statistics: Track how many times each app was locked/unlocked
- Time-based Locking: Auto-lock specific apps during work hours or bedtime
- Location-based Unlocking: Auto-unlock apps when at trusted locations (home, office)
- App Groups: Lock multiple apps with one toggle (Social Media, Banking, etc.)
- Guest Mode: Temporary access to selected apps without unlocking others
- Child Lock Profile: Separate profile with parental controls and time limits
- Backup & Restore: Export/import locked app configurations
- Cloud Sync: Sync settings across multiple devices (optional, privacy-conscious)
- Recommended Apps: Smart suggestions for apps that should be locked
- Quick Actions: Lock/unlock apps directly from notification shade
- Batch Operations: Lock/unlock multiple apps simultaneously
- Screenshot Detection: Alert when someone tries to screenshot lock screen
- Uninstall Protection: Require authentication before uninstalling Bawn
- Notification Privacy: Hide notification content for locked apps
- Fingerprint Limit: Allow only specific enrolled fingerprints
- Two-Factor Lock: Require both biometric AND PIN for sensitive apps
- Auto-lock on USB Debug: Detect developer mode and enforce extra security
- AI-Powered Locking: Learn usage patterns and suggest apps to lock
- Context-Aware Security: Adjust security level based on WiFi network or Bluetooth devices
- Voice Command Support: "Hey Google, lock my banking apps"
- Tasker Integration: Automation support for power users
- Shake to Lock: Lock all apps with device shake gesture
- Wear OS Support: Unlock apps from smartwatch
- Remote Lock: Lock/unlock apps from web dashboard or another device
- Family Sharing: Parent can manage locks on children's devices
- Enterprise Mode: MDM integration for corporate device management
- Honeypot Apps: Fake versions of locked apps that log intrusion attempts
- Geofencing Alerts: Notify if locked apps accessed outside safe zones
- Behavioral Analysis: Detect unusual unlock patterns and trigger extra verification
- Duress PIN: Special PIN that appears to unlock but secretly alerts trusted contacts
Copyright ยฉ 2025 Bawn Security. All Rights Reserved.
This project is licensed under the MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.