[Samsung Galaxy Alpha] Harinus:
Update on the Bluetooth issue II

Hi there,

now as the build enviroment is setup and working I was able to debug the partially broken Bluetooth stack:

Litte background info:

The SDP (Service Discovery Protocol) defines UUIDs for Bluetooth Protocols and Services. (PSMs / Protocol Service Multiplexer)

Example: 0x0017	Audio/Video Control Transport Protocol (AVCTP)

Those PSMs can be registered on the L2CAP (Link layer of the bt-stack) and get a channel assigned. The Bluetooth App is then listening for incoming connections.

useful illustration of a similar stack: https://s-media-cache-ak0.pinimg.com/originals/a9/32/c5/a932c5b7d76cc14a48df816e2ef8990e.jpg

What went wrong on the Alpha:

After comparing many logfiles I found out that on a normal boot 20 services get registered via L2CAP and are available for Bluetooth Security Manager (BTM) (Look for : BTM_SEC_REG in the verbose logs of bt_btm)

Once bt is disabled and re-enabled there are suddenly 25 entries in the array.

Because: BluetoothMapAccountEmailLoader: isEmailAppStarted: true (this was false on boot, which makes sense + I have 5 mail accounts setup)

However it does mess up the registration of the OBEX Object Push PSM (0x1005):

Correct:

2933 3477 D bt_btif : Sdp Server on_create_record_event

2933 3477 D bt_btif : add_opps_sdp(): scn 0x06, psm = 0x1005

2933 3477 D bt_btif : service name OBEX Object Push

Wrong:

6252 6490 D bt_btif : Sdp Server on_create_record_event

6252 6490 D bt_btif : add_maps_sdp(): MASID = 0x02, scn 0x06, psm = 0x1005

6252 6490 D bt_btif : service name EMAIL Message Access

After freezing the E-Mail app all file relatet bt-operations work fine for me. If anyone is having similar issues you might try this workaround.

But still there are more issues with the phone connection inside my car (even though the pairing now works with email frozen):

10786 10815 D bt_btif : AG evt (hdl 0x0001): State 2, Event 0x050e

10786 10832 E HeadsetStateMachine: terminateScoUsingVirtualVoiceCall:No present call to terminate

10786 10832 D bt_btif : phone_state_change: idx = -1

10786 10832 W bt_btif : BTHF: btif_hf_check_if_slc_connected: No SLC connection up

10786 10832 E BluetoothHeadsetServiceJni: Failed report phone state change, status: 2

10786 10832 D bt_btif : BTHF: device_status_notification

Already took me a whole day to figure this out..

Best regards,

Harinus

Edit: Found/Updated two JIRA Issues that descibe similar problems for other devices:

https://jira.lineageos.org/browse/BUGBASH-308 Bluetooth HFP problem car radio klte

https://jira.lineageos.org/browse/BUGBASH-653 Bluetooth tethering only working after a fresh boot, never after BT has disconnected

Edit2: I was able to solve the HFP problem:

#define BTM_WBS_INCLUDED TRUE must be added to bdroid_buildcfg.h of our device

Details: https://jira.lineageos.org/browse/B...issuetabpanels:comment-tabpanel#comment-15303

A temporary patch with WBS enabled is attached (replace the bluetooth.default.so file in /system/lib/hw)

I might also look into the other issue that requires the email app freezing as workaround, but thats again some other fragments of code to debug..

Edit3: Also solved the OBEX issue:

If you set: <bool name="disable_non_aosp_bt_features">true</bool> in the device overlay for android_packages_apps_Bluetooth: res/values/config.xml MAP-EMAIL gets disabled and won't influence the other features anymore. Again, temporary patch for the Bluetooth.apk attached.

Details: https://jira.lineageos.org/browse/B...issuetabpanels:comment-tabpanel#comment-15321

[MENTION=4297219]modpunk[/MENTION]

Please add both changes to the next beta.

FYI: While debugging i saw a new version of the firmware: bcm4350_V0375.0768.hcd (klte-common).