Add TunerTimeFilter/Lnb interface and add openLnb in TunerService
Note that this CL also does some clean up on the namespace of
TunerService and TunerFrontend.
Also replaced the ITuner with IFrontend in TunerFrontend.
Test: make
Bug: 159067322
Change-Id: I3d32511a20b69b323331471c222762aa306a8eab
diff --git a/services/tuner/TunerLnb.cpp b/services/tuner/TunerLnb.cpp
new file mode 100644
index 0000000..18aa11e
--- /dev/null
+++ b/services/tuner/TunerLnb.cpp
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TunerLnb"
+
+#include "TunerLnb.h"
+
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+namespace android {
+
+TunerLnb::TunerLnb(sp<ILnb> lnb, int id) {
+ mLnb = lnb;
+ mId = id;
+}
+
+TunerLnb::~TunerLnb() {
+ mLnb = NULL;
+ mId = -1;
+}
+
+Status TunerLnb::setCallback(
+ const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) {
+ if (mLnb == NULL) {
+ ALOGE("ILnb is not initialized");
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ if (tunerLnbCallback == NULL) {
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ }
+
+ sp<ILnbCallback> lnbCallback = new LnbCallback(tunerLnbCallback);
+ Result status = mLnb->setCallback(lnbCallback);
+ if (status == Result::SUCCESS) {
+ return Status::ok();
+ }
+
+ return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+}
+
+Status TunerLnb::setVoltage(int /*voltage*/) {
+ return Status::ok();
+}
+
+Status TunerLnb::setTone(int /*voltage*/) {
+ return Status::ok();
+}
+
+Status TunerLnb::setSatellitePosition(int /*position*/) {
+ return Status::ok();
+}
+
+Status TunerLnb::sendDiseqcMessage(const vector<uint8_t>& /*diseqcMessage*/) {
+ return Status::ok();
+}
+
+Status TunerLnb::close() {
+ return Status::ok();
+}
+
+/////////////// ILnbCallback ///////////////////////
+
+Return<void> TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
+ if (mTunerLnbCallback != NULL) {
+ mTunerLnbCallback->onEvent((int)lnbEventType);
+ }
+ return Void();
+}
+
+Return<void> TunerLnb::LnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
+ if (mTunerLnbCallback != NULL && diseqcMessage != NULL) {
+ vector<uint8_t> msg(begin(diseqcMessage), end(diseqcMessage));
+ mTunerLnbCallback->onDiseqcMessage(msg);
+ }
+ return Void();
+}
+} // namespace android