Merge "Show single icon layout for unknown device type in advanced header." into udc-dev
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 919d179..07e9633 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -191,23 +191,7 @@
final BluetoothDevice device = mCachedDevice.getDevice();
final String deviceType = BluetoothUtils.getStringMetaData(device,
BluetoothDevice.METADATA_DEVICE_TYPE);
- if (TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_WATCH)
- || 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,
+ if (TextUtils.equals(deviceType,
BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET)
|| BluetoothUtils.getBooleanMetaData(device,
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) {
@@ -237,6 +221,20 @@
RIGHT_DEVICE_ID);
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);
}
}
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index ec100d0..e334af5 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -183,6 +183,26 @@
}
@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
public void refresh_connectedUntetheredHeadset_behaveAsExpected() {
when(mBluetoothDevice.getMetadata(
BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(