diff --git a/tv/cec/1.0/vts/functional/VtsHalTvCecV1_0TargetTest.cpp b/tv/cec/1.0/vts/functional/VtsHalTvCecV1_0TargetTest.cpp index fcd1df8543..9cd6884ef2 100644 --- a/tv/cec/1.0/vts/functional/VtsHalTvCecV1_0TargetTest.cpp +++ b/tv/cec/1.0/vts/functional/VtsHalTvCecV1_0TargetTest.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -29,6 +31,7 @@ using ::android::sp; using ::android::hardware::hidl_death_recipient; using ::android::hardware::hidl_vec; using ::android::hardware::Return; +using ::android::hardware::tv::cec::V1_0::CecDeviceType; using ::android::hardware::tv::cec::V1_0::CecLogicalAddress; using ::android::hardware::tv::cec::V1_0::CecMessage; using ::android::hardware::tv::cec::V1_0::HdmiPortInfo; @@ -55,6 +58,34 @@ class HdmiCecTest : public ::testing::TestWithParam { ASSERT_TRUE(hdmiCec->linkToDeath(hdmiCec_death_recipient, 0).isOk()); } + std::vector getDeviceTypes() { + std::vector deviceTypes; + FILE* p = popen("getprop ro.hdmi.device_type", "re"); + if (p) { + char* line = NULL; + size_t len = 0; + if (getline(&line, &len, p) > 0) { + std::istringstream stream(line); + std::string number{}; + while (std::getline(stream, number, ',')) { + deviceTypes.push_back(stoi(number)); + } + } + pclose(p); + } + return deviceTypes; + } + + bool hasDeviceType(CecDeviceType type) { + std::vector deviceTypes = getDeviceTypes(); + for (auto deviceType = deviceTypes.begin(); deviceType != deviceTypes.end(); ++deviceType) { + if (*deviceType == (int)type) { + return true; + } + } + return false; + } + class HdmiCecDeathRecipient : public hidl_death_recipient { public: void serviceDied(uint64_t /*cookie*/,