Skip to content

Commit 84dbf46

Browse files
author
Winson Chung
committed
Fixing crash in emulator due to no BluetoothAdapter. (Bug 7188166)
Change-Id: I63fe4b229a8a460170df153e71b7ad65655dfad1
1 parent 24ed276 commit 84dbf46

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,18 @@ public void onReceive(Context context, Intent intent) {
9696
}
9797

9898
private void updateBondedBluetoothDevices() {
99-
Set<BluetoothDevice> devices = BluetoothAdapter.getDefaultAdapter().getBondedDevices();
100-
if (devices != null) {
101-
mBondedDevices.clear();
102-
for (BluetoothDevice device : devices) {
103-
if (device.getBondState() != BluetoothDevice.BOND_NONE) {
104-
mBondedDevices.add(device);
99+
mBondedDevices.clear();
100+
101+
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
102+
if (adapter != null) {
103+
Set<BluetoothDevice> devices = adapter.getBondedDevices();
104+
if (devices != null) {
105+
for (BluetoothDevice device : devices) {
106+
if (device.getBondState() != BluetoothDevice.BOND_NONE) {
107+
mBondedDevices.add(device);
108+
}
105109
}
106110
}
107-
} else {
108-
mBondedDevices.clear();
109111
}
110112
}
111113

0 commit comments

Comments
 (0)