Fix settings crash

- This CL before, "Previously connected device" didn't
  handle dock device. If user have disconnected dock
  device will cause Settings crash.

  This CL add condition to handle dock device to avoid crash.
- Update test case.

Bug: 157653997
Bug: 167054620
Test: make -j42 RunSettingsRoboTests
Change-Id: I769cee3f589e14a993b00a0ae6ec3ddfba8ef281
Merged-In: I769cee3f589e14a993b00a0ae6ec3ddfba8ef281
This commit is contained in:
Hugh Chen
2020-09-02 17:00:13 +08:00
parent cb057d6e9e
commit 194dd88e7d
3 changed files with 75 additions and 27 deletions

View File

@@ -96,7 +96,6 @@ public final class BluetoothDevicePreference extends GearPreference implements
}
mCachedDevice = cachedDevice;
mCachedDevice.registerCallback(this);
mCurrentTime = System.currentTimeMillis();
mType = type;
@@ -127,13 +126,24 @@ public final class BluetoothDevicePreference extends GearPreference implements
@Override
protected void onPrepareForRemoval() {
super.onPrepareForRemoval();
mCachedDevice.unregisterCallback(this);
if (mDisconnectDialog != null) {
mDisconnectDialog.dismiss();
mDisconnectDialog = null;
}
}
@Override
public void onAttached() {
super.onAttached();
mCachedDevice.registerCallback(this);
}
@Override
public void onDetached() {
super.onDetached();
mCachedDevice.unregisterCallback(this);
}
public CachedBluetoothDevice getBluetoothDevice() {
return mCachedDevice;
}