Skip to content

Commit 8d84592

Browse files
committed
Settings finds Bluetooth headphones while Quick Share is listening: it starts its own search even when the adapter is already searching, since joining Quick Share's LE-only one never sent the inquiries that classic devices answer with their names
1 parent 6e57f5d commit 8d84592

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎electron/bluetooth.mts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,18 @@ async function discover(on: boolean): Promise<void> {
647647
discoveryTimer = null;
648648
const adapter = adapterPath();
649649
if (!adapter) return;
650-
const discovering = objects.get(adapter)?.get(ADAPTER)?.get('Discovering') === true;
651650
if (on) {
652651
discoveryTimer = setTimeout(() => void discover(false), DISCOVERY_MS);
653652
setPairable(true);
654-
if (!discovering) {
655-
await call('StartDiscovery', adapter, ADAPTER).catch((error) => {
656-
if (!(error instanceof DBusError && error.type === 'org.bluez.Error.InProgress')) throw explain(error);
657-
});
658-
}
653+
// Start this connection's own search even when the adapter is already
654+
// searching: BlueZ searches for the union of its clients' filters, and
655+
// another's may be narrower than Settings' (Quick Share looks for LE
656+
// advertisements alone). Joining it would miss classic devices, such as
657+
// headphones, whose names come only in their replies to an inquiry.
658+
// InProgress means this connection's search is already on.
659+
await call('StartDiscovery', adapter, ADAPTER).catch((error) => {
660+
if (!(error instanceof DBusError && error.type === 'org.bluez.Error.InProgress')) throw explain(error);
661+
});
659662
} else {
660663
if (![...busy.values()].includes('pairing')) setPairable(false);
661664
// Only stops a search this connection started.

0 commit comments

Comments
 (0)