Can I pair smartphone over Bluetooth without a need to confirm this in user interface, accept to pair this devices. I use android studio. I don't need to exchange data over them, I need just pairing without any action. And then safely pair with smartphone over Bluetooth without any user's action?
Asked
Active
Viewed 934 times
1 Answers
1
Yes and no, but you shouldn't anyway.
The only way to do this in Android is by using the BLUETOOTH_PRIVILEGED permission, which, as you can see, is only granted to apps in /system/priv-app/
or apps signed by the platform key of the device.
So unless you have root and can move your app to /system/priv-app/
, you can't do what you want. Even if you can do this, however, don't. It's not a good user experience when someone installs an app, only for it to move itself to the system partition and start pairing without any notification.

TheWanderer
- 16,775
- 6
- 49
- 63
-
`BLUETOOTH_PRIVILEGED` had been deprecated; `BLUETOOTH_ADMIN` is left. – Martin Zeitler Sep 12 '18 at 13:17
-
@MartinZeitler and BLUETOOTH_ADMIN doesn't let you pair without user confirmation. – TheWanderer Sep 12 '18 at 13:18
-
...one can send pairing requests from a remote device - while this still would cause a confirmation dialog to pop up. – Martin Zeitler Sep 12 '18 at 13:19
-
@MartinZeitler also, I'm not sure where you see that it's deprecated. The link I provided doesn't have anything mentioning that, and the framework still uses the permission. – TheWanderer Sep 12 '18 at 13:19
-
@MartinZeitler but that's not the OP's question: `without a need to confirm this in user interface` – TheWanderer Sep 12 '18 at 13:20
-
try adding it to a `Manifest.xml` and you will see it with yellow background... the question might be pointless in general, simply because it ignores security features. – Martin Zeitler Sep 12 '18 at 13:20
-
It's a system API. Android Studio is going to warn you about that. – TheWanderer Sep 12 '18 at 13:20
-
`BLUETOOTH_PRIVILEGED` was available previously, but meanwhile not for apps with later API levels anymore, despite still being used by the ART... even without documentation I'm pretty sure, due to refactoring that. – Martin Zeitler Sep 12 '18 at 13:23
-
`BLUETOOTH_PRIVILEGED` is still used in the framework, mainly in [BluetoothAdapter](https://github.com/aosp-mirror/platform_frameworks_base/blob/c1fd61b3026e15c652ecfd77e7962c2a656f9023/core/java/android/bluetooth/BluetoothAdapter.java) @MartinZeitler – TheWanderer Sep 12 '18 at 13:24
-
My links are from the `master` branch of AOSP. It's very much still in the later APIs. – TheWanderer Sep 12 '18 at 13:24
-
[System UI still uses it](https://github.com/aosp-mirror/platform_frameworks_base/blob/master/packages/SystemUI/AndroidManifest.xml#L57). It's not available to third party applications, like I just said in my answerr, but it exists and can be used by apps in `priv-app` or by apps signed by the platform key. – TheWanderer Sep 12 '18 at 13:26