AndroidIntermediateApp usage

Usage stats (usagestats)

UsageStatsService files: per-interval app aggregates and event logs such as ACTIVITY_RESUMED, screen and keyguard transitions.

01Location

  • /data/system/usagestats/<userId>/{daily,weekly,monthly,yearly}/<begin-time-ms>
  • /data/system_ce/<userId>/usagestats/{daily,weekly,monthly,yearly}/<begin-time-ms>
  • …/usagestats/version and …/usagestats/mappings

02Questions it answers

  • Which app activities moved to the foreground or background, and when?
  • When did the screen become interactive and when was the keyguard hidden?
  • When did the device shut down and start up?
  • How much foreground or visible time did an app accumulate per interval?

03Format and versions

FormatOne file per interval, named with the interval's begin time. UsageStatsDatabase wrote XML before database version 4 and Protocol Buffers since; the current default version is 5, which uses obfuscated package tokens resolved through the mappings file. The version file holds the database version and a build fingerprint (release;codename;incremental).
Applies toThe storage folder moved from /data/system/usagestats to /data/system_ce/<userId>/usagestats depending on OS version. Event types such as ACTIVITY_RESUMED and DEVICE_SHUTDOWN are public from API 29, KEYGUARD_SHOWN/HIDDEN from API 28.

04Key fields

FieldWhat it tells you
event typeNumeric UsageEvents.Event constant, e.g. 1 ACTIVITY_RESUMED, 2 ACTIVITY_PAUSED, 23 ACTIVITY_STOPPED, 15/16 SCREEN_(NON_)INTERACTIVE, 17/18 KEYGUARD_SHOWN/HIDDEN, 26 DEVICE_SHUTDOWN, 27 DEVICE_STARTUP.
package / classPackage and activity class associated with the event.
packages aggregatesPer-interval totals such as last_time_active_ms, total_time_visible_ms and app launch count.
standbyBucketApp standby bucket; ALEAPP splits the stored value into bucket and reason (high/low 16 bits) as its own interpretation.
version fileDatabase version and build fingerprint written during upgrades.

05Timestamps

FieldEncodingNote
File nameUnix epoch, millisecondsBegin time of the interval the file covers.
Event / package timesMilliseconds, offset from file begin timeALEAPP adds each stored time to the file's numeric name to obtain an absolute UTC time.
DEVICE_SHUTDOWNEvent timestampDocumented as the last time the database was persisted before shutdown, not the shutdown moment itself.

Decode raw values with the Timestamp decoder and convert local wall-clock times with the Local time to UTC.

06Examination workflow

  1. Collect the whole usagestats tree, including version and mappings.
  2. Identify the format (XML or protobuf) per file and decode package tokens through mappings where needed.
  3. Rebuild absolute times from the file-name base plus stored offsets.
  4. De-duplicate events that appear in more than one interval folder.
  5. Corroborate foreground events with app databases and the device's other logs.

07Interpretation pitfalls

  • AOSP prunes old files: daily after 10 days, weekly after 4 weeks, monthly after 6 months, yearly after 2 years.
  • Event names label platform transitions; SCREEN_INTERACTIVE is not a lock-state event and ACTIVITY_RESUMED does not by itself prove a person used the app.
  • Open events between DEVICE_SHUTDOWN and DEVICE_STARTUP have unknown closing times and should not be extended.

09Sources

  1. AOSP — UsageStatsDatabase.java Android Open Source Project (GitHub mirror) · checked 2026-10-14
  2. UsageEvents.Event — API reference Android Developers · checked 2026-10-14
  3. ALEAPP — scripts/artifacts/usagestats.py Alexis Brignoni et al. (GitHub) · checked 2026-10-14
  4. ALEAPP — scripts/artifacts/usagestatsVersion.py Alexis Brignoni et al. (GitHub) · checked 2026-10-14