Skip to main content

Summary

This module handles the real-time monitoring of user activity and system notifications. It runs a background listener to track incoming notifications from other apps and uses a monitoring system to display “nudges” (usage reminders) or limit warnings when users exceed their time goals. The system operates primarily through a persistent notification listener service and singleton monitors that react to app changes.

Overview Diagram

Active Listeners & Monitors

These components run continuously or reactively to handle system events.

NotificationListener

What it does: Listens to all notifications posted by other apps on the device to track distraction frequency and batch notifications.
PropertyValue
TypeNotificationListenerService
TriggerSystem Notification Posted/Removed
ConstraintsNotification Access Permission
1

Filter

When a notification arrives, the service immediately filters out noise, such as group summaries, progress bars, and notifications from the app itself.
2

Buffer (Ghost Protocol)

It waits 2 seconds before processing. If the notification is removed within this window (e.g., a rapid update or immediate dismissal), it is ignored to prevent duplicate counting.
3

Commit

If the notification persists, it is classified (Conversation, Interruption, or Passive) and saved to the database.
Triggered by: Android System (whenever any app posts a notification).

NudgeMonitor

What it does: Tracks how long the user has been in the current app and schedules intervention overlays.
PropertyValue
TypeSingleton Monitor
TriggerForeground App Change
ConstraintsOverlay Permission, Usage Stats
1

Debounce

When the user switches apps, the monitor waits briefly (500ms) to ensure the switch is intentional and not a transitional state.
2

Calculate

It retrieves the user’s usage baseline for the day and calculates the next “nudge” threshold (e.g., every 15 minutes).
3

Schedule

It schedules a task to fire exactly when the usage threshold is reached. If the user leaves the app before then, the task is cancelled.
Triggered by: User opening or switching apps.

InsightsNudgeMonitor

What it does: Analyzes usage patterns in real-time to detect unhealthy behaviors like doomscrolling or rapid app switching.
PropertyValue
TypeSingleton Logic Engine
TriggerForeground App Change
ConstraintsNone
1

Pattern Match

Checks for specific behaviors: Bounce Loops (rapidly switching between two apps), Doomscrolling (sessions > 40 mins), or Morning Traps (high usage immediately after waking).
2

Cooldown Check

Ensures the user isn’t bombarded by checking if a similar insight was shown recently (e.g., Bounce Loops have a 1-hour cooldown).
3

Trigger

If a pattern is detected, it requests the NudgeMonitor to display a specific insight message.
Triggered by: User opening or switching apps.

Visual Outputs

The background services communicate with the user through two primary methods.

Nudge Overlay (Heads-Up)

What it does: Draws a floating “pill” over the current app to show usage time or warnings without blocking the screen completely.
PropertyValue
VisualFloating pill with icon & text
Starts whenUsage threshold reached
Stops whenAuto-hides (4-15s) or User clicks

System Notifications

What it does: Posts standard Android notifications for critical alerts or when overlays are not permitted.
ChannelImportancePurpose
Limit AlertsHigh (Sound/Vibrate)Critical warnings when app limits are reached.
NudgesLow (Silent)Gentle reminders of time spent.
CoachDefaultAI suggestions for changing limits.
ServiceLowPersistent indicator that monitoring is active.

Scheduling Flow

This diagram shows how a usage nudge is triggered from the moment a user opens an app.

Logic Rules

  1. Ghost Protocol: Notifications that live for less than 2 seconds are considered “ghosts” (jitter) and are not logged to the database.
  2. Priority Handling: Limit warnings (High Importance) always override standard usage nudges.
  3. DND Respect: Standard nudges respect the device’s mode, but critical limit alerts may bypass it depending on settings.
  4. Debouncing: App switches are debounced by 500ms to prevent triggering logic during rapid task switching or accidental swipes.
  5. Eligibility: Nudges are never shown for system apps, launchers (home screen), or the app itself.
Last modified on January 25, 2026