Make metadata field mandatory for program info struct.

Test: VTS, manual
Change-Id: I532dbb0f3d9cb5194265c67fd1328bce55e43b9d
This commit is contained in:
Tomasz Wasilczyk 2017-01-06 14:19:11 -08:00
parent 3427948833
commit 5cc9d866d2
6 changed files with 18 additions and 29 deletions

View file

@ -103,11 +103,9 @@ interface ITuner {
/*
* Retrieve current station information.
* @param withMetadata True if Metadata should be returned, false otherwise.
* @return result OK if scan successfully started
* NOT_INITIALIZED if another error occurs
* @return info Current program information.
*/
getProgramInformation(bool withMetadata)
generates(Result result, ProgramInfo info);
getProgramInformation() generates(Result result, ProgramInfo info);
};

View file

@ -46,7 +46,7 @@ void Tuner::onCallback(radio_hal_event_t *halEvent)
mCallback->antennaStateChange(halEvent->on);
break;
case RADIO_EVENT_TUNED:
Utils::convertProgramInfoFromHal(&info, &halEvent->info, true);
Utils::convertProgramInfoFromHal(&info, &halEvent->info);
mCallback->tuneComplete(Utils::convertHalResult(halEvent->status), info);
break;
case RADIO_EVENT_METADATA: {
@ -61,7 +61,7 @@ void Tuner::onCallback(radio_hal_event_t *halEvent)
mCallback->trafficAnnouncement(halEvent->on);
break;
case RADIO_EVENT_AF_SWITCH:
Utils::convertProgramInfoFromHal(&info, &halEvent->info, true);
Utils::convertProgramInfoFromHal(&info, &halEvent->info);
mCallback->afSwitch(info);
break;
case RADIO_EVENT_EA:
@ -164,7 +164,7 @@ Return<Result> Tuner::cancel() {
return Utils::convertHalResult(rc);
}
Return<void> Tuner::getProgramInformation(bool withMetadata, getProgramInformation_cb _hidl_cb) {
Return<void> Tuner::getProgramInformation(getProgramInformation_cb _hidl_cb) {
int rc;
radio_program_info_t halInfo;
ProgramInfo info;
@ -174,18 +174,13 @@ Return<void> Tuner::getProgramInformation(bool withMetadata, getProgramInformati
rc = -ENODEV;
goto exit;
}
if (withMetadata) {
radio_metadata_allocate(&halInfo.metadata, 0, 0);
} else {
halInfo.metadata = NULL;
}
radio_metadata_allocate(&halInfo.metadata, 0, 0);
rc = mHalTuner->get_program_information(mHalTuner, &halInfo);
if (rc == 0) {
Utils::convertProgramInfoFromHal(&info, &halInfo, withMetadata);
}
if (withMetadata) {
radio_metadata_deallocate(halInfo.metadata);
Utils::convertProgramInfoFromHal(&info, &halInfo);
}
radio_metadata_deallocate(halInfo.metadata);
exit:
_hidl_cb(Utils::convertHalResult(rc), info);

View file

@ -40,8 +40,7 @@ struct Tuner : public ITuner {
Return<Result> step(Direction direction, bool skipSubChannel) override;
Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
Return<Result> cancel() override;
Return<void> getProgramInformation(bool withMetadata,
getProgramInformation_cb _hidl_cb) override;
Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
static void callback(radio_hal_event_t *halEvent, void *cookie);
void onCallback(radio_hal_event_t *halEvent);

View file

@ -222,8 +222,7 @@ void Utils::convertBandConfigToHal(
//static
void Utils::convertProgramInfoFromHal(ProgramInfo *info,
radio_program_info_t *halInfo,
bool withMetadata)
radio_program_info_t *halInfo)
{
info->channel = halInfo->channel;
info->subChannel = halInfo->sub_channel;
@ -231,9 +230,7 @@ void Utils::convertProgramInfoFromHal(ProgramInfo *info,
info->stereo = halInfo->stereo;
info->digital = halInfo->digital;
info->signalStrength = halInfo->signal_strength;
if (withMetadata && halInfo->metadata != NULL) {
convertMetaDataFromHal(info->metadata, halInfo->metadata);
}
convertMetaDataFromHal(info->metadata, halInfo->metadata);
}
//static
@ -241,6 +238,7 @@ int Utils::convertMetaDataFromHal(hidl_vec<MetaData>& metadata,
radio_metadata_t *halMetadata)
{
if (halMetadata == NULL) {
ALOGE("Invalid argument: halMetadata is NULL");
return 0;
}

View file

@ -36,8 +36,7 @@ public:
static void convertBandConfigToHal(radio_hal_band_config_t *halConfig,
const BandConfig *config);
static void convertProgramInfoFromHal(ProgramInfo *info,
radio_program_info_t *halInfo,
bool withMetadata);
radio_program_info_t *halInfo);
static int convertMetaDataFromHal(hidl_vec<MetaData>& metadata,
radio_metadata_t *halMetadata);
private:

View file

@ -434,11 +434,11 @@ TEST_F(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) {
ProgramInfo halInfo;
Result halResult = Result::NOT_INITIALIZED;
Return<void> hidlReturn = mTuner->getProgramInformation(
false, [&](Result result, const ProgramInfo& info) {
halResult = result;
if (result == Result::OK) {
halInfo = info;
}
[&](Result result, const ProgramInfo& info) {
halResult = result;
if (result == Result::OK) {
halInfo = info;
}
});
EXPECT_TRUE(hidlReturn.isOk());
EXPECT_EQ(Result::OK, halResult);