Skip to content

fix(usb): Surface permission denial as permanent disconnect#5943

Merged
jamesarich merged 1 commit into
meshtastic:mainfrom
jeremiah-k:bugfix/usb-permission-denied-disconnect
Jun 25, 2026
Merged

fix(usb): Surface permission denial as permanent disconnect#5943
jamesarich merged 1 commit into
meshtastic:mainfrom
jeremiah-k:bugfix/usb-permission-denied-disconnect

Conversation

@jeremiah-k

Copy link
Copy Markdown
Contributor

Overview

This pull request fixes the Android USB permission-denial path so a denied permission request surfaces as a clear terminal disconnect instead of silently entering the reconnect path.

Before this change, SerialRadioTransport.onMissingPermission(...) logged the missing permission callback but did not notify the service layer. That left the selected USB device in a retry-oriented state even though Android had denied access for the current connection attempt.

This change reports USB permission denial as a structured transport disconnect reason, keeps user-facing copy out of the serial transport layer, and maps the reason through the existing connectionError flow at the service boundary.

Key Changes

  • Added TransportDisconnectReason.UsbPermissionDenied as a machine-readable transport disconnect cause.
  • Extended RadioTransportCallback.onDisconnect(...) to carry an optional structured disconnect reason.
  • Updated the serial transport path so USB permission denial:
    • stops the current connection attempt,
    • reports a permanent disconnect,
    • passes TransportDisconnectReason.UsbPermissionDenied,
    • leaves user-facing copy selection to the service/UI layer.
  • Mapped UsbPermissionDenied in SharedRadioInterfaceService to the existing connectionError flow.
  • Preserved the early explicit-close guard before serial warning logs so expected close callbacks stay quiet.
  • Added service coverage proving USB permission denial emits the expected error and moves the service to ConnectionState.Disconnected.

Testing

  • Added SharedRadioInterfaceServiceLivenessTest coverage for USB permission denial.
  • Verified the permission-denial path reports the expected connection error and ends in ConnectionState.Disconnected.

Migration Notes

  • No user data migration is required.
  • No USB address format changes are introduced.
  • Existing transient USB unplug / cable-loss behavior remains unchanged.
  • Existing explicit close behavior remains quiet.

Stop retrying the current Android USB connection attempt when the platform denies device permission, while reporting a structured transport disconnect reason instead of transport-owned UI text.

Map that reason at the service boundary for the existing connectionError flow, preserve the quiet explicit-close guard before warning logs, and cover the permanent Disconnected state plus emitted error.
@github-actions github-actions Bot added the bugfix PR tag label Jun 25, 2026
@jeremiah-k jeremiah-k marked this pull request as ready for review June 25, 2026 01:25
@jamesarich jamesarich added this pull request to the merge queue Jun 25, 2026
Merged via the queue into meshtastic:main with commit 09cde67 Jun 25, 2026
22 checks passed
@jeremiah-k jeremiah-k deleted the bugfix/usb-permission-denied-disconnect branch June 25, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants