Merge "Added programInfoChanged callback."

This commit is contained in:
Tomasz Wasilczyk 2017-07-18 16:15:17 +00:00 committed by Android (Google) Code Review
commit 8ca043b286
3 changed files with 43 additions and 14 deletions

View file

@ -28,16 +28,26 @@ interface ITunerCallback extends @1.0::ITunerCallback {
/** /**
* Method called by the HAL when a tuning operation completes * Method called by the HAL when a tuning operation completes
* following a step(), scan() or tune() command. * following a step(), scan() or tune() command.
*
* This callback supersedes V1_0::tuneComplete. For performance reasons,
* the 1.0 callback may not be called when HAL implementation detects 1.1
* client (by casting V1_0::ITunerCallback to V1_1::ITunerCallback).
*
* @param result OK if tune succeeded or TIMEOUT in case of time out. * @param result OK if tune succeeded or TIMEOUT in case of time out.
* @param info A ProgramInfo structure describing the tuned station. * @param selector A ProgramSelector structure describing the tuned station.
*/ */
oneway tuneComplete_1_1(Result result, ProgramInfo info); oneway tuneComplete_1_1(Result result, ProgramSelector selector);
/** /**
* Method called by the HAL when a frequency switch occurs. * Method called by the HAL when a frequency switch occurs.
* @param info A ProgramInfo structure describing the new tuned station. *
* This callback supersedes V1_0::afSwitch. For performance reasons,
* the 1.0 callback may not be called when HAL implementation detects 1.1
* client (by casting V1_0::ITunerCallback to V1_1::ITunerCallback).
*
* @param selector A ProgramSelector structure describing the tuned station.
*/ */
oneway afSwitch_1_1(ProgramInfo info); oneway afSwitch_1_1(ProgramSelector selector);
/** /**
* Called by the HAL when background scan feature becomes available or not. * Called by the HAL when background scan feature becomes available or not.
@ -69,4 +79,20 @@ interface ITunerCallback extends @1.0::ITunerCallback {
* Client may retrieve the actual list with ITuner::getProgramList. * Client may retrieve the actual list with ITuner::getProgramList.
*/ */
oneway programListChanged(); oneway programListChanged();
/**
* Method called by the HAL when current program information (including
* metadata) is updated.
*
* Client may retrieve the actual program info with
* ITuner::getProgramInformation_1_1.
*
* This may be called together with tuneComplete_1_1 or afSwitch_1_1.
*
* This callback supersedes V1_0::tuneComplete, V1_0::afSwitch and
* newMetadata. For performance reasons, these callbacks may not be called
* when HAL implementation detects 1.1 client (by casting
* V1_0::ITunerCallback to V1_1::ITunerCallback).
*/
oneway programInfoChanged();
}; };

View file

@ -126,9 +126,10 @@ void Tuner::tuneInternalLocked(const ProgramSelector& sel) {
} }
mIsTuneCompleted = true; mIsTuneCompleted = true;
mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base); if (mCallback1_1 == nullptr) {
if (mCallback1_1 != nullptr) { mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base);
mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo); } else {
mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo.selector);
} }
} }
@ -146,8 +147,9 @@ Return<Result> Tuner::scan(Direction direction, bool skipSubChannel __unused) {
auto task = [this, direction]() { auto task = [this, direction]() {
ALOGI("Performing failed scan %s", toString(direction).c_str()); ALOGI("Performing failed scan %s", toString(direction).c_str());
mCallback->tuneComplete(Result::TIMEOUT, {}); if (mCallback1_1 == nullptr) {
if (mCallback1_1 != nullptr) { mCallback->tuneComplete(Result::TIMEOUT, {});
} else {
mCallback1_1->tuneComplete_1_1(Result::TIMEOUT, {}); mCallback1_1->tuneComplete_1_1(Result::TIMEOUT, {});
} }
}; };

View file

@ -68,9 +68,9 @@ class TunerCallbackMock : public ITunerCallback {
MOCK_METHOD0(hardwareFailure, Return<void>()); MOCK_METHOD0(hardwareFailure, Return<void>());
MOCK_TIMEOUT_METHOD2(configChange, Return<void>(Result, const BandConfig&)); MOCK_TIMEOUT_METHOD2(configChange, Return<void>(Result, const BandConfig&));
MOCK_METHOD2(tuneComplete, Return<void>(Result, const V1_0::ProgramInfo&)); MOCK_METHOD2(tuneComplete, Return<void>(Result, const V1_0::ProgramInfo&));
MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return<void>(Result, const ProgramInfo&)); MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return<void>(Result, const ProgramSelector&));
MOCK_METHOD1(afSwitch, Return<void>(const V1_0::ProgramInfo&)); MOCK_METHOD1(afSwitch, Return<void>(const V1_0::ProgramInfo&));
MOCK_METHOD1(afSwitch_1_1, Return<void>(const ProgramInfo&)); MOCK_METHOD1(afSwitch_1_1, Return<void>(const ProgramSelector&));
MOCK_METHOD1(antennaStateChange, Return<void>(bool connected)); MOCK_METHOD1(antennaStateChange, Return<void>(bool connected));
MOCK_METHOD1(trafficAnnouncement, Return<void>(bool active)); MOCK_METHOD1(trafficAnnouncement, Return<void>(bool active));
MOCK_METHOD1(emergencyAnnouncement, Return<void>(bool active)); MOCK_METHOD1(emergencyAnnouncement, Return<void>(bool active));
@ -78,6 +78,7 @@ class TunerCallbackMock : public ITunerCallback {
MOCK_METHOD1(backgroundScanAvailable, Return<void>(bool)); MOCK_METHOD1(backgroundScanAvailable, Return<void>(bool));
MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return<void>(ProgramListResult)); MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return<void>(ProgramListResult));
MOCK_METHOD0(programListChanged, Return<void>()); MOCK_METHOD0(programListChanged, Return<void>());
MOCK_METHOD0(programInfoChanged, Return<void>());
}; };
class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase, class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase,
@ -276,14 +277,14 @@ TEST_P(BroadcastRadioHalTest, TuneFromProgramList) {
return; return;
} }
ProgramInfo infoCb; ProgramSelector selCb;
EXPECT_CALL(*mCallback, tuneComplete(_, _)); EXPECT_CALL(*mCallback, tuneComplete(_, _));
EXPECT_TIMEOUT_CALL(*mCallback, tuneComplete_1_1, Result::OK, _) EXPECT_TIMEOUT_CALL(*mCallback, tuneComplete_1_1, Result::OK, _)
.WillOnce(DoAll(SaveArg<1>(&infoCb), testing::Return(ByMove(Void())))); .WillOnce(DoAll(SaveArg<1>(&selCb), testing::Return(ByMove(Void()))));
auto tuneResult = mTuner->tune_1_1(firstProgram.selector); auto tuneResult = mTuner->tune_1_1(firstProgram.selector);
ASSERT_EQ(Result::OK, tuneResult); ASSERT_EQ(Result::OK, tuneResult);
EXPECT_TIMEOUT_CALL_WAIT(*mCallback, tuneComplete_1_1, kTuneTimeout); EXPECT_TIMEOUT_CALL_WAIT(*mCallback, tuneComplete_1_1, kTuneTimeout);
EXPECT_EQ(firstProgram.selector.primaryId, infoCb.selector.primaryId); EXPECT_EQ(firstProgram.selector.primaryId, selCb.primaryId);
} }
INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest, INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest,