Merge "Make HearingAid code more generic"

This commit is contained in:
Hugh Chen
2018-10-26 01:57:24 +00:00
committed by Android (Google) Code Review
5 changed files with 36 additions and 7 deletions

View File

@@ -65,12 +65,10 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
.getBtClassDrawableWithDescription(mContext, mCachedDevice,
mContext.getResources().getFraction(R.fraction.bt_battery_scale_fraction, 1, 1));
String summaryText = mCachedDevice.getConnectionSummary();
// If both the hearing aids are connected, two battery status should be shown.
final String pairDeviceSummary = mDeviceManager
.getHearingAidPairDeviceSummary(mCachedDevice);
if (pairDeviceSummary != null) {
mHeaderController.setSecondSummary(pairDeviceSummary);
}
// If both the hearing aids are connected, two device status should be shown.
// If Second Summary is unavailable, to set it to null.
mHeaderController.setSecondSummary(
mDeviceManager.getSubDeviceSummary(mCachedDevice));
mHeaderController.setLabel(mCachedDevice.getName());
mHeaderController.setIcon(pair.first);
mHeaderController.setIconContentDescription(pair.second);

View File

@@ -51,6 +51,8 @@ public class BluetoothDetailsMacAddressController extends BluetoothDetailsContro
@Override
protected void refresh() {
mFooterPreference.setTitle(mContext.getString(
R.string.bluetooth_device_mac_address, mCachedDevice.getAddress()));
}
@Override

View File

@@ -230,9 +230,19 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
*/
protected void removePreference(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
final CachedBluetoothDevice subCachedDevice = cachedDevice.getSubDevice();
if (mPreferenceMap.containsKey(device)) {
mDevicePreferenceCallback.onDeviceRemoved(mPreferenceMap.get(device));
mPreferenceMap.remove(device);
} else if (subCachedDevice != null) {
// When doing remove, to check if preference maps to sub device.
// This would happen when connection state is changed in detail page that there is no
// callback from SettingsLib.
final BluetoothDevice subDevice = subCachedDevice.getDevice();
if (mPreferenceMap.containsKey(subDevice)) {
mDevicePreferenceCallback.onDeviceRemoved(mPreferenceMap.get(subDevice));
mPreferenceMap.remove(subDevice);
}
}
}