Merge "Add @Nullable to BluetoothAdapter provider." into tm-qpr-dev am: f1f50ee221

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20814153

Change-Id: I865392c362e7f295eeafa01b375f7b5fb7ab84a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Vania Januar
2023-01-03 23:02:37 +00:00
committed by Automerger Merge Worker
2 changed files with 4 additions and 3 deletions

View File

@@ -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();
} }

View File

@@ -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) {