android-x86 / android-x86.github.io

Official Website for Android-x86 Project
MIT License
119 stars 33 forks source link

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

Open projectbtle opened 3 years ago

projectbtle commented 3 years ago

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:

Problem:

Troubleshooting:

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 commented 3 years ago

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

Jikodis commented 2 years ago

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:

Extra Commands:

Notes:

whitedavidp commented 1 year ago

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 bluetoothmanager 6;sleep 5;hciconfig hci0 up

Ch667 commented 2 months ago

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