Branch out Broadcast Radio 1.2 HAL.
Bug: 62945293
Change-Id: Ic84f9fe6c17040053257085801208ed527fd07ab
Fixes: 64115813
Test: instrumentation, VTS
diff --git a/broadcastradio/1.1/default/Android.bp b/broadcastradio/1.1/default/Android.bp
deleted file mode 100644
index 6d26b11..0000000
--- a/broadcastradio/1.1/default/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// 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.
-//
-
-cc_binary {
- name: "android.hardware.broadcastradio@1.1-service",
- init_rc: ["android.hardware.broadcastradio@1.1-service.rc"],
- vendor: true,
- relative_install_path: "hw",
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
- ],
- srcs: [
- "BroadcastRadio.cpp",
- "BroadcastRadioFactory.cpp",
- "Tuner.cpp",
- "VirtualProgram.cpp",
- "VirtualRadio.cpp",
- "service.cpp"
- ],
- static_libs: [
- "android.hardware.broadcastradio@1.1-utils-lib",
- ],
- shared_libs: [
- "android.hardware.broadcastradio@1.0",
- "android.hardware.broadcastradio@1.1",
- "libbase",
- "libhidlbase",
- "libhidltransport",
- "liblog",
- "libutils",
- ],
-}
diff --git a/broadcastradio/1.1/default/BroadcastRadio.cpp b/broadcastradio/1.1/default/BroadcastRadio.cpp
deleted file mode 100644
index 1bcfd82..0000000
--- a/broadcastradio/1.1/default/BroadcastRadio.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "BroadcastRadioDefault.module"
-#define LOG_NDEBUG 0
-
-#include "BroadcastRadio.h"
-
-#include <log/log.h>
-
-#include "resources.h"
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-using V1_0::Band;
-using V1_0::BandConfig;
-using V1_0::Class;
-using V1_0::Deemphasis;
-using V1_0::Rds;
-
-using std::lock_guard;
-using std::map;
-using std::mutex;
-using std::vector;
-
-// clang-format off
-static const map<Class, ModuleConfig> gModuleConfigs{
- {Class::AM_FM, ModuleConfig({
- "Digital radio mock",
- { // amFmBands
- AmFmBandConfig({
- Band::AM,
- 153, // lowerLimit
- 26100, // upperLimit
- {5, 9, 10}, // spacings
- }),
- AmFmBandConfig({
- Band::FM,
- 65800, // lowerLimit
- 108000, // upperLimit
- {10, 100, 200}, // spacings
- }),
- AmFmBandConfig({
- Band::AM_HD,
- 153, // lowerLimit
- 26100, // upperLimit
- {5, 9, 10}, // spacings
- }),
- AmFmBandConfig({
- Band::FM_HD,
- 87700, // lowerLimit
- 107900, // upperLimit
- {200}, // spacings
- }),
- },
- })},
-
- {Class::SAT, ModuleConfig({
- "Satellite radio mock",
- {}, // amFmBands
- })},
-};
-// clang-format on
-
-BroadcastRadio::BroadcastRadio(Class classId)
- : mClassId(classId), mConfig(gModuleConfigs.at(classId)) {}
-
-bool BroadcastRadio::isSupported(Class classId) {
- return gModuleConfigs.find(classId) != gModuleConfigs.end();
-}
-
-Return<void> BroadcastRadio::getProperties(getProperties_cb _hidl_cb) {
- ALOGV("%s", __func__);
- return getProperties_1_1(
- [&](const Properties& properties) { _hidl_cb(Result::OK, properties.base); });
-}
-
-Return<void> BroadcastRadio::getProperties_1_1(getProperties_1_1_cb _hidl_cb) {
- ALOGV("%s", __func__);
- Properties prop11 = {};
- auto& prop10 = prop11.base;
-
- prop10.classId = mClassId;
- prop10.implementor = "Google";
- prop10.product = mConfig.productName;
- prop10.numTuners = 1;
- prop10.numAudioSources = 1;
- prop10.supportsCapture = false;
- prop11.supportsBackgroundScanning = false;
- prop11.supportedProgramTypes = hidl_vec<uint32_t>({
- static_cast<uint32_t>(ProgramType::AM), static_cast<uint32_t>(ProgramType::FM),
- static_cast<uint32_t>(ProgramType::AM_HD), static_cast<uint32_t>(ProgramType::FM_HD),
- });
- prop11.supportedIdentifierTypes = hidl_vec<uint32_t>({
- static_cast<uint32_t>(IdentifierType::AMFM_FREQUENCY),
- static_cast<uint32_t>(IdentifierType::RDS_PI),
- static_cast<uint32_t>(IdentifierType::HD_STATION_ID_EXT),
- static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL),
- });
- prop11.vendorInfo = hidl_vec<VendorKeyValue>({
- {"com.google.dummy", "dummy"},
- });
-
- prop10.bands.resize(mConfig.amFmBands.size());
- for (size_t i = 0; i < mConfig.amFmBands.size(); i++) {
- auto& src = mConfig.amFmBands[i];
- auto& dst = prop10.bands[i];
-
- dst.type = src.type;
- dst.antennaConnected = true;
- dst.lowerLimit = src.lowerLimit;
- dst.upperLimit = src.upperLimit;
- dst.spacings = src.spacings;
-
- if (utils::isAm(src.type)) {
- dst.ext.am.stereo = true;
- } else if (utils::isFm(src.type)) {
- dst.ext.fm.deemphasis = static_cast<Deemphasis>(Deemphasis::D50 | Deemphasis::D75);
- dst.ext.fm.stereo = true;
- dst.ext.fm.rds = static_cast<Rds>(Rds::WORLD | Rds::US);
- dst.ext.fm.ta = true;
- dst.ext.fm.af = true;
- dst.ext.fm.ea = true;
- }
- }
-
- _hidl_cb(prop11);
- return Void();
-}
-
-Return<void> BroadcastRadio::openTuner(const BandConfig& config, bool audio __unused,
- const sp<V1_0::ITunerCallback>& callback,
- openTuner_cb _hidl_cb) {
- ALOGV("%s(%s)", __func__, toString(config.type).c_str());
- lock_guard<mutex> lk(mMut);
-
- auto oldTuner = mTuner.promote();
- if (oldTuner != nullptr) {
- ALOGI("Force-closing previously opened tuner");
- oldTuner->forceClose();
- mTuner = nullptr;
- }
-
- sp<Tuner> newTuner = new Tuner(mClassId, callback);
- mTuner = newTuner;
- if (mClassId == Class::AM_FM) {
- auto ret = newTuner->setConfiguration(config);
- if (ret != Result::OK) {
- _hidl_cb(Result::INVALID_ARGUMENTS, {});
- return Void();
- }
- }
-
- _hidl_cb(Result::OK, newTuner);
- return Void();
-}
-
-Return<void> BroadcastRadio::getImage(int32_t id, getImage_cb _hidl_cb) {
- ALOGV("%s(%x)", __func__, id);
-
- if (id == resources::demoPngId) {
- _hidl_cb(std::vector<uint8_t>(resources::demoPng, std::end(resources::demoPng)));
- return {};
- }
-
- ALOGI("Image %x doesn't exists", id);
- _hidl_cb({});
- return Void();
-}
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/default/BroadcastRadio.h b/broadcastradio/1.1/default/BroadcastRadio.h
deleted file mode 100644
index a96a2ab..0000000
--- a/broadcastradio/1.1/default/BroadcastRadio.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
-
-#include "Tuner.h"
-
-#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
-#include <android/hardware/broadcastradio/1.1/types.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-struct AmFmBandConfig {
- V1_0::Band type;
- uint32_t lowerLimit; // kHz
- uint32_t upperLimit; // kHz
- std::vector<uint32_t> spacings; // kHz
-};
-
-struct ModuleConfig {
- std::string productName;
- std::vector<AmFmBandConfig> amFmBands;
-};
-
-struct BroadcastRadio : public V1_1::IBroadcastRadio {
- /**
- * Constructs new broadcast radio module.
- *
- * Before calling a constructor with a given classId, it must be checked with isSupported
- * method first. Otherwise it results in undefined behaviour.
- *
- * @param classId type of a radio.
- */
- BroadcastRadio(V1_0::Class classId);
-
- /**
- * Checks, if a given radio type is supported.
- *
- * @param classId type of a radio.
- */
- static bool isSupported(V1_0::Class classId);
-
- // V1_1::IBroadcastRadio methods
- Return<void> getProperties(getProperties_cb _hidl_cb) override;
- Return<void> getProperties_1_1(getProperties_1_1_cb _hidl_cb) override;
- Return<void> openTuner(const V1_0::BandConfig& config, bool audio,
- const sp<V1_0::ITunerCallback>& callback,
- openTuner_cb _hidl_cb) override;
- Return<void> getImage(int32_t id, getImage_cb _hidl_cb);
-
- private:
- std::mutex mMut;
- V1_0::Class mClassId;
- ModuleConfig mConfig;
- wp<Tuner> mTuner;
-};
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
diff --git a/broadcastradio/1.1/default/BroadcastRadioFactory.cpp b/broadcastradio/1.1/default/BroadcastRadioFactory.cpp
deleted file mode 100644
index f57bc79..0000000
--- a/broadcastradio/1.1/default/BroadcastRadioFactory.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "BroadcastRadioDefault.factory"
-#define LOG_NDEBUG 0
-
-#include "BroadcastRadioFactory.h"
-
-#include "BroadcastRadio.h"
-
-#include <log/log.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-using V1_0::Class;
-
-using std::vector;
-
-static const vector<Class> gAllClasses = {
- Class::AM_FM, Class::SAT, Class::DT,
-};
-
-IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* name __unused) {
- return new BroadcastRadioFactory();
-}
-
-BroadcastRadioFactory::BroadcastRadioFactory() {
- for (auto&& classId : gAllClasses) {
- if (!BroadcastRadio::isSupported(classId)) continue;
- mRadioModules[classId] = new BroadcastRadio(classId);
- }
-}
-
-Return<void> BroadcastRadioFactory::connectModule(Class classId, connectModule_cb _hidl_cb) {
- ALOGV("%s(%s)", __func__, toString(classId).c_str());
-
- auto moduleIt = mRadioModules.find(classId);
- if (moduleIt == mRadioModules.end()) {
- _hidl_cb(Result::INVALID_ARGUMENTS, nullptr);
- } else {
- _hidl_cb(Result::OK, moduleIt->second);
- }
-
- return Void();
-}
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/default/BroadcastRadioFactory.h b/broadcastradio/1.1/default/BroadcastRadioFactory.h
deleted file mode 100644
index 8b67ac3..0000000
--- a/broadcastradio/1.1/default/BroadcastRadioFactory.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
-
-#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
-#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
-#include <android/hardware/broadcastradio/1.1/types.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-extern "C" IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* name);
-
-struct BroadcastRadioFactory : public IBroadcastRadioFactory {
- BroadcastRadioFactory();
-
- // V1_0::IBroadcastRadioFactory methods
- Return<void> connectModule(V1_0::Class classId, connectModule_cb _hidl_cb) override;
-
- private:
- std::map<V1_0::Class, sp<IBroadcastRadio>> mRadioModules;
-};
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
diff --git a/broadcastradio/1.1/default/OWNERS b/broadcastradio/1.1/default/OWNERS
deleted file mode 100644
index 0c27b71..0000000
--- a/broadcastradio/1.1/default/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-# Automotive team
-egranata@google.com
-keunyoung@google.com
-twasilczyk@google.com
diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp
deleted file mode 100644
index 9a34cb1..0000000
--- a/broadcastradio/1.1/default/Tuner.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * 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.
- */
-
-#define LOG_TAG "BroadcastRadioDefault.tuner"
-#define LOG_NDEBUG 0
-
-#include "BroadcastRadio.h"
-#include "Tuner.h"
-
-#include <broadcastradio-utils/Utils.h>
-#include <log/log.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-using namespace std::chrono_literals;
-
-using V1_0::Band;
-using V1_0::BandConfig;
-using V1_0::Class;
-using V1_0::Direction;
-using utils::HalRevision;
-
-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;
-
-Tuner::Tuner(V1_0::Class classId, const sp<V1_0::ITunerCallback>& callback)
- : mClassId(classId),
- mCallback(callback),
- mCallback1_1(ITunerCallback::castFrom(callback).withDefault(nullptr)),
- mVirtualRadio(getRadio(classId)),
- mIsAnalogForced(false) {}
-
-void Tuner::forceClose() {
- lock_guard<mutex> lk(mMut);
- mIsClosed = true;
- mThread.cancelAll();
-}
-
-Return<Result> Tuner::setConfiguration(const BandConfig& config) {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return Result::NOT_INITIALIZED;
- if (mClassId != Class::AM_FM) {
- ALOGE("Can't set AM/FM configuration on SAT/DT radio tuner");
- return Result::INVALID_STATE;
- }
-
- if (config.lowerLimit >= config.upperLimit) return Result::INVALID_ARGUMENTS;
-
- auto task = [this, config]() {
- ALOGI("Setting AM/FM config");
- lock_guard<mutex> lk(mMut);
-
- mAmfmConfig = move(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);
- };
- mThread.schedule(task, gDefaultDelay.config);
-
- return Result::OK;
-}
-
-Return<void> Tuner::getConfiguration(getConfiguration_cb _hidl_cb) {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
-
- if (!mIsClosed && mIsAmfmConfigSet) {
- _hidl_cb(Result::OK, mAmfmConfig);
- } else {
- _hidl_cb(Result::NOT_INITIALIZED, {});
- }
- return {};
-}
-
-// makes ProgramInfo that points to no program
-static ProgramInfo makeDummyProgramInfo(const ProgramSelector& selector) {
- ProgramInfo info11 = {};
- auto& info10 = info11.base;
-
- utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
- info11.selector = selector;
- info11.flags |= ProgramInfoFlags::MUTED;
-
- return info11;
-}
-
-HalRevision Tuner::getHalRev() const {
- if (mCallback1_1 != nullptr) {
- return HalRevision::V1_1;
- } else {
- return HalRevision::V1_0;
- }
-}
-
-void Tuner::tuneInternalLocked(const ProgramSelector& sel) {
- VirtualProgram virtualProgram;
- if (mVirtualRadio.get().getProgram(sel, virtualProgram)) {
- mCurrentProgram = virtualProgram.selector;
- mCurrentProgramInfo = virtualProgram.getProgramInfo(getHalRev());
- } else {
- mCurrentProgram = sel;
- mCurrentProgramInfo = makeDummyProgramInfo(sel);
- }
- mIsTuneCompleted = true;
-
- if (mCallback1_1 == nullptr) {
- mCallback->tuneComplete(Result::OK, mCurrentProgramInfo.base);
- } else {
- mCallback1_1->tuneComplete_1_1(Result::OK, mCurrentProgramInfo.selector);
- mCallback1_1->currentProgramInfoChanged(mCurrentProgramInfo);
- }
-}
-
-Return<Result> Tuner::scan(Direction direction, bool skipSubChannel __unused) {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return Result::NOT_INITIALIZED;
-
- auto list = mVirtualRadio.get().getProgramList();
-
- if (list.empty()) {
- mIsTuneCompleted = false;
- auto task = [this, direction]() {
- ALOGI("Performing failed scan %s", toString(direction).c_str());
-
- if (mCallback1_1 == nullptr) {
- mCallback->tuneComplete(Result::TIMEOUT, {});
- } else {
- 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) {
- if (utils::tunesTo(current, found->selector)) found++;
- } else {
- found = list.begin();
- }
- } else {
- if (found > list.begin() && found != list.end()) {
- found--;
- } else {
- found = list.end() - 1;
- }
- }
- auto tuneTo = found->selector;
-
- mIsTuneCompleted = false;
- auto task = [this, tuneTo, direction]() {
- ALOGI("Performing scan %s", toString(direction).c_str());
-
- lock_guard<mutex> lk(mMut);
- tuneInternalLocked(tuneTo);
- };
- mThread.schedule(task, gDefaultDelay.scan);
-
- return Result::OK;
-}
-
-Return<Result> Tuner::step(Direction direction, bool skipSubChannel) {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return Result::NOT_INITIALIZED;
-
- ALOGW_IF(!skipSubChannel, "can't step to next frequency without ignoring subChannel");
-
- if (!utils::isAmFm(utils::getType(mCurrentProgram))) {
- ALOGE("Can't step in anything else than AM/FM");
- return Result::NOT_INITIALIZED;
- }
-
- if (!mIsAmfmConfigSet) {
- ALOGW("AM/FM config not set");
- return Result::INVALID_STATE;
- }
- mIsTuneCompleted = false;
-
- auto task = [this, direction]() {
- ALOGI("Performing step %s", toString(direction).c_str());
-
- lock_guard<mutex> lk(mMut);
-
- auto current = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY, 0);
-
- if (direction == Direction::UP) {
- current += mAmfmConfig.spacings[0];
- } else {
- current -= mAmfmConfig.spacings[0];
- }
-
- if (current > mAmfmConfig.upperLimit) current = mAmfmConfig.lowerLimit;
- if (current < mAmfmConfig.lowerLimit) current = mAmfmConfig.upperLimit;
-
- tuneInternalLocked(utils::make_selector(mAmfmConfig.type, current));
- };
- mThread.schedule(task, gDefaultDelay.step);
-
- return Result::OK;
-}
-
-Return<Result> Tuner::tune(uint32_t channel, uint32_t subChannel) {
- ALOGV("%s(%d, %d)", __func__, channel, subChannel);
- Band band;
- {
- lock_guard<mutex> lk(mMut);
- band = mAmfmConfig.type;
- }
- return tuneByProgramSelector(utils::make_selector(band, channel, subChannel));
-}
-
-Return<Result> Tuner::tuneByProgramSelector(const ProgramSelector& sel) {
- ALOGV("%s(%s)", __func__, toString(sel).c_str());
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return Result::NOT_INITIALIZED;
-
- // 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;
- }
-
- auto freq = utils::getId(sel, IdentifierType::AMFM_FREQUENCY);
- if (freq < mAmfmConfig.lowerLimit || freq > mAmfmConfig.upperLimit) {
- return Result::INVALID_ARGUMENTS;
- }
- } else if (programType == ProgramType::DAB) {
- if (!utils::hasId(sel, IdentifierType::DAB_SIDECC)) return Result::INVALID_ARGUMENTS;
- } 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;
- }
-
- mIsTuneCompleted = false;
- auto task = [this, sel]() {
- lock_guard<mutex> lk(mMut);
- tuneInternalLocked(sel);
- };
- mThread.schedule(task, gDefaultDelay.tune);
-
- return Result::OK;
-}
-
-Return<Result> Tuner::cancel() {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return Result::NOT_INITIALIZED;
-
- mThread.cancelAll();
- return Result::OK;
-}
-
-Return<Result> Tuner::cancelAnnouncement() {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return Result::NOT_INITIALIZED;
-
- return Result::OK;
-}
-
-Return<void> Tuner::getProgramInformation(getProgramInformation_cb _hidl_cb) {
- ALOGV("%s", __func__);
- return getProgramInformation_1_1([&](Result result, const ProgramInfo& info) {
- _hidl_cb(result, info.base);
- });
-}
-
-Return<void> Tuner::getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
-
- if (mIsClosed) {
- _hidl_cb(Result::NOT_INITIALIZED, {});
- } else if (mIsTuneCompleted) {
- _hidl_cb(Result::OK, mCurrentProgramInfo);
- } else {
- _hidl_cb(Result::NOT_INITIALIZED, makeDummyProgramInfo(mCurrentProgram));
- }
- return {};
-}
-
-Return<ProgramListResult> Tuner::startBackgroundScan() {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) return ProgramListResult::NOT_INITIALIZED;
-
- return ProgramListResult::UNAVAILABLE;
-}
-
-Return<void> Tuner::getProgramList(const hidl_vec<VendorKeyValue>& vendorFilter,
- getProgramList_cb _hidl_cb) {
- ALOGV("%s(%s)", __func__, toString(vendorFilter).substr(0, 100).c_str());
- lock_guard<mutex> lk(mMut);
- if (mIsClosed) {
- _hidl_cb(ProgramListResult::NOT_INITIALIZED, {});
- return {};
- }
-
- auto list = mVirtualRadio.get().getProgramList();
- ALOGD("returning a list of %zu programs", list.size());
- _hidl_cb(ProgramListResult::OK, getProgramInfoVector(list, getHalRev()));
- return {};
-}
-
-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;
-}
-
-Return<void> Tuner::isAnalogForced(isAnalogForced_cb _hidl_cb) {
- ALOGV("%s", __func__);
- lock_guard<mutex> lk(mMut);
-
- if (mIsClosed) {
- _hidl_cb(Result::NOT_INITIALIZED, false);
- } else {
- _hidl_cb(Result::OK, mIsAnalogForced);
- }
- return {};
-}
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/default/Tuner.h b/broadcastradio/1.1/default/Tuner.h
deleted file mode 100644
index 07d3189..0000000
--- a/broadcastradio/1.1/default/Tuner.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
-
-#include "VirtualRadio.h"
-
-#include <android/hardware/broadcastradio/1.1/ITuner.h>
-#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
-#include <broadcastradio-utils/WorkerThread.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-struct Tuner : public ITuner {
- Tuner(V1_0::Class classId, const sp<V1_0::ITunerCallback>& callback);
-
- void forceClose();
-
- // V1_1::ITuner methods
- virtual Return<Result> setConfiguration(const V1_0::BandConfig& config) override;
- virtual Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
- virtual Return<Result> scan(V1_0::Direction direction, bool skipSubChannel) override;
- virtual Return<Result> step(V1_0::Direction direction, bool skipSubChannel) override;
- virtual Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
- virtual Return<Result> tuneByProgramSelector(const ProgramSelector& program) override;
- virtual Return<Result> cancel() override;
- virtual Return<Result> cancelAnnouncement() override;
- virtual Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
- virtual Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
- virtual Return<ProgramListResult> startBackgroundScan() override;
- virtual Return<void> getProgramList(const hidl_vec<VendorKeyValue>& filter,
- getProgramList_cb _hidl_cb) override;
- virtual Return<Result> setAnalogForced(bool isForced) override;
- virtual Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
-
- private:
- std::mutex mMut;
- WorkerThread mThread;
- bool mIsClosed = false;
-
- V1_0::Class mClassId;
- const sp<V1_0::ITunerCallback> mCallback;
- const sp<V1_1::ITunerCallback> mCallback1_1;
-
- std::reference_wrapper<VirtualRadio> mVirtualRadio;
- bool mIsAmfmConfigSet = false;
- V1_0::BandConfig mAmfmConfig;
- bool mIsTuneCompleted = false;
- ProgramSelector mCurrentProgram = {};
- ProgramInfo mCurrentProgramInfo = {};
- std::atomic<bool> mIsAnalogForced;
-
- utils::HalRevision getHalRev() const;
- void tuneInternalLocked(const ProgramSelector& sel);
-};
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
diff --git a/broadcastradio/1.1/default/VirtualProgram.cpp b/broadcastradio/1.1/default/VirtualProgram.cpp
deleted file mode 100644
index 7977391..0000000
--- a/broadcastradio/1.1/default/VirtualProgram.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.
- */
-#include "VirtualProgram.h"
-
-#include <broadcastradio-utils/Utils.h>
-
-#include "resources.h"
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-using std::vector;
-
-using V1_0::MetaData;
-using V1_0::MetadataKey;
-using V1_0::MetadataType;
-using utils::HalRevision;
-
-static MetaData createDemoBitmap(MetadataKey key, HalRevision halRev) {
- MetaData bmp = {MetadataType::INT, key, resources::demoPngId, {}, {}, {}};
- if (halRev < HalRevision::V1_1) {
- bmp.type = MetadataType::RAW;
- bmp.intValue = 0;
- bmp.rawValue = hidl_vec<uint8_t>(resources::demoPng, std::end(resources::demoPng));
- }
- return bmp;
-}
-
-ProgramInfo VirtualProgram::getProgramInfo(HalRevision halRev) const {
- ProgramInfo info11 = {};
- auto& info10 = info11.base;
-
- utils::getLegacyChannel(selector, &info10.channel, &info10.subChannel);
- info11.selector = selector;
- info10.tuned = true;
- info10.stereo = true;
- info10.digital = utils::isDigital(selector);
- info10.signalStrength = info10.digital ? 100 : 80;
-
- info10.metadata = hidl_vec<MetaData>({
- {MetadataType::TEXT, MetadataKey::RDS_PS, {}, {}, programName, {}},
- {MetadataType::TEXT, MetadataKey::TITLE, {}, {}, songTitle, {}},
- {MetadataType::TEXT, MetadataKey::ARTIST, {}, {}, songArtist, {}},
- createDemoBitmap(MetadataKey::ICON, halRev),
- createDemoBitmap(MetadataKey::ART, halRev),
- });
-
- info11.vendorInfo = hidl_vec<VendorKeyValue>({
- {"com.google.dummy", "dummy"},
- {"com.google.dummy.VirtualProgram", std::to_string(reinterpret_cast<uintptr_t>(this))},
- });
-
- return info11;
-}
-
-// Defining order on virtual programs, how they appear on band.
-// It's mostly for default implementation purposes, may not be complete or correct.
-bool operator<(const VirtualProgram& lhs, const VirtualProgram& rhs) {
- auto& l = lhs.selector;
- auto& r = rhs.selector;
-
- // Two programs with the same primaryId is considered the same.
- if (l.programType != r.programType) return l.programType < r.programType;
- if (l.primaryId.type != r.primaryId.type) return l.primaryId.type < r.primaryId.type;
- if (l.primaryId.value != r.primaryId.value) return l.primaryId.value < r.primaryId.value;
-
- // A little exception for HD Radio subchannel - we check secondary ID too.
- if (utils::hasId(l, IdentifierType::HD_SUBCHANNEL) &&
- utils::hasId(r, IdentifierType::HD_SUBCHANNEL)) {
- return utils::getId(l, IdentifierType::HD_SUBCHANNEL) <
- utils::getId(r, IdentifierType::HD_SUBCHANNEL);
- }
-
- return false;
-}
-
-vector<ProgramInfo> getProgramInfoVector(const vector<VirtualProgram>& vec, HalRevision halRev) {
- vector<ProgramInfo> out;
- out.reserve(vec.size());
- for (auto&& program : vec) {
- out.push_back(program.getProgramInfo(halRev));
- }
- return out;
-}
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/default/VirtualProgram.h b/broadcastradio/1.1/default/VirtualProgram.h
deleted file mode 100644
index a14830d..0000000
--- a/broadcastradio/1.1/default/VirtualProgram.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
-
-#include <android/hardware/broadcastradio/1.1/types.h>
-#include <broadcastradio-utils/Utils.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-/**
- * A radio program mock.
- *
- * This represents broadcast waves flying over the air,
- * not an entry for a captured station in the radio tuner memory.
- */
-struct VirtualProgram {
- ProgramSelector selector;
-
- std::string programName = "";
- std::string songArtist = "";
- std::string songTitle = "";
-
- ProgramInfo getProgramInfo(utils::HalRevision halRev) const;
-
- friend bool operator<(const VirtualProgram& lhs, const VirtualProgram& rhs);
-};
-
-std::vector<ProgramInfo> getProgramInfoVector(const std::vector<VirtualProgram>& vec,
- utils::HalRevision halRev);
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
diff --git a/broadcastradio/1.1/default/VirtualRadio.cpp b/broadcastradio/1.1/default/VirtualRadio.cpp
deleted file mode 100644
index 36d47a9..0000000
--- a/broadcastradio/1.1/default/VirtualRadio.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "BroadcastRadioDefault.VirtualRadio"
-//#define LOG_NDEBUG 0
-
-#include "VirtualRadio.h"
-
-#include <broadcastradio-utils/Utils.h>
-#include <log/log.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-using V1_0::Band;
-using V1_0::Class;
-
-using std::lock_guard;
-using std::move;
-using std::mutex;
-using std::vector;
-
-using utils::make_selector;
-
-static const vector<VirtualProgram> gInitialFmPrograms{
- {make_selector(Band::FM, 94900), "Wild 94.9", "Drake ft. Rihanna", "Too Good"},
- {make_selector(Band::FM, 96500), "KOIT", "Celine Dion", "All By Myself"},
- {make_selector(Band::FM, 97300), "Alice@97.3", "Drops of Jupiter", "Train"},
- {make_selector(Band::FM, 99700), "99.7 Now!", "The Chainsmokers", "Closer"},
- {make_selector(Band::FM, 101300), "101-3 KISS-FM", "Justin Timberlake", "Rock Your Body"},
- {make_selector(Band::FM, 103700), "iHeart80s @ 103.7", "Michael Jackson", "Billie Jean"},
- {make_selector(Band::FM, 106100), "106 KMEL", "Drake", "Marvins Room"},
-};
-
-static VirtualRadio gEmptyRadio({});
-static VirtualRadio gFmRadio(gInitialFmPrograms);
-
-VirtualRadio::VirtualRadio(const vector<VirtualProgram> initialList) : mPrograms(initialList) {}
-
-vector<VirtualProgram> VirtualRadio::getProgramList() {
- lock_guard<mutex> lk(mMut);
- return mPrograms;
-}
-
-bool VirtualRadio::getProgram(const ProgramSelector& selector, VirtualProgram& programOut) {
- lock_guard<mutex> lk(mMut);
- for (auto&& program : mPrograms) {
- if (utils::tunesTo(selector, program.selector)) {
- programOut = program;
- return true;
- }
- }
- return false;
-}
-
-VirtualRadio& getRadio(V1_0::Class classId) {
- switch (classId) {
- case Class::AM_FM:
- return getFmRadio();
- case Class::SAT:
- return getSatRadio();
- case Class::DT:
- return getDigitalRadio();
- default:
- ALOGE("Invalid class ID");
- return gEmptyRadio;
- }
-}
-
-VirtualRadio& getAmRadio() {
- return gEmptyRadio;
-}
-
-VirtualRadio& getFmRadio() {
- return gFmRadio;
-}
-
-VirtualRadio& getSatRadio() {
- return gEmptyRadio;
-}
-
-VirtualRadio& getDigitalRadio() {
- return gEmptyRadio;
-}
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/default/VirtualRadio.h b/broadcastradio/1.1/default/VirtualRadio.h
deleted file mode 100644
index 3c7ae5c..0000000
--- a/broadcastradio/1.1/default/VirtualRadio.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H
-
-#include "VirtualProgram.h"
-
-#include <mutex>
-#include <vector>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-
-/**
- * A radio frequency space mock.
- *
- * This represents all broadcast waves in the air for a given radio technology,
- * not a captured station list in the radio tuner memory.
- *
- * It's meant to abstract out radio content from default tuner implementation.
- */
-class VirtualRadio {
- public:
- VirtualRadio(const std::vector<VirtualProgram> initialList);
-
- std::vector<VirtualProgram> getProgramList();
- bool getProgram(const ProgramSelector& selector, VirtualProgram& program);
-
- private:
- std::mutex mMut;
- std::vector<VirtualProgram> mPrograms;
-};
-
-/**
- * Get virtual radio space for a given radio class.
- *
- * As a space, each virtual radio always exists. For example, DAB frequencies
- * exists in US, but contains no programs.
- *
- * The lifetime of the virtual radio space is virtually infinite, but for the
- * needs of default implementation, it's bound with the lifetime of default
- * implementation process.
- *
- * Internally, it's a static object, so trying to access the reference during
- * default implementation library unloading may result in segmentation fault.
- * It's unlikely for testing purposes.
- *
- * @param classId A class of radio technology.
- * @return A reference to virtual radio space for a given technology.
- */
-VirtualRadio& getRadio(V1_0::Class classId);
-
-VirtualRadio& getAmRadio();
-VirtualRadio& getFmRadio();
-VirtualRadio& getSatRadio();
-VirtualRadio& getDigitalRadio();
-
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H
diff --git a/broadcastradio/1.1/default/android.hardware.broadcastradio@1.1-service.rc b/broadcastradio/1.1/default/android.hardware.broadcastradio@1.1-service.rc
deleted file mode 100644
index 7c57135..0000000
--- a/broadcastradio/1.1/default/android.hardware.broadcastradio@1.1-service.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service broadcastradio-hal /vendor/bin/hw/android.hardware.broadcastradio@1.1-service
- class hal
- user audioserver
- group audio
diff --git a/broadcastradio/1.1/default/resources.h b/broadcastradio/1.1/default/resources.h
deleted file mode 100644
index b7e709f..0000000
--- a/broadcastradio/1.1/default/resources.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_RESOURCES_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_RESOURCES_H
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace implementation {
-namespace resources {
-
-constexpr int32_t demoPngId = 123456;
-constexpr uint8_t demoPng[] = {
- 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44,
- 0x52, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x08, 0x02, 0x00, 0x00, 0x00, 0x25,
- 0x0b, 0xe6, 0x89, 0x00, 0x00, 0x00, 0x5d, 0x49, 0x44, 0x41, 0x54, 0x68, 0xde, 0xed, 0xd9,
- 0xc1, 0x09, 0x00, 0x30, 0x08, 0x04, 0xc1, 0x33, 0xfd, 0xf7, 0x6c, 0x6a, 0xc8, 0x23, 0x04,
- 0xc9, 0x6c, 0x01, 0xc2, 0x20, 0xbe, 0x4c, 0x86, 0x57, 0x49, 0xba, 0xfb, 0xd6, 0xf4, 0xba,
- 0x3e, 0x7f, 0x4d, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x8f, 0x00, 0xbd, 0xce, 0x7f,
- 0xc0, 0x11, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0xb8, 0x0d, 0x32, 0xd4, 0x0c, 0x77, 0xbd,
- 0xfb, 0xc1, 0xce, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
-
-} // namespace resources
-} // namespace implementation
-} // namespace V1_1
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_RESOURCES_H
diff --git a/broadcastradio/1.1/default/service.cpp b/broadcastradio/1.1/default/service.cpp
deleted file mode 100644
index f8af0b7..0000000
--- a/broadcastradio/1.1/default/service.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "BroadcastRadioDefault.service"
-
-#include <android-base/logging.h>
-#include <hidl/HidlTransportSupport.h>
-
-#include "BroadcastRadioFactory.h"
-
-using android::hardware::configureRpcThreadpool;
-using android::hardware::joinRpcThreadpool;
-using android::hardware::broadcastradio::V1_1::implementation::BroadcastRadioFactory;
-
-int main(int /* argc */, char** /* argv */) {
- configureRpcThreadpool(4, true);
-
- BroadcastRadioFactory broadcastRadioFactory;
- auto status = broadcastRadioFactory.registerAsService();
- CHECK_EQ(status, android::OK) << "Failed to register Broadcast Radio HAL implementation";
-
- joinRpcThreadpool();
- return 1; // joinRpcThreadpool shouldn't exit
-}
diff --git a/broadcastradio/1.1/tests/Android.bp b/broadcastradio/1.1/tests/Android.bp
deleted file mode 100644
index fa1fd94..0000000
--- a/broadcastradio/1.1/tests/Android.bp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// 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.
-//
-
-cc_test {
- name: "android.hardware.broadcastradio@1.1-utils-tests",
- vendor: true,
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
- ],
- srcs: [
- "WorkerThread_test.cpp",
- ],
- static_libs: ["android.hardware.broadcastradio@1.1-utils-lib"],
-}
diff --git a/broadcastradio/1.1/tests/OWNERS b/broadcastradio/1.1/tests/OWNERS
deleted file mode 100644
index aa5ce82..0000000
--- a/broadcastradio/1.1/tests/OWNERS
+++ /dev/null
@@ -1,8 +0,0 @@
-# Automotive team
-egranata@google.com
-keunyoung@google.com
-twasilczyk@google.com
-
-# VTS team
-ryanjcampbell@google.com
-yim@google.com
diff --git a/broadcastradio/1.1/tests/WorkerThread_test.cpp b/broadcastradio/1.1/tests/WorkerThread_test.cpp
deleted file mode 100644
index ed36de3..0000000
--- a/broadcastradio/1.1/tests/WorkerThread_test.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.
- */
-
-#include <broadcastradio-utils/WorkerThread.h>
-#include <gtest/gtest.h>
-
-namespace {
-
-using namespace std::chrono_literals;
-
-using android::WorkerThread;
-
-using std::atomic;
-using std::chrono::time_point;
-using std::chrono::steady_clock;
-using std::is_sorted;
-using std::lock_guard;
-using std::mutex;
-using std::this_thread::sleep_for;
-using std::vector;
-
-#define ASSERT_EQ_WITH_TOLERANCE(val1, val2, tolerance) \
- ASSERT_LE((val1) - (tolerance), (val2)); \
- ASSERT_GE((val1) + (tolerance), (val2));
-
-TEST(WorkerThreadTest, oneTask) {
- atomic<bool> executed(false);
- atomic<time_point<steady_clock>> stop;
- WorkerThread thread;
-
- auto start = steady_clock::now();
- thread.schedule(
- [&]() {
- stop = steady_clock::now();
- executed = true;
- },
- 100ms);
-
- sleep_for(150ms);
-
- ASSERT_TRUE(executed);
- auto delta = stop.load() - start;
- ASSERT_EQ_WITH_TOLERANCE(delta, 100ms, 50ms);
-}
-
-TEST(WorkerThreadTest, cancelSecond) {
- atomic<bool> executed1(false);
- atomic<bool> executed2(false);
- WorkerThread thread;
-
- thread.schedule([&]() { executed2 = true; }, 100ms);
- thread.schedule([&]() { executed1 = true; }, 25ms);
-
- sleep_for(50ms);
- thread.cancelAll();
- sleep_for(100ms);
-
- ASSERT_TRUE(executed1);
- ASSERT_FALSE(executed2);
-}
-
-TEST(WorkerThreadTest, executeInOrder) {
- mutex mut;
- vector<int> order;
- WorkerThread thread;
-
- thread.schedule(
- [&]() {
- lock_guard<mutex> lk(mut);
- order.push_back(0);
- },
- 50ms);
-
- thread.schedule(
- [&]() {
- lock_guard<mutex> lk(mut);
- order.push_back(4);
- },
- 400ms);
-
- thread.schedule(
- [&]() {
- lock_guard<mutex> lk(mut);
- order.push_back(1);
- },
- 100ms);
-
- thread.schedule(
- [&]() {
- lock_guard<mutex> lk(mut);
- order.push_back(3);
- },
- 300ms);
-
- thread.schedule(
- [&]() {
- lock_guard<mutex> lk(mut);
- order.push_back(2);
- },
- 200ms);
-
- sleep_for(500ms);
-
- ASSERT_EQ(5u, order.size());
- ASSERT_TRUE(is_sorted(order.begin(), order.end()));
-}
-
-TEST(WorkerThreadTest, dontExecuteAfterDestruction) {
- atomic<bool> executed1(false);
- atomic<bool> executed2(false);
- {
- WorkerThread thread;
-
- thread.schedule([&]() { executed2 = true; }, 100ms);
- thread.schedule([&]() { executed1 = true; }, 25ms);
-
- sleep_for(50ms);
- }
- sleep_for(100ms);
-
- ASSERT_TRUE(executed1);
- ASSERT_FALSE(executed2);
-}
-
-} // anonymous namespace
diff --git a/broadcastradio/1.1/utils/Android.bp b/broadcastradio/1.1/utils/Android.bp
deleted file mode 100644
index e80d133..0000000
--- a/broadcastradio/1.1/utils/Android.bp
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// 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.
-//
-
-cc_library_static {
- name: "android.hardware.broadcastradio@1.1-utils-lib",
- vendor_available: true,
- relative_install_path: "hw",
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
- ],
- srcs: [
- "Utils.cpp",
- "WorkerThread.cpp",
- ],
- export_include_dirs: ["include"],
- shared_libs: [
- "android.hardware.broadcastradio@1.1",
- ],
-}
diff --git a/broadcastradio/1.1/utils/OWNERS b/broadcastradio/1.1/utils/OWNERS
deleted file mode 100644
index 0c27b71..0000000
--- a/broadcastradio/1.1/utils/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-# Automotive team
-egranata@google.com
-keunyoung@google.com
-twasilczyk@google.com
diff --git a/broadcastradio/1.1/utils/Utils.cpp b/broadcastradio/1.1/utils/Utils.cpp
deleted file mode 100644
index 4dd6b13..0000000
--- a/broadcastradio/1.1/utils/Utils.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "BroadcastRadioDefault.utils"
-//#define LOG_NDEBUG 0
-
-#include <broadcastradio-utils/Utils.h>
-
-#include <log/log.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace utils {
-
-using V1_0::Band;
-
-static bool isCompatibleProgramType(const uint32_t ia, const uint32_t ib) {
- auto a = static_cast<ProgramType>(ia);
- auto b = static_cast<ProgramType>(ib);
-
- if (a == b) return true;
- if (a == ProgramType::AM && b == ProgramType::AM_HD) return true;
- if (a == ProgramType::AM_HD && b == ProgramType::AM) return true;
- if (a == ProgramType::FM && b == ProgramType::FM_HD) return true;
- if (a == ProgramType::FM_HD && b == ProgramType::FM) return true;
- return false;
-}
-
-static bool bothHaveId(const ProgramSelector& a, const ProgramSelector& b,
- const IdentifierType type) {
- return hasId(a, type) && hasId(b, type);
-}
-
-static bool anyHaveId(const ProgramSelector& a, const ProgramSelector& b,
- const IdentifierType type) {
- return hasId(a, type) || hasId(b, type);
-}
-
-static bool haveEqualIds(const ProgramSelector& a, const ProgramSelector& b,
- const IdentifierType type) {
- if (!bothHaveId(a, b, type)) return false;
- /* We should check all Ids of a given type (ie. other AF),
- * but it doesn't matter for default implementation.
- */
- auto aId = getId(a, type);
- auto bId = getId(b, type);
- return aId == bId;
-}
-
-bool tunesTo(const ProgramSelector& a, const ProgramSelector& b) {
- if (!isCompatibleProgramType(a.programType, b.programType)) return false;
-
- auto type = getType(a);
-
- switch (type) {
- case ProgramType::AM:
- case ProgramType::AM_HD:
- case ProgramType::FM:
- case ProgramType::FM_HD:
- if (haveEqualIds(a, b, IdentifierType::HD_STATION_ID_EXT)) return true;
-
- // if HD Radio subchannel is specified, it must match
- if (anyHaveId(a, b, IdentifierType::HD_SUBCHANNEL)) {
- // missing subchannel (analog) is an equivalent of first subchannel (MPS)
- auto aCh = getId(a, IdentifierType::HD_SUBCHANNEL, 0);
- auto bCh = getId(b, IdentifierType::HD_SUBCHANNEL, 0);
- if (aCh != bCh) return false;
- }
-
- if (haveEqualIds(a, b, IdentifierType::RDS_PI)) return true;
-
- return haveEqualIds(a, b, IdentifierType::AMFM_FREQUENCY);
- case ProgramType::DAB:
- return haveEqualIds(a, b, IdentifierType::DAB_SIDECC);
- case ProgramType::DRMO:
- return haveEqualIds(a, b, IdentifierType::DRMO_SERVICE_ID);
- case ProgramType::SXM:
- if (anyHaveId(a, b, IdentifierType::SXM_SERVICE_ID)) {
- return haveEqualIds(a, b, IdentifierType::SXM_SERVICE_ID);
- }
- return haveEqualIds(a, b, IdentifierType::SXM_CHANNEL);
- default: // includes all vendor types
- ALOGW("Unsupported program type: %s", toString(type).c_str());
- return false;
- }
-}
-
-ProgramType getType(const ProgramSelector& sel) {
- return static_cast<ProgramType>(sel.programType);
-}
-
-bool isAmFm(const ProgramType type) {
- switch (type) {
- case ProgramType::AM:
- case ProgramType::FM:
- case ProgramType::AM_HD:
- case ProgramType::FM_HD:
- return true;
- default:
- return false;
- }
-}
-
-bool isAm(const Band band) {
- return band == Band::AM || band == Band::AM_HD;
-}
-
-bool isFm(const Band band) {
- return band == Band::FM || band == Band::FM_HD;
-}
-
-bool hasId(const ProgramSelector& sel, const IdentifierType type) {
- auto itype = static_cast<uint32_t>(type);
- if (sel.primaryId.type == itype) return true;
- // not optimal, but we don't care in default impl
- for (auto&& id : sel.secondaryIds) {
- if (id.type == itype) return true;
- }
- return false;
-}
-
-uint64_t getId(const ProgramSelector& sel, const IdentifierType type) {
- auto itype = static_cast<uint32_t>(type);
- if (sel.primaryId.type == itype) return sel.primaryId.value;
- // not optimal, but we don't care in default impl
- for (auto&& id : sel.secondaryIds) {
- if (id.type == itype) return id.value;
- }
- ALOGW("Identifier %s not found", toString(type).c_str());
- return 0;
-}
-
-uint64_t getId(const ProgramSelector& sel, const IdentifierType type, uint64_t defval) {
- if (!hasId(sel, type)) return defval;
- return getId(sel, type);
-}
-
-ProgramSelector make_selector(Band band, uint32_t channel, uint32_t subChannel) {
- ProgramSelector sel = {};
-
- ALOGW_IF((subChannel > 0) && (band == Band::AM || band == Band::FM),
- "got subChannel for non-HD AM/FM");
-
- // we can't use ProgramType::AM_HD or FM_HD, because we don't know HD station ID
- ProgramType type;
- if (isAm(band)) {
- type = ProgramType::AM;
- } else if (isFm(band)) {
- type = ProgramType::FM;
- } else {
- LOG_ALWAYS_FATAL("Unsupported band: %s", toString(band).c_str());
- }
-
- sel.programType = static_cast<uint32_t>(type);
- sel.primaryId.type = static_cast<uint32_t>(IdentifierType::AMFM_FREQUENCY);
- sel.primaryId.value = channel;
- if (subChannel > 0) {
- /* stating sub channel for AM/FM channel does not give any guarantees,
- * but we can't do much more without HD station ID
- *
- * The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based.
- */
- sel.secondaryIds = hidl_vec<ProgramIdentifier>{
- {static_cast<uint32_t>(IdentifierType::HD_SUBCHANNEL), subChannel - 1},
- };
- }
-
- return sel;
-}
-
-bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut) {
- if (channelOut) *channelOut = 0;
- if (subChannelOut) *subChannelOut = 0;
- if (isAmFm(getType(sel))) {
- if (channelOut) *channelOut = getId(sel, IdentifierType::AMFM_FREQUENCY);
- if (subChannelOut && hasId(sel, IdentifierType::HD_SUBCHANNEL)) {
- // The legacy APIs had 1-based subChannels, while ProgramSelector is 0-based.
- *subChannelOut = getId(sel, IdentifierType::HD_SUBCHANNEL) + 1;
- }
- return true;
- }
- return false;
-}
-
-bool isDigital(const ProgramSelector& sel) {
- switch (getType(sel)) {
- case ProgramType::AM:
- case ProgramType::FM:
- return false;
- default:
- // VENDOR might not be digital, but it doesn't matter for default impl.
- return true;
- }
-}
-
-} // namespace utils
-} // namespace V1_1
-
-namespace V1_0 {
-
-bool operator==(const BandConfig& l, const BandConfig& r) {
- if (l.type != r.type) return false;
- if (l.antennaConnected != r.antennaConnected) return false;
- if (l.lowerLimit != r.lowerLimit) return false;
- if (l.upperLimit != r.upperLimit) return false;
- if (l.spacings != r.spacings) return false;
- if (V1_1::utils::isAm(l.type)) {
- return l.ext.am == r.ext.am;
- } else if (V1_1::utils::isFm(l.type)) {
- return l.ext.fm == r.ext.fm;
- } else {
- ALOGW("Unsupported band config type: %s", toString(l.type).c_str());
- return false;
- }
-}
-
-} // namespace V1_0
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/utils/WorkerThread.cpp b/broadcastradio/1.1/utils/WorkerThread.cpp
deleted file mode 100644
index bfcbb39..0000000
--- a/broadcastradio/1.1/utils/WorkerThread.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- */
-
-#define LOG_TAG "WorkerThread"
-//#define LOG_NDEBUG 0
-
-#include <broadcastradio-utils/WorkerThread.h>
-
-#include <log/log.h>
-
-namespace android {
-
-using std::chrono::milliseconds;
-using std::chrono::steady_clock;
-using std::function;
-using std::lock_guard;
-using std::mutex;
-using std::priority_queue;
-using std::this_thread::sleep_for;
-using std::unique_lock;
-
-bool operator<(const WorkerThread::Task& lhs, const WorkerThread::Task& rhs) {
- return lhs.when > rhs.when;
-}
-
-WorkerThread::WorkerThread() : mIsTerminating(false), mThread(&WorkerThread::threadLoop, this) {}
-
-WorkerThread::~WorkerThread() {
- ALOGV("%s", __func__);
- {
- lock_guard<mutex> lk(mMut);
- mIsTerminating = true;
- mCond.notify_one();
- }
- mThread.join();
-}
-
-void WorkerThread::schedule(function<void()> task, milliseconds delay) {
- ALOGV("%s", __func__);
-
- auto when = steady_clock::now() + delay;
-
- lock_guard<mutex> lk(mMut);
- mTasks.push(Task({when, task}));
- mCond.notify_one();
-}
-
-void WorkerThread::cancelAll() {
- ALOGV("%s", __func__);
-
- lock_guard<mutex> lk(mMut);
- priority_queue<Task>().swap(mTasks); // empty queue
-}
-
-void WorkerThread::threadLoop() {
- ALOGV("%s", __func__);
- while (!mIsTerminating) {
- unique_lock<mutex> lk(mMut);
- if (mTasks.empty()) {
- mCond.wait(lk);
- continue;
- }
-
- auto task = mTasks.top();
- if (task.when > steady_clock::now()) {
- mCond.wait_until(lk, task.when);
- continue;
- }
-
- mTasks.pop();
- lk.unlock(); // what() might need to schedule another task
- task.what();
- }
-}
-
-} // namespace android
diff --git a/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h b/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h
deleted file mode 100644
index 24c60ee..0000000
--- a/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
-
-#include <android/hardware/broadcastradio/1.1/types.h>
-#include <chrono>
-#include <queue>
-#include <thread>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace V1_1 {
-namespace utils {
-
-// TODO(b/64115813): move it out from frameworks/base/services/core/jni/BroadcastRadio/types.h
-enum class HalRevision : uint32_t {
- V1_0 = 1,
- V1_1,
-};
-
-/**
- * Checks, if {@code pointer} tunes to {@channel}.
- *
- * For example, having a channel {AMFM_FREQUENCY = 103.3}:
- * - selector {AMFM_FREQUENCY = 103.3, HD_SUBCHANNEL = 0} can tune to this channel;
- * - selector {AMFM_FREQUENCY = 103.3, HD_SUBCHANNEL = 1} can't.
- *
- * @param pointer selector we're trying to match against channel.
- * @param channel existing channel.
- */
-bool tunesTo(const ProgramSelector& pointer, const ProgramSelector& channel);
-
-ProgramType getType(const ProgramSelector& sel);
-bool isAmFm(const ProgramType type);
-
-bool isAm(const V1_0::Band band);
-bool isFm(const V1_0::Band band);
-
-bool hasId(const ProgramSelector& sel, const IdentifierType type);
-
-/**
- * Returns ID (either primary or secondary) for a given program selector.
- *
- * If the selector does not contain given type, returns 0 and emits a warning.
- */
-uint64_t getId(const ProgramSelector& sel, const IdentifierType type);
-
-/**
- * Returns ID (either primary or secondary) for a given program selector.
- *
- * If the selector does not contain given type, returns default value.
- */
-uint64_t getId(const ProgramSelector& sel, const IdentifierType type, uint64_t defval);
-
-ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0);
-
-bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut);
-
-bool isDigital(const ProgramSelector& sel);
-
-} // namespace utils
-} // namespace V1_1
-
-namespace V1_0 {
-
-bool operator==(const BandConfig& l, const BandConfig& r);
-
-} // namespace V1_0
-
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
diff --git a/broadcastradio/1.1/utils/include/broadcastradio-utils/WorkerThread.h b/broadcastradio/1.1/utils/include/broadcastradio-utils/WorkerThread.h
deleted file mode 100644
index 635876f..0000000
--- a/broadcastradio/1.1/utils/include/broadcastradio-utils/WorkerThread.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_WORKERTHREAD_H
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_WORKERTHREAD_H
-
-#include <chrono>
-#include <queue>
-#include <thread>
-
-namespace android {
-
-class WorkerThread {
- public:
- WorkerThread();
- virtual ~WorkerThread();
-
- void schedule(std::function<void()> task, std::chrono::milliseconds delay);
- void cancelAll();
-
- private:
- struct Task {
- std::chrono::time_point<std::chrono::steady_clock> when;
- std::function<void()> what;
- };
- friend bool operator<(const Task& lhs, const Task& rhs);
-
- std::atomic<bool> mIsTerminating;
- std::mutex mMut;
- std::condition_variable mCond;
- std::thread mThread;
- std::priority_queue<Task> mTasks;
-
- void threadLoop();
-};
-
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_WORKERTHREAD_H
diff --git a/broadcastradio/1.1/vts/functional/Android.bp b/broadcastradio/1.1/vts/functional/Android.bp
index 4b93cbc..3d4fe05 100644
--- a/broadcastradio/1.1/vts/functional/Android.bp
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -21,8 +21,8 @@
static_libs: [
"android.hardware.broadcastradio@1.0",
"android.hardware.broadcastradio@1.1",
- "android.hardware.broadcastradio@1.1-utils-lib",
- "android.hardware.broadcastradio@1.1-vts-utils-lib",
+ "android.hardware.broadcastradio@common-utils-lib",
+ "android.hardware.broadcastradio@vts-utils-lib",
"libgmock",
],
}
diff --git a/broadcastradio/1.1/vts/utils/Android.bp b/broadcastradio/1.1/vts/utils/Android.bp
deleted file mode 100644
index 0c7e2a4..0000000
--- a/broadcastradio/1.1/vts/utils/Android.bp
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-// 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.
-//
-
-cc_library_static {
- name: "android.hardware.broadcastradio@1.1-vts-utils-lib",
- srcs: [
- "call-barrier.cpp",
- ],
- export_include_dirs: ["include"],
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
- ],
-}
diff --git a/broadcastradio/1.1/vts/utils/call-barrier.cpp b/broadcastradio/1.1/vts/utils/call-barrier.cpp
deleted file mode 100644
index d8c4716..0000000
--- a/broadcastradio/1.1/vts/utils/call-barrier.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.
- */
-#include <broadcastradio-vts-utils/call-barrier.h>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace vts {
-
-using std::lock_guard;
-using std::mutex;
-using std::unique_lock;
-
-void CallBarrier::call() {
- lock_guard<mutex> lk(mMut);
- mWasCalled = true;
- mCond.notify_all();
-}
-
-bool CallBarrier::waitForCall(std::chrono::milliseconds timeout) {
- unique_lock<mutex> lk(mMut);
-
- if (mWasCalled) return true;
-
- auto status = mCond.wait_for(lk, timeout);
- return status == std::cv_status::no_timeout;
-}
-
-} // namespace vts
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
diff --git a/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/call-barrier.h b/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/call-barrier.h
deleted file mode 100644
index 462396a..0000000
--- a/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/call-barrier.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_CALL_BARRIER
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_CALL_BARRIER
-
-#include <chrono>
-#include <thread>
-
-namespace android {
-namespace hardware {
-namespace broadcastradio {
-namespace vts {
-
-/**
- * A barrier for thread synchronization, where one should wait for another to
- * reach a specific point in execution.
- */
-class CallBarrier {
- public:
- /**
- * Notify the other thread it may continue execution.
- *
- * This may be called before the other thread starts waiting on the barrier.
- */
- void call();
-
- /**
- * Wait for the other thread to reach call() execution point.
- *
- * @param timeout a maximum time to wait.
- * @returns {@code false} if timed out, {@code true} otherwise.
- */
- bool waitForCall(std::chrono::milliseconds timeout);
-
- private:
- bool mWasCalled = false;
- std::mutex mMut;
- std::condition_variable mCond;
-};
-
-} // namespace vts
-} // namespace broadcastradio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_CALL_BARRIER
diff --git a/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h b/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
deleted file mode 100644
index b0ce088..0000000
--- a/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.
- */
-#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_MOCK_TIMEOUT
-#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_MOCK_TIMEOUT
-
-#include <gmock/gmock.h>
-#include <thread>
-
-/**
- * Common helper objects for gmock timeout extension.
- *
- * INTERNAL IMPLEMENTATION - don't use in user code.
- */
-#define EGMOCK_TIMEOUT_METHOD_DEF_(Method, ...) \
- std::atomic<bool> egmock_called_##Method; \
- std::mutex egmock_mut_##Method; \
- std::condition_variable egmock_cond_##Method;
-
-/**
- * Common method body for gmock timeout extension.
- *
- * INTERNAL IMPLEMENTATION - don't use in user code.
- */
-#define EGMOCK_TIMEOUT_METHOD_BODY_(Method, ...) \
- auto ret = egmock_##Method(__VA_ARGS__); \
- { \
- std::lock_guard<std::mutex> lk(egmock_mut_##Method); \
- egmock_called_##Method = true; \
- egmock_cond_##Method.notify_all(); \
- } \
- return ret;
-
-/**
- * Gmock MOCK_METHOD0 timeout-capable extension.
- */
-#define MOCK_TIMEOUT_METHOD0(Method, ...) \
- MOCK_METHOD0(egmock_##Method, __VA_ARGS__); \
- EGMOCK_TIMEOUT_METHOD_DEF_(Method); \
- virtual GMOCK_RESULT_(, __VA_ARGS__) Method() { EGMOCK_TIMEOUT_METHOD_BODY_(Method); }
-
-/**
- * Gmock MOCK_METHOD1 timeout-capable extension.
- */
-#define MOCK_TIMEOUT_METHOD1(Method, ...) \
- MOCK_METHOD1(egmock_##Method, __VA_ARGS__); \
- EGMOCK_TIMEOUT_METHOD_DEF_(Method); \
- virtual GMOCK_RESULT_(, __VA_ARGS__) Method(GMOCK_ARG_(, 1, __VA_ARGS__) egmock_a1) { \
- EGMOCK_TIMEOUT_METHOD_BODY_(Method, egmock_a1); \
- }
-
-/**
- * Gmock MOCK_METHOD2 timeout-capable extension.
- */
-#define MOCK_TIMEOUT_METHOD2(Method, ...) \
- MOCK_METHOD2(egmock_##Method, __VA_ARGS__); \
- EGMOCK_TIMEOUT_METHOD_DEF_(Method); \
- virtual GMOCK_RESULT_(, __VA_ARGS__) \
- Method(GMOCK_ARG_(, 1, __VA_ARGS__) egmock_a1, GMOCK_ARG_(, 2, __VA_ARGS__) egmock_a2) { \
- EGMOCK_TIMEOUT_METHOD_BODY_(Method, egmock_a1, egmock_a2); \
- }
-
-/**
- * Gmock EXPECT_CALL timeout-capable extension.
- *
- * It has slightly different syntax from the original macro, to make method name accessible.
- * So, instead of typing
- * EXPECT_CALL(account, charge(100, Currency::USD));
- * you need to inline arguments
- * EXPECT_TIMEOUT_CALL(account, charge, 100, Currency::USD);
- */
-#define EXPECT_TIMEOUT_CALL(obj, Method, ...) \
- (obj).egmock_called_##Method = false; \
- EXPECT_CALL(obj, egmock_##Method(__VA_ARGS__))
-
-/**
- * Waits for an earlier EXPECT_TIMEOUT_CALL to execute.
- *
- * It does not fully support special constraints of the EXPECT_CALL clause, just proceeds when the
- * first call to a given method comes. For example, in the following code:
- * EXPECT_TIMEOUT_CALL(account, charge, 100, _);
- * account.charge(50, Currency::USD);
- * EXPECT_TIMEOUT_CALL_WAIT(account, charge, 500ms);
- * the wait clause will just continue, as the charge method was called.
- *
- * @param obj object for a call
- * @param Method the method to wait for
- * @param timeout the maximum time for waiting
- */
-#define EXPECT_TIMEOUT_CALL_WAIT(obj, Method, timeout) \
- { \
- std::unique_lock<std::mutex> lk((obj).egmock_mut_##Method); \
- if (!(obj).egmock_called_##Method) { \
- auto status = (obj).egmock_cond_##Method.wait_for(lk, timeout); \
- EXPECT_EQ(std::cv_status::no_timeout, status); \
- } \
- }
-
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_MOCK_TIMEOUT