From 64a3a731c23b5f89ba2c1093c6a30145e8adca39 Mon Sep 17 00:00:00 2001 From: Henry Fang Date: Wed, 16 Dec 2020 14:09:48 -0800 Subject: [PATCH] update connect status along with stream_configuration_change event. bug: 142698113 Test: Manual Change-Id: Ieab767bb333bbe4ba24702668908edec69240d8d --- tv/input/1.0/default/TvInput.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tv/input/1.0/default/TvInput.cpp b/tv/input/1.0/default/TvInput.cpp index 4ea1deca9b..7583a67ea8 100644 --- a/tv/input/1.0/default/TvInput.cpp +++ b/tv/input/1.0/default/TvInput.cpp @@ -142,7 +142,7 @@ Return TvInput::closeStream(int32_t deviceId, int32_t streamId) { // static void TvInput::notify(struct tv_input_device* __unused, tv_input_event_t* event, - void* __unused) { + void* optionalStatus) { if (mCallback != nullptr && event != nullptr) { // Capturing is no longer supported. if (event->type >= TV_INPUT_EVENT_CAPTURE_SUCCEEDED) { @@ -154,7 +154,17 @@ void TvInput::notify(struct tv_input_device* __unused, tv_input_event_t* event, tvInputEvent.deviceInfo.type = static_cast( event->device_info.type); tvInputEvent.deviceInfo.portId = event->device_info.hdmi.port_id; - tvInputEvent.deviceInfo.cableConnectionStatus = CableConnectionStatus::UNKNOWN; + CableConnectionStatus connectionStatus = CableConnectionStatus::UNKNOWN; + if (optionalStatus != nullptr && + ((event->type == TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED) || + (event->type == TV_INPUT_EVENT_DEVICE_AVAILABLE))) { + int newStatus = *reinterpret_cast(optionalStatus); + if (newStatus <= static_cast(CableConnectionStatus::DISCONNECTED) && + newStatus >= static_cast(CableConnectionStatus::UNKNOWN)) { + connectionStatus = static_cast(newStatus); + } + } + tvInputEvent.deviceInfo.cableConnectionStatus = connectionStatus; // TODO: Ensure the legacy audio type code is the same once audio HAL default // implementation is ready. tvInputEvent.deviceInfo.audioType = static_cast(