Merge "Fix crash when no Bluetooth feature in Settings" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-04-24 02:45:09 +00:00
committed by Android (Google) Code Review
8 changed files with 94 additions and 14 deletions

View File

@@ -109,6 +109,10 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
* Force to update the list of bluetooth devices
*/
public void forceUpdate() {
if (mLocalManager == null) {
Log.e(TAG, "forceUpdate() Bluetooth is not supported on this device");
return;
}
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
final Collection<CachedBluetoothDevice> cachedDevices =
mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
@@ -121,6 +125,10 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
}
public void removeAllDevicesFromPreference() {
if (mLocalManager == null) {
Log.e(TAG, "removeAllDevicesFromPreference() BT is not supported on this device");
return;
}
final Collection<CachedBluetoothDevice> cachedDevices =
mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {