Back
Battery: Live Claude Code Usage and Quota Forecasting for Android
BATTERY BATTERY BATTERY

Battery

Live Claude Code Usage and Quota Forecasting for Android

Battery is an Android companion for Claude Code users who need to see session, weekly, model-specific, and extra-usage limits before an unexpected quota interruption.

allthingsclaude/battery

18

Hours

3

Days

74

Commits

Lead Developer · android/

Role

27
About

Battery is an Android companion for Claude Code users who need to see session, weekly, model-specific, and extra-usage limits before an unexpected quota interruption. Extending a macOS menu bar monitor, it brings time-sensitive usage data to lock screens, home-screen widgets, and a compact Jetpack Compose dashboard with reset-time and burn-rate forecasts. A foreground session service couples fast polling to promoted Live Update cards and retains the last truthful value when requests fail. Serialized Kotlin polling uses a mutex and freshness gate, and refreshed OAuth credentials are persisted before usage requests while shared Claude Code credentials remain read-only. When inactive, WorkManager schedules periodic refreshes with a 15-minute minimum interval to repaint widgets and repost cards when work executes. Loopback PKCE and Custom Tabs state validation support the OAuth flow. Historical samples are filtered by reset window before pure Kotlin regression, preventing separate rate-limit sessions from contaminating quota-exhaustion forecasts.

Key Features

Built a foreground session service that posts promoted Android Live Update cards, coupling fast usage polling to a visible lock-screen surface.

Implemented loopback PKCE with Custom Tabs state validation for OAuth request correlation and authorization-code exchange protection.

Engineered serialized usage polling with a mutex and freshness gate, persisting rotated OAuth credentials before requests to preserve valid sessions through failures.

Built configurable home-screen widgets and a WorkManager refresh path that repaints usage and reposts promoted cards when system-scheduled work executes with a 15-minute minimum interval.

Implemented reset-window usage forecasting in pure Kotlin, filtering historical samples before regression to estimate quota exhaustion without mixing separate rate-limit sessions.

Designed a compact Jetpack Compose dashboard to make reset timing and forecasted quota exhaustion glanceable alongside session, weekly, and model-specific usage.

Built with
KotlinAndroidJetpack ComposeAndroidX WorkManager
Impact

Designed to help Android users monitor authenticated Claude usage and anticipate quota interruptions while away from a desktop.