blob: 18aa11ed25d15de7a32b466cfdfcd8c43786f9ad [file] [log] [blame]
Amy Zhanga046eee2021-01-12 14:44:58 -08001/**
2 * Copyright 2021, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "TunerLnb"
18
19#include "TunerLnb.h"
20
21using ::android::hardware::tv::tuner::V1_0::Result;
22
23namespace android {
24
25TunerLnb::TunerLnb(sp<ILnb> lnb, int id) {
26 mLnb = lnb;
27 mId = id;
28}
29
30TunerLnb::~TunerLnb() {
31 mLnb = NULL;
32 mId = -1;
33}
34
35Status TunerLnb::setCallback(
36 const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) {
37 if (mLnb == NULL) {
38 ALOGE("ILnb is not initialized");
39 return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
40 }
41
42 if (tunerLnbCallback == NULL) {
43 return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
44 }
45
46 sp<ILnbCallback> lnbCallback = new LnbCallback(tunerLnbCallback);
47 Result status = mLnb->setCallback(lnbCallback);
48 if (status == Result::SUCCESS) {
49 return Status::ok();
50 }
51
52 return Status::fromServiceSpecificError(static_cast<int32_t>(status));
53}
54
55Status TunerLnb::setVoltage(int /*voltage*/) {
56 return Status::ok();
57}
58
59Status TunerLnb::setTone(int /*voltage*/) {
60 return Status::ok();
61}
62
63Status TunerLnb::setSatellitePosition(int /*position*/) {
64 return Status::ok();
65}
66
67Status TunerLnb::sendDiseqcMessage(const vector<uint8_t>& /*diseqcMessage*/) {
68 return Status::ok();
69}
70
71Status TunerLnb::close() {
72 return Status::ok();
73}
74
75/////////////// ILnbCallback ///////////////////////
76
77Return<void> TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
78 if (mTunerLnbCallback != NULL) {
79 mTunerLnbCallback->onEvent((int)lnbEventType);
80 }
81 return Void();
82}
83
84Return<void> TunerLnb::LnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
85 if (mTunerLnbCallback != NULL && diseqcMessage != NULL) {
86 vector<uint8_t> msg(begin(diseqcMessage), end(diseqcMessage));
87 mTunerLnbCallback->onDiseqcMessage(msg);
88 }
89 return Void();
90}
91} // namespace android