Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea05b4b8 authored by Amy Zhang's avatar Amy Zhang
Browse files

Allow filter configurations to have NULL filterSettings

In Tuner java, we mark Settings in all the FilterConfiguration
as nullable. It could even be set null for the filter subtypes
that could have filter settings, for example, the clients could
config TS AV filter with a null settings or a non-null AvSettings.

In tuner JNI, we read settings by default, which could cause crash

Changing the implementation to allow the filter configurations to
have null settings

Test: atest android.media.tv.tuner.cts
Bug: 181152149
Change-Id: I7c1d8721aae6da8e557138537e65966628584a9a
parent 075cee61
Loading
Loading
Loading
Loading
+82 −89
Original line number Diff line number Diff line
@@ -3571,6 +3571,7 @@ static DemuxFilterSettings getFilterConfiguration(
                .tpid = tpid,
            };

            if (settingsObj != NULL) {
                DemuxTsFilterType tsType = static_cast<DemuxTsFilterType>(subtype);
                switch (tsType) {
                    case DemuxTsFilterType::SECTION:
@@ -3592,6 +3593,7 @@ static DemuxFilterSettings getFilterConfiguration(
                    default:
                        break;
                }
            }
            filterSettings.ts(tsFilterSettings);
            break;
        }
@@ -3602,6 +3604,8 @@ static DemuxFilterSettings getFilterConfiguration(
            DemuxMmtpFilterSettings mmtpFilterSettings {
                .mmtpPid = mmtpPid,
            };

            if (settingsObj != NULL) {
                DemuxMmtpFilterType mmtpType = static_cast<DemuxMmtpFilterType>(subtype);
                switch (mmtpType) {
                    case DemuxMmtpFilterType::SECTION:
@@ -3627,23 +3631,21 @@ static DemuxFilterSettings getFilterConfiguration(
                    default:
                        break;
                }
            }
            filterSettings.mmtp(mmtpFilterSettings);
            break;
        }
        case DemuxFilterMainType::IP: {
            DemuxIpAddress ipAddr = getDemuxIpAddress(env, filterConfigObj);

            DemuxIpFilterSettings ipFilterSettings {
                .ipAddr = ipAddr,
            };

            DemuxIpFilterType ipType = static_cast<DemuxIpFilterType>(subtype);
            switch (ipType) {
                case DemuxIpFilterType::SECTION: {
            if (ipType == DemuxIpFilterType::SECTION && settingsObj != NULL) {
                ipFilterSettings.filterSettings.section(
                                getFilterSectionSettings(env, settingsObj));
                    break;
                }
                case DemuxIpFilterType::IP: {
            } else if (ipType == DemuxIpFilterType::IP) {
                jclass clazz = env->FindClass(
                        "android/media/tv/tuner/filter/IpFilterConfiguration");
                bool bPassthrough = static_cast<bool>(
@@ -3651,11 +3653,6 @@ static DemuxFilterSettings getFilterConfiguration(
                                filterConfigObj, env->GetFieldID(
                                        clazz, "mPassthrough", "Z")));
                ipFilterSettings.filterSettings.bPassthrough(bPassthrough);
                    break;
                }
                default: {
                    break;
                }
            }
            filterSettings.ip(ipFilterSettings);
            break;
@@ -3672,24 +3669,17 @@ static DemuxFilterSettings getFilterConfiguration(
                .packetType = packetType,
                .isCompressedIpPacket = isCompressedIpPacket,
            };

            DemuxTlvFilterType tlvType = static_cast<DemuxTlvFilterType>(subtype);
            switch (tlvType) {
                case DemuxTlvFilterType::SECTION: {
            if (tlvType == DemuxTlvFilterType::SECTION && settingsObj != NULL) {
                tlvFilterSettings.filterSettings.section(
                        getFilterSectionSettings(env, settingsObj));
                    break;
                }
                case DemuxTlvFilterType::TLV: {
            } else if (tlvType == DemuxTlvFilterType::TLV) {
                bool bPassthrough = static_cast<bool>(
                env->GetBooleanField(
                        filterConfigObj, env->GetFieldID(
                                clazz, "mPassthrough", "Z")));
                tlvFilterSettings.filterSettings.bPassthrough(bPassthrough);
                    break;
                }
                default: {
                    break;
                }
            }
            filterSettings.tlv(tlvFilterSettings);
            break;
@@ -3704,6 +3694,8 @@ static DemuxFilterSettings getFilterConfiguration(
                .packetType = packetType,
                .lengthType = lengthType,
            };

            if (settingsObj != NULL) {
                DemuxAlpFilterType alpType = static_cast<DemuxAlpFilterType>(subtype);
                switch (alpType) {
                    case DemuxAlpFilterType::SECTION:
@@ -3713,6 +3705,7 @@ static DemuxFilterSettings getFilterConfiguration(
                    default:
                        break;
                }
            }
            filterSettings.alp(alpFilterSettings);
            break;
        }