Skip to content

Read saved content query text from android_triage and ALEX raw text output - #2082

Merged
abrignoni merged 9 commits into
abrignoni:mainfrom
Maxitelmo:feat/content-query-raw
Nov 26, 2026
Merged

abrignoni merged 9 commits into
abrignoni:mainfrom
Maxitelmo:feat/content-query-raw

Conversation

@Maxitelmo

Copy link
Copy Markdown
Contributor

First part of #2073: a shared reader for the text that adb shell content query --uri <uri> prints, and one artifact per URI for the layouts that android_triage and ALEX (raw text) write.

Reader (scripts/content_query_reader.py, no ALEAPP imports, like dumpstate_reader.py)

  • Says what a file holds: rows, No result found., access denied, provider error, empty file, or text it doesn't recognise. "Access denied" only when the exception is java.lang.SecurityException; any other exception is "provider error", with its class and message.
  • LF and CRLF read the same. Values over several lines are joined back. A row opens only at Row: <next number> <first column>=, so a value line like Row: 7 of the list stays in its value.
  • The column list comes from the rows of the file. Each row is split along it, so , total= inside a body stays in the body. A value holding , <name>= for one of the file's own columns is flagged in Parse Note, since the split there may be off.
  • NULL, BLOB and empty values are kept as printed. Rows printed before an error at the end of the text are read, and the error is reported.

Artifacts (scripts/artifacts/contentQuery.py)

  • Content Query Files: one row per URI the artifacts read, per output folder, plus the other files in it. Keeps apart rows, No result found., access denied, provider error, empty file and no file. For ALEX a missing file is "unknown", since ALEX writes none for no rows, an error, or one of its four error strings anywhere in the output. Also lists the columns each file printed.
  • SMS, MMS, MMS Parts, MMS Addresses and Call Log (content query): ALEX only, since android_triage doesn't query them.
  • MMS rows get From, To, Cc and Bcc from mms/mms_addr.txt in the same folder, joined on msg_id = _id, the way the smsmms artifact shows them. MMS Addresses lists each address row with its Source Line, the PduHeaders name of its type, and whether its msg_id is an MMS row.
  • Contacts, Contact Phone Numbers, Calendar Event Entities, Calendars and MediaStore Files (content query): both layouts.
  • Calendar Events (content query): android_triage only, since ALEX doesn't query content://com.android.calendar/events.
  • Every name ends in "(content query)", so a case holding both the databases and this output doesn't look like duplicate rows.
  • MMS Parts lists the parts and says the media wasn't collected; neither layout saves part content.

Notes and sources

  • Format: AOSP Content.java, pinned to 8d2ed506. Layouts: android_triage.sh at 14edd935 and alex.py at 9ef34bf0.
  • Each note says that a stored text NULL or BLOB can't be told apart from a real one and that an empty string prints as nothing.
  • Time units cite the provider contract: call_log date ms and duration s, contacts contact_last_updated_timestamp ms, calendar dtstart and dtend ms, MediaStore date_added and date_modified s and datetaken ms. For SMS and MMS date and date_sent the contract gives no unit. The notes say so and cite the AOSP providers instead: SmsProvider writes ms and MmsProvider writes s. That's the same split the smsmms notes already describe.
  • AOSP's MmsProvider only matches content://mms/<id>/addr, not content://mms/addr, but some device providers answer content://mms/addr with one row per address keyed by msg_id, and ALEX queries it. The notes say both and keep the pinned MmsProvider link. When ALEX has no mms_addr.txt, Content Query Files reports the file as unknown and each MMS row says in Parse Note that its addresses are unknown; when the file is there but holds no FROM, TO, CC or BCC row for a message, Parse Note says that instead. Address types cite AOSP PduHeaders (FROM 0x89, TO 0x97, CC 0x82, BCC 0x81).
  • ALEX's JSON output isn't read. It waits for content_to_json and the query_content skip check change or drop provider rows prosch88/ALEX#34.

