blob: 3dcc2b1ebd418c061b68d7f5ab9cf607cd298008 [file] [log] [blame]
Amy126ee922019-08-09 16:25:12 -07001/*
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
23namespace android {
24namespace hardware {
25namespace tv {
26namespace tuner {
27namespace V1_0 {
28namespace implementation {
29
30Frontend::Frontend() {
31 // Init callback to nullptr
32 mCallback = nullptr;
33}
34
35Frontend::Frontend(FrontendType type, FrontendId id) {
36 mType = type;
37 mId = id;
38 // Init callback to nullptr
39 mCallback = nullptr;
40}
41
42Frontend::~Frontend() {}
43
44Return<Result> Frontend::close() {
45 ALOGV("%s", __FUNCTION__);
46 // Reset callback
47 mCallback = nullptr;
48
49 return Result::SUCCESS;
50}
51
52Return<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
63Return<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
74Return<Result> Frontend::stopTune() {
75 ALOGV("%s", __FUNCTION__);
76
77 return Result::SUCCESS;
78}
79
80FrontendType Frontend::getFrontendType() {
81 return mType;
82}
83
84FrontendId Frontend::getFrontendId() {
85 return mId;
86}
87
88} // namespace implementation
89} // namespace V1_0
90} // namespace tuner
91} // namespace tv
92} // namespace hardware
93} // namespace android