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

Commit 8e2ec581 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6588207 from 387600c1 to mainline-release

Change-Id: I4e672b2bd0d6478d51390ac4c3867cd4d491f8f6
parents 8553c4a0 387600c1
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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.
-->
<configuration description="Runs VtsHalCameraProviderV2_4TargetTest.">
    <option name="test-suite-tag" value="apct" />
    <option name="test-suite-tag" value="apct-native" />

    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push" value="VtsHalCameraProviderV2_4TargetTest->/data/local/tmp/VtsHalCameraProviderV2_4TargetTest" />
    </target_preparer>

    <test class="com.android.tradefed.testtype.GTest" >
        <option name="native-test-device-path" value="/data/local/tmp" />
        <option name="module-name" value="VtsHalCameraProviderV2_4TargetTest" />
        <option name="native-test-timeout" value="180000"/>
    </test>
</configuration>
+3 −3
Original line number Diff line number Diff line
@@ -17,13 +17,13 @@ cc_test {
        "android.hardware.keymaster@4.0",
        "libbinder",
        "libcrypto",
        "libkeymaster_portable",
        "libsoft_attestation_cert",
        "libpuresoftkeymasterdevice",
        "android.hardware.keymaster-ndk_platform",
    ],
    static_libs: [
        "libcppbor",
        "libkeymaster_portable",
        "libsoft_attestation_cert",
        "libpuresoftkeymasterdevice",
        "android.hardware.identity-support-lib",
        "android.hardware.identity-cpp",
        "android.hardware.keymaster-cpp",
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ TEST_P(RadioHidlTest_v1_1, setSimCardPower_1_1) {
        }
        EXPECT_EQ(CardState::ABSENT, cardStatus.cardState);
    }
#endif

    /* Test setSimCardPower power up */
    serial = GetRandomSerialNumber();
@@ -60,6 +59,7 @@ TEST_P(RadioHidlTest_v1_1, setSimCardPower_1_1) {
    ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_1->rspInfo.error,
                                 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED,
                                  RadioError::INVALID_ARGUMENTS, RadioError::RADIO_NOT_AVAILABLE}));
