https://bugs.kde.org/show_bug.cgi?id=529100
Bug ID: 529100
Summary: Android: Bluetooth backend runs SDP on every bonded
device (car kits, headsets, speakers) on every start,
screen-on and network change
Classification: Applications
Product: kdeconnect
Version First unspecified
Reported In:
Platform: Android
OS: Android 17.x
Status: REPORTED
Severity: normal
Priority: NOR
Component: android-application
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
With "Bluetooth (beta)" enabled, BluetoothLinkProvider pages every bonded
Bluetooth device with SDP much more often than needed.
1. ClientRunnable.discoverDeviceServices() calls device.fetchUuidsWithSdp() for
every bonded device that has no KDE Connect socket yet - car kits, headsets and
speakers included.
2. BluetoothLinkProvider.onNetworkChange() does onStop(); onStart(), so the
whole sweep runs again every time BackgroundService.onNetworkChange() is
called. That happens on IP network changes (Wi-Fi <-> mobile data, handovers),
but also on every screen-on (KdeConnectBroadcastReceiver: ACTION_SCREEN_ON ->
ForceRefreshConnections()), on pull-to-refresh, etc.
For a bonded device that is out of range, each SDP request makes the controller
page it until Page Timeout (5.12 s). The requests are serialised, so with 8
absent devices one sweep keeps the radio paging for about 41 s.
Observed on a OnePlus 9 Pro (Android 17, crDroid), KDE Connect 1.37.2
(F-Droid). 9 bonded devices: 7 of major class AUDIO_VIDEO (three car kits,
earbuds, a soundbar and two speakers), 1 uncategorized, 1 LE-only. None of them
connects to KDE Connect over Bluetooth. In the 8 minutes after leaving the car
there were 9 sweeps and 46 page timeouts. HCI log (addresses masked):
14:44:18.942 CMD Create_Conn xx:xx:xx:xx:87:71
14:44:24.440 EVT ConnComplete status=0x04 (Page Timeout)
14:44:50.301 CMD Create_Conn xx:xx:xx:xx:5e:2c
14:44:55.449 EVT ConnComplete status=0x04
14:44:55.453 CMD Create_Conn xx:xx:xx:xx:5e:32
14:45:00.598 EVT ConnComplete status=0x04
... (every ~5.1 s, all bonded devices, then again after the next
onNetworkChange)
logcat at the same time:
I BluetoothLinkProvider: onNetworkChange called
I BluetoothLinkProvider: onStop called
I BluetoothLinkProvider: onStart called
I ClientRunnable: connectToDevices called
I BluetoothLinkProvider: Bluetooth adapter paired devices: 9
I ClientRunnable: Calling fetchUuidsWithSdp for device: XX:XX:XX:XX:87:71
...
Why it matters: the radio keeps paging absent devices for tens of seconds after
every screen-on and network change. That costs battery, and it can run while
the phone holds an eSCO link to a car kit (HFP call) or streams A2DP, where
paging takes air time that eSCO retransmissions need. To be fair: the bad
car-kit calls that made me look at this turned out to have a different cause.
With the KDE Connect Bluetooth backend disabled there was no paging during
calls and the calls were just as bad. So this report is about the unnecessary
SDP/paging, not a proven audio problem.
The code is unchanged in current master (189525cd).
Proposed fix (merge request follows): skip SDP for devices that can't run KDE
Connect - LE-only devices (no RFCOMM) and major classes AUDIO_VIDEO,
PERIPHERAL, IMAGING, WEARABLE, TOY, HEALTH. Tested on the same phone with a
debug build of master + the patch: on service start and on a forced refresh, 8
of the 9 bonded devices are skipped, and the HCI log shows one
Create_Connection per sweep instead of eight or nine.
Possible further improvements (not in the merge request): don't redo the SDP
sweep on IP network changes - the Bluetooth link doesn't depend on the IP
network, but onNetworkChange() is also the generic "refresh" hook (screen-on,
pull-to-refresh, toggling the setting), so this probably needs a separate
signal; rate-limit the sweep; don't sweep while an audio profile or SCO link is
active.
Workaround: disable Bluetooth in the KDE Connect settings.
Assisted-by: LLM
--
You are receiving this mail because:
You are watching all bug changes.