GetAppUsageTool
Per-app screen time from UsageStatsManager.queryEvents, computed by ScreenTime from activity resume/pause/stop, screen-off and shutdown/boot events (more accurate than the daily-bucketed queryUsageStats, whose buckets don't start at local midnight). Events are read from LOOKBACK_MS before the window so an app already open at its start is counted. The default home-screen launcher is left out. Needs Usage access (UsageAccess); without it the tool returns an error, since queryEvents would silently return nothing. Params: days (1-7, default 1 = since local midnight today; Android keeps only a few days of events), limit (1-100, default 10), package_name filter. Output: the window (start, end), total_seconds, and apps most-used first with foreground_seconds and last_used (yyyy-MM-dd HH:mm, device timezone). app_label is null for apps hidden by package visibility (no launcher activity).