blob: 7f3916fe634d6c8388c10f65073fbba4285e9ab7 [file] [log] [blame]
Amy Zhangb0f63ab2021-01-06 17:19:27 -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 "LnbClient"
18
19#include <android-base/logging.h>
20#include <utils/Log.h>
21
22#include "LnbClient.h"
23
24using ::android::hardware::tv::tuner::V1_0::Result;
25
26namespace android {
27
28/////////////// LnbClient ///////////////////////
29
30// TODO: pending aidl interface
31LnbClient::LnbClient() {
32 //mTunerLnb = tunerLnb;
Amy Zhangd3d57b42021-01-07 11:14:43 -080033 mId = -1;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080034}
35
36LnbClient::~LnbClient() {
37 //mTunerLnb = NULL;
38 mLnb = NULL;
Amy Zhangd3d57b42021-01-07 11:14:43 -080039 mId = -1;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080040}
41
42// TODO: remove after migration to Tuner Service is done.
43void LnbClient::setHidlLnb(sp<ILnb> lnb) {
44 mLnb = lnb;
45}
46
Amy Zhangd3d57b42021-01-07 11:14:43 -080047Result LnbClient::setCallback(sp<LnbClientCallback> cb) {
48 // TODO: pending aidl interface
49 /*if (mTunerFrontend != NULL) {
50 mAidlCallback = ::ndk::SharedRefBase::make<TunerLnbCallback>(cb);
51 mTunerLnb->setCallback(mAidlCallback);
52 return Result::SUCCESS;
53 }*/
54
55 mHidlCallback = new HidlLnbCallback(cb);
56 return mLnb->setCallback(mHidlCallback);
Amy Zhangb0f63ab2021-01-06 17:19:27 -080057}
58
Amy Zhangd3d57b42021-01-07 11:14:43 -080059Result LnbClient::setVoltage(LnbVoltage voltage) {
60 // TODO: pending aidl interface
61
62 if (mLnb != NULL) {
63 return mLnb->setVoltage(voltage);
64 }
65
66 return Result::INVALID_STATE;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080067}
68
Amy Zhangd3d57b42021-01-07 11:14:43 -080069Result LnbClient::setTone(LnbTone tone) {
70 // TODO: pending aidl interface
71
72 if (mLnb != NULL) {
73 return mLnb->setTone(tone);
74 }
75
76 return Result::INVALID_STATE;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080077}
78
Amy Zhangd3d57b42021-01-07 11:14:43 -080079Result LnbClient::setSatellitePosition(LnbPosition position) {
80 // TODO: pending aidl interface
81
82 if (mLnb != NULL) {
83 return mLnb->setSatellitePosition(position);
84 }
85
86 return Result::INVALID_STATE;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080087}
88
Amy Zhangd3d57b42021-01-07 11:14:43 -080089Result LnbClient::sendDiseqcMessage(vector<uint8_t> diseqcMessage) {
90 // TODO: pending aidl interface
91
92 if (mLnb != NULL) {
93 return mLnb->sendDiseqcMessage(diseqcMessage);
94 }
95
96 return Result::INVALID_STATE;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080097}
98
99Result LnbClient::close() {
Amy Zhangd3d57b42021-01-07 11:14:43 -0800100 // TODO: pending aidl interface
101
102 if (mLnb != NULL) {
103 return mLnb->close();
104 }
105
106 return Result::INVALID_STATE;
Amy Zhangb0f63ab2021-01-06 17:19:27 -0800107}
108
109/////////////// ILnbCallback ///////////////////////
110
111HidlLnbCallback::HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback)
112 : mLnbClientCallback(lnbClientCallback) {}
113
114Return<void> HidlLnbCallback::onEvent(const LnbEventType lnbEventType) {
115 if (mLnbClientCallback != NULL) {
116 mLnbClientCallback->onEvent(lnbEventType);
117 }
118 return Void();
119}
120
121Return<void> HidlLnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
122 if (mLnbClientCallback != NULL) {
123 mLnbClientCallback->onDiseqcMessage(diseqcMessage);
124 }
125 return Void();
126}
127
128/////////////// LnbClient Helper Methods ///////////////////////
129
130} // namespace android