dbw9580 / BridgeTooth

Type passwords from KeePass2Android via Bluetooth
GNU General Public License v3.0
10 stars 3 forks source link

Android Pie support #2

Open dbw9580 opened 5 years ago

dbw9580 commented 5 years ago

The new APIs (BluetoothHIDDevice) introduced in Android Pie allows to emulate an HID device, such as a keyboard. This app can function in two ways: on an Android Pie device, it defaults to use the new APIs; otherwise it uses Bluetooth Low Energy APIs. An option exists to override this behavior.

The code around the new APIs has been added but never tested, because my own device does not support that feature although it is already Android 9. If you have a support device please look into this, PRs are very much appreciated!

lizardb0y commented 5 years ago

I'm running Android 9 on a OnePlus 7 Pro. I just installed 0.0.2 from the release package. Initial observation is that the plugin works with default and with BLE API forced.

It took a little bit of fiddling and re-pairing before I was able to send keystrokes but I wasn't methodical about the process so don't have any particular feedback at this stage. When I have some time over the next few days I'll unpair, remove the plugin and take a more methodical approach to testing from scratch. It looks should so far though :)

dbw9580 commented 5 years ago

Really appreciate the effort and glad to know it worked! Although I have bad news about OnePlus because there have been reports here and here about the new APIs not implemented on some of their devices, either.

I don't know how many manufacturers decide not to implement this feature, but from that issue on Android issue tracker it seems at least OnePlus and Nokia devices are affected. I can confirm Sony's also don't work.

If unfortunately your OnePlus device doesn't work with the new APIs, can you please test the stability (the probability) that the app successfully connects with the BLE APIs, as well as the time (setup time) it takes after it shows connected and before anything can be actually typed to a receiver device?

lizardb0y commented 4 years ago

Android device OnePlus 7 Pro GM1910 Build: Oxygen OS 9.5.8.GM21AA

Host device HP Elitebook x360 1030 G2 Windows 10 1703 Intel Wireless-AC 8265 Bluetooth 4.2

Android - Start with Use BLE off Windows host - Android device does not appear Android - Switch use BLE on Android device appears on Windows host as a HID device Windows host - Click Pair Both devices - Show Pairing dialog with matching PIN Both devices - Click Pair Android - shows a second Pairing notification Android - Click on Pairing notification Android - New dialog appears asking to enter the PIN diplayed on the host device Windows host - Shows new PIN Android - Enter the PIN and tap Pair Both devices - pairing successful.

There is a 1-2 minute delay before the host shows as connected and I can sucessfully send data using send string in Bridgetooth and send via bluetooth in Keepass2Android.

seanf commented 4 years ago

@dbw9580 It's working for me on a Redmi Note 8 Pro with Android 9.

Android device Redmi Note 8 Pro Build: Android 9 PPR1.180610.011 MIUI version: MIUI Global 11.0.6

Host device Windows 10 1903 Cheapo USB Bluetooth

At first I couldn't get it to do anything, even with multiple pairings, with or without BLE. Then I noticed that I had an Android security update waiting - so I upgraded, rebooted, re-paired and then Send String just worked immediately (I just had to switch my PC back to QWERTY instead of Dvorak). No BLE in the end. I've just tried three times in a row, with the same result each time.

I doubt that the update had anything to do with it, but maybe the phone's Bluetooth stack just needed restarting after my (successful) experiments with https://play.google.com/store/apps/details?id=io.appground.blek

seanf commented 4 years ago

@dbw9580 Perhaps you've already seen it, but you might be interested in this other (GPL 3) project which also apparently emulates a Bluetooth keyboard when running on Android 9: https://github.com/tejado/Authorizer (EDIT: I can't get it to work, on the two phones I've tried. And make sure you install the latest version for Bluetooth support; Google Play still has v0.3.0)

This KeePassDX discussion is interesting too: https://github.com/Kunzisoft/KeePassDX/issues/80

seanf commented 4 years ago

Also working on a Redmi Note 3 running Android 9 (Pixel Experience ROM).

On a Xiaomi Mi A1, no typing ever comes through (with or without BLE). I don't think my PC is recognising the phone as a keyboard/mouse device, and the BridgeTooth notification says "no host device connected".

I tried out "Serverless Bluetooth Keyboard/Mouse for PC / Phone" on the Mi A1, and it told me "Your device does not seem to support standard connection mode. You may need to switch to Bluetooth Low Energy connection mode to control a device". Even then, it only worked as a mouse, not as a keyboard.