• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
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 
21 #include <aidl/android/hardware/tv/tuner/ILnbCallback.h>
22 #include <aidl/android/hardware/tv/tuner/Result.h>
23 
24 using ::aidl::android::hardware::tv::tuner::ILnbCallback;
25 using ::aidl::android::hardware::tv::tuner::Result;
26 
27 namespace aidl {
28 namespace android {
29 namespace media {
30 namespace tv {
31 namespace tuner {
32 
TunerLnb(shared_ptr<ILnb> lnb,int id)33 TunerLnb::TunerLnb(shared_ptr<ILnb> lnb, int id) {
34     mLnb = lnb;
35     mId = id;
36 }
37 
~TunerLnb()38 TunerLnb::~TunerLnb() {
39     close();
40     mLnb = nullptr;
41     mId = -1;
42 }
43 
setCallback(const shared_ptr<ITunerLnbCallback> & in_tunerLnbCallback)44 ::ndk::ScopedAStatus TunerLnb::setCallback(
45         const shared_ptr<ITunerLnbCallback>& in_tunerLnbCallback) {
46     if (in_tunerLnbCallback == nullptr) {
47         return ::ndk::ScopedAStatus::fromServiceSpecificError(
48                 static_cast<int32_t>(Result::INVALID_ARGUMENT));
49     }
50 
51     shared_ptr<ILnbCallback> lnbCallback =
52             ::ndk::SharedRefBase::make<LnbCallback>(in_tunerLnbCallback);
53     return mLnb->setCallback(lnbCallback);
54 }
55 
setVoltage(LnbVoltage in_voltage)56 ::ndk::ScopedAStatus TunerLnb::setVoltage(LnbVoltage in_voltage) {
57     return mLnb->setVoltage(in_voltage);
58 }
59 
setTone(LnbTone in_tone)60 ::ndk::ScopedAStatus TunerLnb::setTone(LnbTone in_tone) {
61     return mLnb->setTone(in_tone);
62 }
63 
setSatellitePosition(LnbPosition in_position)64 ::ndk::ScopedAStatus TunerLnb::setSatellitePosition(LnbPosition in_position) {
65     return mLnb->setSatellitePosition(in_position);
66 }
67 
sendDiseqcMessage(const vector<uint8_t> & in_diseqcMessage)68 ::ndk::ScopedAStatus TunerLnb::sendDiseqcMessage(const vector<uint8_t>& in_diseqcMessage) {
69     return mLnb->sendDiseqcMessage(in_diseqcMessage);
70 }
71 
close()72 ::ndk::ScopedAStatus TunerLnb::close() {
73     return mLnb->close();
74 }
75 
76 /////////////// ILnbCallback ///////////////////////
onEvent(const LnbEventType lnbEventType)77 ::ndk::ScopedAStatus TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
78     if (mTunerLnbCallback != nullptr) {
79         mTunerLnbCallback->onEvent(lnbEventType);
80     }
81     return ndk::ScopedAStatus::ok();
82 }
83 
onDiseqcMessage(const vector<uint8_t> & diseqcMessage)84 ::ndk::ScopedAStatus TunerLnb::LnbCallback::onDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
85     if (mTunerLnbCallback != nullptr) {
86         mTunerLnbCallback->onDiseqcMessage(diseqcMessage);
87     }
88     return ndk::ScopedAStatus::ok();
89 }
90 
91 }  // namespace tuner
92 }  // namespace tv
93 }  // namespace media
94 }  // namespace android
95 }  // namespace aidl
96