#endif

    /**
     * If the sim card status for the testing environment is PRESENT,
+69 −67
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@ Return<Result> Demux::setFrontendDataSource(uint32_t frontendId) {
        return Result::INVALID_STATE;
    }

    mFrontendSourceFile = mFrontend->getSourceFile();

    mTunerService->setFrontendAsDemuxSource(frontendId, mDemuxId);

    return Result::SUCCESS;
@@ -62,8 +60,6 @@ Return<void> Demux::openFilter(const DemuxFilterType& type, uint32_t bufferSize,
    uint32_t filterId;
    filterId = ++mLastUsedFilterId;

    mUsedFilterIds.insert(filterId);

    if (cb == nullptr) {
        ALOGW("[Demux] callback can't be null");
        _hidl_cb(Result::INVALID_ARGUMENT, new Filter());
@@ -82,8 +78,13 @@ Return<void> Demux::openFilter(const DemuxFilterType& type, uint32_t bufferSize,
        mPcrFilterIds.insert(filterId);
    }
    bool result = true;
    if (mDvr != nullptr && mDvr->getType() == DvrType::PLAYBACK) {
        result = mDvr->addPlaybackFilter(filter);
    if (!filter->isRecordFilter()) {
        // Only save non-record filters for now. Record filters are saved when the
        // IDvr.attacheFilter is called.
        mPlaybackFilterIds.insert(filterId);
        if (mDvrPlayback != nullptr) {
            result = mDvrPlayback->addPlaybackFilter(filterId, filter);
        }
    }

    _hidl_cb(result ? Result::SUCCESS : Result::INVALID_ARGUMENT, filter);
@@ -154,7 +155,13 @@ Return<void> Demux::getAvSyncTime(AvSyncHwId avSyncHwId, getAvSyncTime_cb _hidl_
Return<Result> Demux::close() {
    ALOGV("%s", __FUNCTION__);

    mUsedFilterIds.clear();
    set<uint32_t>::iterator it;
    for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) {
        mDvrPlayback->removePlaybackFilter(*it);
    }
    mPlaybackFilterIds.clear();
    mRecordFilterIds.clear();
    mFilters.clear();
    mLastUsedFilterId = -1;

    return Result::SUCCESS;
@@ -170,15 +177,38 @@ Return<void> Demux::openDvr(DvrType type, uint32_t bufferSize, const sp<IDvrCall
        return Void();
    }

    mDvr = new Dvr(type, bufferSize, cb, this);
    set<uint32_t>::iterator it;
    switch (type) {
        case DvrType::PLAYBACK:
            mDvrPlayback = new Dvr(type, bufferSize, cb, this);
            if (!mDvrPlayback->createDvrMQ()) {
                _hidl_cb(Result::UNKNOWN_ERROR, mDvrPlayback);
                return Void();
            }

            for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) {
                if (!mDvrPlayback->addPlaybackFilter(*it, mFilters[*it])) {
                    ALOGE("[Demux] Can't get filter info for DVR playback");
                    _hidl_cb(Result::UNKNOWN_ERROR, mDvrPlayback);
                    return Void();
                }
            }

    if (!mDvr->createDvrMQ()) {
        _hidl_cb(Result::UNKNOWN_ERROR, mDvr);
            _hidl_cb(Result::SUCCESS, mDvrPlayback);
            return Void();
        case DvrType::RECORD:
            mDvrRecord = new Dvr(type, bufferSize, cb, this);
            if (!mDvrRecord->createDvrMQ()) {
                _hidl_cb(Result::UNKNOWN_ERROR, mDvrRecord);
                return Void();
            }

    _hidl_cb(Result::SUCCESS, mDvr);
            _hidl_cb(Result::SUCCESS, mDvrRecord);
            return Void();
        default:
            _hidl_cb(Result::INVALID_ARGUMENT, nullptr);
            return Void();
    }
}

Return<Result> Demux::connectCiCam(uint32_t ciCamId) {
@@ -198,8 +228,10 @@ Return<Result> Demux::disconnectCiCam() {
Result Demux::removeFilter(uint32_t filterId) {
    ALOGV("%s", __FUNCTION__);

    // resetFilterRecords(filterId);
    mUsedFilterIds.erase(filterId);
    if (mDvrPlayback != nullptr) {
        mDvrPlayback->removePlaybackFilter(filterId);
    }
    mPlaybackFilterIds.erase(filterId);
    mRecordFilterIds.erase(filterId);
    mFilters.erase(filterId);

@@ -212,7 +244,7 @@ void Demux::startBroadcastTsFilter(vector<uint8_t> data) {
    if (DEBUG_DEMUX) {
        ALOGW("[Demux] start ts filter pid: %d", pid);
    }
    for (it = mUsedFilterIds.begin(); it != mUsedFilterIds.end(); it++) {
    for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) {
        if (pid == mFilters[*it]->getTpid()) {
            mFilters[*it]->updateFilterOutput(data);
        }
@@ -233,7 +265,7 @@ bool Demux::startBroadcastFilterDispatcher() {
    set<uint32_t>::iterator it;

    // Handle the output data per filter type
    for (it = mUsedFilterIds.begin(); it != mUsedFilterIds.end(); it++) {
    for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) {
        if (mFilters[*it]->startFilterHandler() != Result::SUCCESS) {
            return false;
        }
@@ -280,58 +312,27 @@ void* Demux::__threadLoopFrontend(void* user) {
void Demux::frontendInputThreadLoop() {
    std::lock_guard<std::mutex> lock(mFrontendInputThreadLock);
    mFrontendInputThreadRunning = true;
    mKeepFetchingDataFromFrontend = true;

    // open the stream and get its length
    std::ifstream inputData(mFrontendSourceFile, std::ifstream::binary);
    // TODO take the packet size from the frontend setting
    int packetSize = 188;
    int writePacketAmount = 6;
    char* buffer = new char[packetSize];
    ALOGW("[Demux] Frontend input thread loop start %s", mFrontendSourceFile.c_str());
    if (!inputData.is_open()) {
        mFrontendInputThreadRunning = false;
        ALOGW("[Demux] Error %s", strerror(errno));
    }

    while (mFrontendInputThreadRunning) {
        // move the stream pointer for packet size * 6 every read until the end
        while (mKeepFetchingDataFromFrontend) {
            for (int i = 0; i < writePacketAmount; i++) {
                inputData.read(buffer, packetSize);
                if (!inputData) {
                    mKeepFetchingDataFromFrontend = false;
                    mFrontendInputThreadRunning = false;
        uint32_t efState = 0;
        status_t status = mDvrPlayback->getDvrEventFlag()->wait(
                static_cast<uint32_t>(DemuxQueueNotifyBits::DATA_READY), &efState, WAIT_TIMEOUT,
                true /* retry on spurious wake */);
        if (status != OK) {
            ALOGD("[Demux] wait for data ready on the playback FMQ");
            continue;
        }
        // Our current implementation filter the data and write it into the filter FMQ immediately
        // after the DATA_READY from the VTS/framework
        if (!mDvrPlayback->readPlaybackFMQ(true /*isVirtualFrontend*/, mIsRecording) ||
            !mDvrPlayback->startFilterDispatcher(true /*isVirtualFrontend*/, mIsRecording)) {
            ALOGE("[Demux] playback data failed to be filtered. Ending thread");
            break;
        }
                // filter and dispatch filter output
                vector<uint8_t> byteBuffer;
                byteBuffer.resize(packetSize);
                for (int index = 0; index < byteBuffer.size(); index++) {
                    byteBuffer[index] = static_cast<uint8_t>(buffer[index]);
                }
                if (mIsRecording) {
                    // Feed the data into the Dvr recording input
                    sendFrontendInputToRecord(byteBuffer);
                } else {
                    // Feed the data into the broadcast demux filter
                    startBroadcastTsFilter(byteBuffer);
                }
            }
            if (mIsRecording) {
                // Dispatch the data into the broadcasting filters.
                startRecordFilterDispatcher();
            } else {
                // Dispatch the data into the broadcasting filters.
                startBroadcastFilterDispatcher();
            }
            usleep(100);
        }
    }

    mFrontendInputThreadRunning = false;
    ALOGW("[Demux] Frontend Input thread end.");
    delete[] buffer;
    inputData.close();
}

void Demux::stopFrontendInput() {
@@ -346,18 +347,19 @@ void Demux::setIsRecording(bool isRecording) {
}

bool Demux::attachRecordFilter(int filterId) {
    if (mFilters[filterId] == nullptr || mDvr == nullptr) {
    if (mFilters[filterId] == nullptr || mDvrRecord == nullptr ||
        !mFilters[filterId]->isRecordFilter()) {
        return false;
    }

    mRecordFilterIds.insert(filterId);
    mFilters[filterId]->attachFilterToRecord(mDvr);
    mFilters[filterId]->attachFilterToRecord(mDvrRecord);

    return true;
}

bool Demux::detachRecordFilter(int filterId) {
    if (mFilters[filterId] == nullptr || mDvr == nullptr) {
    if (mFilters[filterId] == nullptr || mDvrRecord == nullptr) {
        return false;
    }

+16 −15
Original line number Diff line number Diff line
@@ -91,13 +91,23 @@ class Demux : public IDemux {
    void setIsRecording(bool isRecording);
    void startFrontendInputLoop();

    /**
     * A dispatcher to read and dispatch input data to all the started filters.
     * Each filter handler handles the data filtering/output writing/filterEvent updating.
     * Note that recording filters are not included.
     */
    bool startBroadcastFilterDispatcher();
    void startBroadcastTsFilter(vector<uint8_t> data);

    void sendFrontendInputToRecord(vector<uint8_t> data);
    bool startRecordFilterDispatcher();

  private:
    // Tuner service
    sp<Tuner> mTunerService;

    // Frontend source
    sp<Frontend> mFrontend;
    string mFrontendSourceFile;

    // A struct that passes the arguments to a newly created filter thread
    struct ThreadArgs {
@@ -117,16 +127,6 @@ class Demux : public IDemux {
     */
    void deleteEventFlag();
    bool readDataFromMQ();
    /**
     * A dispatcher to read and dispatch input data to all the started filters.
     * Each filter handler handles the data filtering/output writing/filterEvent updating.
     * Note that recording filters are not included.
     */
    bool startBroadcastFilterDispatcher();
    void startBroadcastTsFilter(vector<uint8_t> data);

    void sendFrontendInputToRecord(vector<uint8_t> data);
    bool startRecordFilterDispatcher();

    uint32_t mDemuxId;
    uint32_t mCiCamId;
@@ -137,17 +137,17 @@ class Demux : public IDemux {
     */
    uint32_t mLastUsedFilterId = -1;
    /**
     * Record all the used filter Ids.
     * Record all the used playback filter Ids.
     * Any removed filter id should be removed from this set.
     */
    set<uint32_t> mUsedFilterIds;
    set<uint32_t> mPlaybackFilterIds;
    /**
     * Record all the attached record filter Ids.
     * Any removed filter id should be removed from this set.
     */
    set<uint32_t> mRecordFilterIds;
    /**
     * A list of created FilterMQ ptrs.
     * A list of created Filter sp.
     * The array number is the filter ID.
     */
    std::map<uint32_t, sp<Filter>> mFilters;
@@ -160,7 +160,8 @@ class Demux : public IDemux {
    /**
     * Local reference to the opened DVR object.
     */
    sp<Dvr> mDvr;
    sp<Dvr> mDvrPlayback;
    sp<Dvr> mDvrRecord;

    // Thread handlers
    pthread_t mFrontendInputThread;
Loading