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:
bohu
2016-02-24 06:55:16 -08:00
parent df1cbdcf56
commit 625bc4bd21

View File

@@ -496,8 +496,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
@Override
public void setListening(boolean listening) {
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
if (defaultAdapter == null) return;
if (listening) {
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
mEnabled = defaultAdapter.isEnabled();
mConnected =
defaultAdapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED;