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

Commit 514eb726 authored by Harish Mahendrakar's avatar Harish Mahendrakar Committed by Cherrypicker Worker
Browse files

Codec2CommonUtils: Restrict encoder usage checks to Android U and above

Bug: 293985442
Test: atest CtsMediaV2TestCases:CodecInfoTest
(cherry picked from https://android-review.googlesource.com/q/commit:568008622b531baaa5a75c7252341cc0b710261f)
Merged-In: I55543617d8a9e9765d427b289bd42e667bbcb917
Change-Id: I55543617d8a9e9765d427b289bd42e667bbcb917
parent a5136307
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -31,11 +31,19 @@

namespace android {

bool isAtLeastT() {

static bool isAtLeast(int version, const char *codeName) {
    char deviceCodeName[PROP_VALUE_MAX];
    __system_property_get("ro.build.version.codename", deviceCodeName);
    return android_get_device_api_level() >= __ANDROID_API_T__ ||
           !strcmp(deviceCodeName, "Tiramisu");
    return android_get_device_api_level() >= version || !strcmp(deviceCodeName, codeName);
}

bool isAtLeastT() {
    return isAtLeast(__ANDROID_API_T__, "Tiramisu");
}

bool isAtLeastU() {
    return isAtLeast(__ANDROID_API_U__, "UpsideDownCake");
}

static bool isP010Allowed() {
@@ -127,10 +135,16 @@ bool isHalPixelFormatSupported(AHardwareBuffer_Format format) {
            .rfu0 = 0,
            .rfu1 = 0,
    };

    // Some devices running versions prior to Android U aren't guaranteed to advertise support
    // for some color formats when the consumer is an encoder. Hence limit these checks to
    // Android U and beyond.
    if (isAtLeastU()) {
        return AHardwareBuffer_isSupported(&consumableForDisplayOrGpu)
                && AHardwareBuffer_isSupported(&consumableForHwEncoder)
                && AHardwareBuffer_isSupported(&consumableForSwEncoder);
    } else {
        return AHardwareBuffer_isSupported(&consumableForDisplayOrGpu);
    }
}

}  // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ namespace android {

bool isAtLeastT();

bool isAtLeastU();

bool isVendorApiOrFirstApiAtLeastT();

/**