Skip to content

Commit 4fec6ec

Browse files
authored
Merge pull request #551 from CyDragon80/abort_connection
Provide access to cancelConnection so that a server can deny a client
2 parents 577262c + 8131257 commit 4fec6ec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ble/src/main/java/no/nordicsemi/android/ble/BleServerManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ final void useConnection(@NonNull final BluetoothDevice device, final boolean au
182182
* <p>
183183
* As we're not calling {@link BluetoothGattServer#connect(BluetoothDevice, boolean)}, cancelling
184184
* the connection should not be required. On the other hand, perhaps we should call connect(..).
185+
* Can also be called in onDeviceConnectedToServer to refuse a device connection without accepting it first.
186+
* If you already have a managed connection and want to disconnect, you can use the disconnect request on the connection.
185187
* @param device The device to cancel connection to.
186188
*/
187-
final void cancelConnection(@NonNull final BluetoothDevice device) {
189+
protected final void cancelConnection(@NonNull final BluetoothDevice device) {
188190
if (server != null &&
189191
(Build.VERSION.SDK_INT < Build.VERSION_CODES.S ||
190192
context.checkCallingOrSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED)) {

0 commit comments

Comments
 (0)