Skip to content

Commit

Permalink
lint: Missing permission
Browse files Browse the repository at this point in the history
  • Loading branch information
LeandroSQ committed Oct 24, 2023
1 parent 52750b8 commit 31390e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package quevedo.soares.leandro.blemadeeasy.models

import android.annotation.SuppressLint
import android.bluetooth.BluetoothDevice

class BLEDevice(var device: BluetoothDevice, var rsii: Int = 0, val advertisingId: Int = -1) {

val name: String get () = device.name ?: ""
@get:SuppressLint("MissingPermission")
val name: String
get() = device.name ?: ""

val macAddress: String get () = device.address

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package quevedo.soares.leandro.blemadeeasy.models

import android.Manifest
import android.annotation.SuppressLint
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor
import androidx.annotation.RequiresPermission
import quevedo.soares.leandro.blemadeeasy.exceptions.PeripheralNotObservableException
import java.util.*

Expand All @@ -20,13 +23,16 @@ data class BluetoothCharacteristic(
return this.characteristic.descriptors.find { it.uuid == c }
}

@SuppressLint("MissingPermission")
fun read(gatt: BluetoothGatt): Boolean = gatt.readCharacteristic(this.characteristic)

@SuppressLint("MissingPermission")
fun write(gatt: BluetoothGatt, value: ByteArray): Boolean {
this.characteristic.value = value
return gatt.writeCharacteristic(this.characteristic)
}

@SuppressLint("MissingPermission")
fun enableNotify(gatt: BluetoothGatt) {
// If the characteristic does not export the NOTIFY property, throw an exception
if (!this.isNotifiable) throw PeripheralNotObservableException(gatt.device.address, this.uuid.toString().lowercase())
Expand All @@ -39,6 +45,7 @@ data class BluetoothCharacteristic(
gatt.setCharacteristicNotification(this.characteristic, true)
}

@SuppressLint("MissingPermission")
fun disableNotify(gatt: BluetoothGatt) {
// If the characteristic does not export the NOTIFY property, throw an exception
if (!this.isNotifiable) throw PeripheralNotObservableException(gatt.device.address, this.uuid.toString().lowercase())
Expand Down

0 comments on commit 31390e0

Please sign in to comment.