Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ed9aba0 authored by Vania Januar's avatar Vania Januar
Browse files

Add @Nullable to BluetoothAdapter provider.

Test: compilation and StylusManagerTest
Bug: 263451493
Change-Id: I57c467566afa5635aced88eb6ed322a55cd59938
parent de157676
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -636,6 +636,7 @@ public class FrameworkServicesModule {


    @Provides
    @Provides
    @Singleton
    @Singleton
    @Nullable
    static BluetoothAdapter provideBluetoothAdapter(BluetoothManager bluetoothManager) {
    static BluetoothAdapter provideBluetoothAdapter(BluetoothManager bluetoothManager) {
        return bluetoothManager.getAdapter();
        return bluetoothManager.getAdapter();
    }
    }
+3 −3
Original line number Original line Diff line number Diff line
@@ -38,7 +38,7 @@ class StylusManager
@Inject
@Inject
constructor(
constructor(
    private val inputManager: InputManager,
    private val inputManager: InputManager,
    private val bluetoothAdapter: BluetoothAdapter,
    private val bluetoothAdapter: BluetoothAdapter?,
    @Background private val handler: Handler,
    @Background private val handler: Handler,
    @Background private val executor: Executor,
    @Background private val executor: Executor,
) : InputManager.InputDeviceListener, BluetoothAdapter.OnMetadataChangedListener {
) : InputManager.InputDeviceListener, BluetoothAdapter.OnMetadataChangedListener {
@@ -141,7 +141,7 @@ constructor(
    }
    }


    private fun onStylusBluetoothConnected(btAddress: String) {
    private fun onStylusBluetoothConnected(btAddress: String) {
        val device: BluetoothDevice = bluetoothAdapter.getRemoteDevice(btAddress) ?: return
        val device: BluetoothDevice = bluetoothAdapter?.getRemoteDevice(btAddress) ?: return
        try {
        try {
            bluetoothAdapter.addOnMetadataChangedListener(device, executor, this)
            bluetoothAdapter.addOnMetadataChangedListener(device, executor, this)
        } catch (e: IllegalArgumentException) {
        } catch (e: IllegalArgumentException) {
@@ -150,7 +150,7 @@ constructor(
    }
    }


    private fun onStylusBluetoothDisconnected(btAddress: String) {
    private fun onStylusBluetoothDisconnected(btAddress: String) {
        val device: BluetoothDevice = bluetoothAdapter.getRemoteDevice(btAddress) ?: return
        val device: BluetoothDevice = bluetoothAdapter?.getRemoteDevice(btAddress) ?: return
        try {
        try {
            bluetoothAdapter.removeOnMetadataChangedListener(device, this)
            bluetoothAdapter.removeOnMetadataChangedListener(device, this)
        } catch (e: IllegalArgumentException) {
        } catch (e: IllegalArgumentException) {