Merge "Fix NPE force close if disabling BT feature" into main
diff --git a/src/com/android/settings/network/TetheredRepository.kt b/src/com/android/settings/network/TetheredRepository.kt
index f18bdca..29a5665 100644
--- a/src/com/android/settings/network/TetheredRepository.kt
+++ b/src/com/android/settings/network/TetheredRepository.kt
@@ -72,7 +72,7 @@
flowOf(null), // kick an initial value
context.broadcastReceiverFlow(IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)),
).flatMapLatest {
- if (adapter.getState() == BluetoothAdapter.STATE_ON) {
+ if (adapter?.getState() == BluetoothAdapter.STATE_ON) {
isBluetoothPanTetheringOnFlow()
} else {
flowOf(false)
@@ -93,10 +93,10 @@
override fun onServiceDisconnected(profile: Int) {}
}
- adapter.getProfileProxy(context, listener, BluetoothProfile.PAN)
+ adapter?.getProfileProxy(context, listener, BluetoothProfile.PAN)
awaitClose {
- connectedProxy?.let { adapter.closeProfileProxy(BluetoothProfile.PAN, it) }
+ connectedProxy?.let { adapter?.closeProfileProxy(BluetoothProfile.PAN, it) }
}
}.conflate().flowOn(Dispatchers.Default)
}