[Xiaomi Mi Pad 4 ROMs, Kernels, Recoveries, & Other] TheCaptain501:
No audio over bluetooth headset

After the latest update my bluetooth headset is not working anymore. The headset is connected and audio is enabled but music is played over the speakers. I tried to disable the A2DP feature in the developer options but it still does not work.

Found something in the logs:

Service com.google.android.gms.nearby.discovery.service.DiscoveryService has leaked ServiceConnection android.bluetooth.BluetoothProfileConnector$2@b4081fc that was originally bound here
android.app.ServiceConnectionLeaked: Service com.google.android.gms.nearby.discovery.service.DiscoveryService has leaked ServiceConnection android.bluetooth.BluetoothProfileConnector$2@b4081fc that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1805)
at android.app.LoadedApk.getServiceDispatcherCommon(LoadedApk.java:1677)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1656)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1721)
at android.app.ContextImpl.bindServiceAsUser(ContextImpl.java:1675)
at android.content.ContextWrapper.bindServiceAsUser(ContextWrapper.java:724)
at android.content.ContextWrapper.bindServiceAsUser(ContextWrapper.java:724)
at android.content.ContextWrapper.bindServiceAsUser(ContextWrapper.java:724)
at android.content.ContextWrapper.bindServiceAsUser(ContextWrapper.java:724)
at android.bluetooth.BluetoothProfileConnector.doBind(BluetoothProfileConnector.java:90)
at android.bluetooth.BluetoothProfileConnector.connect(BluetoothProfileConnector.java:130)
at android.bluetooth.BluetoothA2dp.<init>(BluetoothA2dp.java:221)
at android.bluetooth.BluetoothAdapter.getProfileProxy(BluetoothAdapter.java:2515)
at bujw.<init>(:com.google.android.gms@200914038@20.09.14 (120406-300565878):7)
at ahwu.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):61)
at ahme.c(:com.google.android.gms@200914038@20.09.14 (120406-300565878):4)
at ahme.b(:com.google.android.gms@200914038@20.09.14 (120406-300565878):3)
at ahme.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):9)
at ahme.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):8)
at aibo.<init>(:com.google.android.gms@200914038@20.09.14 (120406-300565878):7)
at ahwu.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):34)
at ahme.c(:com.google.android.gms@200914038@20.09.14 (120406-300565878):4)
at ahme.b(:com.google.android.gms@200914038@20.09.14 (120406-300565878):3)
at ahme.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):9)
at ahme.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):8)
at aihm.<init>(:com.google.android.gms@200914038@20.09.14 (120406-300565878):7)
at ahwu.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):63)
at ahme.c(:com.google.android.gms@200914038@20.09.14 (120406-300565878):4)
at ahme.b(:com.google.android.gms@200914038@20.09.14 (120406-300565878):3)
at ahme.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):9)
at ahme.a(:com.google.android.gms@200914038@20.09.14 (120406-300565878):8)
at com.google.android.gms.nearby.discovery.service.DiscoveryChimeraService.onCreate(:com.google.android.gms@200914038@20.09.14 (120406-300565878):2)
at duz.onCreate(:com.google.android.gms@200914038@20.09.14 (120406-300565878):2)
at qst.onCreate(:com.google.android.gms@200914038@20.09.14 (120406-300565878):4)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3953)
at android.app.ActivityThread.access$1500(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

and another line:

[ 03-27 12:32:59.729 1930: 2911 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

[ 03-27 12:33:03.563 1930: 1930 W/Looper ]
Slow dispatch took 125ms main h=android.app.ActivityThread$H c=android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA@5fbe43d m=0

[ 03-27 12:33:07.457 1930: 4381 W/ActivityManager ]
Scheduling restart of crashed service com.qualcomm.atfwd/.AtFwdService in 1000ms

[ 03-27 12:33:07.779 1930: 1951 W/ActivityManager ]
setHasOverlayUi called on unknown pid: 23043

[ 03-27 12:33:10.083 1930:13248 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

[ 03-27 12:33:10.170 1930:13248 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

[ 03-27 12:33:15.979 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.UUID flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

[ 03-27 12:33:15.987 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.UUID flg=0x10 (has extras) } to com.google.android.projection.gearhead/com.google.android.apps.auto.carservice.gmscorecompat.CarBluetoothReceiver

[ 03-27 12:33:15.993 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.device.action.UUID flg=0x10 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.broadcastreceiver.external.ExternalCommonBroadcastReceiver

[ 03-27 12:33:29.749 1930: 6102 E/WifiService ]
Permission violation - getScanResults not allowed for uid=10109, packageName=com.google.android.gms, reason=java.lang.SecurityException: Location mode is disabled for the device

[ 03-27 12:33:29.749 1930: 4381 E/WifiService ]
Permission violation - getScanResults not allowed for uid=10109, packageName=com.google.android.gms, reason=java.lang.SecurityException: Location mode is disabled for the device

[ 03-27 12:34:43.838 1930: 1957 W/ActivityManager ]
Stopping service due to app idle: u0a150 -1h26m43s795ms com.spotify.music/com.spotify.mobile.android.service.SpotifyService

[ 03-27 12:35:54.562 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.auth.easyunlock.authorization.BluetoothStateChangeReceiver

[ 03-27 12:35:54.563 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.auth.proximity.BluetoothServicesAdapterStateChangeReceiver

[ 03-27 12:35:54.563 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

[ 03-27 12:35:54.653 1930: 2897 W/ActivityManager ]
Unable to start service Intent { cmp=com.android.bluetooth/.avrcpcontroller.BluetoothMediaBrowserService } U=0: not found

[ 03-27 12:35:54.677 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.auth.easyunlock.authorization.BluetoothStateChangeReceiver

[ 03-27 12:35:54.679 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.auth.proximity.BluetoothServicesAdapterStateChangeReceiver

[ 03-27 12:35:54.680 1930: 1957 W/BroadcastQueue ]
Background execution not allowed: receiving Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

and

[ 03-27 12:41:41.458 2170: 2170 E/BluetoothDevice ]
BT not enabled. Cannot get Remote Device Alias

[ 03-27 12:41:41.458 2170: 2170 E/BluetoothDevice ]
BT not enabled. Cannot get Remote Device name

[ 03-27 12:41:41.458 2170: 2170 W/BluetoothHeadset ]
Proxy not attached to service

[ 03-27 12:41:41.458 2170: 2170 W/BluetoothA2dp ]
Proxy not attached to service

[ 03-27 12:41:41.458 2170: 2170 E/BluetoothDevice ]
BT not enabled. Cannot get Remote Device Alias

[ 03-27 12:41:41.458 2170: 2170 E/BluetoothDevice ]
BT not enabled. Cannot get Remote Device name

[ 03-27 12:41:41.458 2170: 2170 W/BluetoothHeadset ]
Proxy not attached to service

[ 03-27 12:41:41.458 2170: 2170 W/BluetoothA2dp ]
Proxy not attached to service

Bluetooth was always enabled and device was shown as connected.

Maybe someone has the same problem and could help me out.

Thank you for your great work on this ROM