Add RDS info to virtual stations, convert to ProgramInfo.

Bug: b/36864090
Test: manual, VTS (none added)
Change-Id: Iad54f5abee4c722030ae118cb3c4d8ad64225b34
This commit is contained in:
Tomasz Wasilczyk 2017-06-29 16:04:05 -07:00
parent fcccb150ef
commit 100f2ed58a
4 changed files with 41 additions and 26 deletions

View file

@ -107,24 +107,17 @@ void Tuner::tuneInternalLocked() {
virtualRadio = &mVirtualFm;
}
auto& info11 = mCurrentProgramInfo;
auto& info10 = info11.base;
VirtualProgram virtualProgram;
if (virtualRadio != nullptr && virtualRadio->getProgram(mCurrentProgram, virtualProgram)) {
// TODO(b/36864090): convert virtualProgram to ProgramInfo instead
info10.channel = mCurrentProgram;
info10.tuned = true;
info10.stereo = true;
info10.signalStrength = 100;
mCurrentProgramInfo = static_cast<ProgramInfo>(virtualProgram);
} else {
info11 = makeDummyProgramInfo(mCurrentProgram);
mCurrentProgramInfo = makeDummyProgramInfo(mCurrentProgram);
}
mIsTuneCompleted = true;
mCallback->tuneComplete(Result::OK, info10);
mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base);
if (mCallback1_1 != nullptr) {
mCallback1_1->tuneComplete_1_1(Result::OK, info11);
mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo);
}
}
@ -274,20 +267,8 @@ Return<void> Tuner::getProgramList(const hidl_string& filter __unused, getProgra
return Void();
}
hidl_vec<ProgramInfo> list;
auto vList = virtualRadio.getProgramList();
list.resize(vList.size());
for (size_t i = 0; i < vList.size(); i++) {
auto& src = vList[i];
auto& dst11 = list[i];
auto& dst10 = dst11.base;
// TODO(b/36864090): convert virtualProgram to ProgramInfo instead
dst10.channel = src.channel;
dst10.tuned = true;
}
_hidl_cb(ProgramListResult::OK, list);
auto list = virtualRadio.getProgramList();
_hidl_cb(ProgramListResult::OK, vector<ProgramInfo>(list.begin(), list.end()));
return Void();
}

View file

@ -21,6 +21,28 @@ namespace broadcastradio {
namespace V1_1 {
namespace implementation {
using V1_0::MetaData;
using V1_0::MetadataKey;
using V1_0::MetadataType;
VirtualProgram::operator ProgramInfo() const {
ProgramInfo info11 = {};
auto& info10 = info11.base;
info10.channel = channel;
info10.tuned = true;
info10.stereo = true;
info10.signalStrength = 100;
info10.metadata = hidl_vec<MetaData>({
{MetadataType::TEXT, MetadataKey::RDS_PS, {}, {}, programName, {}},
{MetadataType::TEXT, MetadataKey::TITLE, {}, {}, songTitle, {}},
{MetadataType::TEXT, MetadataKey::ARTIST, {}, {}, songArtist, {}},
});
return info11;
}
bool operator<(const VirtualProgram& lhs, const VirtualProgram& rhs) {
return lhs.channel < rhs.channel;
}

View file

@ -16,6 +16,7 @@
#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
#include <android/hardware/broadcastradio/1.1/types.h>
#include <cstdint>
namespace android {
@ -27,6 +28,11 @@ namespace implementation {
struct VirtualProgram {
uint32_t channel; // TODO(b/32621193): Station Selector
std::string programName = "";
std::string songArtist = "";
std::string songTitle = "";
explicit operator ProgramInfo() const;
friend bool operator<(const VirtualProgram& lhs, const VirtualProgram& rhs);
};

View file

@ -27,7 +27,13 @@ using std::mutex;
using std::vector;
vector<VirtualProgram> gInitialFmPrograms{
{94900}, {96500}, {97300}, {99700}, {101300}, {103700}, {106100},
{94900, "Wild 94.9", "Drake ft. Rihanna", "Too Good"},
{96500, "KOIT", "Celine Dion", "All By Myself"},
{97300, "Alice@97.3", "Drops of Jupiter", "Train"},
{99700, "99.7 Now!", "The Chainsmokers", "Closer"},
{101300, "101-3 KISS-FM", "Justin Timberlake", "Rock Your Body"},
{103700, "iHeart80s @ 103.7", "Michael Jackson", "Billie Jean"},
{106100, "106 KMEL", "Drake", "Marvins Room"},
};
VirtualRadio::VirtualRadio(VirtualRadio&& o) : mPrograms(move(o.mPrograms)) {}