Skip to content

Commit

Permalink
chore: Fix missing permission lints for droidplug
Browse files Browse the repository at this point in the history
We can't do anything about these, we're a library not an application
  • Loading branch information
qdot committed Nov 19, 2023
1 parent b68e0a9 commit 05e6eb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nonpolynomial.btleplug.android.impl;

import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanFilter.Builder;
Expand All @@ -17,6 +18,7 @@ class Adapter {

public Adapter() {}

@SuppressLint("MissingPermission")
public void startScan(ScanFilter filter) {
ArrayList<android.bluetooth.le.ScanFilter> filters = null;
String[] uuids = filter.getUuids();
Expand All @@ -32,6 +34,7 @@ public void startScan(ScanFilter filter) {
BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner().startScan(filters, settings, this.callback);
}

@SuppressLint("MissingPermission")
public void stopScan() {
BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner().stopScan(this.callback);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nonpolynomial.btleplug.android.impl;

import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
Expand Down Expand Up @@ -41,6 +42,7 @@ public Peripheral(Adapter adapter, String address) {
this.callback = new Callback();
}

@SuppressLint("MissingPermission")
public Future<Void> connect() {
SimpleFuture<Void> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -82,6 +84,7 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
return future;
}

@SuppressLint("MissingPermission")
public Future<Void> disconnect() {
SimpleFuture<Void> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -118,6 +121,7 @@ public boolean isConnected() {
return this.connected;
}

@SuppressLint("MissingPermission")
public Future<byte[]> read(UUID uuid) {
SimpleFuture<byte[]> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -163,6 +167,7 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
return future;
}

@SuppressLint("MissingPermission")
public Future<Void> write(UUID uuid, byte[] data, int writeType) {
SimpleFuture<Void> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -210,6 +215,7 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
return future;
}

@SuppressLint("MissingPermission")
public Future<List<BluetoothGattService>> discoverServices() {
SimpleFuture<List<BluetoothGattService>> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -252,6 +258,7 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
return future;
}

@SuppressLint("MissingPermission")
public Future<Void> setCharacteristicNotification(UUID uuid, boolean enable) {
SimpleFuture<Void> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -316,6 +323,7 @@ public Stream<BluetoothGattCharacteristic> getNotifications() {
return stream;
}

@SuppressLint("MissingPermission")
public Future<byte[]> readDescriptor(UUID characteristic, UUID uuid) {
SimpleFuture<byte[]> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -347,6 +355,7 @@ public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descrip
return future;
}

@SuppressLint("MissingPermission")
public Future<Void> writeDescriptor(UUID characteristic, UUID uuid, byte[] data, int writeType) {
SimpleFuture<Void> future = new SimpleFuture<>();
synchronized (this) {
Expand Down Expand Up @@ -379,6 +388,7 @@ public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descri
return future;
}

@SuppressLint("MissingPermission")
private List<BluetoothGattCharacteristic> getCharacteristics() {
List<BluetoothGattCharacteristic> result = new ArrayList<>();
if (this.gatt != null) {
Expand All @@ -389,6 +399,7 @@ private List<BluetoothGattCharacteristic> getCharacteristics() {
return result;
}

@SuppressLint("MissingPermission")
private BluetoothGattCharacteristic getCharacteristicByUuid(UUID uuid) {
for (BluetoothGattCharacteristic characteristic : this.getCharacteristics()) {
if (characteristic.getUuid().equals(uuid)) {
Expand All @@ -399,6 +410,7 @@ private BluetoothGattCharacteristic getCharacteristicByUuid(UUID uuid) {
throw new NoSuchCharacteristicException();
}

@SuppressLint("MissingPermission")
private BluetoothGattDescriptor getDescriptorByUuid(UUID characteristicUuid, UUID uuid) {
BluetoothGattCharacteristic characteristic = getCharacteristicByUuid(characteristicUuid);
for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
Expand Down

0 comments on commit 05e6eb1

Please sign in to comment.