Files
reverse-engineering-anything/src/adb
吴佳浩Albenandmorluto df70b6685e fix(adb): list a transport adb reports without a serial number (#10187)
* fix(adb): list a transport adb reports without a serial number

AOSP `transport.cpp append_transport()` substitutes the literal `(no serial number)` in the serial
column when the transport has none to report, which is reachable: `client/usb_linux.cpp` keeps an
empty serial for a device that cannot report one during early bringup (`http://b/20883914`) and
still registers the transport. The long listing pads that column with `%-22s` and the short one
separates it with a tab, so the placeholder carries spaces either way — and `DEVICE_LINE` required
a single `\S+` token.

The consequence was larger than one lost line. `AdbDeviceOperations` rejects any unparsed line
outright, so a single serial-less transport failed the whole `list_adb_devices` call:

| listing | before | after |
| --- | --- | --- |
| two placeholder transports | 0 devices, 2 unparsed | 2 devices, 0 unparsed |
| placeholder in the short form | 0 devices, 1 unparsed | 1 device, 0 unparsed |
| two healthy devices plus one placeholder | 2 devices **and 1 unparsed**, so the call fails and all three are lost | 3 devices, 0 unparsed |

The state, transport identity, USB metadata and inferred kind parse exactly as before; only the
serial column admits the placeholder. `src/adb` — 40 passing, 3 new cases; restoring `\S+` fails
all three.

* fix(adb): model the missing serial instead of the display placeholder

A review finding: the placeholder `(no serial number)` is formatter text, not an identity. Two
transports without a serial became indistinguishable once it was stored as one, and the text cannot
be passed to any device operation, because `deviceSerialSchema` rejects whitespace while the schema
describes the serial as "Device serial exactly as `adb devices` reports it".

The observation now carries `serial: null` with `serial_status: "not_reported"`, which is the shape
this module already uses for a transport ID it was not given (`transport_identity.status` and
`transport_id_status`). The reported value is unchanged for every transport that has a serial, and
`transport_id` still identifies a transport that has none.

Before this change the placeholder line was not parsed at all — `\S+` cannot match text containing
spaces — so it landed in `unparsedLines`, and `AdbDeviceOperations` refuses any unparsed line, which
removed every healthy device from the listing too:

| input | before | after |
| --- | --- | --- |
| placeholder line only | 0 devices, 1 unparsed | 1 device, `serial: null` |
| two placeholder transports | 0 devices | 2 devices, distinct `transport_id` |
| healthy + placeholder | 0 devices, 1 unparsed | 3 devices, one `serial: null` |

`src/adb` and `tests/boundary/cli/adbCli.test.ts` — 189 passing. `tests/boundary/providers/adb`
fails 4, all of which fail on `main` on this Windows host (where it fails 25). `tsc --noEmit`
0 errors, `npm run lint` 0 errors.

* test(adb): give the MCP fixture the serial status the parser reports

A review finding: `adbDeviceObservationSchema.serial_status` is now required, and the fixture in
`tests/boundary/mcp/adbMcp.test.ts` still omitted it, so `projectDeviceList` refused the listing
before the test's success assertion could run:

```
tests/boundary/mcp/adbMcp.test.ts:372
  expect(listed.isError).not.toBe(true);   → expected true not to be true
```

Both fixture devices report a serial, so both take `serial_status: "reported"`.

The reviewer also mentioned three full-object assertions in `AdbProvider.test.ts`; those do not
exist in the tree at this commit — `src/adb` runs 162 passing with the change, and
`git grep serial_status` finds no other fixture that carries a complete device object. I checked
rather than trusting the report.

* test(adb): give the provider device assertions the serial status

A review finding, and the reviewer was right about this file: I had reported it as not containing the
assertions, because `AdbProvider.test.ts:76` is `test.skipIf(process.platform === "win32")`, so all
117 of its tests are skipped on this Windows host and my local run reported 162 passing without ever
executing them. CI runs the adapters lane on Linux, where the three `toEqual` device objects compared
a 9-field observation against an 8-field one:

```
FAIL  src/adb/AdbProvider.test.ts > lists devices with inferred kinds and observed daemon startup
FAIL  src/adb/AdbProvider.test.ts > observes daemon startup when notices are printed to stderr
FAIL  src/adb/AdbProvider.test.ts > lists a USB device adb has no permission to open alongside online devices
  +     "serial_status": "reported",
```

Those are exactly the three, so `serial_status: "reported"` is added to each. Every device in this
file reports a serial, so the value is the same at all three sites.

Correcting my previous message on this PR: the file does carry them. The lesson is the same one that
has bitten this branch twice — `src/adb` passing locally is not evidence about a lane this host
skips.

`tsc --noEmit` 0 errors, `npm run lint` 0 errors.

* refactor(adb): let a null serial carry the not-reported fact

serial_status restated serial === null on every device row. Drop it and
document the null serial at the schema, where transport_identity still
tells two serial-less transports apart.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 10:45:11 -05:00
..