Skip to content

Android: disconnect during descriptor/MTU/RSSI op permanently wedges command queue #490

Description

@qdot

In src/droidplug/java/.../Peripheral.java, the command callbacks for readDescriptor, writeDescriptor, requestMtu, and readRemoteRssi don't override onConnectionStateChange. The base CommandCallback.onConnectionStateChange throws UnexpectedCallbackException, and that throw happens outside asyncWithFuture, escaping to the Binder thread from inside the synchronized block in the GATT callback.

Failure scenario: the peer disconnects during read_descriptor() / read_rssi() / MTU request. The future never completes, executingCommand stays true, and every later command on that peripheral (connect, disconnect, read, …) hangs forever. adapter.onConnectionStateChanged is never reached, so DeviceDisconnected is never emitted either.

Fix direction: handle disconnect in those callbacks the same way the read/write/discover callbacks do (fail the future with not-connected and run the next command), and make the base class path not throw out of the GATT callback.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidIssues related to the android corebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions