Loading tv/hdmi/connection/aidl/default/HdmiConnectionMock.cpp +23 −6 Original line number Original line Diff line number Diff line Loading @@ -15,12 +15,11 @@ */ */ #define LOG_TAG "android.hardware.tv.hdmi.connection" #define LOG_TAG "android.hardware.tv.hdmi.connection" #include "HdmiConnectionMock.h" #include <android-base/logging.h> #include <android-base/logging.h> #include <fcntl.h> #include <fcntl.h> #include <utils/Log.h> #include <utils/Log.h> #include "HdmiConnectionMock.h" using ndk::ScopedAStatus; using ndk::ScopedAStatus; namespace android { namespace android { Loading @@ -34,6 +33,7 @@ void HdmiConnectionMock::serviceDied(void* cookie) { ALOGE("HdmiConnectionMock died"); ALOGE("HdmiConnectionMock died"); auto hdmi = static_cast<HdmiConnectionMock*>(cookie); auto hdmi = static_cast<HdmiConnectionMock*>(cookie); hdmi->mHdmiThreadRun = false; hdmi->mHdmiThreadRun = false; pthread_join(hdmi->mThreadId, NULL); } } ScopedAStatus HdmiConnectionMock::getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) { ScopedAStatus HdmiConnectionMock::getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) { Loading @@ -55,12 +55,15 @@ ScopedAStatus HdmiConnectionMock::isConnected(int32_t portId, bool* _aidl_return ScopedAStatus HdmiConnectionMock::setCallback( ScopedAStatus HdmiConnectionMock::setCallback( const std::shared_ptr<IHdmiConnectionCallback>& callback) { const std::shared_ptr<IHdmiConnectionCallback>& callback) { if (mCallback != nullptr) { if (mCallback != nullptr) { stopThread(); mCallback = nullptr; mCallback = nullptr; } } if (callback != nullptr) { if (callback != nullptr) { mCallback = callback; mCallback = callback; AIBinder_linkToDeath(this->asBinder().get(), mDeathRecipient.get(), 0 /* cookie */); mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied)); AIBinder_linkToDeath(callback->asBinder().get(), mDeathRecipient.get(), this /* cookie */); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDWR | O_CLOEXEC); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDWR | O_CLOEXEC); pthread_create(&mThreadId, NULL, __threadLoop, this); pthread_create(&mThreadId, NULL, __threadLoop, this); Loading Loading @@ -153,7 +156,7 @@ void HdmiConnectionMock::threadLoop() { int r = -1; int r = -1; // Open the input pipe // Open the input pipe while (mInputFile < 0) { while (mHdmiThreadRun && mInputFile < 0) { usleep(1000 * 1000); usleep(1000 * 1000); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC); } } Loading Loading @@ -193,7 +196,21 @@ HdmiConnectionMock::HdmiConnectionMock() { .physicalAddress = mPhysicalAddress}; .physicalAddress = mPhysicalAddress}; mPortConnectionStatus[0] = false; mPortConnectionStatus[0] = false; mHpdSignal[0] = HpdSignal::HDMI_HPD_PHYSICAL; mHpdSignal[0] = HpdSignal::HDMI_HPD_PHYSICAL; mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied)); mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(nullptr); } void HdmiConnectionMock::stopThread() { if (mCallback != nullptr) { ALOGE("[halimp_aidl] HdmiConnectionMock shutting down."); mCallback = nullptr; mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(nullptr); mHdmiThreadRun = false; pthread_join(mThreadId, NULL); } } HdmiConnectionMock::~HdmiConnectionMock() { stopThread(); } } } // namespace implementation } // namespace implementation Loading tv/hdmi/connection/aidl/default/HdmiConnectionMock.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -41,7 +41,7 @@ using ::aidl::android::hardware::tv::hdmi::connection::Result; struct HdmiConnectionMock : public BnHdmiConnection { struct HdmiConnectionMock : public BnHdmiConnection { HdmiConnectionMock(); HdmiConnectionMock(); ~HdmiConnectionMock(); ::ndk::ScopedAStatus getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) override; ::ndk::ScopedAStatus getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) override; ::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override; ::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override; ::ndk::ScopedAStatus setCallback( ::ndk::ScopedAStatus setCallback( Loading @@ -56,6 +56,7 @@ struct HdmiConnectionMock : public BnHdmiConnection { void threadLoop(); void threadLoop(); int readMessageFromFifo(unsigned char* buf, int msgCount); int readMessageFromFifo(unsigned char* buf, int msgCount); void handleHotplugMessage(unsigned char* msgBuf); void handleHotplugMessage(unsigned char* msgBuf); void stopThread(); private: private: static void serviceDied(void* cookie); static void serviceDied(void* cookie); Loading Loading
tv/hdmi/connection/aidl/default/HdmiConnectionMock.cpp +23 −6 Original line number Original line Diff line number Diff line Loading @@ -15,12 +15,11 @@ */ */ #define LOG_TAG "android.hardware.tv.hdmi.connection" #define LOG_TAG "android.hardware.tv.hdmi.connection" #include "HdmiConnectionMock.h" #include <android-base/logging.h> #include <android-base/logging.h> #include <fcntl.h> #include <fcntl.h> #include <utils/Log.h> #include <utils/Log.h> #include "HdmiConnectionMock.h" using ndk::ScopedAStatus; using ndk::ScopedAStatus; namespace android { namespace android { Loading @@ -34,6 +33,7 @@ void HdmiConnectionMock::serviceDied(void* cookie) { ALOGE("HdmiConnectionMock died"); ALOGE("HdmiConnectionMock died"); auto hdmi = static_cast<HdmiConnectionMock*>(cookie); auto hdmi = static_cast<HdmiConnectionMock*>(cookie); hdmi->mHdmiThreadRun = false; hdmi->mHdmiThreadRun = false; pthread_join(hdmi->mThreadId, NULL); } } ScopedAStatus HdmiConnectionMock::getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) { ScopedAStatus HdmiConnectionMock::getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) { Loading @@ -55,12 +55,15 @@ ScopedAStatus HdmiConnectionMock::isConnected(int32_t portId, bool* _aidl_return ScopedAStatus HdmiConnectionMock::setCallback( ScopedAStatus HdmiConnectionMock::setCallback( const std::shared_ptr<IHdmiConnectionCallback>& callback) { const std::shared_ptr<IHdmiConnectionCallback>& callback) { if (mCallback != nullptr) { if (mCallback != nullptr) { stopThread(); mCallback = nullptr; mCallback = nullptr; } } if (callback != nullptr) { if (callback != nullptr) { mCallback = callback; mCallback = callback; AIBinder_linkToDeath(this->asBinder().get(), mDeathRecipient.get(), 0 /* cookie */); mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied)); AIBinder_linkToDeath(callback->asBinder().get(), mDeathRecipient.get(), this /* cookie */); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDWR | O_CLOEXEC); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDWR | O_CLOEXEC); pthread_create(&mThreadId, NULL, __threadLoop, this); pthread_create(&mThreadId, NULL, __threadLoop, this); Loading Loading @@ -153,7 +156,7 @@ void HdmiConnectionMock::threadLoop() { int r = -1; int r = -1; // Open the input pipe // Open the input pipe while (mInputFile < 0) { while (mHdmiThreadRun && mInputFile < 0) { usleep(1000 * 1000); usleep(1000 * 1000); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC); mInputFile = open(HDMI_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC); } } Loading Loading @@ -193,7 +196,21 @@ HdmiConnectionMock::HdmiConnectionMock() { .physicalAddress = mPhysicalAddress}; .physicalAddress = mPhysicalAddress}; mPortConnectionStatus[0] = false; mPortConnectionStatus[0] = false; mHpdSignal[0] = HpdSignal::HDMI_HPD_PHYSICAL; mHpdSignal[0] = HpdSignal::HDMI_HPD_PHYSICAL; mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied)); mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(nullptr); } void HdmiConnectionMock::stopThread() { if (mCallback != nullptr) { ALOGE("[halimp_aidl] HdmiConnectionMock shutting down."); mCallback = nullptr; mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(nullptr); mHdmiThreadRun = false; pthread_join(mThreadId, NULL); } } HdmiConnectionMock::~HdmiConnectionMock() { stopThread(); } } } // namespace implementation } // namespace implementation Loading
tv/hdmi/connection/aidl/default/HdmiConnectionMock.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -41,7 +41,7 @@ using ::aidl::android::hardware::tv::hdmi::connection::Result; struct HdmiConnectionMock : public BnHdmiConnection { struct HdmiConnectionMock : public BnHdmiConnection { HdmiConnectionMock(); HdmiConnectionMock(); ~HdmiConnectionMock(); ::ndk::ScopedAStatus getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) override; ::ndk::ScopedAStatus getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) override; ::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override; ::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override; ::ndk::ScopedAStatus setCallback( ::ndk::ScopedAStatus setCallback( Loading @@ -56,6 +56,7 @@ struct HdmiConnectionMock : public BnHdmiConnection { void threadLoop(); void threadLoop(); int readMessageFromFifo(unsigned char* buf, int msgCount); int readMessageFromFifo(unsigned char* buf, int msgCount); void handleHotplugMessage(unsigned char* msgBuf); void handleHotplugMessage(unsigned char* msgBuf); void stopThread(); private: private: static void serviceDied(void* cookie); static void serviceDied(void* cookie); Loading