diff --git a/tv/input/aidl/default/TvInput.cpp b/tv/input/aidl/default/TvInput.cpp index 2ee8bcfec8..f6a64c4b40 100644 --- a/tv/input/aidl/default/TvInput.cpp +++ b/tv/input/aidl/default/TvInput.cpp @@ -43,6 +43,9 @@ void TvInput::init() { new TvStreamConfigWrapper(11, 360, 480, false))}}; mStreamConfigs[3] = {{5, shared_ptr( new TvStreamConfigWrapper(5, 1080, 1920, false))}}; + + mQueue = shared_ptr>( + new (std::nothrow) AidlMessageQueue(8)); } ::ndk::ScopedAStatus TvInput::setCallback(const shared_ptr& in_callback) { @@ -74,7 +77,9 @@ void TvInput::init() { return ::ndk::ScopedAStatus::fromServiceSpecificError(STATUS_INVALID_ARGUMENTS); } + // When calling notifyTvMessage, make sure to verify against this map. mTvMessageEventEnabled[deviceId][streamId][in_type] = enabled; + return ::ndk::ScopedAStatus::ok(); } @@ -82,11 +87,17 @@ void TvInput::init() { MQDescriptor* out_queue, int32_t in_deviceId, int32_t in_streamId) { ALOGV("%s", __FUNCTION__); + ::ndk::ScopedAStatus status = ::ndk::ScopedAStatus::ok(); if (mStreamConfigs.count(in_deviceId) == 0) { ALOGW("Device with id %d isn't available", in_deviceId); - return ::ndk::ScopedAStatus::fromServiceSpecificError(STATUS_INVALID_ARGUMENTS); + status = ::ndk::ScopedAStatus::fromServiceSpecificError(STATUS_INVALID_ARGUMENTS); + } else if (!mQueue->isValid()) { + ALOGE("Tv Message Queue was not properly initialized"); + status = ::ndk::ScopedAStatus::fromServiceSpecificError(STATUS_INVALID_STATE); + } else { + *out_queue = mQueue->dupeDesc(); } - return ::ndk::ScopedAStatus::ok(); + return status; } ::ndk::ScopedAStatus TvInput::getStreamConfigurations(int32_t in_deviceId, diff --git a/tv/input/aidl/default/TvInput.h b/tv/input/aidl/default/TvInput.h index 57769618e3..595f017fff 100644 --- a/tv/input/aidl/default/TvInput.h +++ b/tv/input/aidl/default/TvInput.h @@ -66,6 +66,7 @@ class TvInput : public BnTvInput { map> mDeviceInfos; map>> mStreamConfigs; TvMessageEnabledMap mTvMessageEventEnabled; + shared_ptr> mQueue; }; } // namespace input diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp index 8d3395b8d2..746ae1e1af 100644 --- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp +++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp @@ -355,8 +355,12 @@ TEST_P(TvInputAidlTest, GetTvMessageQueueTest) { } int32_t stream_id = streamConfigs[0].streamId; ALOGD("GetTvMessageQueueTest: device_id=%d, stream_id=%d", device_id, stream_id); - MQDescriptor queue; - tv_input_->getTvMessageQueueDesc(&queue, device_id, stream_id); + MQDescriptor queueDescriptor; + AidlMessageQueue* queue; + tv_input_->getTvMessageQueueDesc(&queueDescriptor, device_id, stream_id); + queue = new (std::nothrow) AidlMessageQueue(queueDescriptor); + ASSERT_TRUE(queue->isValid()); + delete queue; } INSTANTIATE_TEST_SUITE_P(PerInstance, TvInputAidlTest,