From afe17c509334c2eae771cc65001152ea96792e1c Mon Sep 17 00:00:00 2001 From: Kensuke Miyagi Date: Thu, 16 Dec 2021 01:06:15 -0800 Subject: [PATCH] Enable LnbCallback in hidl/aidl default tuner implementation Bug: 210960436 Test: cts.TunerTest#testLnbAddAndRemoveSharee Change-Id: I11443144dcd1979afe9b077c446faaa293ccb61c --- tv/tuner/1.0/default/Lnb.cpp | 12 ++++++++++-- tv/tuner/1.0/default/Lnb.h | 1 + tv/tuner/1.1/default/Lnb.cpp | 12 ++++++++++-- tv/tuner/1.1/default/Lnb.h | 1 + tv/tuner/aidl/default/Lnb.cpp | 14 ++++++++++++-- tv/tuner/aidl/default/Lnb.h | 1 + 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tv/tuner/1.0/default/Lnb.cpp b/tv/tuner/1.0/default/Lnb.cpp index 6025339ba7..c770e91145 100644 --- a/tv/tuner/1.0/default/Lnb.cpp +++ b/tv/tuner/1.0/default/Lnb.cpp @@ -33,9 +33,10 @@ Lnb::Lnb(int id) { Lnb::~Lnb() {} -Return Lnb::setCallback(const sp& /* callback */) { +Return Lnb::setCallback(const sp& callback) { ALOGV("%s", __FUNCTION__); + mCallback = callback; return Result::SUCCESS; } @@ -57,9 +58,16 @@ Return Lnb::setSatellitePosition(LnbPosition /* position */) { return Result::SUCCESS; } -Return Lnb::sendDiseqcMessage(const hidl_vec& /* diseqcMessage */) { +Return Lnb::sendDiseqcMessage(const hidl_vec& diseqcMessage) { ALOGV("%s", __FUNCTION__); + if (mCallback != nullptr) { + // The correct implementation should be to return the response from the + // device via onDiseqcMessage(). The below implementation is only to enable + // testing for LnbCallbacks. + ALOGV("[hidl] %s - this is for test purpose only, and must be replaced!", __FUNCTION__); + mCallback->onDiseqcMessage(diseqcMessage); + } return Result::SUCCESS; } diff --git a/tv/tuner/1.0/default/Lnb.h b/tv/tuner/1.0/default/Lnb.h index 1e97214430..c14bbd8735 100644 --- a/tv/tuner/1.0/default/Lnb.h +++ b/tv/tuner/1.0/default/Lnb.h @@ -57,6 +57,7 @@ class Lnb : public ILnb { private: int mId; virtual ~Lnb(); + sp mCallback; }; } // namespace implementation diff --git a/tv/tuner/1.1/default/Lnb.cpp b/tv/tuner/1.1/default/Lnb.cpp index 044727ff54..5dd01472d5 100644 --- a/tv/tuner/1.1/default/Lnb.cpp +++ b/tv/tuner/1.1/default/Lnb.cpp @@ -33,9 +33,10 @@ Lnb::Lnb(int id) { Lnb::~Lnb() {} -Return Lnb::setCallback(const sp& /* callback */) { +Return Lnb::setCallback(const sp& callback) { ALOGV("%s", __FUNCTION__); + mCallback = callback; return Result::SUCCESS; } @@ -57,9 +58,16 @@ Return Lnb::setSatellitePosition(LnbPosition /* position */) { return Result::SUCCESS; } -Return Lnb::sendDiseqcMessage(const hidl_vec& /* diseqcMessage */) { +Return Lnb::sendDiseqcMessage(const hidl_vec& diseqcMessage) { ALOGV("%s", __FUNCTION__); + if (mCallback != nullptr) { + // The correct implementation should be to return the response from the + // device via onDiseqcMessage(). The below implementation is only to enable + // testing for LnbCallbacks. + ALOGV("[hidl] %s - this is for test purpose only, and must be replaced!", __FUNCTION__); + mCallback->onDiseqcMessage(diseqcMessage); + } return Result::SUCCESS; } diff --git a/tv/tuner/1.1/default/Lnb.h b/tv/tuner/1.1/default/Lnb.h index 70a8e41b8b..b34ca396ca 100644 --- a/tv/tuner/1.1/default/Lnb.h +++ b/tv/tuner/1.1/default/Lnb.h @@ -51,6 +51,7 @@ class Lnb : public ILnb { private: int mId; virtual ~Lnb(); + sp mCallback; }; } // namespace implementation diff --git a/tv/tuner/aidl/default/Lnb.cpp b/tv/tuner/aidl/default/Lnb.cpp index 35d2da6310..f9343ae6c8 100644 --- a/tv/tuner/aidl/default/Lnb.cpp +++ b/tv/tuner/aidl/default/Lnb.cpp @@ -34,9 +34,11 @@ Lnb::Lnb(int id) { Lnb::~Lnb() {} -::ndk::ScopedAStatus Lnb::setCallback(const std::shared_ptr& /* in_callback */) { +::ndk::ScopedAStatus Lnb::setCallback(const std::shared_ptr& in_callback) { ALOGV("%s", __FUNCTION__); + mCallback = in_callback; + return ::ndk::ScopedAStatus::ok(); } @@ -58,9 +60,17 @@ Lnb::~Lnb() {} return ::ndk::ScopedAStatus::ok(); } -::ndk::ScopedAStatus Lnb::sendDiseqcMessage(const std::vector& /* in_diseqcMessage */) { +::ndk::ScopedAStatus Lnb::sendDiseqcMessage(const std::vector& in_diseqcMessage) { ALOGV("%s", __FUNCTION__); + if (mCallback != nullptr) { + // The correct implementation should be to return the response from the + // device via onDiseqcMessage(). The below implementation is only to enable + // testing for LnbCallbacks. + ALOGV("[aidl] %s - this is for test purpose only, and must be replaced!", __FUNCTION__); + mCallback->onDiseqcMessage(in_diseqcMessage); + } + return ::ndk::ScopedAStatus::ok(); } diff --git a/tv/tuner/aidl/default/Lnb.h b/tv/tuner/aidl/default/Lnb.h index bfe3097ddc..464f9a453f 100644 --- a/tv/tuner/aidl/default/Lnb.h +++ b/tv/tuner/aidl/default/Lnb.h @@ -44,6 +44,7 @@ class Lnb : public BnLnb { private: int mId; virtual ~Lnb(); + std::shared_ptr mCallback; }; } // namespace tuner