Merge "CCodec: support audio encoders requesting frame size" into sc-dev
diff --git a/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp b/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp
index 1495703..d278633 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp
@@ -119,7 +119,11 @@
         return Void();
     }
 
-    if (source.offset + offset + source.size > sourceBase->getSize()) {
+    size_t totalSize = 0;
+    if (__builtin_add_overflow(source.offset, offset, &totalSize) ||
+        __builtin_add_overflow(totalSize, source.size, &totalSize) ||
+        totalSize > sourceBase->getSize()) {
+        android_errorWriteLog(0x534e4554, "176496160");
         _hidl_cb(Status_V1_2::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size");
         return Void();
     }
diff --git a/media/extractors/mp3/MP3Extractor.cpp b/media/extractors/mp3/MP3Extractor.cpp
index 5165822..5bbabdf 100644
--- a/media/extractors/mp3/MP3Extractor.cpp
+++ b/media/extractors/mp3/MP3Extractor.cpp
@@ -425,8 +425,7 @@
     if (mInitCheck != OK || index != 0) {
         return AMEDIA_ERROR_UNKNOWN;
     }
-    AMediaFormat_copy(meta, mMeta);
-    return AMEDIA_OK;
+    return AMediaFormat_copy(meta, mMeta);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/media/extractors/mp4/MPEG4Extractor.cpp b/media/extractors/mp4/MPEG4Extractor.cpp
index 221bf4f..314a822 100644
--- a/media/extractors/mp4/MPEG4Extractor.cpp
+++ b/media/extractors/mp4/MPEG4Extractor.cpp
@@ -640,8 +640,7 @@
         }
     }
 
