Loading packages/SettingsLib/res/drawable/ic_tv_box_internal_speaker.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2022 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?android:attr/textColorPrimary" android:autoMirrored="true"> <path android:fillColor="#FFFFFFFF" android:pathData="M14,20.725V18.675Q16.25,18.025 17.625,16.175Q19,14.325 19,11.975Q19,9.625 17.625,7.775Q16.25,5.925 14,5.275V3.225Q17.1,3.925 19.05,6.362Q21,8.8 21,11.975Q21,15.15 19.05,17.587Q17.1,20.025 14,20.725ZM3,15V9H7L12,4V20L7,15ZM14,16V7.95Q15.175,8.5 15.838,9.6Q16.5,10.7 16.5,12Q16.5,13.275 15.838,14.362Q15.175,15.45 14,16ZM10,8.85 L7.85,11H5V13H7.85L10,15.15ZM7.5,12Z"/> </vector> No newline at end of file packages/SettingsLib/res/values/strings.xml +6 −7 Original line number Diff line number Diff line Loading @@ -1419,7 +1419,7 @@ <!-- Name of the internal speaker and mic. [CHAR LIMIT=30] --> <string name="media_transfer_this_device_name_desktop">This computer (internal)</string> <!-- Name of the default media output of the TV. [CHAR LIMIT=30] --> <string name="media_transfer_this_device_name_tv">@string/tv_media_transfer_default</string> <string name="media_transfer_this_device_name_tv">This TV</string> <!-- Name of the dock device. [CHAR LIMIT=30] --> <string name="media_transfer_dock_speaker_device_name">Dock speaker</string> <!-- Default name of the external device. [CHAR LIMIT=30] --> Loading Loading @@ -1462,12 +1462,11 @@ <!-- Media output switcher. Subtitle for devices connected through HDMI EARC if a device name is available. [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_earc_subtitle">Connected via eARC</string> <!-- TV media output switcher. Title for the default audio output of the device [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_default">TV default</string> <!-- TV media output switcher. Subtitle for default audio output which is HDMI, e.g. TV dongle [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_hdmi">HDMI output</string> <!-- TV media output switcher. Subtitle for default audio output which is internal speaker, i.e. panel VTs [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_internal_speakers">Internal speakers</string> <!-- TV media output switcher. Subtitle for default audio output which is internal speaker [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_internal_speakers">Built-in speaker</string> <!-- TV media output switcher. Title for default audio output which is HDMI, e.g. TV dongle [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_hdmi_title">TV Audio</string> <!-- Warning message to tell user is have problem during profile connect, it need to turn off device and back on. [CHAR_LIMIT=NONE] --> <string name="profile_connect_timeout_subtext">Problem connecting. Turn device off & back on</string> Loading packages/SettingsLib/src/com/android/settingslib/media/DeviceIconUtil.java +23 −3 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.media.AudioDeviceInfo; import android.media.AudioManager; import android.media.MediaRoute2Info; import android.os.SystemProperties; import android.util.SparseIntArray; Loading Loading @@ -116,14 +118,15 @@ public class DeviceIconUtil { @SuppressLint("SwitchIntDef") @DrawableRes private static int getIconResourceIdForTv(@MediaRoute2Info.Type int type) { private int getIconResourceIdForTv(@MediaRoute2Info.Type int type) { return switch (type) { case MediaRoute2Info.TYPE_USB_DEVICE, MediaRoute2Info.TYPE_USB_HEADSET -> R.drawable.ic_headphone; case MediaRoute2Info.TYPE_USB_ACCESSORY -> R.drawable.ic_usb; case MediaRoute2Info.TYPE_DOCK -> R.drawable.ic_dock_device; case MediaRoute2Info.TYPE_HDMI, MediaRoute2Info.TYPE_BUILTIN_SPEAKER -> R.drawable.ic_tv; case MediaRoute2Info.TYPE_BUILTIN_SPEAKER -> isPanelTv() ? R.drawable.ic_tv : R.drawable.ic_tv_box_internal_speaker; case MediaRoute2Info.TYPE_HDMI -> R.drawable.ic_tv; case MediaRoute2Info.TYPE_HDMI_ARC, MediaRoute2Info.TYPE_HDMI_EARC -> R.drawable.ic_hdmi; case MediaRoute2Info.TYPE_WIRED_HEADSET, MediaRoute2Info.TYPE_WIRED_HEADPHONES -> Loading @@ -132,6 +135,23 @@ public class DeviceIconUtil { }; } private boolean isPanelTv() { if (mContext == null) { // This should only happen during testing. return true; } AudioManager audioManager = mContext.getSystemService(AudioManager.class); AudioDeviceInfo[] devices = audioManager.getDevices( AudioManager.GET_DEVICES_OUTPUTS); // If we have an HDMI output (not ARC/eARC) we can assume it's a dongle / set top box. for (AudioDeviceInfo device : devices) { if (device.getType() == TYPE_HDMI) { return false; } } return true; } static { AUDIO_DEVICE_TO_MEDIA_ROUTE_TYPE.put(TYPE_USB_DEVICE, MediaRoute2Info.TYPE_USB_DEVICE); AUDIO_DEVICE_TO_MEDIA_ROUTE_TYPE.put(TYPE_USB_HEADSET, MediaRoute2Info.TYPE_USB_HEADSET); Loading packages/SettingsLib/src/com/android/settingslib/media/PhoneMediaDevice.java +4 −4 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET; import static android.media.MediaRoute2Info.TYPE_LINE_DIGITAL; import static android.media.MediaRoute2Info.TYPE_LINE_ANALOG; import static android.media.MediaRoute2Info.TYPE_AUX_LINE; import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_TRANSFER; import android.Manifest; Loading @@ -40,6 +41,7 @@ import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.HdmiPortInfo; import android.media.MediaRoute2Info; import android.media.RouteListingPreference; import android.os.Build; import android.os.SystemProperties; import android.util.Log; Loading Loading @@ -72,7 +74,7 @@ public class PhoneMediaDevice extends MediaDevice { /** Returns this device name for media transfer. */ public static @NonNull String getMediaTransferThisDeviceName(@NonNull Context context) { if (isTv(context)) { return context.getString(R.string.media_transfer_this_device_name_tv); return Build.MODEL; } else if (isTablet()) { return context.getString(R.string.media_transfer_this_device_name_tablet); } else if (inputRoutingEnabledAndIsDesktop(context)) { Loading Loading @@ -110,7 +112,7 @@ public class PhoneMediaDevice extends MediaDevice { name = getMediaTransferThisDeviceName(context); break; case TYPE_HDMI: name = context.getString(isTv ? R.string.tv_media_transfer_default : name = context.getString(isTv ? R.string.tv_media_transfer_hdmi_title : R.string.media_transfer_external_device_name); break; case TYPE_HDMI_ARC: Loading Loading @@ -223,8 +225,6 @@ public class PhoneMediaDevice extends MediaDevice { switch (mRouteInfo.getType()) { case TYPE_BUILTIN_SPEAKER: return mContext.getString(R.string.tv_media_transfer_internal_speakers); case TYPE_HDMI: return mContext.getString(R.string.tv_media_transfer_hdmi); case TYPE_HDMI_ARC: if (getHdmiOutDeviceName(mContext) == null) { // Connection type is already part of the title. Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/DeviceIconUtilTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class DeviceIconUtilTest { public void getIconResIdFromMediaRouteType_tv_builtinSpeaker_isTv() { assertThat(new DeviceIconUtil(/* isTv */ true) .getIconResIdFromMediaRouteType(MediaRoute2Info.TYPE_BUILTIN_SPEAKER)) .isEqualTo(R.drawable.ic_tv); .isAnyOf(R.drawable.ic_tv, R.drawable.ic_tv_box_internal_speaker); } @Test Loading Loading @@ -331,7 +331,7 @@ public class DeviceIconUtilTest { public void getIconResIdFromAudioDeviceType_tv_builtinSpeaker_isTv() { assertThat(new DeviceIconUtil(/* isTv */ true) .getIconResIdFromAudioDeviceType(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER)) .isEqualTo(R.drawable.ic_tv); .isAnyOf(R.drawable.ic_tv, R.drawable.ic_tv_box_internal_speaker); } @Test Loading Loading
packages/SettingsLib/res/drawable/ic_tv_box_internal_speaker.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2022 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?android:attr/textColorPrimary" android:autoMirrored="true"> <path android:fillColor="#FFFFFFFF" android:pathData="M14,20.725V18.675Q16.25,18.025 17.625,16.175Q19,14.325 19,11.975Q19,9.625 17.625,7.775Q16.25,5.925 14,5.275V3.225Q17.1,3.925 19.05,6.362Q21,8.8 21,11.975Q21,15.15 19.05,17.587Q17.1,20.025 14,20.725ZM3,15V9H7L12,4V20L7,15ZM14,16V7.95Q15.175,8.5 15.838,9.6Q16.5,10.7 16.5,12Q16.5,13.275 15.838,14.362Q15.175,15.45 14,16ZM10,8.85 L7.85,11H5V13H7.85L10,15.15ZM7.5,12Z"/> </vector> No newline at end of file
packages/SettingsLib/res/values/strings.xml +6 −7 Original line number Diff line number Diff line Loading @@ -1419,7 +1419,7 @@ <!-- Name of the internal speaker and mic. [CHAR LIMIT=30] --> <string name="media_transfer_this_device_name_desktop">This computer (internal)</string> <!-- Name of the default media output of the TV. [CHAR LIMIT=30] --> <string name="media_transfer_this_device_name_tv">@string/tv_media_transfer_default</string> <string name="media_transfer_this_device_name_tv">This TV</string> <!-- Name of the dock device. [CHAR LIMIT=30] --> <string name="media_transfer_dock_speaker_device_name">Dock speaker</string> <!-- Default name of the external device. [CHAR LIMIT=30] --> Loading Loading @@ -1462,12 +1462,11 @@ <!-- Media output switcher. Subtitle for devices connected through HDMI EARC if a device name is available. [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_earc_subtitle">Connected via eARC</string> <!-- TV media output switcher. Title for the default audio output of the device [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_default">TV default</string> <!-- TV media output switcher. Subtitle for default audio output which is HDMI, e.g. TV dongle [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_hdmi">HDMI output</string> <!-- TV media output switcher. Subtitle for default audio output which is internal speaker, i.e. panel VTs [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_internal_speakers">Internal speakers</string> <!-- TV media output switcher. Subtitle for default audio output which is internal speaker [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_internal_speakers">Built-in speaker</string> <!-- TV media output switcher. Title for default audio output which is HDMI, e.g. TV dongle [CHAR LIMIT=NONE] --> <string name="tv_media_transfer_hdmi_title">TV Audio</string> <!-- Warning message to tell user is have problem during profile connect, it need to turn off device and back on. [CHAR_LIMIT=NONE] --> <string name="profile_connect_timeout_subtext">Problem connecting. Turn device off & back on</string> Loading
packages/SettingsLib/src/com/android/settingslib/media/DeviceIconUtil.java +23 −3 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.media.AudioDeviceInfo; import android.media.AudioManager; import android.media.MediaRoute2Info; import android.os.SystemProperties; import android.util.SparseIntArray; Loading Loading @@ -116,14 +118,15 @@ public class DeviceIconUtil { @SuppressLint("SwitchIntDef") @DrawableRes private static int getIconResourceIdForTv(@MediaRoute2Info.Type int type) { private int getIconResourceIdForTv(@MediaRoute2Info.Type int type) { return switch (type) { case MediaRoute2Info.TYPE_USB_DEVICE, MediaRoute2Info.TYPE_USB_HEADSET -> R.drawable.ic_headphone; case MediaRoute2Info.TYPE_USB_ACCESSORY -> R.drawable.ic_usb; case MediaRoute2Info.TYPE_DOCK -> R.drawable.ic_dock_device; case MediaRoute2Info.TYPE_HDMI, MediaRoute2Info.TYPE_BUILTIN_SPEAKER -> R.drawable.ic_tv; case MediaRoute2Info.TYPE_BUILTIN_SPEAKER -> isPanelTv() ? R.drawable.ic_tv : R.drawable.ic_tv_box_internal_speaker; case MediaRoute2Info.TYPE_HDMI -> R.drawable.ic_tv; case MediaRoute2Info.TYPE_HDMI_ARC, MediaRoute2Info.TYPE_HDMI_EARC -> R.drawable.ic_hdmi; case MediaRoute2Info.TYPE_WIRED_HEADSET, MediaRoute2Info.TYPE_WIRED_HEADPHONES -> Loading @@ -132,6 +135,23 @@ public class DeviceIconUtil { }; } private boolean isPanelTv() { if (mContext == null) { // This should only happen during testing. return true; } AudioManager audioManager = mContext.getSystemService(AudioManager.class); AudioDeviceInfo[] devices = audioManager.getDevices( AudioManager.GET_DEVICES_OUTPUTS); // If we have an HDMI output (not ARC/eARC) we can assume it's a dongle / set top box. for (AudioDeviceInfo device : devices) { if (device.getType() == TYPE_HDMI) { return false; } } return true; } static { AUDIO_DEVICE_TO_MEDIA_ROUTE_TYPE.put(TYPE_USB_DEVICE, MediaRoute2Info.TYPE_USB_DEVICE); AUDIO_DEVICE_TO_MEDIA_ROUTE_TYPE.put(TYPE_USB_HEADSET, MediaRoute2Info.TYPE_USB_HEADSET); Loading
packages/SettingsLib/src/com/android/settingslib/media/PhoneMediaDevice.java +4 −4 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET; import static android.media.MediaRoute2Info.TYPE_LINE_DIGITAL; import static android.media.MediaRoute2Info.TYPE_LINE_ANALOG; import static android.media.MediaRoute2Info.TYPE_AUX_LINE; import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_TRANSFER; import android.Manifest; Loading @@ -40,6 +41,7 @@ import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.HdmiPortInfo; import android.media.MediaRoute2Info; import android.media.RouteListingPreference; import android.os.Build; import android.os.SystemProperties; import android.util.Log; Loading Loading @@ -72,7 +74,7 @@ public class PhoneMediaDevice extends MediaDevice { /** Returns this device name for media transfer. */ public static @NonNull String getMediaTransferThisDeviceName(@NonNull Context context) { if (isTv(context)) { return context.getString(R.string.media_transfer_this_device_name_tv); return Build.MODEL; } else if (isTablet()) { return context.getString(R.string.media_transfer_this_device_name_tablet); } else if (inputRoutingEnabledAndIsDesktop(context)) { Loading Loading @@ -110,7 +112,7 @@ public class PhoneMediaDevice extends MediaDevice { name = getMediaTransferThisDeviceName(context); break; case TYPE_HDMI: name = context.getString(isTv ? R.string.tv_media_transfer_default : name = context.getString(isTv ? R.string.tv_media_transfer_hdmi_title : R.string.media_transfer_external_device_name); break; case TYPE_HDMI_ARC: Loading Loading @@ -223,8 +225,6 @@ public class PhoneMediaDevice extends MediaDevice { switch (mRouteInfo.getType()) { case TYPE_BUILTIN_SPEAKER: return mContext.getString(R.string.tv_media_transfer_internal_speakers); case TYPE_HDMI: return mContext.getString(R.string.tv_media_transfer_hdmi); case TYPE_HDMI_ARC: if (getHdmiOutDeviceName(mContext) == null) { // Connection type is already part of the title. Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/DeviceIconUtilTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ public class DeviceIconUtilTest { public void getIconResIdFromMediaRouteType_tv_builtinSpeaker_isTv() { assertThat(new DeviceIconUtil(/* isTv */ true) .getIconResIdFromMediaRouteType(MediaRoute2Info.TYPE_BUILTIN_SPEAKER)) .isEqualTo(R.drawable.ic_tv); .isAnyOf(R.drawable.ic_tv, R.drawable.ic_tv_box_internal_speaker); } @Test Loading Loading @@ -331,7 +331,7 @@ public class DeviceIconUtilTest { public void getIconResIdFromAudioDeviceType_tv_builtinSpeaker_isTv() { assertThat(new DeviceIconUtil(/* isTv */ true) .getIconResIdFromAudioDeviceType(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER)) .isEqualTo(R.drawable.ic_tv); .isAnyOf(R.drawable.ic_tv, R.drawable.ic_tv_box_internal_speaker); } @Test Loading