GetAppUsageTool

class GetAppUsageTool(context: Context) : McpTool

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).

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard
open override val annotations: ToolAnnotations
Link copied to clipboard
open override val description: String
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val outputSchema: Map<String, Any>
Link copied to clipboard
open override val parameters: List<ToolParameter>

Functions

Link copied to clipboard
open suspend override fun execute(params: Map<String, Any>): ToolResult