-    AMediaFormat_copy(meta, track->meta);
-    return AMEDIA_OK;
+    return AMediaFormat_copy(meta, track->meta);
 }
 
 status_t MPEG4Extractor::readMetaData() {
diff --git a/media/extractors/mpeg2/MPEG2TSExtractor.cpp b/media/extractors/mpeg2/MPEG2TSExtractor.cpp
index 9e093eb..2e68809 100644
--- a/media/extractors/mpeg2/MPEG2TSExtractor.cpp
+++ b/media/extractors/mpeg2/MPEG2TSExtractor.cpp
@@ -268,6 +268,9 @@
 media_status_t MPEG2TSExtractor::getTrackMetaData(
         AMediaFormat *meta,
         size_t index, uint32_t /* flags */) {
+    if (meta == nullptr) {
+        return AMEDIA_ERROR_INVALID_PARAMETER;
+    }
     sp<MetaData> implMeta = index < mSourceImpls.size()
         ? mSourceImpls.editItemAt(index)->getFormat() : NULL;
     if (implMeta == NULL) {
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index adf8562..464e67f 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -237,6 +237,10 @@
     VendorTagDescriptor::clearGlobalVendorTagDescriptor();
     mUidPolicy->unregisterSelf();
     mSensorPrivacyPolicy->unregisterSelf();
+
+    for (auto const& [_, policy] : mCameraSensorPrivacyPolicies) {
+        policy->unregisterSelf();
+    }
 }
 
 void CameraService::onNewProviderRegistered() {
@@ -1688,7 +1692,8 @@
 
         // Set camera muting behavior
         if (client->supportsCameraMute()) {
-            client->setCameraMute(mOverrideCameraMuteMode);
+            client->setCameraMute(mOverrideCameraMuteMode ||
+                    isUserSensorPrivacyEnabledForUid(clientUid));
         }
 
         if (shimUpdateOnly) {
@@ -3217,6 +3222,39 @@
     }
 }
 
+status_t CameraService::SensorPrivacyPolicy::registerSelfForIndividual(int userId) {
+    Mutex::Autolock _l(mSensorPrivacyLock);
+    if (mRegistered) {
+        return OK;
+    }
+
+    status_t res = mSpm.addIndividualSensorPrivacyListener(userId,
+            SensorPrivacyManager::INDIVIDUAL_SENSOR_CAMERA, this);
+    if (res != OK) {
+        ALOGE("Unable to register camera privacy listener: %s (%d)", strerror(-res), res);
+        return res;
+    }
+
+    res = mSpm.isIndividualSensorPrivacyEnabled(userId,
+        SensorPrivacyManager::INDIVIDUAL_SENSOR_CAMERA, mSensorPrivacyEnabled);
+    if (res != OK) {
+        ALOGE("Unable to check camera privacy: %s (%d)", strerror(-res), res);
+        return res;
+    }
+
+    res = mSpm.linkToDeath(this);
+    if (res != OK) {
+        ALOGE("Register link to death failed for sensor privacy: %s (%d)", strerror(-res), res);
+        return res;
+    }
+
+    mRegistered = true;
+    isIndividual = true;
+    this->userId = userId;
+    ALOGV("SensorPrivacyPolicy: Registered with SensorPrivacyManager");
+    return OK;
+}
+
 void CameraService::SensorPrivacyPolicy::unregisterSelf() {
     Mutex::Autolock _l(mSensorPrivacyLock);
     mSpm.removeSensorPrivacyListener(this);
@@ -3236,10 +3274,14 @@
         mSensorPrivacyEnabled = enabled;
     }
     // if sensor privacy is enabled then block all clients from accessing the camera
-    if (enabled) {
-        sp<CameraService> service = mService.promote();
-        if (service != nullptr) {
-            service->blockAllClients();
+    sp<CameraService> service = mService.promote();
+    if (service != nullptr) {
+        if (isIndividual) {
+            service->setMuteForAllClients(userId, enabled);
+        } else {
+            if (enabled) {
+                service->blockAllClients();
+            }
         }
     }
     return binder::Status::ok();
@@ -3870,6 +3912,19 @@
     }
 }
 
+void CameraService::setMuteForAllClients(userid_t userId, bool enabled) {
+    const auto clients = mActiveClientManager.getAll();
+    for (auto& current : clients) {
+        if (current != nullptr) {
+            const auto basicClient = current->getValue();
+            if (basicClient.get() != nullptr
+                    && multiuser_get_user_id(basicClient->getClientUid()) == userId) {
+                basicClient->setCameraMute(enabled);
+            }
+        }
+    }
+}
+
 // NOTE: This is a remote API - make sure all args are validated
 status_t CameraService::shellCommand(int in, int out, int err, const Vector<String16>& args) {
     if (!checkCallingPermission(sManageCameraPermission, nullptr, nullptr)) {
@@ -4076,4 +4131,16 @@
     return mode;
 }
 
+bool CameraService::isUserSensorPrivacyEnabledForUid(uid_t uid) {
+    userid_t userId = multiuser_get_user_id(uid);
+    if (mCameraSensorPrivacyPolicies.find(userId) == mCameraSensorPrivacyPolicies.end()) {
+        sp<SensorPrivacyPolicy> userPolicy = new SensorPrivacyPolicy(this);
+        if (userPolicy->registerSelfForIndividual(userId) != OK) {
+            return false;
+        }
+        mCameraSensorPrivacyPolicies[userId] = userPolicy;
+    }
+    return mCameraSensorPrivacyPolicies[userId]->isSensorPrivacyEnabled();
+}
+
 }; // namespace android
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index bc6ad35..f455cbb 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -640,6 +640,7 @@
                     : mService(service), mSensorPrivacyEnabled(false), mRegistered(false) {}
 
             void registerSelf();
+            status_t registerSelfForIndividual(int userId);
             void unregisterSelf();
 
             bool isSensorPrivacyEnabled();
@@ -655,6 +656,8 @@
             Mutex mSensorPrivacyLock;
             bool mSensorPrivacyEnabled;
             bool mRegistered;
+            bool isIndividual;
+            userid_t userId;
     };
 
     sp<UidPolicy> mUidPolicy;
@@ -1029,6 +1032,9 @@
     // Blocks all active clients.
     void blockAllClients();
 
+    // Mutes all active clients for a user.
+    void setMuteForAllClients(userid_t userId, bool enabled);
+
     // Overrides the UID state as if it is idle
     status_t handleSetUidState(const Vector<String16>& args, int err);
 
@@ -1100,6 +1106,12 @@
 
     // Current camera mute mode
     bool mOverrideCameraMuteMode = false;
+
+    // Map from user to sensor privacy policy
+    std::map<userid_t, sp<SensorPrivacyPolicy>> mCameraSensorPrivacyPolicies;
+
+    // Checks if the sensor privacy is enabled for the uid
+    bool isUserSensorPrivacyEnabledForUid(uid_t uid);
 };
 
 } // namespace android
diff --git a/services/tuner/TunerFilter.cpp b/services/tuner/TunerFilter.cpp
index 456a2c1..b712348 100644
--- a/services/tuner/TunerFilter.cpp
+++ b/services/tuner/TunerFilter.cpp
@@ -18,17 +18,24 @@
 
 #include "TunerFilter.h"
 
+using ::aidl::android::media::tv::tuner::TunerFilterSectionCondition;
+
 using ::android::hardware::hidl_handle;
+using ::android::hardware::tv::tuner::V1_0::DemuxAlpLengthType;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
+using ::android::hardware::tv::tuner::V1_0::DemuxIpAddress;
 using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
