android-x86.github.io icon indicating copy to clipboard operation
android-x86.github.io copied to clipboard

Bluetooth not working on Android x86 Pie (android-x86-9.0-r2), but working on Android x86 Nougat (android-x86-7.1-r4)

Open projectbtle opened this issue 5 years ago • 4 comments

Firstly, thanks for this great project. Very useful for researchers.

I'm trying to test Bluetooth on Android Pie, but am unable to get it to work.

Environment:

  • Windows 10 64-bit host
  • VMWare Workstation 14 Player (14.1.8 build-14921873)
  • CSR Bluetooth dongle (BT 4.0)
  • Android x86 Pie (android-x86-9.0-r2)

Problem:

  • Bluetooth doesn't switch on within Settings. The toggle goes to the right but remains grey. No devices are found (within the Settings interface) even though there are several devices advertising.

Troubleshooting:

  • hcitool lescan works (i.e., shows advertising devices in the vicinity), so it can't be a problem with the CSR adapter.
  • logcat shows couldn't write 1002 to /config/sdcardfs/com.android.bluetooth/appid, but it says the same (with different appids) for all the apps that were on /config/sdcardfs in older Android versions. It looks like that folder doesn't have app-specific sub-folders on Android v9.

When we try to turn on Bluetooth within Settings, logcat shows:

08-18 07:00:23.743  1766  2425 D BluetoothManagerService: enable(com.android.settings):  mBluetooth =null mBinding = false mState = OFF
08-18 07:00:23.743  1766  2425 D BluetoothManagerService: enable returning
08-18 07:00:23.743  1766  1834 D BluetoothManagerService: MESSAGE_ENABLE(0): mBluetooth = null
08-18 07:00:23.743  1766  1834 E BluetoothManagerService: Fail to bind to: Intent { act=android.bluetooth.IBluetooth }

The same setup with Android x86 Nougat (android-x86-7.1-r4) works.

projectbtle avatar Aug 18 '20 11:08 projectbtle

Attached logcat and dmesg outputs for Nougat (where Bluetooth works) and Pie (where Bluetooth doesn't work).

logcat_nougat.txt dmesg_nougat.txt logcat_pie.txt dmesg_pie.txt

projectbtle avatar Aug 18 '20 11:08 projectbtle

I have had issues in Android X-86 and BlissOS. This is what I have found to fix my specific issue after toying with different commands. You may be able to automate this process on boot following a process similar to https://android.stackexchange.com/a/6560/342111

Also note that I am on Mac and had to get a bluetooth USB adapter since MacOS does not allow you to use the built in bluetooth.

I also had to force Mac to not auto-capture my bluetooth USB dongle, but to let VirtualBox take it over. The command was sudo nvram bluetoothHostControllerSwitchBehavior=never

As to why this is needed, I don't know, but hopefully Bluetooth is more stable in future versions of Android X-86.

Command Chain (w/Sleep delays):

hciconfig && gsudo hciconfig hci0 down && sleep 10 && gsudo pm disable com.android.bluetooth && sleep 10 && gsudo pm enable com.android.bluetooth && sleep 10 && gsudo service call bluetooth_manager 6 && sleep 10 && gsudo hciconfig hci0 up

Commands to Enter and Leave Terminal:

Enter terminal: Alt + F1

Leave terminal: Alt + F7

Ordered Steps Explanation:

  • hciconfig
    • Shows the status of any bluetooth devices
  • gsudo hciconfig hci0 down
    • Puts the bluetooth receiver into an “off” mode.
    • Change hci0 to the ID of your bluetooth receiver if different
  • gsudo pm disable com.android.bluetooth
    • Stops the bluetooth Android package
  • gsudo pm enable com.android.bluetooth
    • Starts the bluetooth Android package
  • gsudo service call bluetooth_manager 6
    • Terminal call to enable bluetooth on the device. It is possible this could be done through the Android UI as well.
  • gsudo hciconfig hci0 up
    • Tells the bluetooth receiver to turn “on” and start transmissions as needed

Extra Commands:

  • gsudo service call bluetooth_manager 9
    • Disables bluetooth setting through terminal. This may be done manually as well, and this command might not be needed at all.

Notes:

  • gsudo is what the sudo command is in BlissOS. It may be the same in Android X-86 as well. gsudo may not be needed in the commands above, but I used it for good measure.

Jikodis avatar Dec 07 '21 01:12 Jikodis

Well, I'll be darned! Thanks Jikodis for the above post. I really need to have BT working inside my Android x86 Guest and for some reason, this does the trick. I never would have figured this out myself. I had managed to find the hciconfig -a and hciconfig chi0 up myself somehow and I was able to run hcitool scan and lescan and see results. So I thought I had it made. But that was not sufficient. I now have Tasker running this command line (with root) at boot:

hciconfig hci0 down; sleep 5;pm disable com.android.bluetooth;sleep 5;pm enable com.android.bluetooth;sleep 5;service call bluetooth_manager 6;sleep 5;hciconfig hci0 up

whitedavidp avatar Jan 25 '23 20:01 whitedavidp

Thanks a lot Jikodis, bluetooth worked successfully on my android x86 7.0-R5!

Ch667 avatar May 20 '24 04:05 Ch667