How chainfire/holeylight works
Purpose and Build Shape
Holey Light is a native Android LED-emulation app for punch-hole displays. It renders notification animations around the camera cutout or a low-power “Unholey Light” screen-off display, with Samsung and selected Pixel behavior. The Gradle root builds two Android packages: the primary app (app/build.gradle) and an optional AOD helper (helper/build.gradle).
Android Entry Points
The main process is initialized by app/src/main/java/eu/chainfire/holeylight/Application.java and declared components reside in app/src/main/AndroidManifest.xml. User configuration and setup begin in app/src/main/java/eu/chainfire/holeylight/ui/MainActivity.java; dedicated activities tune color and cutout geometry. Runtime operation is driven primarily by Android notification and accessibility service callbacks rather than a server or web request loop.
Notification Intake and State Decisions
app/src/main/java/eu/chainfire/holeylight/service/NotificationListenerService.java receives system notification lifecycle events. app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java maintains actionable notification state and determines what should display. app/src/main/java/eu/chainfire/holeylight/service/AccessibilityService.java supplies screen/UI-state signals that are not available through notification APIs alone. This is the central boundary with Android’s privileged notification and accessibility frameworks.
Policy, Device, and Power Context
Rendering eligibility is derived from persisted app policy plus live device state. app/src/main/java/eu/chainfire/holeylight/misc/Settings.java holds configuration, while app/src/main/java/eu/chainfire/holeylight/misc/Battery.java and app/src/main/java/eu/chainfire/holeylight/misc/Display.java provide power/display context. app/src/main/java/eu/chainfire/holeylight/misc/AODControl.java mediates Always-On Display interactions, including supported vendor-specific control paths. Alarm and package-replacement receivers restore or reschedule behavior across timing and app-update boundaries.
Geometry and Vendor Adaptation
Camera-hole placement is abstracted behind app/src/main/java/eu/chainfire/holeylight/service/area/AreaFinder.java. Device-specific implementations—AreaFinderSamsung.java, AreaFinderSamsung13.java, and AreaFinderGoogle.java—resolve usable render regions from differing System UI/device conventions. Supporting display, fold, resolution, and cutout utilities compensate for device geometry and configuration changes. Local copies of System UI-related classes under app/src/main/java/com/android/systemui/ support this vendor integration boundary.
Rendering Pipeline
Once tracker and policy choose an active notification/display mode, the animation subsystem creates an overlay and plays the selected visual effect. app/src/main/java/eu/chainfire/holeylight/animation/Overlay.java owns the display surface; NotificationAnimation.java represents notification-driven effects; SpritePlayer.java and SpriteSheet.java support sprite rendering. JSON animation manipulation is isolated in JSONAnimationManipulator.java. The pipeline consumes notification color/configuration and resolved geometry, then renders independently of the settings UI.
UI and Calibration
app/src/main/java/eu/chainfire/holeylight/ui/SettingsFragment.java exposes persistent behavior controls. DetectCutoutActivity.java and TuneActivity.java let users establish or correct device-specific placement; ColorActivity.java configures notification coloring. These screens write configuration and invoke test/display behavior, but ongoing presentation is service-controlled.
Companion AOD Helper
The separately installed helper package exposes helper/src/main/java/eu/chainfire/holeylight/aodhelper/AODReceiver.java. The primary app’s AOD control layer can use this package as an external capability for lower-power/vendor-specific AOD operation. Its APK is distributed separately under apks/, making helper installation/version compatibility an explicit deployment boundary.
Main entry points: NotificationTracker.java Notification tracker · Settings.java Persistent policy · NotificationAnimation.java Notification effects · AndroidManifest.xml Component declarations
Components 18
Primary Android app
- Application bootstrap
app/src/main/java/eu/chainfire/holeylight/Application.java - Component declarations
app/src/main/AndroidManifest.xml - Setup entry point
app/src/main/java/eu/chainfire/holeylight/ui/MainActivity.java - Settings controls
app/src/main/java/eu/chainfire/holeylight/ui/SettingsFragment.java - Cutout and color tuning · DetectCutoutActivity, TuneActivity, and ColorActivity calibrate placement and color.
app/src/main/java/eu/chainfire/holeylight/ui/DetectCutoutActivity.java - Persistent policy
app/src/main/java/eu/chainfire/holeylight/misc/Settings.java
Runtime services
- Notification listener
app/src/main/java/eu/chainfire/holeylight/service/NotificationListenerService.java - UI state signals
app/src/main/java/eu/chainfire/holeylight/service/AccessibilityService.java - Notification tracker · Maintains actionable notifications and selects what should display.
app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java - Power and display context · Battery and display state determine rendering eligibility.
app/src/main/java/eu/chainfire/holeylight/misc/Battery.java - AOD control
app/src/main/java/eu/chainfire/holeylight/misc/AODControl.java - Cutout geometry resolver · Selects Samsung, Samsung 13, or Google area-finding behavior.
app/src/main/java/eu/chainfire/holeylight/service/area/AreaFinder.java
Rendering pipeline
- Overlay surface
app/src/main/java/eu/chainfire/holeylight/animation/Overlay.java - Notification effects
app/src/main/java/eu/chainfire/holeylight/animation/NotificationAnimation.java - Sprite renderer · SpritePlayer and SpriteSheet render selected effects.
app/src/main/java/eu/chainfire/holeylight/animation/SpritePlayer.java - JSON animation processing
app/src/main/java/eu/chainfire/holeylight/animation/JSONAnimationManipulator.java
Optional AOD helper
- External AOD receiver · Separately installed helper supplies optional low-power vendor AOD capability.
helper/src/main/java/eu/chainfire/holeylight/aodhelper/AODReceiver.java
Other components
- Android system APIs · Privileged notification, accessibility, display, and AOD integration boundary.
Connections 22
- Component declarations → Application bootstrap: launches
- Component declarations → Notification listener: declares
- Component declarations → UI state signals: declares
- Setup entry point → Settings controls: hosts
- Settings controls → Persistent policy: writes
- Cutout and color tuning → Persistent policy: stores calibration
- Android system APIs → Notification listener: notification events
- Android system APIs → UI state signals: UI state events
- Notification listener → Notification tracker: lifecycle updates
- UI state signals → Notification tracker: screen context
- Persistent policy → Notification tracker: display policy
- Power and display context → Notification tracker: power/display state
- Notification tracker → AOD control: screen-off mode
- Notification tracker → Notification effects: active effect
- Persistent policy → Notification effects: colors and effect config
- Cutout geometry resolver → Overlay surface: render region
- Notification effects → Sprite renderer: plays
- JSON animation processing → Notification effects: transforms assets
- Sprite renderer → Overlay surface: draws
- AOD control → Android system APIs: AOD operations
- AOD control → External AOD receiver: optional capability
- External AOD receiver → Android system APIs: vendor AOD access