The Notifications Module serves as the analytical bridge between the Android System’s notification tray and the application’s internal logic. Instead of merely displaying alerts, this module treats notifications as a stream of data points. It tracks how notifications are born (posted), how they evolve (updated), when they die (removed), and how the user interacts with them (clicked).This is a core component for features related to digital wellbeing, notification history, or “scroll-less” interventions, as it allows the app to understand the “noise level” of a user’s device.
The module operates on an Event-Driven Architecture. It transforms raw system callbacks from the Android NotificationListenerService into a structured domain model.
The module categorizes every interaction into four distinct states:
POSTED: Triggered when a notification first appears. This is the primary “interruption” point.
UPDATED: Triggered when an existing notification changes (e.g., a music player changing tracks or a download progress update). This helps the system distinguish between new interruptions and ongoing activity.
REMOVED: Triggered when the user swipes the notification away or the system clears it. This is crucial for calculating “Time to Dismiss” metrics.
CLICKED: Triggered when the user engages with the notification via the app’s internal UI (like a notification timeline), allowing the system to track which notifications were actually “valuable” to the user.
The system must perform high-frequency mapping. Because Android often sends multiple “Post” events for the same notification (e.g., every time a second ticks on a timer), the logic must differentiate between a POSTED and UPDATED event by comparing the notification’s unique key against a local cache or database.
Main Thread Safety: Notification events can arrive in rapid succession (bursts). The processing of these events must be offloaded to a using Dispatchers.IO.
State Management: The current state of active notifications is likely managed via a to ensure the UI reflects the tray in real-time.