Skip to content

Scan returns zero devices with no signal when another app on the phone holds the GATT link #3774

Description

@CarlKho-Minerva

What happens

The glasses hold one GATT link at a time. While the MentraOS app (or any other app on
the same phone) holds it, the glasses stop advertising, so a second SDK consumer's
scan() completes with zero results and no explanation. It is indistinguishable
from broken hardware or glasses that are switched off.

Reproduction (real hardware)

Mentra Live + Samsung S26 Ultra, both processes live at once:

MentraOS (16051)  BLE_TRACE glasses_to_phone battery_status  {"level":92}
MentraOS (16051)  BLE_TRACE glasses_to_phone speaking_status {"speaking":true}
my relay (16656)  scan found 0 device(s)   [x3]
my relay (16656)  glasses disconnected

MentraOS was receiving live BLE traffic at the exact moment my scan reported nothing.
adb shell am force-stop com.mentra.mentra released the link and my app connected
immediately (glasses connected (battery 85%)).

Why it matters

I lost most of a day to this, on the assumption that my own BLE code was wrong. There
is no signal anywhere in the SDK surface that says "something else has this device".

Suggested fix

After an empty COMPLETED scan, query BluetoothManager.getConnectedDevices(GATT)
and intersect with Mentra device identity for the scanned model. On a match, deliver a
non-terminal diagnostic BluetoothError (device_held_by_other_app) through
ScanCallback.onError immediately before the usual onComplete. onError has a
default empty body, so existing consumers see no behaviour change.

Limitation worth stating in the API docs: this detects same-phone contention only.
getConnectedDevices cannot see a link held by a different phone.

I have this implemented and tested (pure-JVM matcher + unit tests) and am happy to
open it as a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions