fix for AOAP negotiation - #52
Conversation
controlTransfer(ACC_REQ_SEND_STRING, ...) with a per-field index — but all three used index 0, colliding with each other (and with Manufacturer, which correctly uses 0). Only Manufacturer/Model/Desc (indices 0/1/2) were ever correctly received. Fixed to 3/4/5, matching the existing convention. Found by decompiling the old closed-source build (still reliable with the same phone/cable) and comparing against the current USB init sequence.
Without this it blocks with : Execution failed for task ':app:minifyReleaseWithR8'.
Three related changes:
a) Tolerate up to 3 consecutive transient USB errors (native code 1 or 2)
in onChannelError() before actually tearing down the session; counter
resets on a successful ping/pong.
b) isQuitting_ is now std::atomic<bool>, set via exchange() in
triggerQuit()/triggerQuitOnError(), so only one shutdown path runs if
both the ping watchdog and a channel error fire near-simultaneously.
c) 300ms delay before the very first send (VersionRequest) after claiming
the AOAP interface. Tested in the field: no measurable effect on the
connection issue. Kept because harmless
ISteeringMenuService.registerCallbackEx() can throw IllegalStateException
("beginBroadcast() called while already in a broadcast") — a server-side
bug in the head unit firmware. This doesn't extend RemoteException, so the
existing catch missed it, crashing the whole app and forcing a full USB
renegotiation. Added catch (RuntimeException) on all three IPC calls;
logs and continues instead of crashing.
This fix produced the biggest visible drop in restart-loop frequency.
MaKi983
left a comment
There was a problem hiding this comment.
two questions:
- What benefits does StartupSettleTimer provide? Have you verified that in some cases sendVersionRequest fails?
- Are you sure that handling the errors by simply ignoring them works? Errors 1 and 2 can also be native Android Auto errors, in which case I believe the phone itself disconnects. Have you verified that ignoring them actually works?
|
On the StartupSettleTimer (300ms delay): On tolerating errors 1/2: |
Correction of the index where Version/URI/Serial are sent.