Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03eb2ee1 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

media: protect around aconfig flag access in MediaCodec::configure

This API is known to be used from contexts where aconfig flag accessors
fail.

Bug: 325389296
Change-Id: I5164b528c3b852bef9a757d9b2399b0af51feeb0
parent 90d91e97
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2346,7 +2346,15 @@ final public class MediaCodec {
        }

        // at the moment no codecs support detachable surface
        if (android.media.codec.Flags.nullOutputSurface()) {

        // HACKY: aconfig flags accessors may not work in all contexts that MediaCodec API is used,
        // so allow accessors to fail. In those contexts the flags will just not be enabled
        boolean nullOutputSurface = false;
        try {
            nullOutputSurface = android.media.codec.Flags.nullOutputSurface();
        } catch (java.lang.RuntimeException e) { }

        if (nullOutputSurface) {
            // Detached surface flag is only meaningful if surface is null. Otherwise, it is
            // ignored.
            if (surface == null && (flags & CONFIGURE_FLAG_DETACHED_SURFACE) != 0) {