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

Commit 8caa5b88 authored by Guanwei Chen's avatar Guanwei Chen Committed by Songyue Han
Browse files

skip omx codecs check when no needed

skip omx video codecs for devices launching with Android S and above.
skip omx audio codecs for for devices launching with Android T and above.

Bug: 228778569
Test: run cts VtsHalMediaOmxV1_0TargetStoreTest pass

Change-Id: I3c81b57ae9bd17ae05e5f67532d2a6fa43e6efd0
parent ecec96eb
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -99,6 +99,15 @@ void OMXStore::addPlugin(const char *libname) {
    }
}

static int getFirstApiLevel() {
    int boardApiLevel = android::base::GetIntProperty("ro.board.first_api_level", 0);
    if (boardApiLevel != 0) {
        return boardApiLevel;
    }

    return android::base::GetIntProperty("ro.product.first_api_level", __ANDROID_API_T__);
}

void OMXStore::addPlugin(OMXPluginBase *plugin) {
    Mutex::Autolock autoLock(mLock);

@@ -110,6 +119,29 @@ void OMXStore::addPlugin(OMXPluginBase *plugin) {
                    name, sizeof(name), index++)) == OMX_ErrorNone) {
        String8 name8(name);

        Vector<String8> roles;
        OMX_ERRORTYPE err = plugin->getRolesOfComponent(name, &roles);
        if (err == OMX_ErrorNone) {
            bool skip = false;
            for (String8 role : roles) {
                if (role.find("video_decoder") != -1 || role.find("video_encoder") != -1) {
                    if (getFirstApiLevel() >= __ANDROID_API_S__) {
                        skip = true;
                        break;
                    }
                }
                if (role.find("audio_decoder") != -1 || role.find("audio_encoder") != -1) {
                    if (getFirstApiLevel() >= __ANDROID_API_T__) {
                        skip = true;
                        break;
                    }
                }
            }
            if (skip) {
                continue;
            }
        }

        if (mPluginByComponentName.indexOfKey(name8) >= 0) {
            ALOGE("A component of name '%s' already exists, ignoring this one.",
                 name8.string());