Skip to content

v2.0.4

Latest

Choose a tag to compare

@hojin-v hojin-v released this 08 Aug 04:31

fix: start a pairing session knowing nothing about the last one

The notification that peeks over the pairing dialog sometimes did not come
down, and there was no pattern to it - waiting long enough would eventually
bring it back. Three things lined up to cause it.

AdbPortDiscovery keeps its last pairing port after stop() and clears it only
when mDNS reports the service gone, which does not reliably happen when the
dialog closes. begin() then seeded the session from that cache, and
addPairingPortListener hands a new listener the current value immediately -
so a session opened in READY, holding a port adbd had stopped listening on,
before the user had touched anything.

That spent the transition the alert is keyed on. When the real dialog opened
it announced a different port, the phase was already READY, and the service
saw no change worth interrupting for. The prompt arrived silently, over a
dialog it was supposed to peek above. It came back "after a while" whenever
the lost-service event finally landed and dropped the phase, letting the
next discovery count as an arrival.

The stale port was also what the code would have paired against, so this was
one bad attempt away from a failure with no explanation.

A session now clears discovery before starting. A dialog that is genuinely
open is rediscovered in seconds; a closed one is not, which is the right
answer either way. The alert is keyed on the port as well as the phase,
since every dialog gets a fresh one - a second dialog opened without the
phase dropping in between is still a new prompt worth peeking for.

Setup runs once, so its one bad run is the whole impression it leaves.

The toggle also breathes while it works. The first press after setup has to
bring wireless debugging up and wait for adbd to announce itself; a button
that dimmed and sat still read as frozen, and captions do not fix that -
they have to be read, and a still screen has already said "stuck".

Android 16: 9 checks, no failures. 57 unit tests. The stale-port sequence
cannot be staged here - it needs a real pairing dialog to advertise and then
withdraw an mDNS service - so that fix rests on the code, not on a repro.
The pulse could not be photographed either: the toggle completes in about a
second on the emulator, which is shorter than a screenshot round trip.