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

Commit 2b2e801e authored by Wonsik Kim's avatar Wonsik Kim
Browse files

CodecServiceRegistrant: register @1.2 HIDL if missing

Additionally, do not exit at failure to register.

Test: atest vts_treble_vintf_framework_test
Change-Id: I0652661897610adc3b08d80907408c185e506e60
parent b49ef275
Loading
Loading
Loading
Loading
+12 −7
Original line number Original line Diff line number Diff line
@@ -817,6 +817,7 @@ extern "C" void RegisterCodecServices() {
        }
        }
    }
    }


    bool registered = false;
    if (platformVersion >= __ANDROID_API_V__) {
    if (platformVersion >= __ANDROID_API_V__) {
        if (!aidlStore) {
        if (!aidlStore) {
            aidlStore = ::ndk::SharedRefBase::make<c2_aidl::utils::ComponentStore>(
            aidlStore = ::ndk::SharedRefBase::make<c2_aidl::utils::ComponentStore>(
@@ -826,23 +827,27 @@ extern "C" void RegisterCodecServices() {
            std::string(c2_aidl::IComponentStore::descriptor) + "/software";
            std::string(c2_aidl::IComponentStore::descriptor) + "/software";
        binder_exception_t ex = AServiceManager_addService(
        binder_exception_t ex = AServiceManager_addService(
                aidlStore->asBinder().get(), serviceName.c_str());
                aidlStore->asBinder().get(), serviceName.c_str());
        if (ex != EX_NONE) {
        if (ex == EX_NONE) {
            registered = true;
        } else {
            LOG(ERROR) << "Cannot register software Codec2 AIDL service.";
            LOG(ERROR) << "Cannot register software Codec2 AIDL service.";
            return;
        }
        }
    }
    }


    if (!hidlStore) {
    if (!hidlStore) {
        hidlStore = ::android::sp<V1_0::utils::ComponentStore>::make(
        hidlStore = ::android::sp<V1_2::utils::ComponentStore>::make(
                std::make_shared<H2C2ComponentStore>(nullptr));
                std::make_shared<H2C2ComponentStore>(nullptr));
        hidlVer = "1.0";
        hidlVer = "1.2";
    }
    }
    if (hidlStore->registerAsService("software") != android::OK) {
    if (hidlStore->registerAsService("software") == android::OK) {
        registered = true;
    } else {
        LOG(ERROR) << "Cannot register software Codec2 v" << hidlVer << " service.";
        LOG(ERROR) << "Cannot register software Codec2 v" << hidlVer << " service.";
        return;
    }
    }


    if (registered) {
        LOG(INFO) << "Software Codec2 service created and registered.";
        LOG(INFO) << "Software Codec2 service created and registered.";
    }


    ABinderProcess_joinThreadPool();
    ABinderProcess_joinThreadPool();
    ::android::hardware::joinRpcThreadpool();
    ::android::hardware::joinRpcThreadpool();