Merge "Show single icon layout for unknown device type in advanced header." into udc-dev am: 76452f3a1f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21700162 Change-Id: I5cf3fa692a8bd992e78b2a42fe3817487683f5e2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -191,23 +191,7 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
final BluetoothDevice device = mCachedDevice.getDevice();
|
final BluetoothDevice device = mCachedDevice.getDevice();
|
||||||
final String deviceType = BluetoothUtils.getStringMetaData(device,
|
final String deviceType = BluetoothUtils.getStringMetaData(device,
|
||||||
BluetoothDevice.METADATA_DEVICE_TYPE);
|
BluetoothDevice.METADATA_DEVICE_TYPE);
|
||||||
if (TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_WATCH)
|
if (TextUtils.equals(deviceType,
|
||||||
|| TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_DEFAULT)
|
|
||||||
|| TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_STYLUS)) {
|
|
||||||
mLayoutPreference.findViewById(R.id.layout_left).setVisibility(View.GONE);
|
|
||||||
mLayoutPreference.findViewById(R.id.layout_right).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
summary.setText(mCachedDevice.getConnectionSummary(
|
|
||||||
BluetoothUtils.getIntMetaData(device, BluetoothDevice.METADATA_MAIN_BATTERY)
|
|
||||||
!= BluetoothUtils.META_INT_ERROR));
|
|
||||||
updateSubLayout(mLayoutPreference.findViewById(R.id.layout_middle),
|
|
||||||
BluetoothDevice.METADATA_MAIN_ICON,
|
|
||||||
BluetoothDevice.METADATA_MAIN_BATTERY,
|
|
||||||
BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD,
|
|
||||||
BluetoothDevice.METADATA_MAIN_CHARGING,
|
|
||||||
/* titleResId */ 0,
|
|
||||||
MAIN_DEVICE_ID);
|
|
||||||
} else if (TextUtils.equals(deviceType,
|
|
||||||
BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET)
|
BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET)
|
||||||
|| BluetoothUtils.getBooleanMetaData(device,
|
|| BluetoothUtils.getBooleanMetaData(device,
|
||||||
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) {
|
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) {
|
||||||
@@ -237,6 +221,20 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
RIGHT_DEVICE_ID);
|
RIGHT_DEVICE_ID);
|
||||||
|
|
||||||
showBothDevicesBatteryPredictionIfNecessary();
|
showBothDevicesBatteryPredictionIfNecessary();
|
||||||
|
} else {
|
||||||
|
mLayoutPreference.findViewById(R.id.layout_left).setVisibility(View.GONE);
|
||||||
|
mLayoutPreference.findViewById(R.id.layout_right).setVisibility(View.GONE);
|
||||||
|
|
||||||
|
summary.setText(mCachedDevice.getConnectionSummary(
|
||||||
|
BluetoothUtils.getIntMetaData(device, BluetoothDevice.METADATA_MAIN_BATTERY)
|
||||||
|
!= BluetoothUtils.META_INT_ERROR));
|
||||||
|
updateSubLayout(mLayoutPreference.findViewById(R.id.layout_middle),
|
||||||
|
BluetoothDevice.METADATA_MAIN_ICON,
|
||||||
|
BluetoothDevice.METADATA_MAIN_BATTERY,
|
||||||
|
BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD,
|
||||||
|
BluetoothDevice.METADATA_MAIN_CHARGING,
|
||||||
|
/* titleResId */ 0,
|
||||||
|
MAIN_DEVICE_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -182,6 +182,26 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
View.VISIBLE);
|
View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refresh_connectedUnknownType_behaveAsExpected() {
|
||||||
|
when(mBluetoothDevice.getMetadata(
|
||||||
|
BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
|
||||||
|
"UNKNOWN_TYPE".getBytes());
|
||||||
|
when(mBluetoothDevice.getMetadata(
|
||||||
|
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn(
|
||||||
|
String.valueOf(false).getBytes());
|
||||||
|
when(mCachedDevice.isConnected()).thenReturn(true);
|
||||||
|
|
||||||
|
mController.refresh();
|
||||||
|
|
||||||
|
assertThat(mLayoutPreference.findViewById(R.id.layout_left).getVisibility()).isEqualTo(
|
||||||
|
View.GONE);
|
||||||
|
assertThat(mLayoutPreference.findViewById(R.id.layout_right).getVisibility()).isEqualTo(
|
||||||
|
View.GONE);
|
||||||
|
assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
|
||||||
|
View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refresh_connectedUntetheredHeadset_behaveAsExpected() {
|
public void refresh_connectedUntetheredHeadset_behaveAsExpected() {
|
||||||
when(mBluetoothDevice.getMetadata(
|
when(mBluetoothDevice.getMetadata(
|
||||||
|
Reference in New Issue
Block a user