Amy | 126ee92 | 2019-08-09 16:25:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 "android.hardware.tv.tuner@1.0-Frontend" |
| 18 | |
| 19 | #include "Frontend.h" |
| 20 | #include <android/hardware/tv/tuner/1.0/IFrontendCallback.h> |
| 21 | #include <utils/Log.h> |
| 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace tv { |
| 26 | namespace tuner { |
| 27 | namespace V1_0 { |
| 28 | namespace implementation { |
| 29 | |
| 30 | Frontend::Frontend() { |
| 31 | // Init callback to nullptr |
| 32 | mCallback = nullptr; |
| 33 | } |
| 34 | |
| 35 | Frontend::Frontend(FrontendType type, FrontendId id) { |
| 36 | mType = type; |
| 37 | mId = id; |
| 38 | // Init callback to nullptr |
| 39 | mCallback = nullptr; |
| 40 | } |
| 41 | |
| 42 | Frontend::~Frontend() {} |
| 43 | |
| 44 | Return<Result> Frontend::close() { |
| 45 | ALOGV("%s", __FUNCTION__); |
| 46 | // Reset callback |
| 47 | mCallback = nullptr; |
| 48 | |
| 49 | return Result::SUCCESS; |
| 50 | } |
| 51 | |
| 52 | Return<Result> Frontend::setCallback(const sp<IFrontendCallback>& callback) { |
| 53 | ALOGV("%s", __FUNCTION__); |
| 54 | if (callback == nullptr) { |
| 55 | ALOGW("[ WARN ] Set Frontend callback with nullptr"); |
| 56 | return Result::INVALID_ARGUMENT; |
| 57 | } |
| 58 | |
| 59 | mCallback = callback; |
| 60 | return Result::SUCCESS; |
| 61 | } |
| 62 | |
| 63 | Return<Result> Frontend::tune(const FrontendSettings& /* settings */) { |
| 64 | ALOGV("%s", __FUNCTION__); |
| 65 | if (mCallback == nullptr) { |
| 66 | ALOGW("[ WARN ] Frontend callback is not set when tune"); |
| 67 | return Result::INVALID_STATE; |
| 68 | } |
| 69 | |
| 70 | mCallback->onEvent(FrontendEventType::NO_SIGNAL); |
| 71 | return Result::SUCCESS; |
| 72 | } |
| 73 | |
| 74 | Return<Result> Frontend::stopTune() { |
| 75 | ALOGV("%s", __FUNCTION__); |
| 76 | |
| 77 | return Result::SUCCESS; |
| 78 | } |
| 79 | |
Amy | 016b731 | 2019-09-16 15:51:28 -0700 | [diff] [blame] | 80 | Return<Result> Frontend::scan(const FrontendSettings& /* settings */, FrontendScanType /* type */) { |
| 81 | ALOGV("%s", __FUNCTION__); |
| 82 | |
| 83 | return Result::SUCCESS; |
| 84 | } |
| 85 | |
| 86 | Return<Result> Frontend::stopScan() { |
| 87 | ALOGV("%s", __FUNCTION__); |
| 88 | |
| 89 | return Result::SUCCESS; |
| 90 | } |
| 91 | |
| 92 | Return<void> Frontend::getStatus(const hidl_vec<FrontendStatusType>& /* statusTypes */, |
| 93 | getStatus_cb _hidl_cb) { |
| 94 | ALOGV("%s", __FUNCTION__); |
| 95 | |
| 96 | vector<FrontendStatus> statuses; |
| 97 | _hidl_cb(Result::SUCCESS, statuses); |
| 98 | |
| 99 | return Void(); |
| 100 | } |
| 101 | |
| 102 | Return<Result> Frontend::setLna(bool /* bEnable */) { |
| 103 | ALOGV("%s", __FUNCTION__); |
| 104 | |
| 105 | return Result::SUCCESS; |
| 106 | } |
| 107 | |
Amy | 42a5b4b | 2019-10-03 16:49:48 -0700 | [diff] [blame^] | 108 | Return<Result> Frontend::setLnb(uint32_t /* lnb */) { |
Amy | 016b731 | 2019-09-16 15:51:28 -0700 | [diff] [blame] | 109 | ALOGV("%s", __FUNCTION__); |
| 110 | |
| 111 | return Result::SUCCESS; |
| 112 | } |
| 113 | |
Amy | 126ee92 | 2019-08-09 16:25:12 -0700 | [diff] [blame] | 114 | FrontendType Frontend::getFrontendType() { |
| 115 | return mType; |
| 116 | } |
| 117 | |
| 118 | FrontendId Frontend::getFrontendId() { |
| 119 | return mId; |
| 120 | } |
| 121 | |
| 122 | } // namespace implementation |
| 123 | } // namespace V1_0 |
| 124 | } // namespace tuner |
| 125 | } // namespace tv |
| 126 | } // namespace hardware |
| 127 | } // namespace android |