diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java index ec913e52e1..1f6822151d 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java @@ -2305,6 +2305,16 @@ public final class Util { && 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 context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); + } + /** * Gets the size of the current mode of the default display, in pixels. * diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java index 1510aa6e22..39fa2860a6 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java @@ -90,8 +90,9 @@ public final class AudioCapabilities { } // 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 - // it on TV devices, which generally shouldn't support audio offload for surround encodings. - if (Util.SDK_INT >= 29 && Util.isTv(context)) { + // it on TV and Automotive devices, which generally shouldn't support audio offload for surround + // encodings. + if (Util.SDK_INT >= 29 && (Util.isTv(context) || Util.isAutomotive(context))) { return new AudioCapabilities( Api29.getDirectPlaybackSupportedEncodings(), DEFAULT_MAX_CHANNEL_COUNT); }