UsageTracker

Reads real per-app foreground time via UsageStatsManager. Requires the special "usage access" grant (not a normal runtime permission) — the whole point of a minimalist phone: see where the time goes and add friction to the time-sinks.

Functions

Link copied to clipboard
fun dailyTotals(context: Context, days: Int): List<Pair<Long, Long>>

Total screen time per day for the last days days, oldest first; each entry is (day-start millis, total ms). Powers the week-trend rows.

Link copied to clipboard
fun hasAccess(context: Context): Boolean
Link copied to clipboard
Link copied to clipboard

Total foreground time across all apps since midnight (≈ screen time).

Link copied to clipboard

Today's per-app foreground time, biggest first, noise (<1 min) dropped.

Link copied to clipboard
fun unlocksToday(context: Context): Int

How many times the phone was unlocked since midnight (API 28+, else 0).

Link copied to clipboard
fun usageTodayMs(context: Context, packageName: String): Long

Foreground time for one package since midnight.