Fix runtime exception when cachedDevice is null

Finish the activity after call super.onAttach().

Bug: 143187915
Test: make -j42 RunSettingsRoboTests
Change-Id: I8f205ef60797bd9eb96617d413f554613008f65b
This commit is contained in:
hughchen
2019-10-24 14:36:37 +08:00
parent e7f5837319
commit d368c21832
2 changed files with 5 additions and 2 deletions

View File

@@ -92,7 +92,8 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
public int getAvailabilityStatus() {
final boolean advancedEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, true);
final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(
final boolean untetheredHeadset = mCachedDevice != null
&& BluetoothUtils.getBooleanMetaData(
mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
return advancedEnabled && untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}