Merge changes I1f2c9bfe,I38a92abb am: aedfe936ef

am: a843f717c9

Change-Id: Iff0aa535bcc024bb819168fed1f9d3a8f05dae40
This commit is contained in:
Amy Zhang 2019-09-06 15:56:46 -07:00 committed by android-build-merger
commit 42eaeb4824
8 changed files with 366 additions and 3 deletions

View file

@ -5,6 +5,8 @@ cc_defaults {
relative_install_path: "hw",
srcs: [
"Frontend.cpp",
"Descrambler.cpp",
"Demux.cpp",
"Tuner.cpp",
"service.cpp",
],

View file

@ -0,0 +1,55 @@
/*
* Copyright (C) 2019 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.
*/
#define LOG_TAG "android.hardware.tv.tuner@1.0-Demux"
#include "Demux.h"
#include <utils/Log.h>
namespace android {
namespace hardware {
namespace tv {
namespace tuner {
namespace V1_0 {
namespace implementation {
Demux::Demux(uint32_t demuxId) {
mDemuxId = demuxId;
}
Demux::~Demux() {}
Return<Result> Demux::setFrontendDataSource(uint32_t frontendId) {
ALOGV("%s", __FUNCTION__);
mSourceFrontendId = frontendId;
return Result::SUCCESS;
}
Return<Result> Demux::close() {
ALOGV("%s", __FUNCTION__);
return Result::SUCCESS;
;
}
} // namespace implementation
} // namespace V1_0
} // namespace tuner
} // namespace tv
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,55 @@
/*
* Copyright (C) 2019 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.
*/
#ifndef ANDROID_HARDWARE_TV_TUNER_V1_0_DEMUX_H_
#define ANDROID_HARDWARE_TV_TUNER_V1_0_DEMUX_H_
#include <android/hardware/tv/tuner/1.0/IDemux.h>
using namespace std;
namespace android {
namespace hardware {
namespace tv {
namespace tuner {
namespace V1_0 {
namespace implementation {
using ::android::hardware::tv::tuner::V1_0::IDemux;
using ::android::hardware::tv::tuner::V1_0::Result;
class Demux : public IDemux {
public:
Demux(uint32_t demuxId);
virtual Return<Result> setFrontendDataSource(uint32_t frontendId) override;
virtual Return<Result> close() override;
private:
virtual ~Demux();
uint32_t mDemuxId;
uint32_t mSourceFrontendId;
};
} // namespace implementation
} // namespace V1_0
} // namespace tuner
} // namespace tv
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_TV_TUNER_V1_0_DEMUX_H_

View file

@ -0,0 +1,59 @@
/*
* Copyright (C) 2019 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.
*/
#define LOG_TAG "android.hardware.tv.tuner@1.0-Descrambler"
#include <android/hardware/tv/tuner/1.0/IFrontendCallback.h>
#include <utils/Log.h>
#include "Descrambler.h"
namespace android {
namespace hardware {
namespace tv {
namespace tuner {
namespace V1_0 {
namespace implementation {
Descrambler::Descrambler() {}
Descrambler::~Descrambler() {}
Return<Result> Descrambler::setDemuxSource(uint32_t demuxId) {
ALOGV("%s", __FUNCTION__);
if (mDemuxSet) {
ALOGW("[ WARN ] Descrambler has already been set with a demux id %d", mSourceDemuxId);
return Result::INVALID_STATE;
}
mDemuxSet = true;
mSourceDemuxId = demuxId;
return Result::SUCCESS;
}
Return<Result> Descrambler::close() {
ALOGV("%s", __FUNCTION__);
mDemuxSet = false;
return Result::SUCCESS;
}
} // namespace implementation
} // namespace V1_0
} // namespace tuner
} // namespace tv
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,56 @@
/*
* Copyright (C) 2019 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.
*/
#ifndef ANDROID_HARDWARE_TV_TUNER_V1_0_DESCRAMBLER_H_
#define ANDROID_HARDWARE_TV_TUNER_V1_0_DESCRAMBLER_H_
#include <android/hardware/tv/tuner/1.0/IDescrambler.h>
#include <android/hardware/tv/tuner/1.0/ITuner.h>
using namespace std;
namespace android {
namespace hardware {
namespace tv {
namespace tuner {
namespace V1_0 {
namespace implementation {
using ::android::hardware::tv::tuner::V1_0::IDescrambler;
using ::android::hardware::tv::tuner::V1_0::Result;
class Descrambler : public IDescrambler {
public:
Descrambler();
virtual Return<Result> setDemuxSource(uint32_t demuxId) override;
virtual Return<Result> close() override;
private:
virtual ~Descrambler();
uint32_t mSourceDemuxId;
bool mDemuxSet = false;
};
} // namespace implementation
} // namespace V1_0
} // namespace tuner
} // namespace tv
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_TV_TUNER_V1_DESCRAMBLER_H_

View file

@ -19,6 +19,8 @@
#include "Tuner.h"
#include <android/hardware/tv/tuner/1.0/IFrontendCallback.h>
#include <utils/Log.h>
#include "Demux.h"
#include "Descrambler.h"
#include "Frontend.h"
namespace android {
@ -76,8 +78,9 @@ Return<void> Tuner::openFrontendById(uint32_t frontendId, openFrontendById_cb _h
Return<void> Tuner::openDemux(openDemux_cb _hidl_cb) {
ALOGV("%s", __FUNCTION__);
sp<IDemux> demux;
DemuxId demuxId = 0;
DemuxId demuxId = mLastUsedId + 1;
mLastUsedId += 1;
sp<IDemux> demux = new Demux(demuxId);
_hidl_cb(Result::SUCCESS, demuxId, demux);
return Void();
@ -86,7 +89,7 @@ Return<void> Tuner::openDemux(openDemux_cb _hidl_cb) {
Return<void> Tuner::openDescrambler(openDescrambler_cb _hidl_cb) {
ALOGV("%s", __FUNCTION__);
sp<IDescrambler> descrambler;
sp<IDescrambler> descrambler = new Descrambler();
_hidl_cb(Result::SUCCESS, descrambler);
return Void();

View file

@ -47,6 +47,9 @@ class Tuner : public ITuner {
vector<sp<Frontend>> mFrontends;
// To maintain how many Frontends we have
int mFrontendSize;
// The last used demux id. Initial value is -1.
// First used id will be 0.
int mLastUsedId = -1;
};
} // namespace implementation

View file

@ -19,6 +19,9 @@
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/tv/tuner/1.0/IDemux.h>
#include <android/hardware/tv/tuner/1.0/IDemuxCallback.h>
#include <android/hardware/tv/tuner/1.0/IDescrambler.h>
#include <android/hardware/tv/tuner/1.0/IFrontend.h>
#include <android/hardware/tv/tuner/1.0/IFrontendCallback.h>
#include <android/hardware/tv/tuner/1.0/ITuner.h>
@ -52,6 +55,9 @@ using android::hardware::tv::tuner::V1_0::FrontendEventType;
using android::hardware::tv::tuner::V1_0::FrontendId;
using android::hardware::tv::tuner::V1_0::FrontendInnerFec;
using android::hardware::tv::tuner::V1_0::FrontendSettings;
using android::hardware::tv::tuner::V1_0::IDemux;
using android::hardware::tv::tuner::V1_0::IDemuxCallback;
using android::hardware::tv::tuner::V1_0::IDescrambler;
using android::hardware::tv::tuner::V1_0::IFrontend;
using android::hardware::tv::tuner::V1_0::IFrontendCallback;
using android::hardware::tv::tuner::V1_0::ITuner;
@ -146,11 +152,19 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
sp<IFrontend> mFrontend;
sp<FrontendCallback> mFrontendCallback;
sp<IDescrambler> mDescrambler;
sp<IDemux> mDemux;
uint32_t mDemuxId;
::testing::AssertionResult createFrontend(int32_t frontendId);
::testing::AssertionResult tuneFrontend(int32_t frontendId);
::testing::AssertionResult stopTuneFrontend(int32_t frontendId);
::testing::AssertionResult closeFrontend(int32_t frontendId);
::testing::AssertionResult createDemux();
::testing::AssertionResult createDemuxWithFrontend(int32_t frontendId);
::testing::AssertionResult closeDemux();
::testing::AssertionResult createDescrambler();
::testing::AssertionResult closeDescrambler();
};
::testing::AssertionResult TunerHidlTest::createFrontend(int32_t frontendId) {
@ -215,6 +229,78 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
return ::testing::AssertionResult(status == Result::SUCCESS);
}
::testing::AssertionResult TunerHidlTest::createDemux() {
Result status;
mService->openDemux([&](Result result, uint32_t demuxId, const sp<IDemux>& demux) {
mDemux = demux;
mDemuxId = demuxId;
status = result;
});
return ::testing::AssertionResult(status == Result::SUCCESS);
}
::testing::AssertionResult TunerHidlTest::createDemuxWithFrontend(int32_t frontendId) {
Result status;
if (createDemux() == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
if (createFrontend(frontendId) == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
status = mDemux->setFrontendDataSource(frontendId);
return ::testing::AssertionResult(status == Result::SUCCESS);
}
::testing::AssertionResult TunerHidlTest::closeDemux() {
Result status;
if (createDemux() == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
status = mDemux->close();
return ::testing::AssertionResult(status == Result::SUCCESS);
}
::testing::AssertionResult TunerHidlTest::createDescrambler() {
Result status;
mService->openDescrambler([&](Result result, const sp<IDescrambler>& descrambler) {
mDescrambler = descrambler;
status = result;
});
if (status != Result::SUCCESS) {
return ::testing::AssertionFailure();
}
if (createDemux() == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
status = mDescrambler->setDemuxSource(mDemuxId);
if (status != Result::SUCCESS) {
return ::testing::AssertionFailure();
}
// Test if demux source can be set more than once.
status = mDescrambler->setDemuxSource(mDemuxId);
return ::testing::AssertionResult(status == Result::INVALID_STATE);
}
::testing::AssertionResult TunerHidlTest::closeDescrambler() {
Result status;
if (createDescrambler() == ::testing::AssertionFailure()) {
return ::testing::AssertionFailure();
}
status = mDescrambler->close();
return ::testing::AssertionResult(status == Result::SUCCESS);
}
TEST_F(TunerHidlTest, CreateFrontend) {
Result status;
hidl_vec<FrontendId> feIds;
@ -295,6 +381,50 @@ TEST_F(TunerHidlTest, CloseFrontend) {
}
}
TEST_F(TunerHidlTest, CreateDemux) {
description("Create Demux");
ASSERT_TRUE(createDemux());
}
TEST_F(TunerHidlTest, CreateDemuxWithFrontend) {
Result status;
hidl_vec<FrontendId> feIds;
description("Create Demux with Frontend");
mService->getFrontendIds([&](Result result, const hidl_vec<FrontendId>& frontendIds) {
status = result;
feIds = frontendIds;
});
if (feIds.size() == 0) {
ALOGW("[ WARN ] Frontend isn't available");
return;
}
for (size_t i = 0; i < feIds.size(); i++) {
ASSERT_TRUE(createDemuxWithFrontend(feIds[i]));
}
}
TEST_F(TunerHidlTest, CloseDemux) {
description("Close Demux");
ASSERT_TRUE(closeDemux());
}
TEST_F(TunerHidlTest, CreateDescrambler) {
description("Create Descrambler");
ASSERT_TRUE(createDescrambler());
}
TEST_F(TunerHidlTest, CloseDescrambler) {
description("Close Descrambler");
ASSERT_TRUE(closeDescrambler());
}
} // namespace
int main(int argc, char** argv) {