Skip to content

Commit

Permalink
Fix: App Crash on Android 12
Browse files Browse the repository at this point in the history
  • Loading branch information
umer0586 committed Jan 8, 2025
1 parent 25c499f commit de093d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ class BluetoothLEConnection(
private var connectedDevice: BluetoothDevice? = null


val localName: String
@SuppressLint("MissingPermission")
get() = bluetoothAdapter.name ?: "Unknown"
val bluetoothDisplayName: String
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
context.checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
"Unknown"
} else {
bluetoothAdapter.name ?: "Unknown"
}

override val connectionType: ConnectionType
get() = ConnectionType.BLUETOOTH_LE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ControlPadPlayScreenViewModel @Inject constructor(
ConnectionType.UDP -> (connection as UDPConnection).udpConfig.address
ConnectionType.WEBSOCKET -> (connection as WebsocketConnection).webSocketConfig.address
ConnectionType.MQTT -> (connection as MqttConnection).mqttConfig.brokerAddress
ConnectionType.BLUETOOTH_LE -> (connection as BluetoothLEConnection).localName
ConnectionType.BLUETOOTH_LE -> (connection as BluetoothLEConnection).bluetoothDisplayName

}
)
Expand Down

0 comments on commit de093d1

Please sign in to comment.