Merge pull request #9498 from DolbyLaboratories:dev-v2-direct-automotive

PiperOrigin-RevId: 400134426
This commit is contained in:
Oliver Woodman 2021-10-01 11:12:56 +01:00
commit 9926a8f6e3
2 changed files with 14 additions and 2 deletions

View File

@ -2305,6 +2305,17 @@ public final class Util {
&& uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION; && uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
} }
/**
* Returns whether the app is running on an automotive device.
*
* @param context Any context.
* @return Whether the app is running on an automotive device.
*/
public static boolean isAutomotive(Context context) {
return Util.SDK_INT >= 23
&& context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
}
/** /**
* Gets the size of the current mode of the default display, in pixels. * Gets the size of the current mode of the default display, in pixels.
* *

View File

@ -90,8 +90,9 @@ public final class AudioCapabilities {
} }
// AudioTrack.isDirectPlaybackSupported returns true for encodings that are supported for audio // AudioTrack.isDirectPlaybackSupported returns true for encodings that are supported for audio
// offload, as well as for encodings we want to list for passthrough mode. Therefore we only use // offload, as well as for encodings we want to list for passthrough mode. Therefore we only use
// it on TV devices, which generally shouldn't support audio offload for surround encodings. // it on TV and automotive devices, which generally shouldn't support audio offload for surround
if (Util.SDK_INT >= 29 && Util.isTv(context)) { // encodings.
if (Util.SDK_INT >= 29 && (Util.isTv(context) || Util.isAutomotive(context))) {
return new AudioCapabilities( return new AudioCapabilities(
Api29.getDirectPlaybackSupportedEncodings(), DEFAULT_MAX_CHANNEL_COUNT); Api29.getDirectPlaybackSupportedEncodings(), DEFAULT_MAX_CHANNEL_COUNT);
} }