mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
simplified calls to system services
and fixed some code that assumed BluetoothManager to never be NULL
This commit is contained in:
parent
b98a8ea34b
commit
f97bc21719
4 changed files with 22 additions and 15 deletions
|
|
@ -0,0 +1,12 @@
|
|||
package com.geeksville.mesh.android
|
||||
|
||||
import android.bluetooth.BluetoothManager
|
||||
import android.content.Context
|
||||
import android.hardware.usb.UsbManager
|
||||
|
||||
/**
|
||||
* @return null on platforms without a BlueTooth driver (i.e. the emulator)
|
||||
*/
|
||||
val Context.bluetoothManager: BluetoothManager? get() = getSystemService(Context.BLUETOOTH_SERVICE) as? BluetoothManager?
|
||||
|
||||
val Context.usbManager: UsbManager get() = requireNotNull(getSystemService(Context.USB_SERVICE) as? UsbManager) { "USB_SERVICE is not available"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue