Remove a hack for 1.0/1.1 bitmap compatibility.
Instead, implement it correctly.
This hack was a quick jury-rigging before O MR1 FC.
Bug: b/36864090
Test: VTS
Change-Id: Ia9caff9228518ec573a85437e9070db777057359
diff --git a/broadcastradio/1.1/default/VirtualProgram.cpp b/broadcastradio/1.1/default/VirtualProgram.cpp
index ef0e124..1c2285d 100644
--- a/broadcastradio/1.1/default/VirtualProgram.cpp
+++ b/broadcastradio/1.1/default/VirtualProgram.cpp
@@ -25,20 +25,16 @@
namespace V1_1 {
namespace implementation {
+using std::vector;
+
using V1_0::MetaData;
using V1_0::MetadataKey;
using V1_0::MetadataType;
+using utils::HalRevision;
-// TODO (b/36864090): inject this data in a more elegant way
-static int gHalVersion = 2; // 1 = 1.0, 2 = 1.1
-
-void setCompatibilityLevel(int halversion) {
- gHalVersion = halversion;
-}
-
-static MetaData createDemoBitmap(MetadataKey key) {
+static MetaData createDemoBitmap(MetadataKey key, HalRevision halRev) {
MetaData bmp = {MetadataType::INT, key, resources::demoPngId, {}, {}, {}};
- if (gHalVersion < 2) {
+ if (halRev < HalRevision::V1_1) {
bmp.type = MetadataType::RAW;
bmp.intValue = 0;
bmp.rawValue = hidl_vec<uint8_t>(resources::demoPng, std::end(resources::demoPng));
@@ -46,7 +42,7 @@
return bmp;
}
-VirtualProgram::operator ProgramInfo() const {
+ProgramInfo VirtualProgram::getProgramInfo(HalRevision halRev) const {
ProgramInfo info11 = {};
auto& info10 = info11.base;
@@ -61,8 +57,8 @@
{MetadataType::TEXT, MetadataKey::RDS_PS, {}, {}, programName, {}},
{MetadataType::TEXT, MetadataKey::TITLE, {}, {}, songTitle, {}},
{MetadataType::TEXT, MetadataKey::ARTIST, {}, {}, songArtist, {}},
- createDemoBitmap(MetadataKey::ICON),
- createDemoBitmap(MetadataKey::ART),
+ createDemoBitmap(MetadataKey::ICON, halRev),
+ createDemoBitmap(MetadataKey::ART, halRev),
});
return info11;
@@ -89,6 +85,15 @@
return false;
}
+vector<ProgramInfo> getProgramInfoVector(const vector<VirtualProgram>& vec, HalRevision halRev) {
+ vector<ProgramInfo> out;
+ out.reserve(vec.size());
+ for (auto&& program : vec) {
+ out.push_back(program.getProgramInfo(halRev));
+ }
+ return out;
+}
+
} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio