# chainfire/holeylight architecture

> Architecture diagram of the GitHub repository chainfire/holeylight, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chainfire/holeylight
- Repository: https://github.com/chainfire/holeylight

## Overview

#### 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: [`app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java`](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java) (Notification tracker), [`app/src/main/java/eu/chainfire/holeylight/misc/Settings.java`](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/Settings.java) (Persistent policy), [`app/src/main/java/eu/chainfire/holeylight/animation/NotificationAnimation.java`](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/NotificationAnimation.java) (Notification effects), [`app/src/main/AndroidManifest.xml`](https://github.com/chainfire/holeylight/blob/master/app/src/main/AndroidManifest.xml) (Component declarations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_main["Primary Android app"]
  node_application["Application bootstrap<br/>Android application<br/>[Application.java]"]
  node_manifest["Component declarations<br/>Android manifest"]
  node_main_activity["Setup entry point<br/>activity<br/>[MainActivity.java]"]
  node_settings_ui["Settings controls<br/>fragment"]
  node_calibration["Cutout and color tuning<br/>activities"]
  node_settings[("Persistent policy<br/>settings store<br/>[Settings.java]")]
end

subgraph group_runtime["Runtime services"]
  node_notification_listener["Notification listener<br/>notification service"]
  node_accessibility["UI state signals<br/>accessibility service"]
  node_tracker["Notification tracker<br/>state and decision engine"]
  node_device_context["Power and display context<br/>device state<br/>[Battery.java]"]
  node_aod_control["AOD control<br/>vendor power integration<br/>[AODControl.java]"]
  node_area_finder["Cutout geometry resolver<br/>device adapter<br/>[AreaFinder.java]"]
end

subgraph group_rendering["Rendering pipeline"]
  node_overlay["Overlay surface<br/>render surface<br/>[Overlay.java]"]
  node_notification_animation["Notification effects<br/>animation model"]
  node_sprite_renderer["Sprite renderer<br/>animation playback<br/>[SpritePlayer.java]"]
  node_json_animation["JSON animation processing<br/>animation transform"]
end

subgraph group_helper["Optional AOD helper"]
  node_aod_helper["External AOD receiver<br/>companion Android package<br/>[AODReceiver.java]"]
end

node_android{{"Android system APIs<br/>platform boundary"}}

node_manifest -->|"launches"| node_application
node_manifest -->|"declares"| node_notification_listener
node_manifest -->|"declares"| node_accessibility
node_main_activity -->|"hosts"| node_settings_ui
node_settings_ui -->|"writes"| node_settings
node_calibration -->|"stores calibration"| node_settings
node_android -->|"notification events"| node_notification_listener
node_android -->|"UI state events"| node_accessibility
node_notification_listener -->|"lifecycle updates"| node_tracker
node_accessibility -->|"screen context"| node_tracker
node_settings -->|"display policy"| node_tracker
node_device_context -->|"power/display state"| node_tracker
node_tracker -->|"screen-off mode"| node_aod_control
node_tracker -->|"active effect"| node_notification_animation
node_settings -->|"colors and effect config"| node_notification_animation
node_area_finder -->|"render region"| node_overlay
node_notification_animation -->|"plays"| node_sprite_renderer
node_json_animation -->|"transforms assets"| node_notification_animation
node_sprite_renderer -->|"draws"| node_overlay
node_aod_control -->|"AOD operations"| node_android
node_aod_control -.->|"optional capability"| node_aod_helper
node_aod_helper -->|"vendor AOD access"| node_android

