Merge changes from topics "radio-vendor-kvp", "radio-1.2"
* changes:
Implement VTS tests for new radio interfaces.
Implement generic vendor-specific parameters.
Branch out Broadcast Radio 1.2 HAL.
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.2/Android.bp b/broadcastradio/1.2/Android.bp
new file mode 100644
index 0000000..44136c8
--- /dev/null
+++ b/broadcastradio/1.2/Android.bp
@@ -0,0 +1,84 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.broadcastradio@1.2_hal",
+ srcs: [
+ "types.hal",
+ "IBroadcastRadioFactory.hal",
+ "ITuner.hal",
+ "ITunerCallback.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.broadcastradio@1.2_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.broadcastradio@1.2",
+ srcs: [
+ ":android.hardware.broadcastradio@1.2_hal",
+ ],
+ out: [
+ "android/hardware/broadcastradio/1.2/types.cpp",
+ "android/hardware/broadcastradio/1.2/BroadcastRadioFactoryAll.cpp",
+ "android/hardware/broadcastradio/1.2/TunerAll.cpp",
+ "android/hardware/broadcastradio/1.2/TunerCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.broadcastradio@1.2_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.broadcastradio@1.2",
+ srcs: [
+ ":android.hardware.broadcastradio@1.2_hal",
+ ],
+ out: [
+ "android/hardware/broadcastradio/1.2/types.h",
+ "android/hardware/broadcastradio/1.2/hwtypes.h",
+ "android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.2/IHwBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.2/BnHwBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.2/BpHwBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.2/BsBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.2/ITuner.h",
+ "android/hardware/broadcastradio/1.2/IHwTuner.h",
+ "android/hardware/broadcastradio/1.2/BnHwTuner.h",
+ "android/hardware/broadcastradio/1.2/BpHwTuner.h",
+ "android/hardware/broadcastradio/1.2/BsTuner.h",
+ "android/hardware/broadcastradio/1.2/ITunerCallback.h",
+ "android/hardware/broadcastradio/1.2/IHwTunerCallback.h",
+ "android/hardware/broadcastradio/1.2/BnHwTunerCallback.h",
+ "android/hardware/broadcastradio/1.2/BpHwTunerCallback.h",
+ "android/hardware/broadcastradio/1.2/BsTunerCallback.h",
+ ],
+}
+
+cc_library {
+ name: "android.hardware.broadcastradio@1.2",
+ defaults: ["hidl-module-defaults"],
+ generated_sources: ["android.hardware.broadcastradio@1.2_genc++"],
+ generated_headers: ["android.hardware.broadcastradio@1.2_genc++_headers"],
+ export_generated_headers: ["android.hardware.broadcastradio@1.2_genc++_headers"],
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.broadcastradio@1.0",
+ "android.hardware.broadcastradio@1.1",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.broadcastradio@1.0",
+ "android.hardware.broadcastradio@1.1",
+ ],
+}
diff --git a/broadcastradio/1.2/IBroadcastRadioFactory.hal b/broadcastradio/1.2/IBroadcastRadioFactory.hal
new file mode 100644
index 0000000..29f6ab3
--- /dev/null
+++ b/broadcastradio/1.2/IBroadcastRadioFactory.hal
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.2;
+
+import @1.1::IBroadcastRadioFactory;
+
+/**
+ * To use 1.2 features you must cast specific interfaces returned from the
+ * 1.0 HAL. For example V1_0::IBroadcastRadio::openTuner() returns V1_0::ITuner,
+ * which can be cast with V1_2::ITuner::castFrom() call.
+ *
+ * The 1.2 server must always return the 1.2 version of specific interface.
+ */
+interface IBroadcastRadioFactory extends @1.1::IBroadcastRadioFactory {
+};
diff --git a/broadcastradio/1.2/ITuner.hal b/broadcastradio/1.2/ITuner.hal
new file mode 100644
index 0000000..cc966fc
--- /dev/null
+++ b/broadcastradio/1.2/ITuner.hal
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.2;
+
+import @1.1::ITuner;
+
+interface ITuner extends @1.1::ITuner {
+ /**
+ * Generic method for setting vendor-specific parameter values.
+ * The framework does not interpret the parameters, they are passed
+ * in an opaque manner between a vendor application and HAL.
+ *
+ * Framework does not make any assumptions on the keys or values, other than
+ * ones stated in VendorKeyValue documentation (a requirement of key
+ * prefixes).
+ *
+ * Results vector may not contain a result for each parameter being set,
+ * it can even be empty.
+ *
+ * Application and HAL must not use keys with unknown prefix. In particular,
+ * it must not place a key-value pair in results vector for unknown key from
+ * parameters vector - instead, an unknown key should simply be ignored.
+ * In other words, results vector may contain a subset of parameter keys
+ * (however, the framework doesn't enforce a strict subset - the only
+ * formal requirement is vendor domain prefix for keys).
+ *
+ * @param parameters Vendor-specific key-value pairs.
+ * @return results Operation completion status for parameters being set.
+ * Value format for result status is vendor-specific.
+ */
+ setParameters(vec<VendorKeyValue> parameters)
+ generates (vec<VendorKeyValue> results);
+
+ /**
+ * Generic method for retrieving vendor-specific parameter values.
+ * The framework does not interpret the parameters, they are passed
+ * in an opaque manner between a vendor application and HAL.
+ *
+ * Framework does not cache set/get requests, so it's allowed for
+ * getParameter to return a different value than previous setParameter call.
+ *
+ * The syntax and semantics of keys are up to the vendor (as long as prefix
+ * rules are obeyed). For instance, vendors may include some form of
+ * wildcard support. In such case, result vector may be of different size
+ * than requested keys vector. However, wildcards are not recognized by
+ * framework and they are passed as-is to the HAL implementation.
+ *
+ * Unknown keys must be ignored and not placed into results vector.
+ *
+ * @param keys Parameter keys to fetch.
+ * @return parameters Vendor-specific key-value pairs.
+ */
+ getParameters(vec<string> keys) generates (vec<VendorKeyValue> parameters);
+};
diff --git a/broadcastradio/1.2/ITunerCallback.hal b/broadcastradio/1.2/ITunerCallback.hal
new file mode 100644
index 0000000..4e3d0a5
--- /dev/null
+++ b/broadcastradio/1.2/ITunerCallback.hal
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.2;
+
+import @1.1::ITunerCallback;
+
+interface ITunerCallback extends @1.1::ITunerCallback {
+ /**
+ * Generic callback for passing updates to vendor-specific parameter values.
+ * The framework does not interpret the parameters, they are passed
+ * in an opaque manner between a vendor application and HAL.
+ *
+ * It's up to the HAL implementation if and how to implement this callback,
+ * as long as it obeys the prefix rule. In particular, only selected keys
+ * may be notified this way. However, setParameters must not trigger
+ * this callback, while an internal event can change parameters
+ * asynchronously.
+ *
+ * @param parameters Vendor-specific key-value pairs.
+ */
+ oneway parametersUpdated(vec<VendorKeyValue> parameters);
+};
diff --git a/broadcastradio/1.1/default/Android.bp b/broadcastradio/1.2/default/Android.bp
similarity index 83%
rename from broadcastradio/1.1/default/Android.bp
rename to broadcastradio/1.2/default/Android.bp
index 6d26b11..e42cb1e 100644
--- a/broadcastradio/1.1/default/Android.bp
+++ b/broadcastradio/1.2/default/Android.bp
@@ -15,8 +15,8 @@
//
cc_binary {
- name: "android.hardware.broadcastradio@1.1-service",
- init_rc: ["android.hardware.broadcastradio@1.1-service.rc"],
+ name: "android.hardware.broadcastradio@1.2-service",
+ init_rc: ["android.hardware.broadcastradio@1.2-service.rc"],
vendor: true,
relative_install_path: "hw",
cflags: [
@@ -33,11 +33,12 @@
"service.cpp"
],
static_libs: [
- "android.hardware.broadcastradio@1.1-utils-lib",
+ "android.hardware.broadcastradio@common-utils-lib",
],
shared_libs: [
"android.hardware.broadcastradio@1.0",
"android.hardware.broadcastradio@1.1",
+ "android.hardware.broadcastradio@1.2",
"libbase",
"libhidlbase",
"libhidltransport",
diff --git a/broadcastradio/1.1/default/BroadcastRadio.cpp b/broadcastradio/1.2/default/BroadcastRadio.cpp
similarity index 96%
rename from broadcastradio/1.1/default/BroadcastRadio.cpp
rename to broadcastradio/1.2/default/BroadcastRadio.cpp
index 1bcfd82..5164e47 100644
--- a/broadcastradio/1.1/default/BroadcastRadio.cpp
+++ b/broadcastradio/1.2/default/BroadcastRadio.cpp
@@ -25,7 +25,7 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
using V1_0::Band;
@@ -33,6 +33,11 @@
using V1_0::Class;
using V1_0::Deemphasis;
using V1_0::Rds;
+using V1_1::IdentifierType;
+using V1_1::ProgramSelector;
+using V1_1::ProgramType;
+using V1_1::Properties;
+using V1_1::VendorKeyValue;
using std::lock_guard;
using std::map;
@@ -185,7 +190,7 @@
}
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
diff --git a/broadcastradio/1.1/default/BroadcastRadio.h b/broadcastradio/1.2/default/BroadcastRadio.h
similarity index 88%
rename from broadcastradio/1.1/default/BroadcastRadio.h
rename to broadcastradio/1.2/default/BroadcastRadio.h
index a96a2ab..94d62b9 100644
--- a/broadcastradio/1.1/default/BroadcastRadio.h
+++ b/broadcastradio/1.2/default/BroadcastRadio.h
@@ -13,18 +13,18 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_2_BROADCASTRADIO_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_2_BROADCASTRADIO_H
#include "Tuner.h"
#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
-#include <android/hardware/broadcastradio/1.1/types.h>
+#include <android/hardware/broadcastradio/1.2/types.h>
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
struct AmFmBandConfig {
@@ -73,9 +73,9 @@
};
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIO_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_2_BROADCASTRADIO_H
diff --git a/broadcastradio/1.1/default/BroadcastRadioFactory.cpp b/broadcastradio/1.2/default/BroadcastRadioFactory.cpp
similarity index 90%
rename from broadcastradio/1.1/default/BroadcastRadioFactory.cpp
rename to broadcastradio/1.2/default/BroadcastRadioFactory.cpp
index f57bc79..8f17aff 100644
--- a/broadcastradio/1.1/default/BroadcastRadioFactory.cpp
+++ b/broadcastradio/1.2/default/BroadcastRadioFactory.cpp
@@ -25,7 +25,7 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
using V1_0::Class;
@@ -36,10 +36,6 @@
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;
@@ -61,7 +57,7 @@
}
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
diff --git a/broadcastradio/1.1/default/BroadcastRadioFactory.h b/broadcastradio/1.2/default/BroadcastRadioFactory.h
similarity index 69%
rename from broadcastradio/1.1/default/BroadcastRadioFactory.h
rename to broadcastradio/1.2/default/BroadcastRadioFactory.h
index 8b67ac3..c365ae0 100644
--- a/broadcastradio/1.1/default/BroadcastRadioFactory.h
+++ b/broadcastradio/1.2/default/BroadcastRadioFactory.h
@@ -13,21 +13,19 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_2_BROADCASTRADIOFACTORY_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_2_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>
+#include <android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h>
+#include <android/hardware/broadcastradio/1.2/types.h>
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
-extern "C" IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* name);
-
struct BroadcastRadioFactory : public IBroadcastRadioFactory {
BroadcastRadioFactory();
@@ -35,13 +33,13 @@
Return<void> connectModule(V1_0::Class classId, connectModule_cb _hidl_cb) override;
private:
- std::map<V1_0::Class, sp<IBroadcastRadio>> mRadioModules;
+ std::map<V1_0::Class, sp<V1_1::IBroadcastRadio>> mRadioModules;
};
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_BROADCASTRADIOFACTORY_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_2_BROADCASTRADIOFACTORY_H
diff --git a/broadcastradio/1.1/default/OWNERS b/broadcastradio/1.2/default/OWNERS
similarity index 74%
rename from broadcastradio/1.1/default/OWNERS
rename to broadcastradio/1.2/default/OWNERS
index 0c27b71..136b607 100644
--- a/broadcastradio/1.1/default/OWNERS
+++ b/broadcastradio/1.2/default/OWNERS
@@ -1,4 +1,3 @@
# Automotive team
egranata@google.com
-keunyoung@google.com
twasilczyk@google.com
diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.2/default/Tuner.cpp
similarity index 91%
rename from broadcastradio/1.1/default/Tuner.cpp
rename to broadcastradio/1.2/default/Tuner.cpp
index 9a34cb1..70418cf 100644
--- a/broadcastradio/1.1/default/Tuner.cpp
+++ b/broadcastradio/1.2/default/Tuner.cpp
@@ -26,7 +26,7 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
using namespace std::chrono_literals;
@@ -35,6 +35,13 @@
using V1_0::BandConfig;
using V1_0::Class;
using V1_0::Direction;
+using V1_1::IdentifierType;
+using V1_1::ProgramInfo;
+using V1_1::ProgramInfoFlags;
+using V1_1::ProgramListResult;
+using V1_1::ProgramSelector;
+using V1_1::ProgramType;
+using V1_1::VendorKeyValue;
using utils::HalRevision;
using std::chrono::milliseconds;
@@ -54,7 +61,8 @@
Tuner::Tuner(V1_0::Class classId, const sp<V1_0::ITunerCallback>& callback)
: mClassId(classId),
mCallback(callback),
- mCallback1_1(ITunerCallback::castFrom(callback).withDefault(nullptr)),
+ mCallback1_1(V1_1::ITunerCallback::castFrom(callback).withDefault(nullptr)),
+ mCallback1_2(V1_2::ITunerCallback::castFrom(callback).withDefault(nullptr)),
mVirtualRadio(getRadio(classId)),
mIsAnalogForced(false) {}
@@ -122,7 +130,9 @@
}
HalRevision Tuner::getHalRev() const {
- if (mCallback1_1 != nullptr) {
+ if (mCallback1_2 != nullptr) {
+ return HalRevision::V1_2;
+ } else if (mCallback1_1 != nullptr) {
return HalRevision::V1_1;
} else {
return HalRevision::V1_0;
@@ -310,9 +320,8 @@
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 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) {
@@ -373,8 +382,24 @@
return {};
}
+Return<void> Tuner::setParameters(const hidl_vec<VendorKeyValue>& /* parameters */,
+ setParameters_cb _hidl_cb) {
+ ALOGV("%s", __func__);
+
+ _hidl_cb({});
+ return {};
+}
+
+Return<void> Tuner::getParameters(const hidl_vec<hidl_string>& /* keys */,
+ getParameters_cb _hidl_cb) {
+ ALOGV("%s", __func__);
+
+ _hidl_cb({});
+ return {};
+}
+
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
diff --git a/broadcastradio/1.1/default/Tuner.h b/broadcastradio/1.2/default/Tuner.h
similarity index 68%
rename from broadcastradio/1.1/default/Tuner.h
rename to broadcastradio/1.2/default/Tuner.h
index 07d3189..7e68354 100644
--- a/broadcastradio/1.1/default/Tuner.h
+++ b/broadcastradio/1.2/default/Tuner.h
@@ -13,19 +13,19 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_2_TUNER_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_2_TUNER_H
#include "VirtualRadio.h"
-#include <android/hardware/broadcastradio/1.1/ITuner.h>
-#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
+#include <android/hardware/broadcastradio/1.2/ITuner.h>
+#include <android/hardware/broadcastradio/1.2/ITunerCallback.h>
#include <broadcastradio-utils/WorkerThread.h>
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
struct Tuner : public ITuner {
@@ -33,22 +33,26 @@
void forceClose();
- // V1_1::ITuner methods
+ // V1_2::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> tuneByProgramSelector(const V1_1::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,
+ virtual Return<V1_1::ProgramListResult> startBackgroundScan() override;
+ virtual Return<void> getProgramList(const hidl_vec<V1_1::VendorKeyValue>& filter,
getProgramList_cb _hidl_cb) override;
virtual Return<Result> setAnalogForced(bool isForced) override;
virtual Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
+ virtual Return<void> setParameters(const hidl_vec<V1_1::VendorKeyValue>& parameters,
+ setParameters_cb _hidl_cb) override;
+ virtual Return<void> getParameters(const hidl_vec<hidl_string>& keys,
+ getParameters_cb _hidl_cb) override;
private:
std::mutex mMut;
@@ -58,23 +62,24 @@
V1_0::Class mClassId;
const sp<V1_0::ITunerCallback> mCallback;
const sp<V1_1::ITunerCallback> mCallback1_1;
+ const sp<V1_2::ITunerCallback> mCallback1_2;
std::reference_wrapper<VirtualRadio> mVirtualRadio;
bool mIsAmfmConfigSet = false;
V1_0::BandConfig mAmfmConfig;
bool mIsTuneCompleted = false;
- ProgramSelector mCurrentProgram = {};
- ProgramInfo mCurrentProgramInfo = {};
+ V1_1::ProgramSelector mCurrentProgram = {};
+ V1_1::ProgramInfo mCurrentProgramInfo = {};
std::atomic<bool> mIsAnalogForced;
utils::HalRevision getHalRev() const;
- void tuneInternalLocked(const ProgramSelector& sel);
+ void tuneInternalLocked(const V1_1::ProgramSelector& sel);
};
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_2_TUNER_H
diff --git a/broadcastradio/1.1/default/VirtualProgram.cpp b/broadcastradio/1.2/default/VirtualProgram.cpp
similarity index 96%
rename from broadcastradio/1.1/default/VirtualProgram.cpp
rename to broadcastradio/1.2/default/VirtualProgram.cpp
index 7977391..95879e3 100644
--- a/broadcastradio/1.1/default/VirtualProgram.cpp
+++ b/broadcastradio/1.2/default/VirtualProgram.cpp
@@ -22,7 +22,7 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
using std::vector;
@@ -30,6 +30,9 @@
using V1_0::MetaData;
using V1_0::MetadataKey;
using V1_0::MetadataType;
+using V1_1::IdentifierType;
+using V1_1::ProgramInfo;
+using V1_1::VendorKeyValue;
using utils::HalRevision;
static MetaData createDemoBitmap(MetadataKey key, HalRevision halRev) {
@@ -100,7 +103,7 @@
}
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
diff --git a/broadcastradio/1.1/default/VirtualProgram.h b/broadcastradio/1.2/default/VirtualProgram.h
similarity index 68%
rename from broadcastradio/1.1/default/VirtualProgram.h
rename to broadcastradio/1.2/default/VirtualProgram.h
index a14830d..5342c84 100644
--- a/broadcastradio/1.1/default/VirtualProgram.h
+++ b/broadcastradio/1.2/default/VirtualProgram.h
@@ -13,16 +13,16 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_2_VIRTUALPROGRAM_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_2_VIRTUALPROGRAM_H
-#include <android/hardware/broadcastradio/1.1/types.h>
+#include <android/hardware/broadcastradio/1.2/types.h>
#include <broadcastradio-utils/Utils.h>
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
/**
@@ -32,24 +32,24 @@
* not an entry for a captured station in the radio tuner memory.
*/
struct VirtualProgram {
- ProgramSelector selector;
+ V1_1::ProgramSelector selector;
std::string programName = "";
std::string songArtist = "";
std::string songTitle = "";
- ProgramInfo getProgramInfo(utils::HalRevision halRev) const;
+ V1_1::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);
+std::vector<V1_1::ProgramInfo> getProgramInfoVector(const std::vector<VirtualProgram>& vec,
+ utils::HalRevision halRev);
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALPROGRAM_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_2_VIRTUALPROGRAM_H
diff --git a/broadcastradio/1.1/default/VirtualRadio.cpp b/broadcastradio/1.2/default/VirtualRadio.cpp
similarity index 97%
rename from broadcastradio/1.1/default/VirtualRadio.cpp
rename to broadcastradio/1.2/default/VirtualRadio.cpp
index 36d47a9..867726d 100644
--- a/broadcastradio/1.1/default/VirtualRadio.cpp
+++ b/broadcastradio/1.2/default/VirtualRadio.cpp
@@ -24,11 +24,12 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
using V1_0::Band;
using V1_0::Class;
+using V1_1::ProgramSelector;
using std::lock_guard;
using std::move;
@@ -99,7 +100,7 @@
}
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
diff --git a/broadcastradio/1.1/default/VirtualRadio.h b/broadcastradio/1.2/default/VirtualRadio.h
similarity index 87%
rename from broadcastradio/1.1/default/VirtualRadio.h
rename to broadcastradio/1.2/default/VirtualRadio.h
index 3c7ae5c..8cfaefe 100644
--- a/broadcastradio/1.1/default/VirtualRadio.h
+++ b/broadcastradio/1.2/default/VirtualRadio.h
@@ -13,8 +13,8 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_2_VIRTUALRADIO_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_2_VIRTUALRADIO_H
#include "VirtualProgram.h"
@@ -24,7 +24,7 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
/**
@@ -40,7 +40,7 @@
VirtualRadio(const std::vector<VirtualProgram> initialList);
std::vector<VirtualProgram> getProgramList();
- bool getProgram(const ProgramSelector& selector, VirtualProgram& program);
+ bool getProgram(const V1_1::ProgramSelector& selector, VirtualProgram& program);
private:
std::mutex mMut;
@@ -72,9 +72,9 @@
VirtualRadio& getDigitalRadio();
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_2_VIRTUALRADIO_H
diff --git a/broadcastradio/1.1/default/android.hardware.broadcastradio@1.1-service.rc b/broadcastradio/1.2/default/android.hardware.broadcastradio@1.2-service.rc
similarity index 83%
rename from broadcastradio/1.1/default/android.hardware.broadcastradio@1.1-service.rc
rename to broadcastradio/1.2/default/android.hardware.broadcastradio@1.2-service.rc
index 7c57135..3741f21 100644
--- a/broadcastradio/1.1/default/android.hardware.broadcastradio@1.1-service.rc
+++ b/broadcastradio/1.2/default/android.hardware.broadcastradio@1.2-service.rc
@@ -1,4 +1,4 @@
-service broadcastradio-hal /vendor/bin/hw/android.hardware.broadcastradio@1.1-service
+service broadcastradio-hal /vendor/bin/hw/android.hardware.broadcastradio@1.2-service
class hal
user audioserver
group audio
diff --git a/broadcastradio/1.1/default/resources.h b/broadcastradio/1.2/default/resources.h
similarity index 89%
rename from broadcastradio/1.1/default/resources.h
rename to broadcastradio/1.2/default/resources.h
index b7e709f..b383c27 100644
--- a/broadcastradio/1.1/default/resources.h
+++ b/broadcastradio/1.2/default/resources.h
@@ -13,13 +13,13 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_2_RESOURCES_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_2_RESOURCES_H
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
+namespace V1_2 {
namespace implementation {
namespace resources {
@@ -38,9 +38,9 @@
} // namespace resources
} // namespace implementation
-} // namespace V1_1
+} // namespace V1_2
} // namespace broadcastradio
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_RESOURCES_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_2_RESOURCES_H
diff --git a/broadcastradio/1.1/default/service.cpp b/broadcastradio/1.2/default/service.cpp
similarity index 94%
rename from broadcastradio/1.1/default/service.cpp
rename to broadcastradio/1.2/default/service.cpp
index f8af0b7..ea86fba 100644
--- a/broadcastradio/1.1/default/service.cpp
+++ b/broadcastradio/1.2/default/service.cpp
@@ -22,7 +22,7 @@
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
-using android::hardware::broadcastradio::V1_1::implementation::BroadcastRadioFactory;
+using android::hardware::broadcastradio::V1_2::implementation::BroadcastRadioFactory;
int main(int /* argc */, char** /* argv */) {
configureRpcThreadpool(4, true);
diff --git a/broadcastradio/1.2/types.hal b/broadcastradio/1.2/types.hal
new file mode 100644
index 0000000..5edb097
--- /dev/null
+++ b/broadcastradio/1.2/types.hal
@@ -0,0 +1,23 @@
+/**
+ * Copyright 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.
+ */
+
+package android.hardware.broadcastradio@1.2;
+
+import @1.1::Result;
+import @1.1::VendorKeyValue;
+
+typedef @1.1::Result Result;
+typedef @1.1::VendorKeyValue VendorKeyValue;
diff --git a/broadcastradio/1.1/tests/OWNERS b/broadcastradio/1.2/vts/OWNERS
similarity index 84%
rename from broadcastradio/1.1/tests/OWNERS
rename to broadcastradio/1.2/vts/OWNERS
index aa5ce82..21e1cd6 100644
--- a/broadcastradio/1.1/tests/OWNERS
+++ b/broadcastradio/1.2/vts/OWNERS
@@ -1,6 +1,5 @@
# Automotive team
egranata@google.com
-keunyoung@google.com
twasilczyk@google.com
# VTS team
diff --git a/broadcastradio/1.1/utils/Android.bp b/broadcastradio/1.2/vts/functional/Android.bp
similarity index 62%
copy from broadcastradio/1.1/utils/Android.bp
copy to broadcastradio/1.2/vts/functional/Android.bp
index e80d133..12da14e 100644
--- a/broadcastradio/1.1/utils/Android.bp
+++ b/broadcastradio/1.2/vts/functional/Android.bp
@@ -14,21 +14,16 @@
// 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: [
+cc_test {
+ name: "VtsHalBroadcastradioV1_2TargetTest",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: ["VtsHalBroadcastradioV1_2TargetTest.cpp"],
+ static_libs: [
+ "android.hardware.broadcastradio@1.0",
"android.hardware.broadcastradio@1.1",
+ "android.hardware.broadcastradio@1.2",
+ "android.hardware.broadcastradio@common-utils-lib",
+ "android.hardware.broadcastradio@vts-utils-lib",
+ "libgmock",
],
}
diff --git a/broadcastradio/1.2/vts/functional/VtsHalBroadcastradioV1_2TargetTest.cpp b/broadcastradio/1.2/vts/functional/VtsHalBroadcastradioV1_2TargetTest.cpp
new file mode 100644
index 0000000..f075945
--- /dev/null
+++ b/broadcastradio/1.2/vts/functional/VtsHalBroadcastradioV1_2TargetTest.cpp
@@ -0,0 +1,312 @@
+/*
+ * 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 "broadcastradio.vts"
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
+#include <android/hardware/broadcastradio/1.2/IBroadcastRadioFactory.h>
+#include <android/hardware/broadcastradio/1.2/ITuner.h>
+#include <android/hardware/broadcastradio/1.2/ITunerCallback.h>
+#include <android/hardware/broadcastradio/1.2/types.h>
+#include <android-base/logging.h>
+#include <broadcastradio-utils/Utils.h>
+#include <broadcastradio-vts-utils/call-barrier.h>
+#include <broadcastradio-vts-utils/mock-timeout.h>
+#include <cutils/native_handle.h>
+#include <cutils/properties.h>
+#include <gmock/gmock.h>
+#include <hidl/HidlTransportSupport.h>
+#include <utils/threads.h>
+
+#include <chrono>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_2 {
+namespace vts {
+
+using namespace std::chrono_literals;
+
+using testing::_;
+using testing::AnyNumber;
+using testing::ByMove;
+using testing::DoAll;
+using testing::Invoke;
+using testing::SaveArg;
+
+using broadcastradio::vts::CallBarrier;
+using V1_0::BandConfig;
+using V1_0::Class;
+using V1_0::MetaData;
+using V1_0::MetadataKey;
+using V1_0::MetadataType;
+using V1_1::IBroadcastRadio;
+using V1_1::ProgramInfo;
+using V1_1::ProgramListResult;
+using V1_1::ProgramSelector;
+using V1_1::Properties;
+
+using std::chrono::steady_clock;
+using std::this_thread::sleep_for;
+
+static constexpr auto kConfigTimeout = 10s;
+static constexpr auto kConnectModuleTimeout = 1s;
+
+static void printSkipped(std::string msg) {
+ std::cout << "[ SKIPPED ] " << msg << std::endl;
+}
+
+struct TunerCallbackMock : public ITunerCallback {
+ TunerCallbackMock() { EXPECT_CALL(*this, hardwareFailure()).Times(0); }
+
+ MOCK_METHOD0(hardwareFailure, Return<void>());
+ MOCK_TIMEOUT_METHOD2(configChange, Return<void>(Result, const BandConfig&));
+ MOCK_METHOD2(tuneComplete, Return<void>(Result, const V1_0::ProgramInfo&));
+ MOCK_TIMEOUT_METHOD2(tuneComplete_1_1, Return<void>(Result, const ProgramSelector&));
+ MOCK_METHOD1(afSwitch, Return<void>(const V1_0::ProgramInfo&));
+ MOCK_METHOD1(antennaStateChange, Return<void>(bool connected));
+ MOCK_METHOD1(trafficAnnouncement, Return<void>(bool active));
+ MOCK_METHOD1(emergencyAnnouncement, Return<void>(bool active));
+ MOCK_METHOD3(newMetadata, Return<void>(uint32_t ch, uint32_t subCh, const hidl_vec<MetaData>&));
+ MOCK_METHOD1(backgroundScanAvailable, Return<void>(bool));
+ MOCK_TIMEOUT_METHOD1(backgroundScanComplete, Return<void>(ProgramListResult));
+ MOCK_METHOD0(programListChanged, Return<void>());
+ MOCK_TIMEOUT_METHOD1(currentProgramInfoChanged, Return<void>(const ProgramInfo&));
+ MOCK_METHOD1(parametersUpdated, Return<void>(const hidl_vec<VendorKeyValue>& parameters));
+};
+
+class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase,
+ public ::testing::WithParamInterface<Class> {
+ protected:
+ virtual void SetUp() override;
+ virtual void TearDown() override;
+
+ bool openTuner();
+
+ Class radioClass;
+ bool skipped = false;
+
+ sp<IBroadcastRadio> mRadioModule;
+ sp<ITuner> mTuner;
+ sp<TunerCallbackMock> mCallback = new TunerCallbackMock();
+
+ private:
+ const BandConfig& getBand(unsigned idx);
+
+ hidl_vec<BandConfig> mBands;
+};
+
+/**
+ * Clears strong pointer and waits until the object gets destroyed.
+ *
+ * @param ptr The pointer to get cleared.
+ * @param timeout Time to wait for other references.
+ */
+template <typename T>
+static void clearAndWait(sp<T>& ptr, std::chrono::milliseconds timeout) {
+ wp<T> wptr = ptr;
+ ptr.clear();
+ auto limit = steady_clock::now() + timeout;
+ while (wptr.promote() != nullptr) {
+ constexpr auto step = 10ms;
+ if (steady_clock::now() + step > limit) {
+ FAIL() << "Pointer was not released within timeout";
+ break;
+ }
+ sleep_for(step);
+ }
+}
+
+void BroadcastRadioHalTest::SetUp() {
+ radioClass = GetParam();
+
+ // lookup HIDL service
+ auto factory = getService<IBroadcastRadioFactory>();
+ ASSERT_NE(nullptr, factory.get());
+
+ // connect radio module
+ Result connectResult;
+ CallBarrier onConnect;
+ factory->connectModule(radioClass, [&](Result ret, const sp<V1_0::IBroadcastRadio>& radio) {
+ connectResult = ret;
+ if (ret == Result::OK) mRadioModule = IBroadcastRadio::castFrom(radio);
+ onConnect.call();
+ });
+ ASSERT_TRUE(onConnect.waitForCall(kConnectModuleTimeout));
+
+ if (connectResult == Result::INVALID_ARGUMENTS) {
+ printSkipped("This device class is not supported.");
+ skipped = true;
+ return;
+ }
+ ASSERT_EQ(connectResult, Result::OK);
+ ASSERT_NE(nullptr, mRadioModule.get());
+
+ // get module properties
+ Properties prop11;
+ auto& prop10 = prop11.base;
+ auto propResult =
+ mRadioModule->getProperties_1_1([&](const Properties& properties) { prop11 = properties; });
+
+ ASSERT_TRUE(propResult.isOk());
+ EXPECT_EQ(radioClass, prop10.classId);
+ EXPECT_GT(prop10.numTuners, 0u);
+ EXPECT_GT(prop11.supportedProgramTypes.size(), 0u);
+ EXPECT_GT(prop11.supportedIdentifierTypes.size(), 0u);
+ if (radioClass == Class::AM_FM) {
+ EXPECT_GT(prop10.bands.size(), 0u);
+ }
+ mBands = prop10.bands;
+}
+
+void BroadcastRadioHalTest::TearDown() {
+ mTuner.clear();
+ mRadioModule.clear();
+ clearAndWait(mCallback, 1s);
+}
+
+bool BroadcastRadioHalTest::openTuner() {
+ EXPECT_EQ(nullptr, mTuner.get());
+
+ if (radioClass == Class::AM_FM) {
+ EXPECT_TIMEOUT_CALL(*mCallback, configChange, Result::OK, _);
+ }
+
+ Result halResult = Result::NOT_INITIALIZED;
+ auto openCb = [&](Result result, const sp<V1_0::ITuner>& tuner) {
+ halResult = result;
+ if (result != Result::OK) return;
+ mTuner = ITuner::castFrom(tuner);
+ };
+ auto hidlResult = mRadioModule->openTuner(getBand(0), true, mCallback, openCb);
+
+ EXPECT_TRUE(hidlResult.isOk());
+ EXPECT_EQ(Result::OK, halResult);
+ EXPECT_NE(nullptr, mTuner.get());
+ if (radioClass == Class::AM_FM && mTuner != nullptr) {
+ EXPECT_TIMEOUT_CALL_WAIT(*mCallback, configChange, kConfigTimeout);
+
+ BandConfig halConfig;
+ Result halResult = Result::NOT_INITIALIZED;
+ mTuner->getConfiguration([&](Result result, const BandConfig& config) {
+ halResult = result;
+ halConfig = config;
+ });
+ EXPECT_EQ(Result::OK, halResult);
+ EXPECT_TRUE(halConfig.antennaConnected);
+ }
+
+ EXPECT_NE(nullptr, mTuner.get());
+ return nullptr != mTuner.get();
+}
+
+const BandConfig& BroadcastRadioHalTest::getBand(unsigned idx) {
+ static const BandConfig dummyBandConfig = {};
+
+ if (radioClass != Class::AM_FM) {
+ ALOGD("Not AM/FM radio, returning dummy band config");
+ return dummyBandConfig;
+ }
+
+ EXPECT_GT(mBands.size(), idx);
+ if (mBands.size() <= idx) {
+ ALOGD("Band index out of bound, returning dummy band config");
+ return dummyBandConfig;
+ }
+
+ auto& band = mBands[idx];
+ ALOGD("Returning %s band", toString(band.type).c_str());
+ return band;
+}
+
+/**
+ * Test IBroadcastRadio::get|setParameters() methods called with no parameters.
+ *
+ * Verifies that:
+ * - callback is called for empty parameters set.
+ */
+TEST_P(BroadcastRadioHalTest, NoParameters) {
+ if (skipped) return;
+
+ ASSERT_TRUE(openTuner());
+
+ hidl_vec<VendorKeyValue> halResults = {};
+ bool wasCalled = false;
+ auto cb = [&](hidl_vec<VendorKeyValue> results) {
+ wasCalled = true;
+ halResults = results;
+ };
+
+ auto hidlResult = mTuner->setParameters({}, cb);
+ ASSERT_TRUE(hidlResult.isOk());
+ ASSERT_TRUE(wasCalled);
+ ASSERT_EQ(0u, halResults.size());
+
+ wasCalled = false;
+ hidlResult = mTuner->getParameters({}, cb);
+ ASSERT_TRUE(hidlResult.isOk());
+ ASSERT_TRUE(wasCalled);
+ ASSERT_EQ(0u, halResults.size());
+}
+
+/**
+ * Test IBroadcastRadio::get|setParameters() methods called with unknown parameters.
+ *
+ * Verifies that:
+ * - unknown parameters are ignored;
+ * - callback is called also for empty results set.
+ */
+TEST_P(BroadcastRadioHalTest, UnknownParameters) {
+ if (skipped) return;
+
+ ASSERT_TRUE(openTuner());
+
+ hidl_vec<VendorKeyValue> halResults = {};
+ bool wasCalled = false;
+ auto cb = [&](hidl_vec<VendorKeyValue> results) {
+ wasCalled = true;
+ halResults = results;
+ };
+
+ auto hidlResult = mTuner->setParameters({{"com.google.unknown", "dummy"}}, cb);
+ ASSERT_TRUE(hidlResult.isOk());
+ ASSERT_TRUE(wasCalled);
+ ASSERT_EQ(0u, halResults.size());
+
+ wasCalled = false;
+ hidlResult = mTuner->getParameters({{"com.google.unknown*", "dummy"}}, cb);
+ ASSERT_TRUE(hidlResult.isOk());
+ ASSERT_TRUE(wasCalled);
+ ASSERT_EQ(0u, halResults.size());
+}
+
+INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest,
+ ::testing::Values(Class::AM_FM, Class::SAT, Class::DT));
+
+} // namespace vts
+} // namespace V1_2
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
diff --git a/broadcastradio/Android.bp b/broadcastradio/Android.bp
index 8c65bf6..68cc99f 100644
--- a/broadcastradio/Android.bp
+++ b/broadcastradio/Android.bp
@@ -4,9 +4,11 @@
"1.0/default",
"1.0/vts/functional",
"1.1",
- "1.1/default",
- "1.1/tests",
- "1.1/utils",
"1.1/vts/functional",
- "1.1/vts/utils",
+ "1.2",
+ "1.2/default",
+ "1.2/vts/functional",
+ "common/tests",
+ "common/utils",
+ "common/vts/utils",
]
diff --git a/broadcastradio/1.1/tests/Android.bp b/broadcastradio/common/tests/Android.bp
similarity index 85%
rename from broadcastradio/1.1/tests/Android.bp
rename to broadcastradio/common/tests/Android.bp
index fa1fd94..4456602 100644
--- a/broadcastradio/1.1/tests/Android.bp
+++ b/broadcastradio/common/tests/Android.bp
@@ -15,7 +15,7 @@
//
cc_test {
- name: "android.hardware.broadcastradio@1.1-utils-tests",
+ name: "android.hardware.broadcastradio@common-utils-tests",
vendor: true,
cflags: [
"-Wall",
@@ -25,5 +25,5 @@
srcs: [
"WorkerThread_test.cpp",
],
- static_libs: ["android.hardware.broadcastradio@1.1-utils-lib"],
-}
+ static_libs: ["android.hardware.broadcastradio@common-utils-lib"],
+}
\ No newline at end of file
diff --git a/broadcastradio/1.1/tests/OWNERS b/broadcastradio/common/tests/OWNERS
similarity index 84%
copy from broadcastradio/1.1/tests/OWNERS
copy to broadcastradio/common/tests/OWNERS
index aa5ce82..21e1cd6 100644
--- a/broadcastradio/1.1/tests/OWNERS
+++ b/broadcastradio/common/tests/OWNERS
@@ -1,6 +1,5 @@
# Automotive team
egranata@google.com
-keunyoung@google.com
twasilczyk@google.com
# VTS team
diff --git a/broadcastradio/1.1/tests/WorkerThread_test.cpp b/broadcastradio/common/tests/WorkerThread_test.cpp
similarity index 100%
rename from broadcastradio/1.1/tests/WorkerThread_test.cpp
rename to broadcastradio/common/tests/WorkerThread_test.cpp
diff --git a/broadcastradio/1.1/utils/Android.bp b/broadcastradio/common/utils/Android.bp
similarity index 93%
rename from broadcastradio/1.1/utils/Android.bp
rename to broadcastradio/common/utils/Android.bp
index e80d133..d8bd125 100644
--- a/broadcastradio/1.1/utils/Android.bp
+++ b/broadcastradio/common/utils/Android.bp
@@ -15,7 +15,7 @@
//
cc_library_static {
- name: "android.hardware.broadcastradio@1.1-utils-lib",
+ name: "android.hardware.broadcastradio@common-utils-lib",
vendor_available: true,
relative_install_path: "hw",
cflags: [
diff --git a/broadcastradio/1.1/utils/OWNERS b/broadcastradio/common/utils/OWNERS
similarity index 74%
rename from broadcastradio/1.1/utils/OWNERS
rename to broadcastradio/common/utils/OWNERS
index 0c27b71..136b607 100644
--- a/broadcastradio/1.1/utils/OWNERS
+++ b/broadcastradio/common/utils/OWNERS
@@ -1,4 +1,3 @@
# Automotive team
egranata@google.com
-keunyoung@google.com
twasilczyk@google.com
diff --git a/broadcastradio/1.1/utils/Utils.cpp b/broadcastradio/common/utils/Utils.cpp
similarity index 97%
rename from broadcastradio/1.1/utils/Utils.cpp
rename to broadcastradio/common/utils/Utils.cpp
index 4dd6b13..bdaf8e8 100644
--- a/broadcastradio/1.1/utils/Utils.cpp
+++ b/broadcastradio/common/utils/Utils.cpp
@@ -23,10 +23,13 @@
namespace android {
namespace hardware {
namespace broadcastradio {
-namespace V1_1 {
namespace utils {
using V1_0::Band;
+using V1_1::IdentifierType;
+using V1_1::ProgramIdentifier;
+using V1_1::ProgramSelector;
+using V1_1::ProgramType;
static bool isCompatibleProgramType(const uint32_t ia, const uint32_t ib) {
auto a = static_cast<ProgramType>(ia);
@@ -208,7 +211,6 @@
}
} // namespace utils
-} // namespace V1_1
namespace V1_0 {
@@ -218,9 +220,9 @@
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)) {
+ if (utils::isAm(l.type)) {
return l.ext.am == r.ext.am;
- } else if (V1_1::utils::isFm(l.type)) {
+ } else if (utils::isFm(l.type)) {
return l.ext.fm == r.ext.fm;
} else {
ALOGW("Unsupported band config type: %s", toString(l.type).c_str());
diff --git a/broadcastradio/1.1/utils/WorkerThread.cpp b/broadcastradio/common/utils/WorkerThread.cpp
similarity index 100%
rename from broadcastradio/1.1/utils/WorkerThread.cpp
rename to broadcastradio/common/utils/WorkerThread.cpp
diff --git a/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h b/broadcastradio/common/utils/include/broadcastradio-utils/Utils.h
similarity index 66%
rename from broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h
rename to broadcastradio/common/utils/include/broadcastradio-utils/Utils.h
index 24c60ee..b07ce79 100644
--- a/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h
+++ b/broadcastradio/common/utils/include/broadcastradio-utils/Utils.h
@@ -13,8 +13,8 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_COMMON_UTILS_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_COMMON_UTILS_H
#include <android/hardware/broadcastradio/1.1/types.h>
#include <chrono>
@@ -24,13 +24,12 @@
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,
+ V1_2,
};
/**
@@ -43,38 +42,38 @@
* @param pointer selector we're trying to match against channel.
* @param channel existing channel.
*/
-bool tunesTo(const ProgramSelector& pointer, const ProgramSelector& channel);
+bool tunesTo(const V1_1::ProgramSelector& pointer, const V1_1::ProgramSelector& channel);
-ProgramType getType(const ProgramSelector& sel);
-bool isAmFm(const ProgramType type);
+V1_1::ProgramType getType(const V1_1::ProgramSelector& sel);
+bool isAmFm(const V1_1::ProgramType type);
bool isAm(const V1_0::Band band);
bool isFm(const V1_0::Band band);
-bool hasId(const ProgramSelector& sel, const IdentifierType type);
+bool hasId(const V1_1::ProgramSelector& sel, const V1_1::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);
+uint64_t getId(const V1_1::ProgramSelector& sel, const V1_1::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);
+uint64_t getId(const V1_1::ProgramSelector& sel, const V1_1::IdentifierType type, uint64_t defval);
-ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0);
+V1_1::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 getLegacyChannel(const V1_1::ProgramSelector& sel,
+ uint32_t* channelOut, uint32_t* subChannelOut);
-bool isDigital(const ProgramSelector& sel);
+bool isDigital(const V1_1::ProgramSelector& sel);
} // namespace utils
-} // namespace V1_1
namespace V1_0 {
@@ -86,4 +85,4 @@
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_COMMON_UTILS_H
diff --git a/broadcastradio/1.1/utils/include/broadcastradio-utils/WorkerThread.h b/broadcastradio/common/utils/include/broadcastradio-utils/WorkerThread.h
similarity index 87%
rename from broadcastradio/1.1/utils/include/broadcastradio-utils/WorkerThread.h
rename to broadcastradio/common/utils/include/broadcastradio-utils/WorkerThread.h
index 635876f..62bede6 100644
--- a/broadcastradio/1.1/utils/include/broadcastradio-utils/WorkerThread.h
+++ b/broadcastradio/common/utils/include/broadcastradio-utils/WorkerThread.h
@@ -13,8 +13,8 @@
* 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
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_COMMON_WORKERTHREAD_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_COMMON_WORKERTHREAD_H
#include <chrono>
#include <queue>
@@ -48,4 +48,4 @@
} // namespace android
-#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_WORKERTHREAD_H
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_COMMON_WORKERTHREAD_H
diff --git a/broadcastradio/1.1/vts/utils/Android.bp b/broadcastradio/common/vts/utils/Android.bp
similarity index 92%
rename from broadcastradio/1.1/vts/utils/Android.bp
rename to broadcastradio/common/vts/utils/Android.bp
index 0c7e2a4..4ba8a17 100644
--- a/broadcastradio/1.1/vts/utils/Android.bp
+++ b/broadcastradio/common/vts/utils/Android.bp
@@ -15,7 +15,7 @@
//
cc_library_static {
- name: "android.hardware.broadcastradio@1.1-vts-utils-lib",
+ name: "android.hardware.broadcastradio@vts-utils-lib",
srcs: [
"call-barrier.cpp",
],
diff --git a/broadcastradio/1.1/tests/OWNERS b/broadcastradio/common/vts/utils/OWNERS
similarity index 83%
copy from broadcastradio/1.1/tests/OWNERS
copy to broadcastradio/common/vts/utils/OWNERS
index aa5ce82..21e1cd6 100644
--- a/broadcastradio/1.1/tests/OWNERS
+++ b/broadcastradio/common/vts/utils/OWNERS
@@ -1,6 +1,5 @@
# Automotive team
egranata@google.com
-keunyoung@google.com
twasilczyk@google.com
# VTS team
diff --git a/broadcastradio/1.1/vts/utils/call-barrier.cpp b/broadcastradio/common/vts/utils/call-barrier.cpp
similarity index 100%
rename from broadcastradio/1.1/vts/utils/call-barrier.cpp
rename to broadcastradio/common/vts/utils/call-barrier.cpp
diff --git a/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/call-barrier.h b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/call-barrier.h
similarity index 100%
rename from broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/call-barrier.h
rename to broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/call-barrier.h
diff --git a/broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
similarity index 100%
rename from broadcastradio/1.1/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h
rename to broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/mock-timeout.h