Fix boadcastradio HAL 1.1 tuneByProgramSelector implementation.
It was not compliant with the HAL definition - it didn't auto-change
band if necessary.
Bug: 74353024
Test: manual
Change-Id: I015faffc42778fa27fca3030306f31b0abe409c7
diff --git a/broadcastradio/1.1/default/BroadcastRadio.cpp b/broadcastradio/1.1/default/BroadcastRadio.cpp
index 2933aa7..e01812e 100644
--- a/broadcastradio/1.1/default/BroadcastRadio.cpp
+++ b/broadcastradio/1.1/default/BroadcastRadio.cpp
@@ -122,28 +122,7 @@
{"com.google.dummy", "dummy"},
});
- prop10.bands.resize(mConfig.amFmBands.size());
- for (size_t i = 0; i < mConfig.amFmBands.size(); i++) {
- auto& src = mConfig.amFmBands[i];
- auto& dst = prop10.bands[i];
-
- dst.type = src.type;
- dst.antennaConnected = true;
- dst.lowerLimit = src.lowerLimit;
- dst.upperLimit = src.upperLimit;
- dst.spacings = src.spacings;
-
- if (utils::isAm(src.type)) {
- dst.ext.am.stereo = true;
- } else if (utils::isFm(src.type)) {
- dst.ext.fm.deemphasis = static_cast<Deemphasis>(Deemphasis::D50 | Deemphasis::D75);
- dst.ext.fm.stereo = true;
- dst.ext.fm.rds = static_cast<Rds>(Rds::WORLD | Rds::US);
- dst.ext.fm.ta = true;
- dst.ext.fm.af = true;
- dst.ext.fm.ea = true;
- }
- }
+ prop10.bands = getAmFmBands();
_hidl_cb(prop11);
return Void();
@@ -162,7 +141,7 @@
mTuner = nullptr;
}
- sp<Tuner> newTuner = new Tuner(mClassId, callback);
+ sp<Tuner> newTuner = new Tuner(this, mClassId, callback);
mTuner = newTuner;
if (mClassId == Class::AM_FM) {
auto ret = newTuner->setConfiguration(config);
@@ -189,6 +168,33 @@
return Void();
}
+std::vector<V1_0::BandConfig> BroadcastRadio::getAmFmBands() const {
+ std::vector<V1_0::BandConfig> out;
+ for (auto&& src : mConfig.amFmBands) {
+ V1_0::BandConfig dst;
+
+ dst.type = src.type;
+ dst.antennaConnected = true;
+ dst.lowerLimit = src.lowerLimit;
+ dst.upperLimit = src.upperLimit;
+ dst.spacings = src.spacings;
+
+ if (utils::isAm(src.type)) {
+ dst.ext.am.stereo = true;
+ } else if (utils::isFm(src.type)) {
+ dst.ext.fm.deemphasis = static_cast<Deemphasis>(Deemphasis::D50 | Deemphasis::D75);
+ dst.ext.fm.stereo = true;
+ dst.ext.fm.rds = static_cast<Rds>(Rds::WORLD | Rds::US);
+ dst.ext.fm.ta = true;
+ dst.ext.fm.af = true;
+ dst.ext.fm.ea = true;
+ }
+
+ out.push_back(dst);
+ }
+ return out;
+}
+
} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio