ralismark / bluehid

Bluetooth HID device for Android Oreo (proof of concept)
Apache License 2.0
36 stars 9 forks source link

Xposed module causing com.android.bluetooth to constantly restart #3

Closed sisiplac closed 4 years ago

sisiplac commented 4 years ago

After installing BlueHID (using "adb install ...") I get a notification in the status bar saying: Xposed module is not activated yet. As soon as I activate the module in Xposed Installer and reboot the system, the bluetooth module of my device does no more work properly - it turns on and off all the time. When I then start the BlueHID app, it asks for Bluetooth activation, buy pressing "yes" results in an endless loop (same dialog appearing again). Is there maybe a known solution to fix this problem?

By not activating BlueHID as Xposed module I get one step further after starting the app (no endless bluetooth activation dialog), but the app is not able to connect as HID to my phone (my phone appears in the list, but after selecting it the app crashes).

Here is some information about my system:

OS: Android Oreo 8.0 Platform: Arm64 Root Status: Rooted with Magisk Manager v7.5.0 (boot partition replacement) Xposed framework version: v90-beta3 installed via Magisk manager, XposedInstaller_3.1.5-Magisk to manage Xposed modules.

Thanks a lot in advance for your thoughts!

ralismark commented 4 years ago

Before API level 28 (Android P), the Bluetooth HID API can't be enabled without Xposed, so the module is required. There is also no known fix for bluetooth turning on and off - this is the first time I've encountered this issue, though I do remember my phone freezing when I was initially developing this. If possible, try turning bluetooth on before opening BlueHID and avoid reopening it from recents (#5).

However, I suspect your problem is coming from a lack of support in Oreo 8.0, so barring any fixes to your issue I'm going to close this in favour of #2.

Out of interest, can you upload your com.android.bluetooth apk? You can do this by runing adb shell pm path com.android.bluetooth, and then running adb pull <path> where is the output to the first command without the initial package:.

sisiplac commented 4 years ago

If possible, try turning bluetooth on before opening BlueHID and avoid reopening it from recents

Unfortunately, this is not possible. As long as BlueHID is activated as Xposed module, I can no more activate Bluetooth using the Android settings app. When BT is activated, it automatically gets deactivated in less than one second. Deactivating the BlueHID Xposed module (and rebooting) resolves this issue, so Bluetooth can again be turned on using the Android settings app.

sisiplac commented 4 years ago

Out of interest, can you upload your com.android.bluetooth apk?

Yes, sure - probably I can upload the APK on Monday. Thanks a lot for your good support!

sisiplac commented 4 years ago

As announced, here is the com.android.bluetooth APK extracted from the device (file extension changed from "apk" to "zip"): Bluetooth.zip

ralismark commented 4 years ago

Thanks! From a quick look, the necessary settings and components do exist to support BlueHID on Oreo 8.0, just like 8.1. Though I just realised your issue might be due to the Xposed module restarting the bluetooth module whenever it is started... If this is the case, Xposed logs should contain many instanced of the message "Forced enable com.android.bluetooth.hid.HidDevService".

sisiplac commented 4 years ago

Yes - you are absoutely right! The Xposed logs shows one line Loading class io.github.ralismark.bluehid.XMod and following many lines Forced enable com.android.bluetooth.hid.HidDevService (around every 1 or 2 seconds).

ralismark commented 4 years ago

I've made a change that'll hopefully stop this repeated restarting. Could you please test this change and see if is fixed, and also if BlueHID works on Oreo 8.0?

sisiplac commented 4 years ago

Thanks a lot for your change! Unfortunately, I could not test it yet, but I will definitely try it on monday.

sisiplac commented 4 years ago

I tried to run BlueHID again with your change: The Xposed log output now only shows the line Loading class io.github.ralismark.bluehid.XMod and no more the lines Forced enable com.android.bluetooth.hid.HidDevService. But the observed behavior is still the same. After activating the Xposed module and restarting the device the Bluetooth symbol in the status bar pops up a couple of times, but then remains deactivated. If BlueHID gets started, we are running again in the BlueHID wants to turn on Bluetooth loop. Even through the Android settings Bluetooth can no longer be activated.

ralismark commented 4 years ago

Unfortunately that probably means that your system doesn't have support for Bluetooth HID. Re-implementing it would be out of the scope of BlueHID, so there's not much I can do to resolve this problem. If you really want to use BlueHID, a different ROM might work.

sisiplac commented 4 years ago

I agree, working with a different ROM probably makes sense. But thanks a lot for your help anyway!