click node_application "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/Application.java"
click node_manifest "https://github.com/chainfire/holeylight/blob/master/app/src/main/AndroidManifest.xml"
click node_main_activity "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/ui/MainActivity.java"
click node_settings_ui "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/ui/SettingsFragment.java"
click node_calibration "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/ui/DetectCutoutActivity.java"
click node_settings "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/Settings.java"
click node_notification_listener "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/NotificationListenerService.java"
click node_accessibility "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/AccessibilityService.java"
click node_tracker "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java"
click node_device_context "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/Battery.java"
click node_aod_control "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/AODControl.java"
click node_area_finder "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/area/AreaFinder.java"
click node_overlay "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/Overlay.java"
click node_notification_animation "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/NotificationAnimation.java"
click node_sprite_renderer "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/SpritePlayer.java"
click node_json_animation "https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/JSONAnimationManipulator.java"
click node_aod_helper "https://github.com/chainfire/holeylight/blob/master/helper/src/main/java/eu/chainfire/holeylight/aodhelper/AODReceiver.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_manifest,node_main_activity,node_settings_ui,node_calibration,node_settings toneBlue
class node_notification_listener,node_accessibility,node_tracker,node_device_context,node_aod_control,node_area_finder toneAmber
class node_overlay,node_notification_animation,node_sprite_renderer,node_json_animation toneMint
class node_aod_helper toneRose
class node_android toneNeutral
```

## Components

### Primary Android app

- [Application bootstrap](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/Application.java): Android application · `app/src/main/java/eu/chainfire/holeylight/Application.java`
- [Component declarations](https://github.com/chainfire/holeylight/blob/master/app/src/main/AndroidManifest.xml): Android manifest · `app/src/main/AndroidManifest.xml`
- [Setup entry point](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/ui/MainActivity.java): activity · `app/src/main/java/eu/chainfire/holeylight/ui/MainActivity.java`
- [Settings controls](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/ui/SettingsFragment.java): fragment · `app/src/main/java/eu/chainfire/holeylight/ui/SettingsFragment.java`
- [Cutout and color tuning](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/ui/DetectCutoutActivity.java): activities · DetectCutoutActivity, TuneActivity, and ColorActivity calibrate placement and color. · `app/src/main/java/eu/chainfire/holeylight/ui/DetectCutoutActivity.java`
- [Persistent policy](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/Settings.java): settings store · `app/src/main/java/eu/chainfire/holeylight/misc/Settings.java`

### Runtime services

- [Notification listener](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/NotificationListenerService.java): notification service · `app/src/main/java/eu/chainfire/holeylight/service/NotificationListenerService.java`
- [UI state signals](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/AccessibilityService.java): accessibility service · `app/src/main/java/eu/chainfire/holeylight/service/AccessibilityService.java`
- [Notification tracker](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java): state and decision engine · Maintains actionable notifications and selects what should display. · `app/src/main/java/eu/chainfire/holeylight/service/NotificationTracker.java`
- [Power and display context](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/Battery.java): device state · Battery and display state determine rendering eligibility. · `app/src/main/java/eu/chainfire/holeylight/misc/Battery.java`
- [AOD control](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/misc/AODControl.java): vendor power integration · `app/src/main/java/eu/chainfire/holeylight/misc/AODControl.java`
- [Cutout geometry resolver](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/service/area/AreaFinder.java): device adapter · Selects Samsung, Samsung 13, or Google area-finding behavior. · `app/src/main/java/eu/chainfire/holeylight/service/area/AreaFinder.java`

### Rendering pipeline

- [Overlay surface](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/Overlay.java): render surface · `app/src/main/java/eu/chainfire/holeylight/animation/Overlay.java`
- [Notification effects](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/NotificationAnimation.java): animation model · `app/src/main/java/eu/chainfire/holeylight/animation/NotificationAnimation.java`
- [Sprite renderer](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/SpritePlayer.java): animation playback · SpritePlayer and SpriteSheet render selected effects. · `app/src/main/java/eu/chainfire/holeylight/animation/SpritePlayer.java`
- [JSON animation processing](https://github.com/chainfire/holeylight/blob/master/app/src/main/java/eu/chainfire/holeylight/animation/JSONAnimationManipulator.java): animation transform · `app/src/main/java/eu/chainfire/holeylight/animation/JSONAnimationManipulator.java`

### Optional AOD helper

- [External AOD receiver](https://github.com/chainfire/holeylight/blob/master/helper/src/main/java/eu/chainfire/holeylight/aodhelper/AODReceiver.java): companion Android package · 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**: platform boundary · Privileged notification, accessibility, display, and AOD integration boundary.

## Connections

- 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
