Merge "Unable to show correct device icon in Output Switcher" into rvc-dev am: fb87c72c66 am: 54091ba0f1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12055443 Change-Id: I46943e8d21424d0cf07408359aad9e2ef3efb7b3
This commit is contained in:
@@ -15,16 +15,12 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="11dp"
|
||||
android:viewportWidth="14"
|
||||
android:viewportHeight="11"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="18">
|
||||
<path
|
||||
android:pathData="M10,10v1H4v-1H1.5A1.5,1.5 0,0 1,0 8.5v-7A1.5,1.5 0,
|
||||
0 1,1.5 0h11A1.5,1.5 0,0 1,14 1.5v7a1.5,1.5 0,0 1,-1.5 1.5H10zM1.5,
|
||||
1a0.5,0.5 0,0 0,-0.5 0.5v7a0.5,0.5 0,0 0,0.5 0.5h11a0.5,0.5 0,0 0,
|
||||
0.5 -0.5v-7a0.5,0.5 0,0 0,-0.5 -0.5h-11z"
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M12,14V15H6V14H3.5C3.1022,14 2.7206,13.842 2.4393,13.5607C2.158,13.2794 2,12.8978 2,12.5V5.5C2,5.1022 2.158,4.7206 2.4393,4.4393C2.7206,4.158 3.1022,4 3.5,4H14.5C14.8978,4 15.2794,4.158 15.5607,4.4393C15.842,4.7206 16,5.1022 16,5.5V12.5C16,12.8978 15.842,13.2794 15.5607,13.5607C15.2794,13.842 14.8978,14 14.5,14H12ZM3.5,5C3.3674,5 3.2402,5.0527 3.1465,5.1465C3.0527,5.2402 3,5.3674 3,5.5V12.5C3,12.6326 3.0527,12.7598 3.1465,12.8536C3.2402,12.9473 3.3674,13 3.5,13H14.5C14.6326,13 14.7598,12.9473 14.8536,12.8536C14.9473,12.7598 15,12.6326 15,12.5V5.5C15,5.3674 14.9473,5.2402 14.8536,5.1465C14.7598,5.0527 14.6326,5 14.5,5H3.5Z"
|
||||
android:fillColor="#5F6368"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.settingslib.media;
|
||||
|
||||
import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK;
|
||||
import static android.media.MediaRoute2Info.FEATURE_REMOTE_VIDEO_PLAYBACK;
|
||||
import static android.media.MediaRoute2Info.TYPE_GROUP;
|
||||
import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER;
|
||||
import static android.media.MediaRoute2Info.TYPE_REMOTE_TV;
|
||||
@@ -29,6 +31,8 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* InfoMediaDevice extends MediaDevice to represents wifi device.
|
||||
*/
|
||||
@@ -62,7 +66,7 @@ public class InfoMediaDevice extends MediaDevice {
|
||||
|
||||
@Override
|
||||
public Drawable getIconWithoutBackground() {
|
||||
return mContext.getDrawable(getDrawableResId());
|
||||
return mContext.getDrawable(getDrawableResIdByFeature());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -83,6 +87,21 @@ public class InfoMediaDevice extends MediaDevice {
|
||||
return resId;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getDrawableResIdByFeature() {
|
||||
int resId;
|
||||
final List<String> features = mRouteInfo.getFeatures();
|
||||
if (features.contains(FEATURE_REMOTE_GROUP_PLAYBACK)) {
|
||||
resId = R.drawable.ic_media_group_device;
|
||||
} else if (features.contains(FEATURE_REMOTE_VIDEO_PLAYBACK)) {
|
||||
resId = R.drawable.ic_media_display_device;
|
||||
} else {
|
||||
resId = R.drawable.ic_media_speaker_device;
|
||||
}
|
||||
|
||||
return resId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return MediaDeviceUtils.getId(mRouteInfo);
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settingslib.media;
|
||||
|
||||
import static android.media.MediaRoute2Info.FEATURE_REMOTE_AUDIO_PLAYBACK;
|
||||
import static android.media.MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK;
|
||||
import static android.media.MediaRoute2Info.FEATURE_REMOTE_VIDEO_PLAYBACK;
|
||||
import static android.media.MediaRoute2Info.TYPE_GROUP;
|
||||
import static android.media.MediaRoute2Info.TYPE_REMOTE_SPEAKER;
|
||||
import static android.media.MediaRoute2Info.TYPE_REMOTE_TV;
|
||||
@@ -38,6 +41,8 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class InfoMediaDeviceTest {
|
||||
|
||||
@@ -107,4 +112,28 @@ public class InfoMediaDeviceTest {
|
||||
|
||||
assertThat(mInfoMediaDevice.getDrawableResId()).isEqualTo(R.drawable.ic_media_group_device);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDrawableResIdByFeature_returnCorrectResId() {
|
||||
final ArrayList<String> features = new ArrayList<>();
|
||||
features.add(FEATURE_REMOTE_VIDEO_PLAYBACK);
|
||||
when(mRouteInfo.getFeatures()).thenReturn(features);
|
||||
|
||||
assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo(
|
||||
R.drawable.ic_media_display_device);
|
||||
|
||||
features.clear();
|
||||
features.add(FEATURE_REMOTE_AUDIO_PLAYBACK);
|
||||
when(mRouteInfo.getFeatures()).thenReturn(features);
|
||||
|
||||
assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo(
|
||||
R.drawable.ic_media_speaker_device);
|
||||
|
||||
features.clear();
|
||||
features.add(FEATURE_REMOTE_GROUP_PLAYBACK);
|
||||
when(mRouteInfo.getFeatures()).thenReturn(features);
|
||||
|
||||
assertThat(mInfoMediaDevice.getDrawableResIdByFeature()).isEqualTo(
|
||||
R.drawable.ic_media_group_device);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user