Add setStatusCheckIntervalHint method

Bug: 232426514
Test: atest VtsHalTvTunerTargetTest
Change-Id: Icba606f2cd36bb52a48e7fe5798fb8dcc8c2fb0a
This commit is contained in:
Ray Chin 2022-09-15 15:07:33 +08:00
parent c8074521fb
commit 62ab6c9506
11 changed files with 153 additions and 3 deletions

View file

@ -43,4 +43,5 @@ interface IDvr {
void stop();
void flush();
void close();
void setStatusCheckIntervalHint(in long milliseconds);
}

View file

@ -18,7 +18,6 @@ package android.hardware.tv.tuner;
import android.hardware.common.fmq.MQDescriptor;
import android.hardware.common.fmq.SynchronizedReadWrite;
import android.hardware.tv.tuner.DvrSettings;
import android.hardware.tv.tuner.IFilter;
@ -101,4 +100,12 @@ interface IDvr {
* instance any more and all methods should return a failure.
*/
void close();
/**
* Set status check time interval.
*
* This time interval hint will be used by the Dvr to decide how often
* to evaluate data.
*/
void setStatusCheckIntervalHint(in long milliseconds);
}

View file

@ -29,7 +29,7 @@ cc_defaults {
],
shared_libs: [
"android.hardware.common.fmq-V1-ndk",
"android.hardware.tv.tuner-V1-ndk",
"android.hardware.tv.tuner-V2-ndk",
"libbase",
"libbinder_ndk",
"libcutils",

View file

@ -154,6 +154,14 @@ Dvr::~Dvr() {
return ::ndk::ScopedAStatus::ok();
}
::ndk::ScopedAStatus Dvr::setStatusCheckIntervalHint(int64_t /* in_milliseconds */) {
ALOGV("%s", __FUNCTION__);
// There is no active polling in this default implementation,
// so directly return ok here.
return ::ndk::ScopedAStatus::ok();
}
bool Dvr::createDvrMQ() {
ALOGV("%s", __FUNCTION__);

View file

@ -70,6 +70,7 @@ class Dvr : public BnDvr {
::ndk::ScopedAStatus stop() override;
::ndk::ScopedAStatus flush() override;
::ndk::ScopedAStatus close() override;
::ndk::ScopedAStatus setStatusCheckIntervalHint(int64_t in_milliseconds) override;
binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;

View file

@ -53,7 +53,7 @@ cc_test {
"android.hardware.cas@1.2",
"android.hardware.common-V2-ndk",
"android.hardware.common.fmq-V1-ndk",
"android.hardware.tv.tuner-V1-ndk",
"android.hardware.tv.tuner-V2-ndk",
"libaidlcommonsupport",
"libfmq",
"libcutils",

View file

@ -323,3 +323,41 @@ void DvrTests::closeDvrRecord() {
ASSERT_TRUE(mDvrRecord);
ASSERT_TRUE(mDvrRecord->close().isOk());
}
AssertionResult DvrTests::setPlaybackStatusCheckIntervalHint(int64_t milliseconds) {
ndk::ScopedAStatus status;
EXPECT_TRUE(mDemux) << "Test with openDemux first.";
EXPECT_TRUE(mDvrPlayback) << "Test with openDvr first.";
status = mDvrPlayback->setStatusCheckIntervalHint(milliseconds);
if (getDvrPlaybackInterfaceVersion() < 2) {
return AssertionResult(status.getStatus() == STATUS_UNKNOWN_TRANSACTION);
}
return AssertionResult(status.isOk());
}
AssertionResult DvrTests::setRecordStatusCheckIntervalHint(int64_t milliseconds) {
ndk::ScopedAStatus status;
EXPECT_TRUE(mDemux) << "Test with openDemux first.";
EXPECT_TRUE(mDvrRecord) << "Test with openDvr first.";
status = mDvrRecord->setStatusCheckIntervalHint(milliseconds);
if (getDvrRecordInterfaceVersion() < 2) {
return AssertionResult(status.getStatus() == STATUS_UNKNOWN_TRANSACTION);
}
return AssertionResult(status.isOk());
}
int32_t DvrTests::getDvrPlaybackInterfaceVersion() {
int32_t version;
mDvrPlayback->getInterfaceVersion(&version);
return version;
}
int32_t DvrTests::getDvrRecordInterfaceVersion() {
int32_t version;
mDvrRecord->getInterfaceVersion(&version);
return version;
}

View file

@ -162,8 +162,12 @@ class DvrTests {
AssertionResult startDvrPlayback();
AssertionResult stopDvrRecord();
AssertionResult startDvrRecord();
AssertionResult setPlaybackStatusCheckIntervalHint(int64_t milliseconds);
AssertionResult setRecordStatusCheckIntervalHint(int64_t milliseconds);
void closeDvrPlayback();
void closeDvrRecord();
int32_t getDvrPlaybackInterfaceVersion();
int32_t getDvrRecordInterfaceVersion();
protected:
static AssertionResult failure() { return ::testing::AssertionFailure(); }

View file

@ -241,6 +241,28 @@ void TunerPlaybackAidlTest::playbackSingleFilterTest(FilterConfig filterConf, Dv
ASSERT_TRUE(mDemuxTests.closeDemux());
}
void TunerPlaybackAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
DvrConfig dvrConf) {
int32_t demuxId;
std::shared_ptr<IDemux> demux;
ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
mDvrTests.setDemux(demux);
ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
ASSERT_TRUE(mDvrTests.setPlaybackStatusCheckIntervalHint(statusCheckIntervalHint));
mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
dvrConf.settings.get<DvrSettings::Tag::playback>());
ASSERT_TRUE(mDvrTests.startDvrPlayback());
mDvrTests.stopPlaybackThread();
ASSERT_TRUE(mDvrTests.stopDvrPlayback());
mDvrTests.closeDvrPlayback();
ASSERT_TRUE(mDemuxTests.closeDemux());
}
void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf,
FrontendConfig frontendConf,
DvrConfig dvrConf, LnbConfig lnbConf) {
@ -426,6 +448,45 @@ void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,
ASSERT_TRUE(mDemuxTests.closeDemux());
}
void TunerRecordAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
FrontendConfig frontendConf,
DvrConfig dvrConf) {
int32_t demuxId;
std::shared_ptr<IDemux> demux;
ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
mDvrTests.setDemux(demux);
DvrConfig dvrSourceConfig;
if (record.hasFrontendConnection) {
int32_t feId;
mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
ASSERT_TRUE(feId != INVALID_ID);
ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
ASSERT_TRUE(mFrontendTests.setFrontendCallback());
ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
} else {
dvrSourceConfig = dvrMap[record.dvrSourceId];
ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
}
ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
ASSERT_TRUE(mDvrTests.setRecordStatusCheckIntervalHint(statusCheckIntervalHint));
ASSERT_TRUE(mDvrTests.startDvrRecord());
ASSERT_TRUE(mDvrTests.stopDvrRecord());
mDvrTests.closeDvrRecord();
ASSERT_TRUE(mDemuxTests.closeDemux());
if (record.hasFrontendConnection) {
ASSERT_TRUE(mFrontendTests.closeFrontend());
}
}
void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
FrontendConfig frontendConf,
DescramblerConfig descConfig,
@ -1000,6 +1061,18 @@ TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
}
}
TEST_P(TunerPlaybackAidlTest, SetStatusCheckIntervalHintToPlaybackTest) {
description("Set status check interval hint to playback test.");
if (!playback.support) {
return;
}
vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
for (auto& configuration : playback_configs) {
playback = configuration;
setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, dvrMap[playback.dvrId]);
}
}
TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
description("Feed ts data from frontend to recording and test with ts record filter");
if (!record.support) {
@ -1046,6 +1119,19 @@ TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
}
}
TEST_P(TunerRecordAidlTest, SetStatusCheckIntervalHintToRecordTest) {
description("Set status check interval hint to record test.");
if (!record.support) {
return;
}
auto record_configs = generateRecordConfigurations();
for (auto& configuration : record_configs) {
record = configuration;
setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, frontendMap[record.frontendId],
dvrMap[record.dvrRecordId]);
}
}
TEST_P(TunerFrontendAidlTest, TuneFrontend) {
description("Tune one Frontend with specific setting and check Lock event");
if (!live.hasFrontendConnection) {

View file

@ -255,6 +255,8 @@ class TunerPlaybackAidlTest : public testing::TestWithParam<std::string> {
AssertionResult filterDataOutputTest();
void playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf);
void setStatusCheckIntervalHintTest(int64_t milliseconds, DvrConfig dvrConf);
};
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerPlaybackAidlTest);
@ -294,6 +296,8 @@ class TunerRecordAidlTest : public testing::TestWithParam<std::string> {
DvrConfig dvrConf, LnbConfig lnbConf);
void recordSingleFilterTest(FilterConfig filterConf, FrontendConfig frontendConf,
DvrConfig dvrConf, Dataflow_Context context);
void setStatusCheckIntervalHintTest(int64_t milliseconds, FrontendConfig frontendConf,
DvrConfig dvrConf);
std::shared_ptr<ITuner> mService;
FrontendTests mFrontendTests;

View file

@ -55,6 +55,7 @@ const int32_t FMQ_SIZE_16M = 0x1000000;
const string configFilePath = "/vendor/etc/tuner_vts_config_aidl_V1.xml";
#define FILTER_MAIN_TYPE_BIT_COUNT 5
#define STATUS_CHECK_INTERVAL_MS 100L
// Hardware configs
static map<string, FrontendConfig> frontendMap;