Overlay Guard is a high-performance system utility designed to bring the advanced privacy features of the 2026 Galaxy S26 Ultra to Android 13+ devices. By leveraging real-time sensor fusion and the WindowManager API, this app simulates a "software-defined" hardware privacy screen.
| Key | Value |
|---|---|
| Package | com.moclg.overlayguard |
| Target SDK | 35 (Android 15) |
| Min SDK | 33 (Android 13) |
| Language | Kotlin |
| Build System | Gradle 9.3.1 / AGP 8.7.3, Kotlin DSL |
| UI | Jetpack Compose (Material 3) |
| Target Device | Rooted Samsung Note 20 Ultra (custom kernel) |
- Uses
WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAYto draw a blackViewover the status bar. - Flags:
FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCHABLE | FLAG_LAYOUT_IN_SCREEN— the overlay covers the notch/status bar without intercepting touch events. LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYSto cover display cutouts/notches.- Sets
PRIVATE_FLAG_IS_SCREEN_DECORvia reflection for elevated z-order on supported devices. - Overlay height (default 150 px) and roll threshold are stored in
SharedPreferencesand updated at runtime. - Supports pause / resume — toggling off stops the sensor and overlay without unregistering the accessibility service, so no re-enablement is needed.
- DND toggle — enables Do Not Disturb (ALARMS-only) via
NotificationManagerAPI when the overlay is active; restores on deactivation. - Root DND fallback — also sets
heads_up_notifications_enabled,zen_mode, andcmd notification set_dndvia root. - Heads-up swipe dismissal — Samsung One UI renders heads-up notification (HUN) windows above
TYPE_ACCESSIBILITY_OVERLAY. OnTYPE_NOTIFICATION_STATE_CHANGEDevents while the overlay is active:- With root:
PersistentRootShellexecutesinput swipefor zero-latency physical dismissal. - Without root:
AccessibilityService.dispatchGesture()simulates the same upward swipe.
- With root:
- DND access is auto-granted via root on launch (
cmd notification allow_dnd).
- Registers
Sensor.TYPE_ROTATION_VECTORatSENSOR_DELAY_UI. - Derives a 3×3 rotation matrix via
SensorManager.getRotationMatrixFromVector. - Extracts orientation angles via
SensorManager.getOrientation; index 2 = roll (radians → degrees). - Trigger logic:
|roll| > threshold ⟹ α = 1.0; otherwiseα = 0.0.
- Start / Stop Toggle — on rooted devices, automatically runs
settings putcommands viasu; on non-rooted devices:- If service is already enabled, pauses/resumes without opening settings.
- Only opens
ACTION_ACCESSIBILITY_SETTINGSwhen the service needs initial enablement.
- Height Slider — adjusts overlay height from 50 px to 500 px.
- Sensitivity Slider — adjusts roll threshold from 10° to 45°.
- Status card — shows green "Running without root" when active, or yellow "Root not detected" with setup instructions when inactive.
- Detects root by checking for
subinary paths (Magisk, KernelSU, legacy). RootHelperexecutes commands via interactivesustdin (ProcessBuilder) — more compatible with Magisk/KernelSU thanRuntime.exec(arrayOf("su", "-c", ...)).PersistentRootShellkeeps a singlesuprocess alive for the service lifetime — commands are written to stdin with zero process-spawn overhead.
Starting with Android 13, sideloaded apps are blocked from enabling accessibility services. To bypass:
- Go to Settings → Apps → Overlay Guard → ⋮ (three-dot menu).
- Tap "Allow Restricted Settings".
- Authenticate with your PIN / biometric.
- Now navigate to Settings → Accessibility → Overlay Guard and enable the service.
On rooted devices this step is unnecessary — the root toggle writes the settings directly.
# Requires JDK 17 — gradle.properties pins org.gradle.java.home
./gradlew clean assembleDebug
# Install on device
adb install -r app/build/outputs/apk/debug/app-debug.apkOr download and install an apk file from release section.
All commits must be signed off:
git commit -s -m "type: description"Types: feat, fix, docs, refactor, chore.
Proprietary — all rights reserved.