Repository navigation
Case Popup & Overlay System
The case-open proximity card is one of the most recognizable features of AirPods on iOS. When the charging case lid opens near an Android device, iNA detects the BLE advertising frame within 200ms and presents a modal bottom sheet.
Android has strict background activity start restrictions (introduced in Android 10 and expanded through Android 15). To present an instant popup over any running app or home screen without breaking OS security policies:
-
System Overlay Window (
TYPE_APPLICATION_OVERLAY):- When the user grants the "Draw over other apps" (
SYSTEM_ALERT_WINDOW) permission, iNA displays the popup as an overlay window viaWindowManager. - Advantages: Renders smoothly over any foreground application or lock screen without interrupting the user's active task.
- When the user grants the "Draw over other apps" (
-
Translucent Activity Fallback:
- If overlay permission has not been granted, iNA launches a translucent
Activity(CasePopupOverlayActivity.kt) with an animated Compose bottom sheet.
- If overlay permission has not been granted, iNA launches a translucent
-
High-Priority Heads-Up Notification:
- If background activity launching is blocked by OEM battery restrictions,
IBridgeForegroundServiceimmediately displays a high-priority heads-up status card with battery levels and a tap-to-expand action.
- If background activity launching is blocked by OEM battery restrictions,
Repeatedly opening and closing the lid or leaving the case open next to your phone should not continuously re-trigger intrusive popups.
iNA implements a dedicated state-machine gate (CasePopupGate.kt, verified by CasePopupGateTest.kt):
Case Lid Opens (Byte 8 Bit 3 == 1)
│
▼
Is Popup Already Active?
├── YES ──► Ignore (Update battery percentages only)
└── NO ──► Has User Dismissed Current Session?
├── YES ──► Snooze until lid is seen closed
└── NO ──► Display Case-Open Bottom Sheet
- Snooze Mechanism: Once the user taps outside the popup or presses dismiss, no further popups are shown until the case lid is confirmed closed (or the Bluetooth frame goes silent for > 60 seconds).
- Lid Close Auto-Dismiss: When the user closes the lid, the bottom sheet gracefully animates closed automatically.
To ensure the sheet matches the buttery-smooth 120Hz ProMotion animation of iOS:
- Windows invoke
HighRefreshRate.apply(window). - Inspects
display.supportedModesto request the maximum available refresh rate from the panel (e.g., 90Hz, 120Hz, or 144Hz on Samsung, OnePlus, Xiaomi, and Pixel devices).
iNA is an independent, community-driven, open-source software project licensed under the MIT License.
Apple, AirPods, AirPods Pro, AirPods Max, Apple Watch, AirTag, HomePod, and Beats are registered trademarks of Apple Inc. This software is not affiliated with, sponsored by, or endorsed by Apple Inc.