Skip to content

Conversation

@annathedroid
Copy link
Contributor

@annathedroid annathedroid commented Oct 27, 2025

This change introduces the ability to parse, store, and query Android user list information from Perfetto traces.

Previously, information about the different Android users (e.g., system, secondary, guest) present on the device was not extracted from the trace. This change adds the necessary logic to process the AndroidUserList trace packet.

Key changes include:

  • New Table: Added a table __intrinsic_user_list to store the user ID (uid) and user type (type).
  • Proto Parsing: Implemented parsing logic within AndroidProbesModule to handle the AndroidUserList message and populate the new table.
  • SQL View: Exposed the data through a new Perfetto SQL view named android_users, with columns uid and type.
  • Error Handling: Added stats::user_list_errors to track any issues during parsing.
  • Testing: Included a new diff test (test_ftrace_user_list) using a dedicated trace file (trace_user_list.pftrace) to validate the end-to-end functionality of parsing and querying the android_users view.

These changes enable trace analysts to easily query and correlate trace events with specific Android users on the system.

@annathedroid annathedroid requested a review from a team as a code owner October 27, 2025 10:33
@annathedroid annathedroid force-pushed the dev/annabauza/android_users_table_probes branch from ccb8b3a to 82a676b Compare October 27, 2025 10:46
Base automatically changed from dev/annabauza/android_users_table_probes to main October 27, 2025 12:40
@annathedroid annathedroid enabled auto-merge (squash) October 27, 2025 13:18
@annathedroid annathedroid disabled auto-merge October 28, 2025 11:18
@annathedroid annathedroid force-pushed the dev/annabauza/android_users_table_processor branch from 9c3598c to e770237 Compare October 28, 2025 15:25
Copy link
Member

@aMayzner aMayzner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to me!

@annathedroid annathedroid removed the request for review from rsavitski October 30, 2025 12:32
@annathedroid annathedroid enabled auto-merge (squash) October 30, 2025 12:33
@annathedroid annathedroid requested a review from aMayzner October 30, 2025 12:33
@annathedroid annathedroid force-pushed the dev/annabauza/android_users_table_processor branch from 08dd013 to 26c5be9 Compare November 14, 2025 08:58
@annathedroid annathedroid changed the title Add users table processor Add support for Android User List in Trace Processor Nov 14, 2025
@primiano
Copy link
Member

Removing myself and Ryan, Anna or Lalit (just one of the two) are the best candidates to review this

-- NOTE: sorted by Android user id
CREATE PERFETTO VIEW android_users (
-- Android user id
uid LONG,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I also asked about this but how does this correspond to uid on the android_process_metadata [1] table.

I think just calling this uid and "android user id" is highly confusing for everyone. I would like to see a explanation of this somewhere.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/angle/third_party/perfetto/src/trace_processor/perfetto_sql/stdlib/android/process_metadata.sql;l=78?q=android_process_metadata&ss=chromium

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On android_process_metada, I also see user_id as a column and says it is for "multi-user devices". How does that factor into things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it to android_user_id because it is exactly that in processes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in android_process_metadata

linux uid = user_id * 1000 + uid (android app id)

bear in mind uid which is shown by linux ps is not present in android_process_metadata and android app id is called uid

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a historical mistake. It's too late to change this now beyond adding some documentation there. We should have done a better job on this when we first designed that table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can name it user_id to keep the same name in tables

@annathedroid annathedroid force-pushed the dev/annabauza/android_users_table_processor branch from 4404ab8 to bd24240 Compare November 18, 2025 10:32
@annathedroid annathedroid force-pushed the dev/annabauza/android_users_table_processor branch 3 times, most recently from d64902d to 4eaa597 Compare November 19, 2025 16:24
Change-Id: I9a53d68a4ad475984f715f420d7cc498b987a053
@annathedroid annathedroid force-pushed the dev/annabauza/android_users_table_processor branch from 4eaa597 to 5c17d4b Compare November 19, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants