Skip to content

Commit

Permalink
Provide access to cancelConnection so that a server can deny a device…
Browse files Browse the repository at this point in the history
… connection without creating a managed connection just to disconnect it
  • Loading branch information
CyDragon80 committed Mar 31, 2024
1 parent 6dd5bec commit f294666
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ final void useConnection(@NonNull final BluetoothDevice device, final boolean au
* <p>
* As we're not calling {@link BluetoothGattServer#connect(BluetoothDevice, boolean)}, cancelling
* the connection should not be required. On the other hand, perhaps we should call connect(..).
* Can also be called in onDeviceConnectedToServer to refuse a device connection without accepting it first.
* If you already have a managed connection and want to disconnect, you can use the disconnect request on the connection.
* @param device The device to cancel connection to.
*/
final void cancelConnection(@NonNull final BluetoothDevice device) {
public final void cancelConnection(@NonNull final BluetoothDevice device) {
if (server != null &&
(Build.VERSION.SDK_INT < Build.VERSION_CODES.S ||
context.checkCallingOrSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED)) {
Expand Down

0 comments on commit f294666

Please sign in to comment.