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

Commit f08dbaf6 authored by Hongguang Chen's avatar Hongguang Chen
Browse files

Check tvinput AIDL existing before using

Not all TV devices have the tvinput HAL. We should check whether it's existed before using.

Bug: 261699781
Test: Test on TV device w/o tvinput HAL
Change-Id: I6a46fdae3823a0ba2774d94824f8fbfa3c4a1cfd
parent 6a5c7459
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -42,8 +42,11 @@ JTvInputHal* JTvInputHal::createInstance(JNIEnv* env, jobject thiz, const sp<Loo
                               std::shared_ptr<ITvInputWrapper>(new ITvInputWrapper(hidlITvInput)),
                               looper);
    }
    std::shared_ptr<AidlITvInput> aidlITvInput = nullptr;
    if (AServiceManager_isDeclared(TV_INPUT_AIDL_SERVICE_NAME)) {
        ::ndk::SpAIBinder binder(AServiceManager_waitForService(TV_INPUT_AIDL_SERVICE_NAME));
    std::shared_ptr<AidlITvInput> aidlITvInput = AidlITvInput::fromBinder(binder);
        aidlITvInput = AidlITvInput::fromBinder(binder);
    }
    if (aidlITvInput == nullptr) {
        ALOGE("Couldn't get tv.input service.");
        return nullptr;