+using ::android::hardware::tv::tuner::V1_0::DemuxMmtpPid;
+using ::android::hardware::tv::tuner::V1_0::DemuxRecordScIndexType;
+using ::android::hardware::tv::tuner::V1_0::DemuxStreamId;
 using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
 using ::android::hardware::tv::tuner::V1_0::Result;
 using ::android::hardware::tv::tuner::V1_1::Constant;
 
 namespace android {
 
+using namespace std;
+
 TunerFilter::TunerFilter(
         sp<IFilter> filter, sp<IFilterCallback> callback) {
     mFilter = filter;
@@ -42,13 +49,6 @@
     mFilterCallback = nullptr;
 }
 
-DemuxFilterAvSettings TunerFilter::getAvSettings(const TunerFilterSettings& settings) {
-    DemuxFilterAvSettings av {
-        .isPassthrough = settings.get<TunerFilterSettings::av>().isPassthrough,
-    };
-    return av;
-}
-
 Status TunerFilter::getId(int32_t* _aidl_return) {
     if (mFilter == nullptr) {
         ALOGE("IFilter is not initialized");
@@ -91,34 +91,293 @@
         return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
     }
 
-    // TODO: more filter types.
-    TunerFilterSettings tunerSettings;
-    DemuxFilterSettings halSettings;
+    DemuxFilterSettings settings;
     switch (config.getTag()) {
         case TunerFilterConfiguration::ts: {
-            uint16_t tpid = static_cast<uint16_t>(config.get<TunerFilterConfiguration::ts>().tpid);
-            tunerSettings = config.get<TunerFilterConfiguration::ts>().filterSettings;
-            DemuxTsFilterSettings ts {
-                .tpid = tpid,
-            };
-
-            switch (tunerSettings.getTag()) {
-                case TunerFilterSettings::av: {
-                    ts.filterSettings.av(getAvSettings(tunerSettings));
-                    break;
-                }
-            }
-            halSettings.ts(ts);
+            getHidlTsSettings(config, settings);
+            break;
+        }
+        case TunerFilterConfiguration::mmtp: {
+            getHidlMmtpSettings(config, settings);
+            break;
+        }
+        case TunerFilterConfiguration::ip: {
+            getHidlIpSettings(config, settings);
+            break;
+        }
+        case TunerFilterConfiguration::tlv: {
+            getHidlTlvSettings(config, settings);
+            break;
+        }
+        case TunerFilterConfiguration::alp: {
+            getHidlAlpSettings(config, settings);
             break;
         }
     }
-    Result res = mFilter->configure(halSettings);
+
+    Result res = mFilter->configure(settings);
     if (res != Result::SUCCESS) {
         return Status::fromServiceSpecificError(static_cast<int32_t>(res));
     }
     return Status::ok();
 }
 
+void TunerFilter::getHidlTsSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
+    auto tsConf = config.get<TunerFilterConfiguration::ts>();
+    DemuxTsFilterSettings ts{
+        .tpid = static_cast<uint16_t>(tsConf.tpid),
+    };
+
+    TunerFilterSettings tunerSettings = tsConf.filterSettings;
+    switch (tunerSettings.getTag()) {
+        case TunerFilterSettings::av: {
+            ts.filterSettings.av(getAvSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::section: {
+            ts.filterSettings.section(getSectionSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::pesData: {
+            ts.filterSettings.pesData(getPesDataSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::record: {
+            ts.filterSettings.record(getRecordSettings(tunerSettings));
+            break;
+        }
+        default: {
+            ts.filterSettings.noinit();
+            break;
+        }
+    }
+    settings.ts(ts);
+}
+
+void TunerFilter::getHidlMmtpSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
+    auto mmtpConf = config.get<TunerFilterConfiguration::mmtp>();
+    DemuxMmtpFilterSettings mmtp{
+        .mmtpPid = static_cast<DemuxMmtpPid>(mmtpConf.mmtpPid),
+    };
+
+    TunerFilterSettings tunerSettings = mmtpConf.filterSettings;
+    switch (tunerSettings.getTag()) {
+        case TunerFilterSettings::av: {
+            mmtp.filterSettings.av(getAvSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::section: {
+            mmtp.filterSettings.section(getSectionSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::pesData: {
+            mmtp.filterSettings.pesData(getPesDataSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::record: {
+            mmtp.filterSettings.record(getRecordSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::download: {
+            mmtp.filterSettings.download(getDownloadSettings(tunerSettings));
+            break;
+        }
+        default: {
+            mmtp.filterSettings.noinit();
+            break;
+        }
+    }
+    settings.mmtp(mmtp);
+}
+
+void TunerFilter::getHidlIpSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
+    auto ipConf = config.get<TunerFilterConfiguration::ip>();
+    DemuxIpAddress ipAddr{
+        .srcPort = static_cast<uint16_t>(ipConf.ipAddr.srcPort),
+        .dstPort = static_cast<uint16_t>(ipConf.ipAddr.dstPort),
+    };
+    ipConf.ipAddr.srcIpAddress.isIpV6
+            ? ipAddr.srcIpAddress.v6(getIpV6Address(ipConf.ipAddr.srcIpAddress))
+            : ipAddr.srcIpAddress.v4(getIpV4Address(ipConf.ipAddr.srcIpAddress));
+    ipConf.ipAddr.dstIpAddress.isIpV6
+            ? ipAddr.dstIpAddress.v6(getIpV6Address(ipConf.ipAddr.dstIpAddress))
+            : ipAddr.dstIpAddress.v4(getIpV4Address(ipConf.ipAddr.dstIpAddress));
+    DemuxIpFilterSettings ip{
+        .ipAddr = ipAddr,
+    };
+
+    TunerFilterSettings tunerSettings = ipConf.filterSettings;
+    switch (tunerSettings.getTag()) {
+        case TunerFilterSettings::section: {
+            ip.filterSettings.section(getSectionSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::isPassthrough: {
+            ip.filterSettings.bPassthrough(tunerSettings.isPassthrough);
+            break;
+        }
+        default: {
+            ip.filterSettings.noinit();
+            break;
+        }
+    }
+    settings.ip(ip);
+}
+
+hidl_array<uint8_t, IP_V6_LENGTH> TunerFilter::getIpV6Address(TunerDemuxIpAddress addr) {
+    hidl_array<uint8_t, IP_V6_LENGTH> ip = {0};
+    if (addr.addr.size() != IP_V6_LENGTH) {
+        return ip;
+    }
+    copy(addr.addr.begin(), addr.addr.end(), ip.data());
+    return ip;
+}
+
+hidl_array<uint8_t, IP_V4_LENGTH> TunerFilter::getIpV4Address(TunerDemuxIpAddress addr) {
+    hidl_array<uint8_t, IP_V4_LENGTH> ip = {0};
+    if (addr.addr.size() != IP_V4_LENGTH) {
+        return ip;
+    }
+    copy(addr.addr.begin(), addr.addr.end(), ip.data());
+    return ip;
+}
+
+void TunerFilter::getHidlTlvSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
+    auto tlvConf = config.get<TunerFilterConfiguration::tlv>();
+    DemuxTlvFilterSettings tlv{
+        .packetType = static_cast<uint8_t>(tlvConf.packetType),
+        .isCompressedIpPacket = tlvConf.isCompressedIpPacket,
+    };
+
+    TunerFilterSettings tunerSettings = tlvConf.filterSettings;
+    switch (tunerSettings.getTag()) {
+        case TunerFilterSettings::section: {
+            tlv.filterSettings.section(getSectionSettings(tunerSettings));
+            break;
+        }
+        case TunerFilterSettings::isPassthrough: {
+            tlv.filterSettings.bPassthrough(tunerSettings.isPassthrough);
+            break;
+        }
+        default: {
+            tlv.filterSettings.noinit();
+            break;
+        }
+    }
+    settings.tlv(tlv);
+}
+
+void TunerFilter::getHidlAlpSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
+    auto alpConf = config.get<TunerFilterConfiguration::alp>();
+    DemuxAlpFilterSettings alp{
+        .packetType = static_cast<uint8_t>(alpConf.packetType),
+        .lengthType = static_cast<DemuxAlpLengthType>(alpConf.lengthType),
+    };
+
+    TunerFilterSettings tunerSettings = alpConf.filterSettings;
+    switch (tunerSettings.getTag()) {
+        case TunerFilterSettings::section: {
+            alp.filterSettings.section(getSectionSettings(tunerSettings));
+            break;
+        }
+        default: {
+            alp.filterSettings.noinit();
+            break;
+        }
+    }
+    settings.alp(alp);
+}
+
+DemuxFilterAvSettings TunerFilter::getAvSettings(const TunerFilterSettings& settings) {
+    DemuxFilterAvSettings av {
+        .isPassthrough = settings.get<TunerFilterSettings::av>().isPassthrough,
+    };
+    return av;
+}
+
+DemuxFilterSectionSettings TunerFilter::getSectionSettings(const TunerFilterSettings& settings) {
+    auto s = settings.get<TunerFilterSettings::section>();
+    DemuxFilterSectionSettings section{
+        .isCheckCrc = s.isCheckCrc,
+        .isRepeat = s.isRepeat,
+        .isRaw = s.isRaw,
+    };
+
+    switch (s.condition.getTag()) {
+        case TunerFilterSectionCondition::sectionBits: {
+            auto sectionBits = s.condition.get<TunerFilterSectionCondition::sectionBits>();
+            vector<uint8_t> filter(sectionBits.filter.size());
+            vector<uint8_t> mask(sectionBits.mask.size());
+            vector<uint8_t> mode(sectionBits.mode.size());
+            copy(sectionBits.filter.begin(), sectionBits.filter.end(), filter.begin());
+            copy(sectionBits.mask.begin(), sectionBits.mask.end(), mask.begin());
+            copy(sectionBits.mode.begin(), sectionBits.mode.end(), mode.begin());
+            section.condition.sectionBits({
+                .filter = filter,
+                .mask = mask,
+                .mode = mode,
+            });
+            break;
+        }
+        case TunerFilterSectionCondition::tableInfo: {
+            auto tableInfo = s.condition.get<TunerFilterSectionCondition::tableInfo>();
+            section.condition.tableInfo({
+                .tableId = static_cast<uint16_t>(tableInfo.tableId),
+                .version = static_cast<uint16_t>(tableInfo.version),
+            });
+            break;
+        }
+        default: {
+            break;
+        }
+    }
+    return section;
+}
+
+DemuxFilterPesDataSettings TunerFilter::getPesDataSettings(const TunerFilterSettings& settings) {
+    DemuxFilterPesDataSettings pes{
+        .streamId = static_cast<DemuxStreamId>(
+                settings.get<TunerFilterSettings::pesData>().streamId),
+        .isRaw = settings.get<TunerFilterSettings::pesData>().isRaw,
+    };
+    return pes;
+}
+
+DemuxFilterRecordSettings TunerFilter::getRecordSettings(const TunerFilterSettings& settings) {
+    auto r = settings.get<TunerFilterSettings::record>();
+    DemuxFilterRecordSettings record{
+        .tsIndexMask = static_cast<uint32_t>(r.tsIndexMask),
+        .scIndexType = static_cast<DemuxRecordScIndexType>(r.scIndexType),
+    };
+
+    switch (r.scIndexMask.getTag()) {
+        case TunerFilterScIndexMask::sc: {
+            record.scIndexMask.sc(static_cast<uint32_t>(
+                    r.scIndexMask.get<TunerFilterScIndexMask::sc>()));
+            break;
+        }
+        case TunerFilterScIndexMask::scHevc: {
+            record.scIndexMask.scHevc(static_cast<uint32_t>(
+                    r.scIndexMask.get<TunerFilterScIndexMask::scHevc>()));
+            break;
+        }
+    }
+    return record;
+}
+
+DemuxFilterDownloadSettings TunerFilter::getDownloadSettings(const TunerFilterSettings& settings) {
+    DemuxFilterDownloadSettings download {
+        .downloadId = static_cast<uint32_t>(
+                settings.get<TunerFilterSettings::download>().downloadId),
+    };
+    return download;
+}
+
 Status TunerFilter::getAvSharedHandleInfo(TunerFilterSharedHandleInfo* _aidl_return) {
     if (mFilter_1_1 == nullptr) {
         ALOGE("IFilter_1_1 is not initialized");
@@ -133,7 +392,7 @@
                 .handle = dupToAidl(hidl_handle(avMemory.getNativeHandle())),
                 .size = static_cast<int64_t>(avMemSize),
             };
-            *_aidl_return = std::move(info);
+            *_aidl_return = move(info);
         } else {
             _aidl_return = NULL;
         }
@@ -219,7 +478,7 @@
 }
 
 Return<void> TunerFilter::FilterCallback::onFilterEvent(const DemuxFilterEvent& filterEvent) {
-    std::vector<DemuxFilterEventExt::Event> emptyEventsExt;
+    vector<DemuxFilterEventExt::Event> emptyEventsExt;
     DemuxFilterEventExt emptyFilterEventExt {
             .events = emptyEventsExt,
     };
@@ -230,9 +489,9 @@
 Return<void> TunerFilter::FilterCallback::onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
         const DemuxFilterEventExt& filterEventExt) {
     if (mTunerFilterCallback != NULL) {
-        std::vector<DemuxFilterEvent::Event> events = filterEvent.events;
-        std::vector<DemuxFilterEventExt::Event> eventsExt = filterEventExt.events;
-        std::vector<TunerFilterEvent> tunerEvent;
+        vector<DemuxFilterEvent::Event> events = filterEvent.events;
+        vector<DemuxFilterEventExt::Event> eventsExt = filterEventExt.events;
+        vector<TunerFilterEvent> tunerEvent;
 
         getAidlFilterEvent(events, eventsExt, tunerEvent);
         mTunerFilterCallback->onFilterEvent(tunerEvent);
@@ -242,9 +501,9 @@
 
 /////////////// FilterCallback Helper Methods ///////////////////////
 
-void TunerFilter::FilterCallback::getAidlFilterEvent(std::vector<DemuxFilterEvent::Event>& events,
-        std::vector<DemuxFilterEventExt::Event>& eventsExt,
-        std::vector<TunerFilterEvent>& tunerEvent) {
+void TunerFilter::FilterCallback::getAidlFilterEvent(vector<DemuxFilterEvent::Event>& events,
+        vector<DemuxFilterEventExt::Event>& eventsExt,
+        vector<TunerFilterEvent>& tunerEvent) {
     if (events.empty() && !eventsExt.empty()) {
         auto eventExt = eventsExt[0];
         switch (eventExt.getDiscriminator()) {
@@ -305,7 +564,7 @@
 }
 
 void TunerFilter::FilterCallback::getMediaEvent(
-        std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
     for (DemuxFilterEvent::Event e : events) {
         DemuxFilterMediaEvent mediaEvent = e.media();
         TunerFilterMediaEvent tunerMedia;
@@ -346,13 +605,13 @@
         }
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::media>(std::move(tunerMedia));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::media>(move(tunerMedia));
+        res.push_back(move(tunerEvent));
     }
 }
 
 void TunerFilter::FilterCallback::getSectionEvent(
-        std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
     for (DemuxFilterEvent::Event e : events) {
         DemuxFilterSectionEvent sectionEvent = e.section();
         TunerFilterSectionEvent tunerSection;
@@ -363,13 +622,13 @@
         tunerSection.dataLength = static_cast<char>(sectionEvent.dataLength);
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::section>(std::move(tunerSection));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::section>(move(tunerSection));
+        res.push_back(move(tunerEvent));
     }
 }
 
 void TunerFilter::FilterCallback::getPesEvent(
-        std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
     for (DemuxFilterEvent::Event e : events) {
         DemuxFilterPesEvent pesEvent = e.pes();
         TunerFilterPesEvent tunerPes;
@@ -379,13 +638,13 @@
         tunerPes.mpuSequenceNumber = static_cast<int>(pesEvent.mpuSequenceNumber);
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::pes>(std::move(tunerPes));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::pes>(move(tunerPes));
+        res.push_back(move(tunerEvent));
     }
 }
 
-void TunerFilter::FilterCallback::getTsRecordEvent(std::vector<DemuxFilterEvent::Event>& events,
-        std::vector<DemuxFilterEventExt::Event>& eventsExt, std::vector<TunerFilterEvent>& res) {
+void TunerFilter::FilterCallback::getTsRecordEvent(vector<DemuxFilterEvent::Event>& events,
+        vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
     for (int i = 0; i < events.size(); i++) {
         TunerFilterTsRecordEvent tunerTsRecord;
         DemuxFilterTsRecordEvent tsRecordEvent = events[i].tsRecord();
@@ -421,13 +680,13 @@
         }
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::tsRecord>(std::move(tunerTsRecord));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::tsRecord>(move(tunerTsRecord));
+        res.push_back(move(tunerEvent));
     }
 }
 
-void TunerFilter::FilterCallback::getMmtpRecordEvent(std::vector<DemuxFilterEvent::Event>& events,
-        std::vector<DemuxFilterEventExt::Event>& eventsExt, std::vector<TunerFilterEvent>& res) {
+void TunerFilter::FilterCallback::getMmtpRecordEvent(vector<DemuxFilterEvent::Event>& events,
+        vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
     for (int i = 0; i < events.size(); i++) {
         TunerFilterMmtpRecordEvent tunerMmtpRecord;
         DemuxFilterMmtpRecordEvent mmtpRecordEvent = events[i].mmtpRecord();
@@ -449,13 +708,13 @@
         }
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::mmtpRecord>(std::move(tunerMmtpRecord));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::mmtpRecord>(move(tunerMmtpRecord));
+        res.push_back(move(tunerEvent));
     }
 }
 
 void TunerFilter::FilterCallback::getDownloadEvent(
-        std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
     for (DemuxFilterEvent::Event e : events) {
         DemuxFilterDownloadEvent downloadEvent = e.download();
         TunerFilterDownloadEvent tunerDownload;
@@ -467,13 +726,13 @@
         tunerDownload.dataLength = static_cast<char>(downloadEvent.dataLength);
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::download>(std::move(tunerDownload));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::download>(move(tunerDownload));
+        res.push_back(move(tunerEvent));
     }
 }
 
 void TunerFilter::FilterCallback::getIpPayloadEvent(
-        std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
     for (DemuxFilterEvent::Event e : events) {
         DemuxFilterIpPayloadEvent ipPayloadEvent = e.ipPayload();
         TunerFilterIpPayloadEvent tunerIpPayload;
@@ -481,31 +740,31 @@
         tunerIpPayload.dataLength = static_cast<char>(ipPayloadEvent.dataLength);
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::ipPayload>(std::move(tunerIpPayload));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::ipPayload>(move(tunerIpPayload));
+        res.push_back(move(tunerEvent));
     }
 }
 
 void TunerFilter::FilterCallback::getTemiEvent(
-        std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
     for (DemuxFilterEvent::Event e : events) {
         DemuxFilterTemiEvent temiEvent = e.temi();
         TunerFilterTemiEvent tunerTemi;
 
         tunerTemi.pts = static_cast<long>(temiEvent.pts);
         tunerTemi.descrTag = static_cast<int8_t>(temiEvent.descrTag);
-        std::vector<uint8_t> descrData = temiEvent.descrData;
+        vector<uint8_t> descrData = temiEvent.descrData;
         tunerTemi.descrData.resize(descrData.size());
         copy(descrData.begin(), descrData.end(), tunerTemi.descrData.begin());
 
         TunerFilterEvent tunerEvent;
-        tunerEvent.set<TunerFilterEvent::temi>(std::move(tunerTemi));
-        res.push_back(std::move(tunerEvent));
+        tunerEvent.set<TunerFilterEvent::temi>(move(tunerTemi));
+        res.push_back(move(tunerEvent));
     }
 }
 
 void TunerFilter::FilterCallback::getMonitorEvent(
-        std::vector<DemuxFilterEventExt::Event>& eventsExt, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
     DemuxFilterMonitorEvent monitorEvent = eventsExt[0].monitorEvent();
     TunerFilterMonitorEvent tunerMonitor;
 
@@ -525,14 +784,14 @@
     }
 
     TunerFilterEvent tunerEvent;
-    tunerEvent.set<TunerFilterEvent::monitor>(std::move(tunerMonitor));
-    res.push_back(std::move(tunerEvent));
+    tunerEvent.set<TunerFilterEvent::monitor>(move(tunerMonitor));
+    res.push_back(move(tunerEvent));
 }
 
 void TunerFilter::FilterCallback::getRestartEvent(
-        std::vector<DemuxFilterEventExt::Event>& eventsExt, std::vector<TunerFilterEvent>& res) {
+        vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
     TunerFilterEvent tunerEvent;
     tunerEvent.set<TunerFilterEvent::startId>(static_cast<int>(eventsExt[0].startId()));
-    res.push_back(std::move(tunerEvent));
+    res.push_back(move(tunerEvent));
 }
 }  // namespace android
diff --git a/services/tuner/TunerFilter.h b/services/tuner/TunerFilter.h
index 422a12a..0055b53 100644
--- a/services/tuner/TunerFilter.h
+++ b/services/tuner/TunerFilter.h
@@ -29,6 +29,7 @@
 using Status = ::ndk::ScopedAStatus;
 using ::aidl::android::media::tv::tuner::BnTunerFilter;
 using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
+using ::aidl::android::media::tv::tuner::TunerDemuxIpAddress;
 using ::aidl::android::media::tv::tuner::TunerFilterConfiguration;
 using ::aidl::android::media::tv::tuner::TunerFilterDownloadEvent;
 using ::aidl::android::media::tv::tuner::TunerFilterIpPayloadEvent;
@@ -45,17 +46,28 @@
 using ::aidl::android::media::tv::tuner::TunerFilterTsRecordEvent;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+using ::android::hardware::hidl_array;
+using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadEvent;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterIpPayloadEvent;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterMediaEvent;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterMmtpRecordEvent;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesDataSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesEvent;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterRecordSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionEvent;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionSettings;
+using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterTemiEvent;
 using ::android::hardware::tv::tuner::V1_0::DemuxFilterTsRecordEvent;
+using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterSettings;
+using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterSettings;
+using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterSettings;
+using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
 using ::android::hardware::tv::tuner::V1_0::DemuxPid;
 using ::android::hardware::tv::tuner::V1_0::IFilter;
 using ::android::hardware::tv::tuner::V1_1::DemuxFilterEventExt;
@@ -65,6 +77,9 @@
 
 namespace android {
 
+const static int IP_V4_LENGTH = 4;
+const static int IP_V6_LENGTH = 16;
+
 class TunerFilter : public BnTunerFilter {
 
 public:
@@ -127,6 +142,25 @@
 
 private:
     DemuxFilterAvSettings getAvSettings(const TunerFilterSettings& settings);
+    DemuxFilterSectionSettings getSectionSettings(const TunerFilterSettings& settings);
+    DemuxFilterPesDataSettings getPesDataSettings(const TunerFilterSettings& settings);
+    DemuxFilterRecordSettings getRecordSettings(const TunerFilterSettings& settings);
+    DemuxFilterDownloadSettings getDownloadSettings(const TunerFilterSettings& settings);
+
+    void getHidlTsSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
+    void getHidlMmtpSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
+    void getHidlIpSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
+    void getHidlTlvSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
+    void getHidlAlpSettings(
+        const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
+
+    hidl_array<uint8_t, IP_V4_LENGTH> getIpV4Address(TunerDemuxIpAddress addr);
+    hidl_array<uint8_t, IP_V6_LENGTH> getIpV6Address(TunerDemuxIpAddress addr);
+
     sp<IFilter> mFilter;
     sp<::android::hardware::tv::tuner::V1_1::IFilter> mFilter_1_1;
     sp<IFilterCallback> mFilterCallback;
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl
index d3e4735..df3374a 100644
--- a/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl
@@ -22,7 +22,7 @@
  * {@hide}
  */
 parcelable TunerAudioExtraMetaData {
-	byte adFade;
+    byte adFade;
 
     byte adPan;
 
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddress.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddress.aidl
new file mode 100644
index 0000000..b65f404
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddress.aidl
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Demux ip address configure.
+ *
+ * {@hide}
+ */
+parcelable TunerDemuxIpAddress {
+    boolean isIpV6;
+
+    byte[] addr;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddressSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddressSettings.aidl
new file mode 100644
index 0000000..b244388
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddressSettings.aidl
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerDemuxIpAddress;
+
+/**
+ * Filter Settings for an Ip filter.
+ *
+ * {@hide}
+ */
+parcelable TunerDemuxIpAddressSettings {
+    TunerDemuxIpAddress srcIpAddress;
+
+    TunerDemuxIpAddress dstIpAddress;
+
+    char srcPort;
+
+    char dstPort;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterAlpConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterAlpConfiguration.aidl
new file mode 100644
index 0000000..4c9e3af
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterAlpConfiguration.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerFilterSettings;
+
+/**
+ * Filter Settings for an ALP filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterAlpConfiguration {
+    byte packetType;
+
+    byte lengthType;
+
+    TunerFilterSettings filterSettings;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl
index c208dde..808cfd1 100644
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl
@@ -16,6 +16,10 @@
 
 package android.media.tv.tuner;
 
+import android.media.tv.tuner.TunerFilterAlpConfiguration;
+import android.media.tv.tuner.TunerFilterIpConfiguration;
+import android.media.tv.tuner.TunerFilterMmtpConfiguration;
+import android.media.tv.tuner.TunerFilterTlvConfiguration;
 import android.media.tv.tuner.TunerFilterTsConfiguration;
 
 /**
@@ -25,4 +29,12 @@
  */
 union TunerFilterConfiguration {
     TunerFilterTsConfiguration ts;
+
+    TunerFilterMmtpConfiguration mmtp;
+
+    TunerFilterIpConfiguration ip;
+
+    TunerFilterTlvConfiguration tlv;
+
+    TunerFilterAlpConfiguration alp;
 }
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadSettings.aidl
new file mode 100644
index 0000000..417a5fe
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadSettings.aidl
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Filter Settings for downloading.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterDownloadSettings {
+    int downloadId;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpConfiguration.aidl
new file mode 100644
index 0000000..8b4d889
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpConfiguration.aidl
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerDemuxIpAddressSettings;
+import android.media.tv.tuner.TunerFilterSettings;
+
+/**
+ * Filter Settings for a ip filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterIpConfiguration {
+    TunerDemuxIpAddressSettings ipAddr;
+
+    TunerFilterSettings filterSettings;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpConfiguration.aidl
new file mode 100644
index 0000000..162ca8e
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpConfiguration.aidl
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerFilterSettings;
+
+/**
+ * Filter Settings for an mmtp filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterMmtpConfiguration {
+    char mmtpPid;
+
+    TunerFilterSettings filterSettings;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl
index dfbb9e2..b8871cf 100644
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl
@@ -17,7 +17,7 @@
 package android.media.tv.tuner;
 
 /**
- * Filter Event for MMTP Record Filter.
+ * Filter Event for an MMTP Record Filter.
  *
  * {@hide}
  */
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesDataSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesDataSettings.aidl
new file mode 100644
index 0000000..312f314
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesDataSettings.aidl
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Filter Settings for Pes Data.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterPesDataSettings {
+    char streamId;
+
+    boolean isRaw;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterRecordSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterRecordSettings.aidl
new file mode 100644
index 0000000..29be624
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterRecordSettings.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerFilterScIndexMask;
+
+/**
+ * Filter Settings for recording.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterRecordSettings {
+    int tsIndexMask;
+
+    int scIndexType;
+
+    TunerFilterScIndexMask scIndexMask;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionBits.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionBits.aidl
new file mode 100644
index 0000000..dd4f842
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionBits.aidl
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Bits settings of a section Filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterSectionBits {
+    byte[] filter;
+
+    byte[] mask;
+
+    byte[] mode;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionCondition.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionCondition.aidl
new file mode 100644
index 0000000..00aabe4
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionCondition.aidl
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerFilterSectionBits;
+import android.media.tv.tuner.TunerFilterSectionTableInfo;
+
+/**
+ * Section filter condition settings.
+ *
+ * {@hide}
+ */
+union TunerFilterSectionCondition {
+    TunerFilterSectionBits sectionBits;
+
+    TunerFilterSectionTableInfo tableInfo;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionSettings.aidl
new file mode 100644
index 0000000..22129b6
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionSettings.aidl
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerFilterSectionCondition;
+
+/**
+ * Filter Settings for a section filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterSectionSettings {
+    TunerFilterSectionCondition condition;
+
+    boolean isCheckCrc;
+
+    boolean isRepeat;
+
+    boolean isRaw;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionTableInfo.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionTableInfo.aidl
new file mode 100644
index 0000000..cc78c9d
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionTableInfo.aidl
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Table info settings of a section Filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterSectionTableInfo {
+    char tableId;
+
+    char version;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl
index 8b9e9c2..eb7eaa5 100644
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl
@@ -17,6 +17,10 @@
 package android.media.tv.tuner;
 
 import android.media.tv.tuner.TunerFilterAvSettings;
+import android.media.tv.tuner.TunerFilterDownloadSettings;
+import android.media.tv.tuner.TunerFilterPesDataSettings;
+import android.media.tv.tuner.TunerFilterRecordSettings;
+import android.media.tv.tuner.TunerFilterSectionSettings;
 
 /**
  * Filter Settings.
@@ -24,5 +28,17 @@
  * {@hide}
  */
 union TunerFilterSettings {
+    boolean nothing;
+
     TunerFilterAvSettings av;
+
+    TunerFilterSectionSettings section;
+
+    TunerFilterPesDataSettings pesData;
+
+    TunerFilterRecordSettings record;
+
+    TunerFilterDownloadSettings download;
+
+    boolean isPassthrough;
 }
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTlvConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTlvConfiguration.aidl
new file mode 100644
index 0000000..0b237b4
--- /dev/null
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTlvConfiguration.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+import android.media.tv.tuner.TunerFilterSettings;
+
+/**
+ * Filter Settings for a tlv filter.
+ *
+ * {@hide}
+ */
+parcelable TunerFilterTlvConfiguration {
+    byte packetType;
+
+    boolean isCompressedIpPacket;
+
+    TunerFilterSettings filterSettings;
+}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl
index 5b94988..2e386e6 100644
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl
@@ -24,6 +24,7 @@
  * {@hide}
  */
 parcelable TunerFilterTsConfiguration {
-    int tpid;
+    char tpid;
+
     TunerFilterSettings filterSettings;
 }