Initial change to add mock DAB stations (hardcoded for now).
Test: VtsHalBroadcastradioV2_0TargetTest Change-Id: Ice8923490728402ed945e8cc0891fd8b2c5bf9dd
This commit is contained in:
parent
9cc43c58a4
commit
f62374d024
6 changed files with 38 additions and 2 deletions
|
@ -49,6 +49,7 @@ static Properties initProperties(const VirtualRadio& virtualRadio) {
|
|||
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"},
|
||||
|
|
|
@ -28,6 +28,7 @@ using std::move;
|
|||
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 @@ VirtualRadio gAmFmRadio(
|
|||
{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) {}
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ class VirtualRadio {
|
|||
/** AM/FM virtual radio space. */
|
||||
extern VirtualRadio gAmFmRadio;
|
||||
|
||||
/** DAB virtual radio space. */
|
||||
extern VirtualRadio gDabRadio;
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace broadcastradio
|
||||
|
|
|
@ -23,6 +23,7 @@ using android::hardware::configureRpcThreadpool;
|
|||
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 @@ int main() {
|
|||
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
|
||||
|
|
|
@ -299,6 +299,20 @@ ProgramSelector make_selector_amfm(uint32_t frequency) {
|
|||
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);
|
||||
|
|
|
@ -126,6 +126,7 @@ bool isValid(const V2_0::ProgramSelector& sel);
|
|||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue