Exclude Xiaomi and OPPO devices from detached surface mode

Ideally, we'd find a more targeted exclusion as it may depend on
specific codecs. The current workaround should help with the
reported issues that are limited to Xiaomi and OPPO.

Issue: androidx/media#2059

#cherrypick

PiperOrigin-RevId: 738017969
This commit is contained in:
tonihei 2025-03-18 08:35:56 -07:00 committed by Copybara-Service
parent 6470c97af4
commit 06c0f5549e
2 changed files with 12 additions and 3 deletions

View File

@ -92,6 +92,9 @@ This release includes the following changes since
* Fix issue where a player without a surface was ready immediately and
very slow decoding any pending frames
([#1973](https://github.com/androidx/media/issues/1973)).
* Exclude Xiaomi and OPPO devices from detached surface mode to avoid
screen flickering
([#2059](https://github.com/androidx/media/issues/2059)).
* Session:
* Fix bug where a stale notification stays visible when the playlist is
cleared ([#2211](https://github.com/androidx/media/issues/2211)).

View File

@ -711,7 +711,8 @@ public final class MediaCodecInfo {
private static boolean isDetachedSurfaceSupported(@Nullable CodecCapabilities capabilities) {
return Util.SDK_INT >= 35
&& capabilities != null
&& capabilities.isFeatureSupported(CodecCapabilities.FEATURE_DetachedSurface);
&& capabilities.isFeatureSupported(CodecCapabilities.FEATURE_DetachedSurface)
&& !needsDetachedSurfaceUnsupportedWorkaround();
}
private static boolean areSizeAndRateSupported(
@ -855,8 +856,8 @@ public final class MediaCodecInfo {
}
/**
* Whether a profile is excluded from the list of supported profiles. This may happen when a
* device declares support for a profile it doesn't actually support.
* Returns whether a profile is excluded from the list of supported profiles. This may happen when
* a device declares support for a profile it doesn't actually support.
*/
private static boolean needsProfileExcludedWorkaround(String mimeType, int profile) {
// See https://github.com/google/ExoPlayer/issues/3537
@ -864,4 +865,9 @@ public final class MediaCodecInfo {
&& CodecProfileLevel.HEVCProfileMain10 == profile
&& ("sailfish".equals(Build.DEVICE) || "marlin".equals(Build.DEVICE));
}
/** Returns whether the device is known to have issues with the detached surface mode. */
private static boolean needsDetachedSurfaceUnsupportedWorkaround() {
return Build.MANUFACTURER.equals("Xiaomi") || Build.MANUFACTURER.equals("OPPO");
}
}