Update tuner default AIDL HAL.
*) Use tuner AIDL HAL return values.
*) Replace mTunerService with mTuner to avoid confusing.
*) Merge other HIDL HAL changes.
*) ag/15371813, ag/15371814 and ag/15371815.
Bug: 191825295
Test: make and run VtsHalTvTunerTargetTest
Change-Id: Ibbf94c4fc36c3bda94a7e0f3e0697c83ac414d0e
diff --git a/tv/tuner/aidl/default/Demux.cpp b/tv/tuner/aidl/default/Demux.cpp
index 15022ee..d5a653b 100644
--- a/tv/tuner/aidl/default/Demux.cpp
+++ b/tv/tuner/aidl/default/Demux.cpp
@@ -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 @@
Demux::Demux(int32_t demuxId, std::shared_ptr<Tuner> tuner) {
mDemuxId = demuxId;
- mTunerService = tuner;
+ mTuner = tuner;
}
Demux::~Demux() {
@@ -43,17 +44,18 @@
::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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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));
}
}