Loading broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp +21 −20 Original line number Diff line number Diff line Loading @@ -137,29 +137,30 @@ TunerCallbackMock::TunerCallbackMock() { } Return<void> TunerCallbackMock::onCurrentProgramInfoChanged(const ProgramInfo& info) { for (auto&& id : info.selector) { EXPECT_NE(IdentifierType::INVALID, utils::getType(id)); } auto logically = utils::getType(info.logicallyTunedTo); if (logically != IdentifierType::INVALID) { EXPECT_TRUE(logically == IdentifierType::AMFM_FREQUENCY || logically == IdentifierType::RDS_PI || /* This field is required for currently tuned program and should be INVALID * for entries from the program list. */ EXPECT_TRUE( logically == IdentifierType::AMFM_FREQUENCY || logically == IdentifierType::RDS_PI || logically == IdentifierType::HD_STATION_ID_EXT || logically == IdentifierType::DAB_SID_EXT || logically == IdentifierType::DRMO_SERVICE_ID || logically == IdentifierType::DAB_SID_EXT || logically == IdentifierType::DRMO_SERVICE_ID || logically == IdentifierType::SXM_SERVICE_ID || (logically >= IdentifierType::VENDOR_START && logically <= IdentifierType::VENDOR_END) || (logically >= IdentifierType::VENDOR_START && logically <= IdentifierType::VENDOR_END) || logically > IdentifierType::SXM_CHANNEL); } auto physically = utils::getType(info.physicallyTunedTo); if (physically != IdentifierType::INVALID) { EXPECT_TRUE(physically == IdentifierType::AMFM_FREQUENCY || // ditto (see "logically" above) EXPECT_TRUE( physically == IdentifierType::AMFM_FREQUENCY || physically == IdentifierType::DAB_ENSEMBLE || physically == IdentifierType::DRMO_FREQUENCY || physically == IdentifierType::SXM_CHANNEL || (physically >= IdentifierType::VENDOR_START && physically <= IdentifierType::VENDOR_END) || physically == IdentifierType::DRMO_FREQUENCY || physically == IdentifierType::SXM_CHANNEL || (physically >= IdentifierType::VENDOR_START && physically <= IdentifierType::VENDOR_END) || physically > IdentifierType::SXM_CHANNEL); } if (logically == IdentifierType::AMFM_FREQUENCY) { auto ps = utils::getMetadataString(info, MetadataKey::RDS_PS); Loading broadcastradio/common/tests/IdentifierIterator_test.cpp +24 −11 Original line number Diff line number Diff line Loading @@ -33,8 +33,8 @@ TEST(IdentifierIteratorTest, singleSecondary) { }; // clang-format on auto it = utils::begin(sel); auto end = utils::end(sel); auto it = V2_0::begin(sel); auto end = V2_0::end(sel); ASSERT_NE(end, it); EXPECT_EQ(sel.primaryId, *it); Loading @@ -46,8 +46,8 @@ TEST(IdentifierIteratorTest, singleSecondary) { TEST(IdentifierIteratorTest, empty) { V2_0::ProgramSelector sel{}; auto it = utils::begin(sel); auto end = utils::end(sel); auto it = V2_0::begin(sel); auto end = V2_0::end(sel); ASSERT_NE(end, it++); // primary id is always present ASSERT_EQ(end, it); Loading @@ -57,8 +57,8 @@ TEST(IdentifierIteratorTest, twoSelectors) { V2_0::ProgramSelector sel1{}; V2_0::ProgramSelector sel2{}; auto it1 = utils::begin(sel1); auto it2 = utils::begin(sel2); auto it1 = V2_0::begin(sel1); auto it2 = V2_0::begin(sel2); EXPECT_NE(it1, it2); } Loading @@ -66,8 +66,8 @@ TEST(IdentifierIteratorTest, twoSelectors) { TEST(IdentifierIteratorTest, increments) { V2_0::ProgramSelector sel{{}, {{}, {}}}; auto it = utils::begin(sel); auto end = utils::end(sel); auto it = V2_0::begin(sel); auto end = V2_0::end(sel); auto pre = it; auto post = it; Loading Loading @@ -102,8 +102,8 @@ TEST(IdentifierIteratorTest, findType) { auto isRdsPi = std::bind(typeEquals, _1, IdentifierType::RDS_PI); auto isFreq = std::bind(typeEquals, _1, IdentifierType::AMFM_FREQUENCY); auto end = utils::end(sel); auto it = std::find_if(utils::begin(sel), end, isRdsPi); auto end = V2_0::end(sel); auto it = std::find_if(V2_0::begin(sel), end, isRdsPi); ASSERT_NE(end, it); EXPECT_EQ(rds_pi1, it->value); Loading @@ -111,7 +111,7 @@ TEST(IdentifierIteratorTest, findType) { ASSERT_NE(end, it); EXPECT_EQ(rds_pi2, it->value); it = std::find_if(utils::begin(sel), end, isFreq); it = std::find_if(V2_0::begin(sel), end, isFreq); ASSERT_NE(end, it); EXPECT_EQ(freq1, it->value); Loading @@ -120,4 +120,17 @@ TEST(IdentifierIteratorTest, findType) { EXPECT_EQ(freq2, it->value); } TEST(IdentifierIteratorTest, rangeLoop) { V2_0::ProgramSelector sel{{}, {{}, {}, {}}}; unsigned count = 0; for (auto&& id : sel) { ASSERT_EQ(0u, id.type); count++; } const auto expectedCount = 1 + sel.secondaryIds.size(); ASSERT_EQ(expectedCount, count); } } // anonymous namespace broadcastradio/common/utils2x/Utils.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -81,14 +81,6 @@ bool IdentifierIterator::operator==(const IdentifierIterator& rhs) const { return mPos == rhs.mPos; } IdentifierIterator begin(const V2_0::ProgramSelector& sel) { return IdentifierIterator(sel); } IdentifierIterator end(const V2_0::ProgramSelector& sel) { return IdentifierIterator(sel) + 1 /* primary id */ + sel.secondaryIds.size(); } FrequencyBand getBand(uint64_t freq) { // keep in sync with // frameworks/base/services/core/java/com/android/server/broadcastradio/hal2/Utils.java Loading Loading @@ -411,6 +403,18 @@ V2_0::ProgramIdentifier make_hdradio_station_name(const std::string& name) { } } // namespace utils namespace V2_0 { utils::IdentifierIterator begin(const ProgramSelector& sel) { return utils::IdentifierIterator(sel); } utils::IdentifierIterator end(const ProgramSelector& sel) { return utils::IdentifierIterator(sel) + 1 /* primary id */ + sel.secondaryIds.size(); } } // namespace V2_0 } // namespace broadcastradio } // namespace hardware } // namespace android broadcastradio/common/utils2x/include/broadcastradio-utils-2x/Utils.h +7 −3 Original line number Diff line number Diff line Loading @@ -69,9 +69,6 @@ class IdentifierIterator size_t mPos = 0; }; IdentifierIterator begin(const V2_0::ProgramSelector& sel); IdentifierIterator end(const V2_0::ProgramSelector& sel); /** * Guesses band from the frequency value. * Loading Loading @@ -153,6 +150,13 @@ std::optional<std::string> getMetadataString(const V2_0::ProgramInfo& info, V2_0::ProgramIdentifier make_hdradio_station_name(const std::string& name); } // namespace utils namespace V2_0 { utils::IdentifierIterator begin(const ProgramSelector& sel); utils::IdentifierIterator end(const ProgramSelector& sel); } // namespace V2_0 } // namespace broadcastradio } // namespace hardware } // namespace android Loading Loading
broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp +21 −20 Original line number Diff line number Diff line Loading @@ -137,29 +137,30 @@ TunerCallbackMock::TunerCallbackMock() { } Return<void> TunerCallbackMock::onCurrentProgramInfoChanged(const ProgramInfo& info) { for (auto&& id : info.selector) { EXPECT_NE(IdentifierType::INVALID, utils::getType(id)); } auto logically = utils::getType(info.logicallyTunedTo); if (logically != IdentifierType::INVALID) { EXPECT_TRUE(logically == IdentifierType::AMFM_FREQUENCY || logically == IdentifierType::RDS_PI || /* This field is required for currently tuned program and should be INVALID * for entries from the program list. */ EXPECT_TRUE( logically == IdentifierType::AMFM_FREQUENCY || logically == IdentifierType::RDS_PI || logically == IdentifierType::HD_STATION_ID_EXT || logically == IdentifierType::DAB_SID_EXT || logically == IdentifierType::DRMO_SERVICE_ID || logically == IdentifierType::DAB_SID_EXT || logically == IdentifierType::DRMO_SERVICE_ID || logically == IdentifierType::SXM_SERVICE_ID || (logically >= IdentifierType::VENDOR_START && logically <= IdentifierType::VENDOR_END) || (logically >= IdentifierType::VENDOR_START && logically <= IdentifierType::VENDOR_END) || logically > IdentifierType::SXM_CHANNEL); } auto physically = utils::getType(info.physicallyTunedTo); if (physically != IdentifierType::INVALID) { EXPECT_TRUE(physically == IdentifierType::AMFM_FREQUENCY || // ditto (see "logically" above) EXPECT_TRUE( physically == IdentifierType::AMFM_FREQUENCY || physically == IdentifierType::DAB_ENSEMBLE || physically == IdentifierType::DRMO_FREQUENCY || physically == IdentifierType::SXM_CHANNEL || (physically >= IdentifierType::VENDOR_START && physically <= IdentifierType::VENDOR_END) || physically == IdentifierType::DRMO_FREQUENCY || physically == IdentifierType::SXM_CHANNEL || (physically >= IdentifierType::VENDOR_START && physically <= IdentifierType::VENDOR_END) || physically > IdentifierType::SXM_CHANNEL); } if (logically == IdentifierType::AMFM_FREQUENCY) { auto ps = utils::getMetadataString(info, MetadataKey::RDS_PS); Loading
broadcastradio/common/tests/IdentifierIterator_test.cpp +24 −11 Original line number Diff line number Diff line Loading @@ -33,8 +33,8 @@ TEST(IdentifierIteratorTest, singleSecondary) { }; // clang-format on auto it = utils::begin(sel); auto end = utils::end(sel); auto it = V2_0::begin(sel); auto end = V2_0::end(sel); ASSERT_NE(end, it); EXPECT_EQ(sel.primaryId, *it); Loading @@ -46,8 +46,8 @@ TEST(IdentifierIteratorTest, singleSecondary) { TEST(IdentifierIteratorTest, empty) { V2_0::ProgramSelector sel{}; auto it = utils::begin(sel); auto end = utils::end(sel); auto it = V2_0::begin(sel); auto end = V2_0::end(sel); ASSERT_NE(end, it++); // primary id is always present ASSERT_EQ(end, it); Loading @@ -57,8 +57,8 @@ TEST(IdentifierIteratorTest, twoSelectors) { V2_0::ProgramSelector sel1{}; V2_0::ProgramSelector sel2{}; auto it1 = utils::begin(sel1); auto it2 = utils::begin(sel2); auto it1 = V2_0::begin(sel1); auto it2 = V2_0::begin(sel2); EXPECT_NE(it1, it2); } Loading @@ -66,8 +66,8 @@ TEST(IdentifierIteratorTest, twoSelectors) { TEST(IdentifierIteratorTest, increments) { V2_0::ProgramSelector sel{{}, {{}, {}}}; auto it = utils::begin(sel); auto end = utils::end(sel); auto it = V2_0::begin(sel); auto end = V2_0::end(sel); auto pre = it; auto post = it; Loading Loading @@ -102,8 +102,8 @@ TEST(IdentifierIteratorTest, findType) { auto isRdsPi = std::bind(typeEquals, _1, IdentifierType::RDS_PI); auto isFreq = std::bind(typeEquals, _1, IdentifierType::AMFM_FREQUENCY); auto end = utils::end(sel); auto it = std::find_if(utils::begin(sel), end, isRdsPi); auto end = V2_0::end(sel); auto it = std::find_if(V2_0::begin(sel), end, isRdsPi); ASSERT_NE(end, it); EXPECT_EQ(rds_pi1, it->value); Loading @@ -111,7 +111,7 @@ TEST(IdentifierIteratorTest, findType) { ASSERT_NE(end, it); EXPECT_EQ(rds_pi2, it->value); it = std::find_if(utils::begin(sel), end, isFreq); it = std::find_if(V2_0::begin(sel), end, isFreq); ASSERT_NE(end, it); EXPECT_EQ(freq1, it->value); Loading @@ -120,4 +120,17 @@ TEST(IdentifierIteratorTest, findType) { EXPECT_EQ(freq2, it->value); } TEST(IdentifierIteratorTest, rangeLoop) { V2_0::ProgramSelector sel{{}, {{}, {}, {}}}; unsigned count = 0; for (auto&& id : sel) { ASSERT_EQ(0u, id.type); count++; } const auto expectedCount = 1 + sel.secondaryIds.size(); ASSERT_EQ(expectedCount, count); } } // anonymous namespace
broadcastradio/common/utils2x/Utils.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -81,14 +81,6 @@ bool IdentifierIterator::operator==(const IdentifierIterator& rhs) const { return mPos == rhs.mPos; } IdentifierIterator begin(const V2_0::ProgramSelector& sel) { return IdentifierIterator(sel); } IdentifierIterator end(const V2_0::ProgramSelector& sel) { return IdentifierIterator(sel) + 1 /* primary id */ + sel.secondaryIds.size(); } FrequencyBand getBand(uint64_t freq) { // keep in sync with // frameworks/base/services/core/java/com/android/server/broadcastradio/hal2/Utils.java Loading Loading @@ -411,6 +403,18 @@ V2_0::ProgramIdentifier make_hdradio_station_name(const std::string& name) { } } // namespace utils namespace V2_0 { utils::IdentifierIterator begin(const ProgramSelector& sel) { return utils::IdentifierIterator(sel); } utils::IdentifierIterator end(const ProgramSelector& sel) { return utils::IdentifierIterator(sel) + 1 /* primary id */ + sel.secondaryIds.size(); } } // namespace V2_0 } // namespace broadcastradio } // namespace hardware } // namespace android
broadcastradio/common/utils2x/include/broadcastradio-utils-2x/Utils.h +7 −3 Original line number Diff line number Diff line Loading @@ -69,9 +69,6 @@ class IdentifierIterator size_t mPos = 0; }; IdentifierIterator begin(const V2_0::ProgramSelector& sel); IdentifierIterator end(const V2_0::ProgramSelector& sel); /** * Guesses band from the frequency value. * Loading Loading @@ -153,6 +150,13 @@ std::optional<std::string> getMetadataString(const V2_0::ProgramInfo& info, V2_0::ProgramIdentifier make_hdradio_station_name(const std::string& name); } // namespace utils namespace V2_0 { utils::IdentifierIterator begin(const ProgramSelector& sel); utils::IdentifierIterator end(const ProgramSelector& sel); } // namespace V2_0 } // namespace broadcastradio } // namespace hardware } // namespace android Loading