Keepass2android: Feature Request: Connect to a PC as a Bluetooth keyboard

Created on 6 Nov 2018  路  7Comments  路  Source: PhilippC/keepass2android

An interesting feature would be the ability to connect to a PC as a Bluetooth keyboard, allowing the user to press "username" and "password" buttons to send the text to the PC.

It appears that the latest versions of Android natively support the HID protocol, and others have made it work on older versions of Android, so it should be possible (and, perhaps, easy) to implement.

Most helpful comment

@dbw9580 , if you start writing a plug in, please let me know. I've been considering writing the code, too, so perhaps we can work together on it. The Bluetooth HID keyboard is simple, and there are good examples out there, but I haven't looked at Keepass's code to see what's needed there.

@RealOrangeOne , wired USB is an interesting idea, too. No pairing needed. However, it looks like it's difficult to implement and it may require a kernel patch. That InputStick looks interesting -- basically it's a Bluetooth receiver dongle with custom firmware to emulate HID devices?

All 7 comments

Definitely a must-have. I'm thinking about creating a plugin for this, maybe recently.

This would be a really nice idea! I personally use http://blog.inputstick.com/ to achieve this at the moment, which does work over bluetooth using a specific device on the host machine. But, the ability to do it wired over USB would be quite a bit nicer than having to carry around a specific dongle.

@dbw9580 , if you start writing a plug in, please let me know. I've been considering writing the code, too, so perhaps we can work together on it. The Bluetooth HID keyboard is simple, and there are good examples out there, but I haven't looked at Keepass's code to see what's needed there.

@RealOrangeOne , wired USB is an interesting idea, too. No pairing needed. However, it looks like it's difficult to implement and it may require a kernel patch. That InputStick looks interesting -- basically it's a Bluetooth receiver dongle with custom firmware to emulate HID devices?

@pearson I managed to find some time to write the code, but now I'm stuck. Sony has not pushed the Android 9 update to my phone (shame on you, Sony!) and their implementation of Android 8.0 doesn't include support for Bluetooth HID input device, so I am not able to test it.

This is my work in progress: https://github.com/dbw9580/BridgeTooth. App can run now but does nothing other than showing a list of entries sent from KP2A. The Bluetooth part is broken because it cannot bind to the BluetoothInputHost (BluetoothHIDDevice in API 28) profile. If you have got Android 9 on your phone, you can try it out, maybe finish where I left off.

I found the KP2A part of the plugin was a breeze thanks to good documentation and an example plugin, while the Bluetooth keyboard part was too much hard work. I was not able to find good references and examples regarding Android's new Bluetooth HID framework, so I had to dig into the USB HID protocol as well as Bluetooth HID specification and tried to make an implementation of my own.

I am totally new to Android so code review is appreciated. Thanks in advance!

I found a library that uses BLE interfaces to emulate a keyboard, and it turned out working fine. So the app is now doing all of its expected jobs, at least on my phone and with my computer.

On the other hand, finally Sony pushed that button and my phone is running Android Pie now. However, they seemed to still have not enabled support for Bluetooth HID device. I couldn't get it to work with legacy Bluetooth on my phone. I think I have finished the code, but I have no other devices to test it. If someone more experienced is interested, this is exactly the same situation I am now facing: https://stackoverflow.com/questions/53555092/how-can-i-use-the-bluetooth-hid-device-profile-in-android-pie

I just released a debug version, and someone please help me verify the BLE part is working, as well as test the legacy Bluetooth part: https://github.com/dbw9580/BridgeTooth/releases. The latest code is on the legacy-bt branch.

Note for testers: the app will try to use legacy bluetooth on an Android Pie device, and will fallback to BLE on lower. If you have an Android Pie device, look in logcat for that Could not bind to Bluetooth HID Device Service error. Otherwise please simply verify that all funtionalities are working as expected.

@dbw9580 Thanks for posting this! I had missed your previous message.

I have a Pixel device that I can test this on. It'll be a few days before I have the chance, but I'll definitely give it a try.

As well, I've seen references to emulating HID mode on older versions of Android. I'll see if I can find some of that code. That may require the device to be rooted, but we shall see.

I tried https://play.google.com/store/apps/details?id=io.appground.blek and by setting Keepass2 Keyboard on the phone, I can send username & Password to the computer. The only annoyance is I use QWERTY on phone and Programmers Dvorak on my PC So, I have to switch to US QWERTY before sending my keepass info.

Was this page helpful?
0 / 5 - 0 ratings