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

Commit 3d1aa862 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Codec2CommonUtils: Restrict encoder usage checks to Android U and above" into main

parents 7733af86 56800862
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();

/**