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

Commit 644bf7a9 authored by Songyue Han's avatar Songyue Han
Browse files

Java MediaCodecInfo: Fix lazy initialization of getSizeRange.

The getSizeRange method was not doing lazy initialization. On low end
devices like Gambit, the MediaProperties is not ready when SIZE_RANGE is
initialized.

Bug: 400911661
Test: atest NativeAMediaCodecInfoTest#testAMediaCodecInfoGetVideoCapsGetSupportForNative
Change-Id: I8568074c2c242062e44ac8d91d724314ec9a922a
parent 2a6357c5
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -218,13 +218,14 @@ public final class MediaCodecInfo {
    private static final int DEFAULT_MAX_SUPPORTED_INSTANCES = 32;
    private static final int MAX_SUPPORTED_INSTANCES_LIMIT = 256;

    private static final class LazyHolder {
        private static final Range<Integer> SIZE_RANGE = Process.is64Bit()
    private static Range<Integer> SIZE_RANGE;
    private static synchronized Range<Integer> getSizeRange() {
        if (SIZE_RANGE == null) {
            SIZE_RANGE = Process.is64Bit()
                    ? Range.create(1, 32768)
                    : Range.create(1, MediaProperties.resolution_limit_32bit().orElse(4096));
        }
    private static Range<Integer> getSizeRange() {
        return LazyHolder.SIZE_RANGE;
        return SIZE_RANGE;
    }

    // found stuff that is not supported by framework (=> this should not happen)