Initial change to add mock DAB stations (hardcoded for now).
Test: VtsHalBroadcastradioV2_0TargetTest
Change-Id: Ice8923490728402ed945e8cc0891fd8b2c5bf9dd
diff --git a/broadcastradio/2.0/default/BroadcastRadio.cpp b/broadcastradio/2.0/default/BroadcastRadio.cpp
index 28a0dd5..88a726f 100644
--- a/broadcastradio/2.0/default/BroadcastRadio.cpp
+++ b/broadcastradio/2.0/default/BroadcastRadio.cpp
@@ -49,6 +49,7 @@
static_cast<uint32_t>(IdentifierType::AMFM_FREQUENCY),
static_cast<uint32_t>(IdentifierType::RDS_PI),
static_cast<uint32_t>(IdentifierType::HD_STATION_ID_EXT),
+ static_cast<uint32_t>(IdentifierType::DAB_SID_EXT),
});
prop.vendorInfo = hidl_vec<VendorKeyValue>({
{"com.google.dummy", "dummy"},
diff --git a/broadcastradio/2.0/default/VirtualRadio.cpp b/broadcastradio/2.0/default/VirtualRadio.cpp
index 0b65979..c59fd8f 100644
--- a/broadcastradio/2.0/default/VirtualRadio.cpp
+++ b/broadcastradio/2.0/default/VirtualRadio.cpp
@@ -28,6 +28,7 @@
using std::mutex;
using std::vector;
using utils::make_selector_amfm;
+using utils::make_selector_dab;
VirtualRadio gAmFmRadio(
"AM/FM radio mock",
@@ -41,6 +42,16 @@
{make_selector_amfm(106100), "106 KMEL", "Drake", "Marvins Room"},
});
+// clang-format off
+VirtualRadio gDabRadio(
+ "DAB radio mock",
+ {
+ {make_selector_dab(12345, 225648), "BBC Radio 1", "Khalid", "Talk"}, // 12B
+ {make_selector_dab(22345, 222064), "Classic FM", "Jean Sibelius", "Andante Festivo"}, // 11D
+ {make_selector_dab(32345, 222064), "Absolute Radio", "Coldplay", "Clocks"}, // 11D
+ });
+// clang-format on
+
VirtualRadio::VirtualRadio(const std::string& name, const vector<VirtualProgram>& initialList)
: mName(name), mPrograms(initialList) {}
diff --git a/broadcastradio/2.0/default/VirtualRadio.h b/broadcastradio/2.0/default/VirtualRadio.h
index 9c07816..6fa70c5 100644
--- a/broadcastradio/2.0/default/VirtualRadio.h
+++ b/broadcastradio/2.0/default/VirtualRadio.h
@@ -52,6 +52,9 @@
/** AM/FM virtual radio space. */
extern VirtualRadio gAmFmRadio;
+/** DAB virtual radio space. */
+extern VirtualRadio gDabRadio;
+
} // namespace implementation
} // namespace V2_0
} // namespace broadcastradio
diff --git a/broadcastradio/2.0/default/service.cpp b/broadcastradio/2.0/default/service.cpp
index af96dad..349aba2 100644
--- a/broadcastradio/2.0/default/service.cpp
+++ b/broadcastradio/2.0/default/service.cpp
@@ -23,6 +23,7 @@
using android::hardware::joinRpcThreadpool;
using android::hardware::broadcastradio::V2_0::implementation::BroadcastRadio;
using android::hardware::broadcastradio::V2_0::implementation::gAmFmRadio;
+using android::hardware::broadcastradio::V2_0::implementation::gDabRadio;
int main() {
android::base::SetDefaultTag("BcRadioDef");
@@ -30,8 +31,13 @@
configureRpcThreadpool(4, true);
BroadcastRadio broadcastRadio(gAmFmRadio);
- auto status = broadcastRadio.registerAsService();
- CHECK_EQ(status, android::OK) << "Failed to register Broadcast Radio HAL implementation";
+ auto amFmStatus = broadcastRadio.registerAsService("amfm");
+ CHECK_EQ(amFmStatus, android::OK)
+ << "Failed to register Broadcast Radio AM/FM HAL implementation";
+
+ BroadcastRadio dabRadio(gDabRadio);
+ auto dabStatus = dabRadio.registerAsService("dab");
+ CHECK_EQ(dabStatus, android::OK) << "Failed to register Broadcast Radio DAB HAL implementation";
joinRpcThreadpool();
return 1; // joinRpcThreadpool shouldn't exit
diff --git a/broadcastradio/common/utils2x/Utils.cpp b/broadcastradio/common/utils2x/Utils.cpp
index 7892653..43f272e 100644
--- a/broadcastradio/common/utils2x/Utils.cpp
+++ b/broadcastradio/common/utils2x/Utils.cpp
@@ -299,6 +299,20 @@
return sel;
}
+ProgramSelector make_selector_dab(uint32_t sidExt, uint32_t ensemble) {
+ ProgramSelector sel = {};
+ // TODO(maryabad): Have a helper function to create the sidExt instead of
+ // passing the whole identifier here. Something like make_dab_sid_ext.
+ sel.primaryId = make_identifier(IdentifierType::DAB_SID_EXT, sidExt);
+ hidl_vec<ProgramIdentifier> secondaryIds = {
+ make_identifier(IdentifierType::DAB_ENSEMBLE, ensemble),
+ // TODO(maryabad): Include frequency here when the helper method to
+ // translate between ensemble and frequency is implemented.
+ };
+ sel.secondaryIds = secondaryIds;
+ return sel;
+}
+
Metadata make_metadata(MetadataKey key, int64_t value) {
Metadata meta = {};
meta.key = static_cast<uint32_t>(key);
diff --git a/broadcastradio/common/utils2x/include/broadcastradio-utils-2x/Utils.h b/broadcastradio/common/utils2x/include/broadcastradio-utils-2x/Utils.h
index c4aecb2..f4e0732 100644
--- a/broadcastradio/common/utils2x/include/broadcastradio-utils-2x/Utils.h
+++ b/broadcastradio/common/utils2x/include/broadcastradio-utils-2x/Utils.h
@@ -126,6 +126,7 @@
V2_0::ProgramIdentifier make_identifier(V2_0::IdentifierType type, uint64_t value);
V2_0::ProgramSelector make_selector_amfm(uint32_t frequency);
+V2_0::ProgramSelector make_selector_dab(uint32_t sidExt, uint32_t ensemble);
V2_0::Metadata make_metadata(V2_0::MetadataKey key, int64_t value);
V2_0::Metadata make_metadata(V2_0::MetadataKey key, std::string value);