Emulator: avoid accessing null BluetoothAdapter
bug: 27324609 Emulator has no bluetooth support at this moment, and settings should not crash in this case. Change-Id: I1bfc6c907ac02d4798b6c118291e6a9d1bf23c7c
This commit is contained in:
@@ -496,8 +496,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setListening(boolean listening) {
|
public void setListening(boolean listening) {
|
||||||
if (listening) {
|
|
||||||
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
if (defaultAdapter == null) return;
|
||||||
|
if (listening) {
|
||||||
mEnabled = defaultAdapter.isEnabled();
|
mEnabled = defaultAdapter.isEnabled();
|
||||||
mConnected =
|
mConnected =
|
||||||
defaultAdapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED;
|
defaultAdapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED;
|
||||||
|
Reference in New Issue
Block a user