OSDN Git Service

Remove "Play media to" when no connected device
authorTim Peng <timhypeng@google.com>
Mon, 22 Apr 2019 06:05:09 +0000 (14:05 +0800)
committertim peng <timhypeng@google.com>
Mon, 22 Apr 2019 06:09:36 +0000 (06:09 +0000)
Bug: 130251782
Test: make -j42 RunSettingsRoboTests
Change-Id: Id40199a67aef48b99f59cf6e04f93be2abe5e8fc

src/com/android/settings/media/MediaOutputIndicatorSlice.java
tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java

index 0023e3f..fe59d75 100644 (file)
@@ -114,29 +114,29 @@ public class MediaOutputIndicatorSlice implements CustomSliceable {
     private boolean isVisible() {
         // To decide Slice's visibility.
         // return true if device is connected or previously connected, false for other cases.
-        return !CollectionUtils.isEmpty(getConnectableA2dpDevices())
-                || !CollectionUtils.isEmpty(getConnectableHearingAidDevices());
+        return !CollectionUtils.isEmpty(getConnectedA2dpDevices())
+                || !CollectionUtils.isEmpty(getConnectedHearingAidDevices());
     }
 
-    private List<BluetoothDevice> getConnectableA2dpDevices() {
-        // Get A2dp devices on all states
-        // (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED,  STATE_DISCONNECTING)
+    private List<BluetoothDevice> getConnectedA2dpDevices() {
+        // Get A2dp devices on states
+        // (STATE_CONNECTING, STATE_CONNECTED,  STATE_DISCONNECTING)
         final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
         if (a2dpProfile == null) {
             return new ArrayList<>();
         }
-        return a2dpProfile.getConnectableDevices();
+        return a2dpProfile.getConnectedDevices();
     }
 
-    private List<BluetoothDevice> getConnectableHearingAidDevices() {
-        // Get hearing aid profile devices on all states
-        // (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED,  STATE_DISCONNECTING)
+    private List<BluetoothDevice> getConnectedHearingAidDevices() {
+        // Get hearing aid profile devices on states
+        // (STATE_CONNECTING, STATE_CONNECTED,  STATE_DISCONNECTING)
         final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
         if (hapProfile == null) {
             return new ArrayList<>();
         }
 
-        return hapProfile.getConnectableDevices();
+        return hapProfile.getConnectedDevices();
     }
 
     private CharSequence findActiveDeviceName() {
index b39f77e..1ba1dc9 100644 (file)
@@ -106,9 +106,9 @@ public class MediaOutputIndicatorSliceTest {
     }
 
     @Test
-    public void getSlice_noConnectableDevice_returnNull() {
+    public void getSlice_noConnectedDevice_returnNull() {
         mDevicesList.clear();
-        when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
+        when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
 
         assertThat(mMediaOutputIndicatorSlice.getSlice()).isNull();
     }
@@ -116,7 +116,7 @@ public class MediaOutputIndicatorSliceTest {
     @Test
     public void getSlice_noActiveDevice_verifyDefaultName() {
         mDevicesList.add(mA2dpDevice);
-        when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
+        when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
         when(mA2dpProfile.getActiveDevice()).thenReturn(null);
 
         // Verify slice title and subtitle
@@ -130,7 +130,7 @@ public class MediaOutputIndicatorSliceTest {
     @Test
     public void getSlice_A2dpDeviceActive_verifyName() {
         mDevicesList.add(mA2dpDevice);
-        when(mA2dpProfile.getConnectableDevices()).thenReturn(mDevicesList);
+        when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
         when(mA2dpProfile.getActiveDevice()).thenReturn(mA2dpDevice);
 
         final Slice mediaSlice = mMediaOutputIndicatorSlice.getSlice();
@@ -142,7 +142,7 @@ public class MediaOutputIndicatorSliceTest {
     @Test
     public void getSlice_HADeviceActive_verifyName() {
         mDevicesList.add(mHapDevice);
-        when(mHearingAidProfile.getConnectableDevices()).thenReturn(mDevicesList);
+        when(mHearingAidProfile.getConnectedDevices()).thenReturn(mDevicesList);
         when(mHearingAidProfile.getActiveDevices()).thenReturn(mDevicesList);
 
         // Verify slice title and subtitle