Add error handle for device that not support Bluetooth

- Add LocalBluetoothManager null check for device that
  not support Bluetooth
- Add test to verify when LocalBluetoothManager is null
  will not crash

Bug: 110712414
Test: make -j42 RunSettingsRoboTests
Change-Id: Ib506a0206cfcfdfec60bdfcf9a1944338a7ab729
This commit is contained in:
hughchen
2018-06-25 11:06:45 +08:00
parent a5f68f9c3c
commit 34066fa21a
6 changed files with 81 additions and 3 deletions

View File

@@ -167,4 +167,20 @@ public class BluetoothDeviceUpdaterTest {
assertThat(mBluetoothDeviceUpdater.isDeviceConnected(mCachedBluetoothDevice)).isFalse();
}
@Test
public void registerCallback_localBluetoothManagerNull_shouldNotCrash() {
mBluetoothDeviceUpdater.mLocalManager = null;
// Shouldn't crash
mBluetoothDeviceUpdater.registerCallback();
}
@Test
public void unregisterCallback_localBluetoothManagerNull_shouldNotCrash() {
mBluetoothDeviceUpdater.mLocalManager = null;
// Shouldn't crash
mBluetoothDeviceUpdater.unregisterCallback();
}
}