Merge "Check tvinput AIDL existing before using"

This commit is contained in:
Henry Fang
2022-12-07 18:03:59 +00:00
committed by Android (Google) Code Review

View File

@@ -42,8 +42,11 @@ JTvInputHal* JTvInputHal::createInstance(JNIEnv* env, jobject thiz, const sp<Loo
std::shared_ptr<ITvInputWrapper>(new ITvInputWrapper(hidlITvInput)),
looper);
}
::ndk::SpAIBinder binder(AServiceManager_waitForService(TV_INPUT_AIDL_SERVICE_NAME));
std::shared_ptr<AidlITvInput> aidlITvInput = AidlITvInput::fromBinder(binder);
std::shared_ptr<AidlITvInput> aidlITvInput = nullptr;
if (AServiceManager_isDeclared(TV_INPUT_AIDL_SERVICE_NAME)) {
::ndk::SpAIBinder binder(AServiceManager_waitForService(TV_INPUT_AIDL_SERVICE_NAME));
aidlITvInput = AidlITvInput::fromBinder(binder);
}
if (aidlITvInput == nullptr) {
ALOGE("Couldn't get tv.input service.");
return nullptr;