2017-02-08 02:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 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.
|
|
|
|
*/
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
#define LOG_TAG "BroadcastRadioDefault.tuner"
|
|
|
|
#define LOG_NDEBUG 0
|
2017-02-08 02:38:21 +01:00
|
|
|
|
|
|
|
#include "Tuner.h"
|
2018-02-08 22:42:31 +01:00
|
|
|
#include "BroadcastRadio.h"
|
2017-06-22 19:45:33 +02:00
|
|
|
|
2017-12-04 18:53:32 +01:00
|
|
|
#include <broadcastradio-utils-1x/Utils.h>
|
2017-06-22 19:45:33 +02:00
|
|
|
#include <log/log.h>
|
2017-02-08 02:38:21 +01:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace hardware {
|
|
|
|
namespace broadcastradio {
|
2018-02-08 22:42:31 +01:00
|
|
|
namespace V1_1 {
|
2017-02-08 02:38:21 +01:00
|
|
|
namespace implementation {
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
using namespace std::chrono_literals;
|
2017-02-08 02:38:21 +01:00
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
using V1_0::Band;
|
|
|
|
using V1_0::BandConfig;
|
2017-07-28 19:08:46 +02:00
|
|
|
using V1_0::Class;
|
2017-06-22 19:45:33 +02:00
|
|
|
using V1_0::Direction;
|
2018-02-08 22:42:31 +01:00
|
|
|
using V1_1::IdentifierType;
|
2017-09-14 18:43:35 +02:00
|
|
|
using V1_1::ProgramInfo;
|
|
|
|
using V1_1::ProgramInfoFlags;
|
|
|
|
using V1_1::ProgramListResult;
|
|
|
|
using V1_1::ProgramSelector;
|
|
|
|
using V1_1::ProgramType;
|
|
|
|
using V1_1::VendorKeyValue;
|
2017-07-27 22:17:07 +02:00
|
|
|
using utils::HalRevision;
|
2017-06-22 19:45:33 +02:00
|
|
|
|
|
|
|
using std::chrono::milliseconds;
|
|
|
|
using std::lock_guard;
|
|
|
|
using std::move;
|
|
|
|
using std::mutex;
|
|
|
|
using std::sort;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
const struct {
|
|
|
|
milliseconds config = 50ms;
|
|
|
|
milliseconds scan = 200ms;
|
|
|
|
milliseconds step = 100ms;
|
|
|
|
milliseconds tune = 150ms;
|
|
|
|
} gDefaultDelay;
|
|
|
|
|
2018-03-07 23:28:55 +01:00
|
|
|
Tuner::Tuner(const sp<BroadcastRadio> module, V1_0::Class classId,
|
|
|
|
const sp<V1_0::ITunerCallback>& callback)
|
|
|
|
: mModule(module),
|
|
|
|
mClassId(classId),
|
2017-07-28 19:08:46 +02:00
|
|
|
mCallback(callback),
|
2017-09-14 18:43:35 +02:00
|
|
|
mCallback1_1(V1_1::ITunerCallback::castFrom(callback).withDefault(nullptr)),
|
2017-07-28 19:08:46 +02:00
|
|
|
mVirtualRadio(getRadio(classId)),
|
2017-07-27 22:17:07 +02:00
|
|
|
mIsAnalogForced(false) {}
|
2017-02-08 02:38:21 +01:00
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
void Tuner::forceClose() {
|
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
mIsClosed = true;
|
|
|
|
mThread.cancelAll();
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2018-03-07 23:28:55 +01:00
|
|
|
void Tuner::setConfigurationInternalLocked(const BandConfig& config) {
|
|
|
|
mAmfmConfig = config;
|
|
|
|
mAmfmConfig.antennaConnected = true;
|
|
|
|
mCurrentProgram = utils::make_selector(mAmfmConfig.type, mAmfmConfig.lowerLimit);
|
|
|
|
|
|
|
|
if (utils::isFm(mAmfmConfig.type)) {
|
|
|
|
mVirtualRadio = std::ref(getFmRadio());
|
|
|
|
} else {
|
|
|
|
mVirtualRadio = std::ref(getAmRadio());
|
|
|
|
}
|
|
|
|
|
|
|
|
mIsAmfmConfigSet = true;
|
|
|
|
mCallback->configChange(Result::OK, mAmfmConfig);
|
2018-03-29 02:48:18 +02:00
|
|
|
if (mCallback1_1 != nullptr) mCallback1_1->programListChanged();
|
2018-03-07 23:28:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Tuner::autoConfigureLocked(uint64_t frequency) {
|
|
|
|
for (auto&& config : mModule->getAmFmBands()) {
|
|
|
|
// The check here is rather poor, but it's enough for default implementation.
|
|
|
|
if (config.lowerLimit <= frequency && config.upperLimit >= frequency) {
|
|
|
|
ALOGI("Auto-switching band to %s", toString(config).c_str());
|
|
|
|
setConfigurationInternalLocked(config);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
Return<Result> Tuner::setConfiguration(const BandConfig& config) {
|
|
|
|
ALOGV("%s", __func__);
|
2017-07-25 23:55:49 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
2017-07-28 19:08:46 +02:00
|
|
|
if (mClassId != Class::AM_FM) {
|
|
|
|
ALOGE("Can't set AM/FM configuration on SAT/DT radio tuner");
|
|
|
|
return Result::INVALID_STATE;
|
|
|
|
}
|
2017-02-08 02:38:21 +01:00
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
if (config.lowerLimit >= config.upperLimit) return Result::INVALID_ARGUMENTS;
|
|
|
|
|
|
|
|
auto task = [this, config]() {
|
|
|
|
ALOGI("Setting AM/FM config");
|
|
|
|
lock_guard<mutex> lk(mMut);
|
2018-03-07 23:28:55 +01:00
|
|
|
setConfigurationInternalLocked(config);
|
2017-06-22 19:45:33 +02:00
|
|
|
};
|
|
|
|
mThread.schedule(task, gDefaultDelay.config);
|
|
|
|
|
|
|
|
return Result::OK;
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
Return<void> Tuner::getConfiguration(getConfiguration_cb _hidl_cb) {
|
|
|
|
ALOGV("%s", __func__);
|
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-25 23:55:49 +02:00
|
|
|
|
|
|
|
if (!mIsClosed && mIsAmfmConfigSet) {
|
2017-06-22 19:45:33 +02:00
|
|
|
_hidl_cb(Result::OK, mAmfmConfig);
|
|
|
|
} else {
|
|
|
|
_hidl_cb(Result::NOT_INITIALIZED, {});
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
2017-07-25 23:55:49 +02:00
|
|
|
return {};
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
// makes ProgramInfo that points to no program
|
|
|
|
static ProgramInfo makeDummyProgramInfo(const ProgramSelector& selector) {
|
2017-06-22 19:45:33 +02:00
|
|
|
ProgramInfo info11 = {};
|
|
|
|
auto& info10 = info11.base;
|
|
|
|
|
2017-07-12 23:17:09 +02:00
|
|
|
utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
|
2017-07-05 20:23:30 +02:00
|
|
|
info11.selector = selector;
|
2017-06-22 19:45:33 +02:00
|
|
|
info11.flags |= ProgramInfoFlags::MUTED;
|
|
|
|
|
|
|
|
return info11;
|
|
|
|
}
|
2017-02-08 02:38:21 +01:00
|
|
|
|
2017-07-27 22:17:07 +02:00
|
|
|
HalRevision Tuner::getHalRev() const {
|
2018-02-08 22:42:31 +01:00
|
|
|
if (mCallback1_1 != nullptr) {
|
2017-07-27 22:17:07 +02:00
|
|
|
return HalRevision::V1_1;
|
|
|
|
} else {
|
|
|
|
return HalRevision::V1_0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
void Tuner::tuneInternalLocked(const ProgramSelector& sel) {
|
2017-06-22 19:45:33 +02:00
|
|
|
VirtualProgram virtualProgram;
|
2017-07-28 19:08:46 +02:00
|
|
|
if (mVirtualRadio.get().getProgram(sel, virtualProgram)) {
|
2017-07-05 20:23:30 +02:00
|
|
|
mCurrentProgram = virtualProgram.selector;
|
2017-07-27 22:17:07 +02:00
|
|
|
mCurrentProgramInfo = virtualProgram.getProgramInfo(getHalRev());
|
2017-06-22 19:45:33 +02:00
|
|
|
} else {
|
2017-07-05 20:23:30 +02:00
|
|
|
mCurrentProgram = sel;
|
|
|
|
mCurrentProgramInfo = makeDummyProgramInfo(sel);
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
2017-06-22 19:45:33 +02:00
|
|
|
mIsTuneCompleted = true;
|
2017-02-08 02:38:21 +01:00
|
|
|
|
2017-07-14 00:51:21 +02:00
|
|
|
if (mCallback1_1 == nullptr) {
|
|
|
|
mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base);
|
|
|
|
} else {
|
|
|
|
mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo.selector);
|
2017-08-04 03:08:57 +02:00
|
|
|
mCallback1_1->currentProgramInfoChanged(mCurrentProgramInfo);
|
2017-06-22 19:45:33 +02:00
|
|
|
}
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
Return<Result> Tuner::scan(Direction direction, bool skipSubChannel __unused) {
|
|
|
|
ALOGV("%s", __func__);
|
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-25 23:55:49 +02:00
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
|
|
|
|
2017-07-28 19:08:46 +02:00
|
|
|
auto list = mVirtualRadio.get().getProgramList();
|
2017-02-08 02:38:21 +01:00
|
|
|
|
2017-07-07 22:28:00 +02:00
|
|
|
if (list.empty()) {
|
2017-06-22 19:45:33 +02:00
|
|
|
mIsTuneCompleted = false;
|
|
|
|
auto task = [this, direction]() {
|
|
|
|
ALOGI("Performing failed scan %s", toString(direction).c_str());
|
|
|
|
|
2017-07-14 00:51:21 +02:00
|
|
|
if (mCallback1_1 == nullptr) {
|
|
|
|
mCallback->tuneComplete(Result::TIMEOUT, {});
|
|
|
|
} else {
|
2017-06-22 19:45:33 +02:00
|
|
|
mCallback1_1->tuneComplete_1_1(Result::TIMEOUT, {});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
mThread.schedule(task, gDefaultDelay.scan);
|
|
|
|
|
|
|
|
return Result::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not optimal (O(sort) instead of O(n)), but not a big deal here;
|
|
|
|
// also, it's likely that list is already sorted (so O(n) anyway).
|
|
|
|
sort(list.begin(), list.end());
|
|
|
|
auto current = mCurrentProgram;
|
|
|
|
auto found = lower_bound(list.begin(), list.end(), VirtualProgram({current}));
|
|
|
|
if (direction == Direction::UP) {
|
|
|
|
if (found < list.end() - 1) {
|
2017-07-05 20:23:30 +02:00
|
|
|
if (utils::tunesTo(current, found->selector)) found++;
|
2017-06-22 19:45:33 +02:00
|
|
|
} else {
|
|
|
|
found = list.begin();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (found > list.begin() && found != list.end()) {
|
|
|
|
found--;
|
|
|
|
} else {
|
|
|
|
found = list.end() - 1;
|
|
|
|
}
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
2017-07-05 20:23:30 +02:00
|
|
|
auto tuneTo = found->selector;
|
2017-06-22 19:45:33 +02:00
|
|
|
|
|
|
|
mIsTuneCompleted = false;
|
|
|
|
auto task = [this, tuneTo, direction]() {
|
|
|
|
ALOGI("Performing scan %s", toString(direction).c_str());
|
|
|
|
|
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-05 20:23:30 +02:00
|
|
|
tuneInternalLocked(tuneTo);
|
2017-06-22 19:45:33 +02:00
|
|
|
};
|
|
|
|
mThread.schedule(task, gDefaultDelay.scan);
|
|
|
|
|
|
|
|
return Result::OK;
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
Return<Result> Tuner::step(Direction direction, bool skipSubChannel) {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s", __func__);
|
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-25 23:55:49 +02:00
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
|
|
|
|
|
|
|
ALOGW_IF(!skipSubChannel, "can't step to next frequency without ignoring subChannel");
|
2017-07-05 20:23:30 +02:00
|
|
|
|
|
|
|
if (!utils::isAmFm(utils::getType(mCurrentProgram))) {
|
|
|
|
ALOGE("Can't step in anything else than AM/FM");
|
|
|
|
return Result::NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
|
2017-07-31 23:28:04 +02:00
|
|
|
if (!mIsAmfmConfigSet) {
|
|
|
|
ALOGW("AM/FM config not set");
|
|
|
|
return Result::INVALID_STATE;
|
|
|
|
}
|
2017-06-22 19:45:33 +02:00
|
|
|
mIsTuneCompleted = false;
|
|
|
|
|
|
|
|
auto task = [this, direction]() {
|
|
|
|
ALOGI("Performing step %s", toString(direction).c_str());
|
|
|
|
|
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
auto current = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY, 0);
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
if (direction == Direction::UP) {
|
2017-07-05 20:23:30 +02:00
|
|
|
current += mAmfmConfig.spacings[0];
|
2017-06-22 19:45:33 +02:00
|
|
|
} else {
|
2017-07-05 20:23:30 +02:00
|
|
|
current -= mAmfmConfig.spacings[0];
|
2017-06-22 19:45:33 +02:00
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
if (current > mAmfmConfig.upperLimit) current = mAmfmConfig.lowerLimit;
|
|
|
|
if (current < mAmfmConfig.lowerLimit) current = mAmfmConfig.upperLimit;
|
2017-06-22 19:45:33 +02:00
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
tuneInternalLocked(utils::make_selector(mAmfmConfig.type, current));
|
2017-06-22 19:45:33 +02:00
|
|
|
};
|
|
|
|
mThread.schedule(task, gDefaultDelay.step);
|
|
|
|
|
|
|
|
return Result::OK;
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
Return<Result> Tuner::tune(uint32_t channel, uint32_t subChannel) {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s(%d, %d)", __func__, channel, subChannel);
|
2017-07-05 20:23:30 +02:00
|
|
|
Band band;
|
|
|
|
{
|
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
band = mAmfmConfig.type;
|
|
|
|
}
|
2017-08-01 19:52:18 +02:00
|
|
|
return tuneByProgramSelector(utils::make_selector(band, channel, subChannel));
|
2017-07-05 20:23:30 +02:00
|
|
|
}
|
|
|
|
|
2017-08-01 19:52:18 +02:00
|
|
|
Return<Result> Tuner::tuneByProgramSelector(const ProgramSelector& sel) {
|
2017-07-05 20:23:30 +02:00
|
|
|
ALOGV("%s(%s)", __func__, toString(sel).c_str());
|
2017-06-22 19:45:33 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-25 23:55:49 +02:00
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
2017-07-05 20:23:30 +02:00
|
|
|
|
2017-07-31 23:28:04 +02:00
|
|
|
// checking if ProgramSelector is valid
|
|
|
|
auto programType = utils::getType(sel);
|
|
|
|
if (utils::isAmFm(programType)) {
|
|
|
|
if (!mIsAmfmConfigSet) {
|
|
|
|
ALOGW("AM/FM config not set");
|
|
|
|
return Result::INVALID_STATE;
|
|
|
|
}
|
2017-07-05 20:23:30 +02:00
|
|
|
|
|
|
|
auto freq = utils::getId(sel, IdentifierType::AMFM_FREQUENCY);
|
|
|
|
if (freq < mAmfmConfig.lowerLimit || freq > mAmfmConfig.upperLimit) {
|
2018-03-07 23:28:55 +01:00
|
|
|
if (!autoConfigureLocked(freq)) return Result::INVALID_ARGUMENTS;
|
2017-07-05 20:23:30 +02:00
|
|
|
}
|
2017-07-31 23:28:04 +02:00
|
|
|
} else if (programType == ProgramType::DAB) {
|
2018-02-08 22:42:31 +01:00
|
|
|
if (!utils::hasId(sel, IdentifierType::DAB_SIDECC)) return Result::INVALID_ARGUMENTS;
|
2017-07-31 23:28:04 +02:00
|
|
|
} else if (programType == ProgramType::DRMO) {
|
|
|
|
if (!utils::hasId(sel, IdentifierType::DRMO_SERVICE_ID)) return Result::INVALID_ARGUMENTS;
|
|
|
|
} else if (programType == ProgramType::SXM) {
|
|
|
|
if (!utils::hasId(sel, IdentifierType::SXM_SERVICE_ID)) return Result::INVALID_ARGUMENTS;
|
|
|
|
} else {
|
|
|
|
return Result::INVALID_ARGUMENTS;
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
2017-06-22 19:45:33 +02:00
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
mIsTuneCompleted = false;
|
|
|
|
auto task = [this, sel]() {
|
2017-06-22 19:45:33 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-05 20:23:30 +02:00
|
|
|
tuneInternalLocked(sel);
|
2017-06-22 19:45:33 +02:00
|
|
|
};
|
|
|
|
mThread.schedule(task, gDefaultDelay.tune);
|
|
|
|
|
|
|
|
return Result::OK;
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
Return<Result> Tuner::cancel() {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s", __func__);
|
2017-07-25 23:55:49 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
mThread.cancelAll();
|
|
|
|
return Result::OK;
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-07-14 19:44:52 +02:00
|
|
|
Return<Result> Tuner::cancelAnnouncement() {
|
|
|
|
ALOGV("%s", __func__);
|
2017-07-25 23:55:49 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
|
|
|
|
2017-07-14 19:44:52 +02:00
|
|
|
return Result::OK;
|
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
Return<void> Tuner::getProgramInformation(getProgramInformation_cb _hidl_cb) {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s", __func__);
|
2017-09-14 18:43:35 +02:00
|
|
|
return getProgramInformation_1_1(
|
|
|
|
[&](Result result, const ProgramInfo& info) { _hidl_cb(result, info.base); });
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-07-05 20:23:30 +02:00
|
|
|
Return<void> Tuner::getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s", __func__);
|
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-25 23:55:49 +02:00
|
|
|
|
|
|
|
if (mIsClosed) {
|
|
|
|
_hidl_cb(Result::NOT_INITIALIZED, {});
|
|
|
|
} else if (mIsTuneCompleted) {
|
2017-06-22 19:45:33 +02:00
|
|
|
_hidl_cb(Result::OK, mCurrentProgramInfo);
|
|
|
|
} else {
|
|
|
|
_hidl_cb(Result::NOT_INITIALIZED, makeDummyProgramInfo(mCurrentProgram));
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
2017-07-25 23:55:49 +02:00
|
|
|
return {};
|
2017-02-08 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
2017-03-13 22:30:15 +01:00
|
|
|
Return<ProgramListResult> Tuner::startBackgroundScan() {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s", __func__);
|
2017-07-25 23:55:49 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
if (mIsClosed) return ProgramListResult::NOT_INITIALIZED;
|
|
|
|
|
2018-01-09 00:37:09 +01:00
|
|
|
if (mCallback1_1 != nullptr) {
|
|
|
|
mCallback1_1->backgroundScanComplete(ProgramListResult::OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ProgramListResult::OK;
|
2017-03-13 22:30:15 +01:00
|
|
|
}
|
|
|
|
|
2017-08-03 20:06:09 +02:00
|
|
|
Return<void> Tuner::getProgramList(const hidl_vec<VendorKeyValue>& vendorFilter,
|
|
|
|
getProgramList_cb _hidl_cb) {
|
|
|
|
ALOGV("%s(%s)", __func__, toString(vendorFilter).substr(0, 100).c_str());
|
2017-07-07 22:28:00 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
2017-07-25 23:55:49 +02:00
|
|
|
if (mIsClosed) {
|
|
|
|
_hidl_cb(ProgramListResult::NOT_INITIALIZED, {});
|
|
|
|
return {};
|
|
|
|
}
|
2017-06-22 19:45:33 +02:00
|
|
|
|
2017-07-28 19:08:46 +02:00
|
|
|
auto list = mVirtualRadio.get().getProgramList();
|
2017-07-07 22:28:00 +02:00
|
|
|
ALOGD("returning a list of %zu programs", list.size());
|
2017-07-27 22:17:07 +02:00
|
|
|
_hidl_cb(ProgramListResult::OK, getProgramInfoVector(list, getHalRev()));
|
2017-07-25 23:55:49 +02:00
|
|
|
return {};
|
2017-03-01 23:21:07 +01:00
|
|
|
}
|
|
|
|
|
2017-08-01 19:52:18 +02:00
|
|
|
Return<Result> Tuner::setAnalogForced(bool isForced) {
|
|
|
|
ALOGV("%s", __func__);
|
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
if (mIsClosed) return Result::NOT_INITIALIZED;
|
|
|
|
|
|
|
|
mIsAnalogForced = isForced;
|
|
|
|
return Result::OK;
|
|
|
|
}
|
|
|
|
|
2017-03-27 23:29:16 +02:00
|
|
|
Return<void> Tuner::isAnalogForced(isAnalogForced_cb _hidl_cb) {
|
2017-06-22 19:45:33 +02:00
|
|
|
ALOGV("%s", __func__);
|
2017-07-25 23:55:49 +02:00
|
|
|
lock_guard<mutex> lk(mMut);
|
|
|
|
|
|
|
|
if (mIsClosed) {
|
|
|
|
_hidl_cb(Result::NOT_INITIALIZED, false);
|
|
|
|
} else {
|
|
|
|
_hidl_cb(Result::OK, mIsAnalogForced);
|
|
|
|
}
|
|
|
|
return {};
|
2017-03-27 23:29:16 +02:00
|
|
|
}
|
|
|
|
|
2017-06-22 19:45:33 +02:00
|
|
|
} // namespace implementation
|
2018-02-08 22:42:31 +01:00
|
|
|
} // namespace V1_1
|
2017-02-08 02:38:21 +01:00
|
|
|
} // namespace broadcastradio
|
|
|
|
} // namespace hardware
|
|
|
|
} // namespace android
|