Merge changes from topic 'radio-sprint-selector'
* changes:
Split VENDOR program type to four distinct types.
Move utils lib out from implementation namespace.
diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp
index a36ec3f..3c43c2e 100644
--- a/broadcastradio/1.1/default/Tuner.cpp
+++ b/broadcastradio/1.1/default/Tuner.cpp
@@ -98,7 +98,7 @@
ProgramInfo info11 = {};
auto& info10 = info11.base;
- utils::getLegacyChannel(selector, info10.channel, info10.subChannel);
+ utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
info11.selector = selector;
info11.flags |= ProgramInfoFlags::MUTED;
diff --git a/broadcastradio/1.1/default/VirtualProgram.cpp b/broadcastradio/1.1/default/VirtualProgram.cpp
index ef8bd1c..babf0d8 100644
--- a/broadcastradio/1.1/default/VirtualProgram.cpp
+++ b/broadcastradio/1.1/default/VirtualProgram.cpp
@@ -31,7 +31,7 @@
ProgramInfo info11 = {};
auto& info10 = info11.base;
- utils::getLegacyChannel(selector, info10.channel, info10.subChannel);
+ utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
info11.selector = selector;
info10.tuned = true;
info10.stereo = true;
diff --git a/broadcastradio/1.1/types.hal b/broadcastradio/1.1/types.hal
index dee38b8..44bb507 100644
--- a/broadcastradio/1.1/types.hal
+++ b/broadcastradio/1.1/types.hal
@@ -70,6 +70,10 @@
/**
* Type of a radio technology.
*
+ * There are multiple VENDOR program types just to make vendor implementation
+ * easier with multiple properitary radio technologies. They are treated the
+ * same by the framework.
+ *
* All other values are reserved for future use.
*/
enum ProgramType : uint32_t {
@@ -80,7 +84,10 @@
DAB, // Digital audio broadcasting
DRMO, // Digital Radio Mondiale
SXM, // SiriusXM Satellite Radio
- VENDOR, // vendor-specific, not synced across devices
+ VENDOR1, // Vendor-specific, not synced across devices.
+ VENDOR2, // Vendor-specific, not synced across devices.
+ VENDOR3, // Vendor-specific, not synced across devices.
+ VENDOR4, // Vendor-specific, not synced across devices.
};
/**
@@ -142,9 +149,12 @@
* Primary identifier for vendor-specific radio technology.
* The value format is determined by a vendor.
*
- * It must not be used in any other programType than VENDOR.
+ * It must not be used in any other programType than VENDORx.
*/
- VENDOR_PRIMARY,
+ VENDOR1_PRIMARY,
+ VENDOR2_PRIMARY,
+ VENDOR3_PRIMARY,
+ VENDOR4_PRIMARY,
};
/**
diff --git a/broadcastradio/1.1/utils/Utils.cpp b/broadcastradio/1.1/utils/Utils.cpp
index 9dc0a53..f8a4479 100644
--- a/broadcastradio/1.1/utils/Utils.cpp
+++ b/broadcastradio/1.1/utils/Utils.cpp
@@ -24,7 +24,6 @@
namespace hardware {
namespace broadcastradio {
namespace V1_1 {
-namespace implementation {
namespace utils {
using V1_0::Band;
@@ -92,7 +91,10 @@
return haveEqualIds(a, b, IdentifierType::SXM_SERVICE_ID);
}
return haveEqualIds(a, b, IdentifierType::SXM_CHANNEL);
- case ProgramType::VENDOR:
+ case ProgramType::VENDOR1:
+ case ProgramType::VENDOR2:
+ case ProgramType::VENDOR3:
+ case ProgramType::VENDOR4:
default:
ALOGW("Unsupported program type: %s", toString(type).c_str());
return false;
@@ -166,26 +168,31 @@
sel.primaryId.type = static_cast<uint32_t>(IdentifierType::AMFM_FREQUENCY);
sel.primaryId.value = channel;
if (subChannel > 0) {
- // stating sub channel for AM/FM channel does not give any guarantees,
- // but we can't do much more without HD station ID
+ /* stating sub channel for AM/FM channel does not give any guarantees,
+ * but we can't do much more without HD station ID
+ *
+ * The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based.
+ */
sel.secondaryIds = hidl_vec<ProgramIdentifier>{
- {static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL), subChannel},
+ {static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL), subChannel - 1},
};
}
return sel;
}
-bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut) {
+bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut) {
+ if (channelOut) *channelOut = 0;
+ if (subChannelOut) *subChannelOut = 0;
if (isAmFm(getType(sel))) {
- channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY);
- subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL, 0);
+ if (channelOut) *channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY);
+ if (subChannelOut && hasId(sel, IdentifierType::HD_SUBCHANNEL)) {
+ // The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based.
+ *subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL) + 1;
+ }
return true;
- } else {
- channelOut = 0;
- subChannelOut = 0;
- return false;
}
+ return false;
}
bool isDigital(const ProgramSelector& sel) {
@@ -200,7 +207,6 @@
}
} // namespace utils
-} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio
} // namespace hardware
diff --git a/broadcastradio/1.1/utils/Utils.h b/broadcastradio/1.1/utils/Utils.h
index 1110e79..cd86ffa 100644
--- a/broadcastradio/1.1/utils/Utils.h
+++ b/broadcastradio/1.1/utils/Utils.h
@@ -25,7 +25,6 @@
namespace hardware {
namespace broadcastradio {
namespace V1_1 {
-namespace implementation {
namespace utils {
/**
@@ -61,12 +60,11 @@
ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0);
-bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut);
+bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut);
bool isDigital(const ProgramSelector& sel);
} // namespace utils
-} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio
} // namespace hardware