Add descrambler dynamic configuration into Tuner 1.0 VTS
Test: atest VtsHalTvTunerV1_0TargetTest
Bug: 182519645
CTS-Coverage-Bug: 184077478
Change-Id: I2ab16fa9645dba07f8969e3cd7a26cf3b9bcb527
Merged-In: I2ab16fa9645dba07f8969e3cd7a26cf3b9bcb527
diff --git a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp
index 9c1d457..4c92665 100644
--- a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp
+++ b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp
@@ -441,11 +441,9 @@
if (caps.linkCaps[i] & (bitMask << j)) {
uint32_t sourceFilterId;
uint32_t sinkFilterId;
- ASSERT_TRUE(mFilterTests.openFilterInDemux(filterLinkageTypes[SOURCE][i],
- FMQ_SIZE_16M));
+ ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M));
ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId(sourceFilterId));
- ASSERT_TRUE(
- mFilterTests.openFilterInDemux(filterLinkageTypes[SINK][j], FMQ_SIZE_16M));
+ ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M));
ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId(sinkFilterId));
ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId));
ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId));
@@ -561,7 +559,7 @@
filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
- descramblerArray[DESC_0]);
+ descramblerMap[descrambling.descramblerId]);
}
INSTANTIATE_TEST_SUITE_P(
diff --git a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.h b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.h
index bf8e383..e240604 100644
--- a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.h
+++ b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.h
@@ -20,6 +20,9 @@
#include "LnbTests.h"
using android::hardware::tv::tuner::V1_0::DataFormat;
+using android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
+using android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
+using android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
using android::hardware::tv::tuner::V1_0::IDescrambler;
static AssertionResult success() {
@@ -37,14 +40,12 @@
initDvrConfig();
initLnbConfig();
initTimeFilterConfig();
+ initDescramblerConfig();
connectHardwaresToTestCases();
if (!validateConnections()) {
ALOGW("[vts] failed to validate connections.");
return false;
}
-
- initDescramblerConfig();
-
return true;
}
@@ -148,6 +149,29 @@
void configSingleFilterInDemuxTest(FilterConfig filterConf, FrontendConfig frontendConf);
void testTimeFilter(TimeFilterConfig filterConf);
+ DemuxFilterType getLinkageFilterType(int bit) {
+ DemuxFilterType type;
+ type.mainType = static_cast<DemuxFilterMainType>(1 << bit);
+ switch (type.mainType) {
+ case DemuxFilterMainType::TS:
+ type.subType.tsFilterType(DemuxTsFilterType::UNDEFINED);
+ break;
+ case DemuxFilterMainType::MMTP:
+ type.subType.mmtpFilterType(DemuxMmtpFilterType::UNDEFINED);
+ break;
+ case DemuxFilterMainType::IP:
+ type.subType.ipFilterType(DemuxIpFilterType::UNDEFINED);
+ break;
+ case DemuxFilterMainType::TLV:
+ type.subType.tlvFilterType(DemuxTlvFilterType::UNDEFINED);
+ break;
+ case DemuxFilterMainType::ALP:
+ type.subType.alpFilterType(DemuxAlpFilterType::UNDEFINED);
+ break;
+ }
+ return type;
+ }
+
sp<ITuner> mService;
FrontendTests mFrontendTests;
DemuxTests mDemuxTests;
diff --git a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h
index bdf94dc..65f8615 100644
--- a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h
+++ b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h
@@ -23,82 +23,23 @@
#include "../../../config/TunerTestingConfigReader.h"
-// TODO: remove unnecessary imports after config reader refactoring is done.
-using android::hardware::tv::tuner::V1_0::DataFormat;
-using android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
-using android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
using android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using android::hardware::tv::tuner::V1_0::DemuxIpFilterType;
-using android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using android::hardware::tv::tuner::V1_0::DemuxRecordScIndexType;
-using android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
-using android::hardware::tv::tuner::V1_0::DemuxTpid;
using android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using android::hardware::tv::tuner::V1_0::DvrSettings;
-using android::hardware::tv::tuner::V1_0::DvrType;
using android::hardware::tv::tuner::V1_0::FrontendDvbtBandwidth;
-using android::hardware::tv::tuner::V1_0::FrontendDvbtCoderate;
-using android::hardware::tv::tuner::V1_0::FrontendDvbtConstellation;
-using android::hardware::tv::tuner::V1_0::FrontendDvbtGuardInterval;
-using android::hardware::tv::tuner::V1_0::FrontendDvbtHierarchy;
using android::hardware::tv::tuner::V1_0::FrontendDvbtSettings;
-using android::hardware::tv::tuner::V1_0::FrontendDvbtStandard;
using android::hardware::tv::tuner::V1_0::FrontendDvbtTransmissionMode;
using android::hardware::tv::tuner::V1_0::FrontendSettings;
using android::hardware::tv::tuner::V1_0::FrontendStatus;
using android::hardware::tv::tuner::V1_0::FrontendStatusType;
using android::hardware::tv::tuner::V1_0::FrontendType;
-using android::hardware::tv::tuner::V1_0::LnbPosition;
-using android::hardware::tv::tuner::V1_0::LnbTone;
-using android::hardware::tv::tuner::V1_0::LnbVoltage;
-using android::hardware::tv::tuner::V1_0::PlaybackSettings;
-using android::hardware::tv::tuner::V1_0::RecordSettings;
using namespace std;
using namespace android::media::tuner::testing::configuration::V1_0;
-// TODO: remove all the constants and structs after config reader refactoring is done.
-const uint32_t FMQ_SIZE_512K = 0x80000;
-const uint32_t FMQ_SIZE_1M = 0x100000;
const uint32_t FMQ_SIZE_4M = 0x400000;
const uint32_t FMQ_SIZE_16M = 0x1000000;
-#define CLEAR_KEY_SYSTEM_ID 0xF6D8
-#define FILTER_MAIN_TYPE_BIT_COUNT 32
-#define PROVISION_STR \
- "{ " \
- " \"id\": 21140844, " \
- " \"name\": \"Test Title\", " \
- " \"lowercase_organization_name\": \"Android\", " \
- " \"asset_key\": { " \
- " \"encryption_key\": \"nezAr3CHFrmBR9R8Tedotw==\" " \
- " }, " \
- " \"cas_type\": 1, " \
- " \"track_types\": [ ] " \
- "} "
-
-typedef enum {
- SOURCE,
- SINK,
- LINKAGE_DIR,
-} Linkage;
-
-typedef enum {
- DESC_0,
- DESC_MAX,
-} Descrambler;
-
-struct DescramblerConfig {
- uint32_t casSystemId;
- string provisionStr;
- vector<uint8_t> hidlPvtData;
-};
-
-// TODO: remove all the manual config array after the dynamic config refactoring is done.
-static DemuxFilterType filterLinkageTypes[LINKAGE_DIR][FILTER_MAIN_TYPE_BIT_COUNT];
-static DescramblerConfig descramblerArray[DESC_MAX];
+#define FILTER_MAIN_TYPE_BIT_COUNT 5
// Hardware configs
static map<string, FrontendConfig> frontendMap;
@@ -107,6 +48,7 @@
static map<string, LnbConfig> lnbMap;
static map<string, TimeFilterConfig> timeFilterMap;
static map<string, vector<uint8_t>> diseqcMsgMap;
+static map<string, DescramblerConfig> descramblerMap;
// Hardware and test cases connections
static LiveBroadcastHardwareConnections live;
@@ -187,6 +129,12 @@
TunerTestingConfigReader::readTimeFilterConfig1_0(timeFilterMap);
};
+/** Config all the descramblers that would be used in the tests */
+inline void initDescramblerConfig() {
+ // Read customized config
+ TunerTestingConfigReader::readDescramblerConfig1_0(descramblerMap);
+};
+
/** Read the vendor configurations of which hardware to use for each test cases/data flows */
inline void connectHardwaresToTestCases() {
TunerTestingConfigReader::connectLiveBroadcast(live);
@@ -265,6 +213,16 @@
return false;
}
+ bool descramblerIsValid =
+ descrambling.support
+ ? descramblerMap.find(descrambling.descramblerId) != descramblerMap.end()
+ : true;
+
+ if (!descramblerIsValid) {
+ ALOGW("[vts config] dynamic config descrambler connection is invalid.");
+ return false;
+ }
+
bool diseqcMsgIsValid = true;
if (lnbLive.support) {
for (auto msgName : lnbLive.diseqcMsgs) {
@@ -284,11 +242,3 @@
return true;
}
-
-// TODO: remove all the manual configs after the dynamic config refactoring is done.
-/** Configuration array for the descrambler test */
-inline void initDescramblerConfig() {
- descramblerArray[DESC_0].casSystemId = CLEAR_KEY_SYSTEM_ID;
- descramblerArray[DESC_0].provisionStr = PROVISION_STR;
- descramblerArray[DESC_0].hidlPvtData.resize(256);
-};
diff --git a/tv/tuner/config/TunerTestingConfigReader.h b/tv/tuner/config/TunerTestingConfigReader.h
index bc35ac4..90499c4 100644
--- a/tv/tuner/config/TunerTestingConfigReader.h
+++ b/tv/tuner/config/TunerTestingConfigReader.h
@@ -66,6 +66,18 @@
const string configFilePath = "/vendor/etc/tuner_vts_config.xml";
const string emptyHardwareId = "";
+#define PROVISION_STR \
+ "{ " \
+ " \"id\": 21140844, " \
+ " \"name\": \"Test Title\", " \
+ " \"lowercase_organization_name\": \"Android\", " \
+ " \"asset_key\": { " \
+ " \"encryption_key\": \"nezAr3CHFrmBR9R8Tedotw==\" " \
+ " }, " \
+ " \"cas_type\": 1, " \
+ " \"track_types\": [ ] " \
+ "} "
+
struct FrontendConfig {
bool isSoftwareFe;
FrontendType type;
@@ -101,6 +113,12 @@
uint64_t timeStamp;
};
+struct DescramblerConfig {
+ uint32_t casSystemId;
+ string provisionStr;
+ vector<uint8_t> hidlPvtData;
+};
+
struct LiveBroadcastHardwareConnections {
string frontendId;
string dvrSoftwareFeId;
@@ -139,8 +157,8 @@
string dvrSoftwareFeId;
string audioFilterId;
string videoFilterId;
- /* string descramblerId;
- list string of extra filters; */
+ string descramblerId;
+ /* list string of extra filters; */
};
struct LnbLiveHardwareConnections {
@@ -326,6 +344,31 @@
}
}
+ static void readDescramblerConfig1_0(map<string, DescramblerConfig>& descramblerMap) {
+ auto hardwareConfig = getHardwareConfig();
+ if (hardwareConfig.hasDescramblers()) {
+ auto descramblers = *hardwareConfig.getFirstDescramblers();
+ for (auto descramblerConfig : descramblers.getDescrambler()) {
+ string id = descramblerConfig.getId();
+ descramblerMap[id].casSystemId =
+ static_cast<uint32_t>(descramblerConfig.getCasSystemId());
+ if (descramblerConfig.hasProvisionStr()) {
+ descramblerMap[id].provisionStr = descramblerConfig.getProvisionStr();
+ } else {
+ descramblerMap[id].provisionStr = PROVISION_STR;
+ }
+ if (descramblerConfig.hasSesstionPrivatData()) {
+ auto privateData = descramblerConfig.getSesstionPrivatData();
+ int size = privateData.size();
+ descramblerMap[id].hidlPvtData.resize(size);
+ memcpy(descramblerMap[id].hidlPvtData.data(), privateData.data(), size);
+ } else {
+ descramblerMap[id].hidlPvtData.resize(256);
+ }
+ }
+ }
+ }
+
static void readDiseqcMessages(map<string, vector<uint8_t>>& diseqcMsgMap) {
auto hardwareConfig = getHardwareConfig();
if (hardwareConfig.hasDiseqcMessages()) {
@@ -420,6 +463,7 @@
}
auto descConfig = *dataFlow.getFirstDescrambling();
descrambling.frontendId = descConfig.getFrontendConnection();
+ descrambling.descramblerId = descConfig.getDescramblerConnection();
descrambling.audioFilterId = descConfig.getAudioFilterConnection();
descrambling.videoFilterId = descConfig.getVideoFilterConnection();
if (descConfig.hasDvrSoftwareFeConnection()) {
diff --git a/tv/tuner/config/api/current.txt b/tv/tuner/config/api/current.txt
index 78e958b..4255a60 100644
--- a/tv/tuner/config/api/current.txt
+++ b/tv/tuner/config/api/current.txt
@@ -46,10 +46,12 @@
public static class DataFlowConfiguration.Descrambling {
ctor public DataFlowConfiguration.Descrambling();
method @Nullable public String getAudioFilterConnection();
+ method @Nullable public String getDescramblerConnection();
method @Nullable public String getDvrSoftwareFeConnection();
method @Nullable public String getFrontendConnection();
method @Nullable public String getVideoFilterConnection();
method public void setAudioFilterConnection(@Nullable String);
+ method public void setDescramblerConnection(@Nullable String);
method public void setDvrSoftwareFeConnection(@Nullable String);
method public void setFrontendConnection(@Nullable String);
method public void setVideoFilterConnection(@Nullable String);
@@ -119,6 +121,18 @@
method public void setTimeFilterConnection(@Nullable String);
}
+ public class Descrambler {
+ ctor public Descrambler();
+ method @Nullable public java.math.BigInteger getCasSystemId();
+ method @Nullable public String getId();
+ method @Nullable public String getProvisionStr();
+ method @Nullable public java.util.List<java.lang.Short> getSesstionPrivatData();
+ method public void setCasSystemId(@Nullable java.math.BigInteger);
+ method public void setId(@Nullable String);
+ method public void setProvisionStr(@Nullable String);
+ method public void setSesstionPrivatData(@Nullable java.util.List<java.lang.Short>);
+ }
+
public class DiseqcMessage {
ctor public DiseqcMessage();
method @Nullable public java.util.List<java.lang.Short> getMsgBody();
@@ -269,12 +283,14 @@
public class HardwareConfiguration {
ctor public HardwareConfiguration();
+ method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Descramblers getDescramblers();
method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.DiseqcMessages getDiseqcMessages();
method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Dvrs getDvrs();
method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Filters getFilters();
method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Frontends getFrontends();
method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Lnbs getLnbs();
method @Nullable public android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.TimeFilters getTimeFilters();
+ method public void setDescramblers(@Nullable android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Descramblers);
method public void setDiseqcMessages(@Nullable android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.DiseqcMessages);
method public void setDvrs(@Nullable android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Dvrs);
method public void setFilters(@Nullable android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.Filters);
@@ -283,6 +299,11 @@
method public void setTimeFilters(@Nullable android.media.tuner.testing.configuration.V1_0.HardwareConfiguration.TimeFilters);
}
+ public static class HardwareConfiguration.Descramblers {
+ ctor public HardwareConfiguration.Descramblers();
+ method @Nullable public java.util.List<android.media.tuner.testing.configuration.V1_0.Descrambler> getDescrambler();
+ }
+
public static class HardwareConfiguration.DiseqcMessages {
ctor public HardwareConfiguration.DiseqcMessages();
method @Nullable public java.util.List<android.media.tuner.testing.configuration.V1_0.DiseqcMessage> getDiseqcMessage();
diff --git a/tv/tuner/config/sample_tuner_vts_config.xml b/tv/tuner/config/sample_tuner_vts_config.xml
index 6a3e814..570171e 100644
--- a/tv/tuner/config/sample_tuner_vts_config.xml
+++ b/tv/tuner/config/sample_tuner_vts_config.xml
@@ -168,6 +168,22 @@
<timeFilters>
<timeFilter id="TIME_FILTER_0" timeStamp="1"/>
</timeFilters>
+ <!-- Descrambler section:
+ This section contains configurations of all the descramblers that would be used in
+ the tests.
+ - This section is optional and can be skipped if Descrambler is not supported.
+ - The users can configure 1 or more descrambler elements in the descramblers sections.
+
+ Each Descrambler element contain the following attributes:
+ "id": unique id of the descrambler that could be used to connect to the test the
+ "dataFlowConfiguration"
+ "casSystemId": the cas system id to connect to the descrambler.
+ "provisionStr": the provision string to use with the cas plugin.
+ "sesstionPrivatData": the session private data used to open the cas session.
+ -->
+ <descramblers>
+ <descrambler id="DESCRAMBLER_0" casSystemId="63192"/>
+ </descramblers>
</hardwareConfiguration>
<!-- Data flow configuration section connects each data flow under test to the ids of the
@@ -181,6 +197,7 @@
dvrSoftwareFeConnection="DVR_PLAYBACK_0"/>
<scan frontendConnection="FE_DEFAULT"/>
<descrambling frontendConnection="FE_DEFAULT"
+ descramblerConnection="DESCRAMBLER_0"
audioFilterConnection="FILTER_AUDIO_DEFAULT"
videoFilterConnection="FILTER_VIDEO_DEFAULT"
dvrSoftwareFeConnection="DVR_PLAYBACK_0"/>
diff --git a/tv/tuner/config/tuner_testing_dynamic_configuration.xsd b/tv/tuner/config/tuner_testing_dynamic_configuration.xsd
index 7c99597..3fe93ff 100644
--- a/tv/tuner/config/tuner_testing_dynamic_configuration.xsd
+++ b/tv/tuner/config/tuner_testing_dynamic_configuration.xsd
@@ -372,6 +372,34 @@
<xs:attribute name="timeStamp" type="xs:nonNegativeInteger" use="required"/>
</xs:complexType>
+ <!-- DESCRAMBLER SESSION -->
+ <xs:simpleType name="descramblerId">
+ <!-- Descrambler id must be DESCRAMBLER_NUM: <descrambler id="DESCRAMBLER_2"/> -->
+ <xs:restriction base="xs:string">
+ <xs:pattern value="DESCRAMBLER_[0-9]+"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="sessionPrivateData">
+ <xs:list itemType="xs:unsignedByte"/>
+ </xs:simpleType>
+
+ <xs:complexType name="descrambler">
+ <xs:annotation>
+ <xs:documentation>
+ Each descrambler element contain the following attributes:
+ "id": unique id of the descrambler that could be used to connect to the test the
+ "dataFlowConfiguration"
+ "casSystemId": the cas system id to connect to the descrambler.
+ "provisionStr": the provision string to use with the cas plugin.
+ "sesstionPrivatData": the session private data used to open the cas session.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="id" type="descramblerId" use="required"/>
+ <xs:attribute name="casSystemId" type="xs:nonNegativeInteger" use="required"/>
+ <xs:attribute name="provisionStr" type="xs:string" use="required"/>
+ <xs:attribute name="sesstionPrivatData" type="sessionPrivateData" use="optional"/>
+ </xs:complexType>
+
<!-- HARDWARE CONFIGURATION SESSION -->
<xs:complexType name="hardwareConfiguration">
<xs:sequence>
@@ -483,6 +511,23 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:element name="descramblers" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ This section contains configurations of all the descramblers that would
+ be used in the tests.
+ - This section is optional and can be skipped if descrambling is not
+ supported.
+ - The users can configure 1 or more descrambler elements in the
+ descramblers sections.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="descrambler" type="descrambler" minOccurs="1" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
</xs:sequence>
</xs:complexType>
@@ -509,6 +554,7 @@
<xs:element name="descrambling" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="frontendConnection" type="frontendId" use="required"/>
+ <xs:attribute name="descramblerConnection" type="descramblerId" use="required"/>
<xs:attribute name="audioFilterConnection" type="filterId" use="required"/>
<xs:attribute name="videoFilterConnection" type="filterId" use="required"/>
<!-- TODO: b/182519645 allow the users to insert extra filters -->
@@ -590,5 +636,9 @@
<xs:selector xpath="hardwareConfiguration/timeFilters/timeFilter"/>
<xs:field xpath="@id"/>
</xs:key>
+ <xs:key name="descramblerIdUniqueness">
+ <xs:selector xpath="hardwareConfiguration/descramblers/descrambler"/>
+ <xs:field xpath="@id"/>
+ </xs:key>
</xs:element>
</xs:schema>