Loading broadcastradio/1.1/ITunerCallback.hal +30 −4 Original line number Diff line number Diff line Loading @@ -28,16 +28,26 @@ interface ITunerCallback extends @1.0::ITunerCallback { /** * Method called by the HAL when a tuning operation completes * 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 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. * @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. Loading Loading @@ -69,4 +79,20 @@ interface ITunerCallback extends @1.0::ITunerCallback { * Client may retrieve the actual list with ITuner::getProgramList. */ 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(); }; broadcastradio/1.1/default/Tuner.cpp +7 −5 Original line number Diff line number Diff line Loading @@ -126,9 +126,10 @@ void Tuner::tuneInternalLocked(const ProgramSelector& sel) { } mIsTuneCompleted = true; if (mCallback1_1 == nullptr) { mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base); if (mCallback1_1 != nullptr) { mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo); } else { mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo.selector); } } Loading @@ -146,8 +147,9 @@ Return<Result> Tuner::scan(Direction direction, bool skipSubChannel __unused) { auto task = [this, direction]() { ALOGI("Performing failed scan %s", toString(direction).c_str()); if (mCallback1_1 == nullptr) { mCallback->tuneComplete(Result::TIMEOUT, {}); if (mCallback1_1 != nullptr) { } else { mCallback1_1->tuneComplete_1_1(Result::TIMEOUT, {}); } }; Loading broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -68,9 +68,9 @@ class TunerCallbackMock : public ITunerCallback { MOCK_METHOD0(hardwareFailure, Return<void>()); MOCK_TIMEOUT_METHOD2(configChange, Return<void>(Result, const BandConfig&)); 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_1_1, Return<void>(const ProgramInfo&)); MOCK_METHOD1(afSwitch_1_1, Return<void>(const ProgramSelector&)); MOCK_METHOD1(antennaStateChange, Return<void>(bool connected)); MOCK_METHOD1(trafficAnnouncement, Return<void>(bool active)); MOCK_METHOD1(emergencyAnnouncement, Return<void>(bool active)); Loading @@ -78,6 +78,7 @@ class TunerCallbackMock : public ITunerCallback { MOCK_METHOD1(backgroundScanAvailable, Return<void>(bool)); MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return<void>(ProgramListResult)); MOCK_METHOD0(programListChanged, Return<void>()); MOCK_METHOD0(programInfoChanged, Return<void>()); }; class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase, Loading Loading @@ -276,14 +277,14 @@ TEST_P(BroadcastRadioHalTest, TuneFromProgramList) { return; } ProgramInfo infoCb; ProgramSelector selCb; EXPECT_CALL(*mCallback, tuneComplete(_, _)); 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); ASSERT_EQ(Result::OK, tuneResult); 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, Loading Loading
broadcastradio/1.1/ITunerCallback.hal +30 −4 Original line number Diff line number Diff line Loading @@ -28,16 +28,26 @@ interface ITunerCallback extends @1.0::ITunerCallback { /** * Method called by the HAL when a tuning operation completes * 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 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. * @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. Loading Loading @@ -69,4 +79,20 @@ interface ITunerCallback extends @1.0::ITunerCallback { * Client may retrieve the actual list with ITuner::getProgramList. */ 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(); };
broadcastradio/1.1/default/Tuner.cpp +7 −5 Original line number Diff line number Diff line Loading @@ -126,9 +126,10 @@ void Tuner::tuneInternalLocked(const ProgramSelector& sel) { } mIsTuneCompleted = true; if (mCallback1_1 == nullptr) { mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base); if (mCallback1_1 != nullptr) { mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo); } else { mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo.selector); } } Loading @@ -146,8 +147,9 @@ Return<Result> Tuner::scan(Direction direction, bool skipSubChannel __unused) { auto task = [this, direction]() { ALOGI("Performing failed scan %s", toString(direction).c_str()); if (mCallback1_1 == nullptr) { mCallback->tuneComplete(Result::TIMEOUT, {}); if (mCallback1_1 != nullptr) { } else { mCallback1_1->tuneComplete_1_1(Result::TIMEOUT, {}); } }; Loading
broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -68,9 +68,9 @@ class TunerCallbackMock : public ITunerCallback { MOCK_METHOD0(hardwareFailure, Return<void>()); MOCK_TIMEOUT_METHOD2(configChange, Return<void>(Result, const BandConfig&)); 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_1_1, Return<void>(const ProgramInfo&)); MOCK_METHOD1(afSwitch_1_1, Return<void>(const ProgramSelector&)); MOCK_METHOD1(antennaStateChange, Return<void>(bool connected)); MOCK_METHOD1(trafficAnnouncement, Return<void>(bool active)); MOCK_METHOD1(emergencyAnnouncement, Return<void>(bool active)); Loading @@ -78,6 +78,7 @@ class TunerCallbackMock : public ITunerCallback { MOCK_METHOD1(backgroundScanAvailable, Return<void>(bool)); MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return<void>(ProgramListResult)); MOCK_METHOD0(programListChanged, Return<void>()); MOCK_METHOD0(programInfoChanged, Return<void>()); }; class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase, Loading Loading @@ -276,14 +277,14 @@ TEST_P(BroadcastRadioHalTest, TuneFromProgramList) { return; } ProgramInfo infoCb; ProgramSelector selCb; EXPECT_CALL(*mCallback, tuneComplete(_, _)); 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); ASSERT_EQ(Result::OK, tuneResult); 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, Loading