Android Question Bluetooth silent pairing in a kiosk app

Uitenhage

Member
Licensed User
Longtime User
I have a Kiosk app based on https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/. It is set as the Device Owner and the Home Launcher.
At the end of a shift the user needs to upload the data they have collected to a PC via Bluetooth which isn't a problem if the device has already been paired. But because this is a kiosk app the dialogs to initially pair the phone with the PC are not visible so pairing without a passkey or user confirmation is necessary.

Erel's code at https://www.b4x.com/android/forum/threads/hidden-bluetooth-pairing-notification.79196/#post-730621 came close to a solution but complained of a missing permission ("android.permission.BLUETOOTH_PRIVILEGED"). I added that in the manifest and requested the permission in code but it still throws an error: "java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission: Neither user 10264 nor current process has android.permission.BLUETOOTH_PRIVILEGED." I tried running "adb shell pm grant my_package_name_here android.permission.BLUETOOTH_PRIVILEGED" in a CMD window but adb would not set it.

I used the technique at https://www.b4x.com/android/forum/t...ivityforresult-with-javaobject.40374/#content to show the basic Bluetooth settings page but it doesn't show the passkey confirmation dialog in the foreground like it does in non-kiosk app.

Google led me to https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_PRIVILEGED which tells me "Not for use by third-party applications." This apparently restricts the permission to system apps only. Does this not include device-owner apps?

Am I missing something or is it truly not feasible on a non-custom ROM device?
 
Top