Tests

  • Four synthetic cases in admin/test/cases, built by admin/test/scripts/content_query_fixture.py. All values are invented (+1555 numbers, example.com):
    • ALEX: CRLF, multi-line values, , total=, , seen=, a Row: line inside a body, NULL, BLOB and empty values, MMS parts, MMS addresses (FROM, TO, CC and BCC rows, a NULL address, a msg_id with no MMS row, a type that isn't an address field).
    • ALEX with only the call log and MMS rows, so the rest is reported as unknown and each MMS row says its addresses are unknown; the ALEX case also has an MMS row with no address rows.
    • android_triage: No result found., an empty file, the tool's own log and provider list left out.
    • android_triage files holding stderr text: SecurityException, IllegalArgumentException, and rows followed by an error.
  • run_test_cases.py --module contentQuery --strict: 27 PASS. test_content_query_reader.py: reader unit tests.
  • Locally the CI checks pass, and lint_changed.py reports no new warnings. The 14 tool-folder patterns have no package to anchor to, so they are in path_anchor_allowlist.json with the reason.
  • Categories from admin/data/artifact_categories.json, matching the database artifacts for the same data: Messaging (SMS, MMS, MMS Parts, MMS Addresses), Calls & Contacts (Call Log, Contacts, Contact Phone Numbers), Productivity (the calendar ones), Photos & Media (MediaStore Files) and Logs & Diagnostics (Content Query Files). No new category. Merged with main after Group artifacts into 30 categories #2071; the full unittest suite shows the same failures on this branch as on main in a local Windows run, and the 24 new tests pass.

Real devices
Device A (Android 16, API 36): both tools. Device B (Android 14, API 34): ALEX only. Run on Windows 11 (android_triage from Git Bash), at the commits above. Checked independently of this reader, on all three runs: every row rebuilt from the split columns is identical to the raw text, the row count of each artifact matches the raw file, and the times, SMS bodies, numbers, names, paths, owner packages and MMS addresses shown match the raw values on every row.

Artifact A: android_triage A: ALEX raw text B: ALEX raw text
SMS not queried 436 26
MMS not queried 9 1
MMS Parts not queried 12 2
MMS Addresses not queried 25 no file (unknown)
Call Log not queried 1211 3
Contacts 1282 1282 18
Contact Phone Numbers 1273 1273 20
Calendar Events 112 not queried not queried
Calendar Event Entities 112 112 no file (unknown)
Calendars 11 11 3
MediaStore Files 59478 59478 174

On device A, android_triage also left 37 files holding No result found. and 2 empty files. Device A's provider answers content://mms/addr; device B's does not, so ALEX kept no mms_addr.txt there, Content Query Files reports that file as unknown, and each MMS row says its addresses are unknown. Both tools wrote CRLF line endings on Windows. Any row that comes out wrong on further devices will come back here as a synthetic case.

🤖 Generated with Claude Code

Maxitelmo and others added 5 commits November 25, 2026 12:06
…utput

A shared reader for the text that adb shell content query prints
(scripts/content_query_reader.py) and one artifact per URI for the
layouts android_triage and ALEX (raw text) write, plus a Content Query
Files artifact that keeps apart rows, No result found., access denied
(SecurityException only), provider error, empty file and no file.

Synthetic test cases for both layouts, reader unit tests, and allowlist
entries for the tool output folders, which have no package anchor.

Part of abrignoni#2073.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AOSP's MmsProvider only matches content://mms/<id>/addr, but device
providers can answer content://mms/addr with one row per address keyed
by msg_id, and ALEX saves it as mms/mms_addr.txt. The MMS note said no
address file was expected, which dropped senders and recipients.

- New MMS Addresses (content query) artifact, one row per address row,
  with the PduHeaders name of its type and whether its msg_id is an
  MMS row.
- MMS rows get From, To, Cc and Bcc joined on msg_id = _id; blank and
  logged as unknown when the folder has no mms_addr.txt.
- Content Query Files lists the new URI.
- Synthetic case with FROM, TO, CC and BCC rows, a NULL address, a
  msg_id with no MMS row and a non-address type; MMS without an
  address file in the skipped case.

Part of abrignoni#2073.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the folder has no mms/mms_addr.txt, From, To, Cc and Bcc stay
blank and Parse Note now says the addresses are unknown, so a blank
reads as not known rather than as no sender. When mms_addr.txt is
there but holds no FROM, TO, CC or BCC row for a message, Parse Note
says that instead. Synthetic cases cover both.

Part of abrignoni#2073.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move each artifact from "Android Content Query" to the category in
admin/data/artifact_categories.json that the database artifacts for the
same data use: Messaging, Calls & Contacts, Productivity, Photos & Media,
and Logs & Diagnostics for Content Query Files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the mac-review Enrolled for local review on the maintainer Mac label Nov 25, 2026

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
Comment thread scripts/content_query_reader.py Resolved
Comment thread scripts/artifacts/contentQuery.py Resolved
Comment thread scripts/artifacts/contentQuery.py Resolved
Comment thread scripts/artifacts/contentQuery.py Resolved
Comment thread scripts/content_query_reader.py Resolved
Maxitelmo and others added 3 commits November 25, 2026 23:32
…t is part of a value, do not split on a repeated column name

- read_file keeps dumps only for the run object it is given (the run's
  seeker), held and compared by identity, so a new run reads its own
  staged files even at the same path and size. Without a run object it
  does not cache.
- An 'Error while accessing provider:' line and an exception line in
  the last row are read as an error after it only when the row without
  them still holds the dump's columns. When the whole row holds them
  too, the row's Parse Note says the boundary is ambiguous.
- When the inferred column list names a column twice, which a value
  holding ', <name>=' in the only row (or in every row) also produces,
  rows are not split and keep their full text in Parse Note.

Review of abrignoni#2082.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le keys, list the sibling as a source; bound ALEX notes to its commits

- MMS and MMS Addresses read the sibling file (mms_addr.txt or mms.txt)
  through the run cache and keep its status. When it is not a full list
  of rows (a provider error, rows then an error, rows not split, an
  empty, unrecognised or unreadable file), recovered matches are kept
  and an unmatched row says the relation is unknown, with the reason,
  instead of "no address rows" or "no".
- An _id or msg_id that is empty or the text NULL is never indexed or
  matched; the row says so in Parse Note.
- The sibling actually read is added to the source list; Source File
  and Source Line stay those of the primary row.
- ALEX notes are bounded to its commits, as abrignoni#2084 does: up to 8f27e7a
  it writes no file when the output holds one of its four error strings
  anywhere; from ed3d41eb it writes the file whenever the output holds a
  row. ed3d41eb's PRFS zip layout (extra/content_provider/) is not read.
- New synthetic cases alex_join_incomplete, alex_mms_incomplete and
  alex_row_edges, and unit tests for the joins and sources.

Review of abrignoni#2082.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Maxitelmo

Copy link
Copy Markdown
Contributor Author

Pushed the fixes for the six review comments (252e154, f1cc632), after merging main (#2083, #2084).

  • ALEX changed on 25-nov: from ed3d41eb on, it writes the file whenever the output holds at least one row, and checks its four error strings only when it holds none. The notes, the missing-file text and "addresses unknown" are now bounded to the ALEX commits that behave each way, as Bound the ALEX rebuild notes to the ALEX commits that behave that way #2084 does for the rebuilt databases. The real-device runs in the description used ALEX 9ef34bf0, before that change.
  • --strict: 35/35 PASS. Reader and join tests: 33 pass. The full unittest suite shows the same failures as main in a local Windows run. CI check scripts and lint_changed.py: no new findings.
  • Rerun of the real-device output from the description: same row counts for every artifact, no new Parse Notes, and every row rebuilt from the split columns is identical to the raw text.

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Automated ALEAPP review.

Comment thread scripts/artifacts/contentQuery.py Resolved
Comment thread scripts/artifacts/contentQuery.py Resolved
Comment thread scripts/artifacts/contentQuery.py Resolved
@abrignoni

Copy link
Copy Markdown
Owner

Thanks Maxi, and thanks for the quick fixes on the first six. CI is green and the Mac review of f1cc632 raised three new ones. One needs a fix before this can merge; the other two can go in a follow-up.

  1. Partial addresses (contentQuery.py:764). When the address dump ends in an error but still gave some addresses for a message, the MMS row shows them with no note, so it reads as complete. Your alex_join_incomplete result shows it: message 7 has a From and an empty Parse Note. Please keep the addresses and add the partial-address note whenever the dump was incomplete, matched or not.

For the follow-up (I'll open one issue for both):

  1. One unreadable file (contentQuery.py:807). An OSError on one dump stops the artifact, so the other capture folders' rows are lost. The run log does record it with the traceback, which is why it can wait. Catching it per file and showing that file as unreadable in Content Query Files would be the fix.
  2. Missing join columns (contentQuery.py:779). Only a dump that leaves out _id, msg_id or type hits this. ALEX and android_triage query without --projection, and the MMS address joins worked on your device A run.

Also for later: ALEX's PRFS zip now keeps the raw text too, as extra/content_provider/<provider>/<name>.txt with a .status.json beside each file (prosch88/ALEX ed3d41eb). That could be a third layout.

When mms_addr.txt ends in an error but still gave some addresses for a
message, the MMS row showed them with an empty Parse Note, so it read as
complete. It now says the addresses may be partial, with the reason. A
message with none still says the addresses are unknown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abrignoni

Copy link
Copy Markdown
Owner

Maxi, I went ahead and pushed the partial-address fix to your branch (2763b8b) so this can move while you sleep. Small change: a new Parse Note for messages that got some addresses from an incomplete mms_addr.txt, one test, and the one baseline it changes. All 35 strict cases pass. Pull before your next push.

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Automated ALEAPP review.

Comment thread scripts/content_query_reader.py Resolved
Comment thread scripts/content_query_reader.py Resolved
Comment thread scripts/content_query_reader.py Resolved

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks Maxi, this is a solid first part. Merging.

@abrignoni
abrignoni merged commit 8fb4654 into abrignoni:main Nov 26, 2026
29 checks passed
Maxitelmo added a commit to Maxitelmo/ALEAPP that referenced this pull request Nov 26, 2026
…t first columns

Taking the first 'Row: 0' line as row 0 lost the real rows when a
row-like line came before them ('Row: 0 example=x', then 'Row: 0 _id=1',
'Row: 1 _id=2'), a case the vote of abrignoni#2082 read correctly. When 'Row: 0'
lines name different first columns, each reading is now tried and the
one kept has the fewest rows that cannot be split, then the least text
before its first row, then the earliest 'Row: 0'. A single real row
whose value quotes 'Row: 0' and 'Row: 1' lines still keeps its own
first column. Tests for both.

Review of abrignoni#2127.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mac-review Enrolled for local review on the maintainer Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants