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

Commit ce2411a6 authored by Hongguang Chen's avatar Hongguang Chen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "refine_tuner_aidl_status"

* changes:
  Update tuner default AIDL HAL.
  Add Tuner AIDL error codes to align with HIDL.
parents 92106709 e423acd4
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
/*
 * 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.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.tv.tuner;
/* @hide */
@Backing(type="int") @VintfStability
enum Result {
  SUCCESS = 0,
  UNAVAILABLE = 1,
  NOT_INITIALIZED = 2,
  INVALID_STATE = 3,
  INVALID_ARGUMENT = 4,
  OUT_OF_MEMORY = 5,
  UNKNOWN_ERROR = 6,
}
+34 −0
Original line number Diff line number Diff line
/*
 * 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.hardware.tv.tuner;

/**
 * Tuner error codes. Aidl will return these error codes as service specific
 * errors in EX_SERVICE_SPECIFIC.
 * @hide
 */
@VintfStability
@Backing(type="int")
enum Result {
    SUCCESS,
    UNAVAILABLE,
    NOT_INITIALIZED,
    INVALID_STATE,
    INVALID_ARGUMENT,
    OUT_OF_MEMORY,
    UNKNOWN_ERROR,
}
+36 −21
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define LOG_TAG "android.hardware.tv.tuner-service.example-Demux"

#include <aidl/android/hardware/tv/tuner/DemuxQueueNotifyBits.h>
#include <aidl/android/hardware/tv/tuner/Result.h>

#include <utils/Log.h>
#include "Demux.h"
@@ -32,7 +33,7 @@ namespace tuner {

Demux::Demux(int32_t demuxId, std::shared_ptr<Tuner> tuner) {
    mDemuxId = demuxId;
    mTunerService = tuner;
    mTuner = tuner;
}

Demux::~Demux() {
@@ -43,17 +44,18 @@ Demux::~Demux() {
::ndk::ScopedAStatus Demux::setFrontendDataSource(int32_t in_frontendId) {
    ALOGV("%s", __FUNCTION__);

    if (mTunerService == nullptr) {
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_NO_INIT);
    if (mTuner == nullptr) {
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::NOT_INITIALIZED));
    }

    mFrontend = mTunerService->getFrontendById(in_frontendId);

    mFrontend = mTuner->getFrontendById(in_frontendId);
    if (mFrontend == nullptr) {
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_STATE));
    }

    mTunerService->setFrontendAsDemuxSource(in_frontendId, mDemuxId);
    mTuner->setFrontendAsDemuxSource(in_frontendId, mDemuxId);

    return ::ndk::ScopedAStatus::ok();
}
@@ -69,14 +71,16 @@ Demux::~Demux() {
    if (in_cb == nullptr) {
        ALOGW("[Demux] callback can't be null");
        *_aidl_return = nullptr;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_ARGUMENT));
    }

    std::shared_ptr<Filter> filter =
            ndk::SharedRefBase::make<Filter>(in_type, filterId, in_bufferSize, in_cb, ref<Demux>());
    if (!filter->createFilterMQ()) {
        *_aidl_return = nullptr;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_UNKNOWN_ERROR);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::UNKNOWN_ERROR));
    }

    mFilters[filterId] = filter;
@@ -95,7 +99,8 @@ Demux::~Demux() {

    if (!result) {
        *_aidl_return = nullptr;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_ARGUMENT));
    }

    *_aidl_return = filter;
@@ -122,13 +127,15 @@ Demux::~Demux() {
    if (!status.isOk()) {
        ALOGE("[Demux] Can't get filter Id.");
        *_aidl_return = -1;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_STATE));
    }

    if (!mFilters[id]->isMediaFilter()) {
        ALOGE("[Demux] Given filter is not a media filter.");
        *_aidl_return = -1;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_STATE));
    }

    if (!mPcrFilterIds.empty()) {
@@ -139,7 +146,8 @@ Demux::~Demux() {

    ALOGE("[Demux] No PCR filter opened.");
    *_aidl_return = -1;
    return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
    return ::ndk::ScopedAStatus::fromServiceSpecificError(
            static_cast<int32_t>(Result::INVALID_STATE));
}

::ndk::ScopedAStatus Demux::getAvSyncTime(int32_t in_avSyncHwId, int64_t* _aidl_return) {
@@ -147,11 +155,13 @@ Demux::~Demux() {

    if (mPcrFilterIds.empty()) {
        *_aidl_return = -1;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_STATE));
    }
    if (in_avSyncHwId != *mPcrFilterIds.begin()) {
        *_aidl_return = -1;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_ARGUMENT));
    }

    *_aidl_return = -1;
@@ -169,7 +179,7 @@ Demux::~Demux() {
    mRecordFilterIds.clear();
    mFilters.clear();
    mLastUsedFilterId = -1;
    mTunerService->removeDemux(mDemuxId);
    mTuner->removeDemux(mDemuxId);
    mFrontendInputThreadRunning = false;
    std::lock_guard<std::mutex> lock(mFrontendInputThreadLock);

@@ -184,7 +194,8 @@ Demux::~Demux() {
    if (in_cb == nullptr) {
        ALOGW("[Demux] DVR callback can't be null");
        *_aidl_return = nullptr;
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_ARGUMENT));
    }

    set<int64_t>::iterator it;
@@ -195,7 +206,8 @@ Demux::~Demux() {
            if (!mDvrPlayback->createDvrMQ()) {
                mDvrPlayback = nullptr;
                *_aidl_return = mDvrPlayback;
                return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_UNKNOWN_ERROR);
                return ::ndk::ScopedAStatus::fromServiceSpecificError(
                        static_cast<int32_t>(Result::UNKNOWN_ERROR));
            }

            for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) {
@@ -203,7 +215,8 @@ Demux::~Demux() {
                    ALOGE("[Demux] Can't get filter info for DVR playback");
                    mDvrPlayback = nullptr;
                    *_aidl_return = mDvrPlayback;
                    return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_UNKNOWN_ERROR);
                    return ::ndk::ScopedAStatus::fromServiceSpecificError(
                            static_cast<int32_t>(Result::UNKNOWN_ERROR));
                }
            }

@@ -214,14 +227,16 @@ Demux::~Demux() {
            if (!mDvrRecord->createDvrMQ()) {
                mDvrRecord = nullptr;
                *_aidl_return = mDvrRecord;
                return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_UNKNOWN_ERROR);
                return ::ndk::ScopedAStatus::fromServiceSpecificError(
                        static_cast<int32_t>(Result::UNKNOWN_ERROR));
            }

            *_aidl_return = mDvrRecord;
            return ::ndk::ScopedAStatus::ok();
        default:
            *_aidl_return = nullptr;
            return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
            return ::ndk::ScopedAStatus::fromServiceSpecificError(
                    static_cast<int32_t>(Result::INVALID_ARGUMENT));
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ class Demux : public BnDemux {

  private:
    // Tuner service
    std::shared_ptr<Tuner> mTunerService;
    std::shared_ptr<Tuner> mTuner;

    // Frontend source
    std::shared_ptr<Frontend> mFrontend;
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define LOG_TAG "android.hardware.tv.tuner-service.example-Descrambler"

#include <aidl/android/hardware/tv/tuner/IFrontendCallback.h>
#include <aidl/android/hardware/tv/tuner/Result.h>
#include <utils/Log.h>

#include "Descrambler.h"
@@ -37,7 +38,8 @@ Descrambler::~Descrambler() {}
    if (mDemuxSet) {
        ALOGW("[   WARN   ] Descrambler has already been set with a demux id %" PRIu32,
              mSourceDemuxId);
        return ::ndk::ScopedAStatus::fromExceptionCode(STATUS_INVALID_OPERATION);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(
                static_cast<int32_t>(Result::INVALID_STATE));
    }
    mDemuxSet = true;
    mSourceDemuxId = in_demuxId;
Loading