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_NDEBUG 0
18 #define LOG_TAG "android.hardware.tv.tuner-service.example-Lnb"
19 
20 #include "Lnb.h"
21 #include <utils/Log.h>
22 
23 namespace aidl {
24 namespace android {
25 namespace hardware {
26 namespace tv {
27 namespace tuner {
28 
Lnb()29 Lnb::Lnb() {}
30 
Lnb(int id)31 Lnb::Lnb(int id) {
32     mId = id;
33 }
34 
~Lnb()35 Lnb::~Lnb() {}
36 
setCallback(const std::shared_ptr<ILnbCallback> & in_callback)37 ::ndk::ScopedAStatus Lnb::setCallback(const std::shared_ptr<ILnbCallback>& in_callback) {
38     ALOGV("%s", __FUNCTION__);
39 
40     mCallback = in_callback;
41 
42     return ::ndk::ScopedAStatus::ok();
43 }
44 
setVoltage(LnbVoltage)45 ::ndk::ScopedAStatus Lnb::setVoltage(LnbVoltage /* in_voltage */) {
46     ALOGV("%s", __FUNCTION__);
47 
48     return ::ndk::ScopedAStatus::ok();
49 }
50 
setTone(LnbTone)51 ::ndk::ScopedAStatus Lnb::setTone(LnbTone /* in_tone */) {
52     ALOGV("%s", __FUNCTION__);
53 
54     return ::ndk::ScopedAStatus::ok();
55 }
56 
setSatellitePosition(LnbPosition)57 ::ndk::ScopedAStatus Lnb::setSatellitePosition(LnbPosition /* in_position */) {
58     ALOGV("%s", __FUNCTION__);
59 
60     return ::ndk::ScopedAStatus::ok();
61 }
62 
sendDiseqcMessage(const std::vector<uint8_t> & in_diseqcMessage)63 ::ndk::ScopedAStatus Lnb::sendDiseqcMessage(const std::vector<uint8_t>& in_diseqcMessage) {
64     ALOGV("%s", __FUNCTION__);
65 
66     if (mCallback != nullptr) {
67         // The correct implementation should be to return the response from the
68         // device via onDiseqcMessage(). The below implementation is only to enable
69         // testing for LnbCallbacks.
70         ALOGV("[aidl] %s - this is for test purpose only, and must be replaced!", __FUNCTION__);
71         mCallback->onDiseqcMessage(in_diseqcMessage);
72     }
73 
74     return ::ndk::ScopedAStatus::ok();
75 }
76 
close()77 ::ndk::ScopedAStatus Lnb::close() {
78     ALOGV("%s", __FUNCTION__);
79 
80     return ::ndk::ScopedAStatus::ok();
81 }
82 
getId()83 int Lnb::getId() {
84     return mId;
85 }
86 
87 }  // namespace tuner
88 }  // namespace tv
89 }  // namespace hardware
90 }  // namespace android
91 }  // namespace aidl
92