Merge "graphics: add IMapper@2.1"
diff --git a/audio/2.0/Android.bp b/audio/2.0/Android.bp
index ea3ea84..06299b6 100644
--- a/audio/2.0/Android.bp
+++ b/audio/2.0/Android.bp
@@ -186,6 +186,7 @@
cc_test {
name: "android.hardware.audio@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp
index 104bbac..82b38c0 100644
--- a/audio/common/2.0/default/Android.bp
+++ b/audio/common/2.0/default/Android.bp
@@ -15,6 +15,7 @@
cc_library_shared {
name: "android.hardware.audio.common@2.0-util",
+ defaults: ["hidl_defaults"],
vendor_available: true,
vndk: {
enabled: true,
diff --git a/audio/effect/2.0/Android.bp b/audio/effect/2.0/Android.bp
index e940296..e939ece 100644
--- a/audio/effect/2.0/Android.bp
+++ b/audio/effect/2.0/Android.bp
@@ -249,6 +249,7 @@
cc_test {
name: "android.hardware.audio.effect@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/automotive/evs/1.0/Android.bp b/automotive/evs/1.0/Android.bp
index be58711..da68c2a 100644
--- a/automotive/evs/1.0/Android.bp
+++ b/automotive/evs/1.0/Android.bp
@@ -155,6 +155,7 @@
cc_test {
name: "android.hardware.automotive.evs@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/automotive/vehicle/2.0/Android.bp b/automotive/vehicle/2.0/Android.bp
index ffc768e..0d0d28f 100644
--- a/automotive/vehicle/2.0/Android.bp
+++ b/automotive/vehicle/2.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.automotive.vehicle@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/biometrics/fingerprint/2.1/Android.bp b/biometrics/fingerprint/2.1/Android.bp
index 719f47d..e6e4827 100644
--- a/biometrics/fingerprint/2.1/Android.bp
+++ b/biometrics/fingerprint/2.1/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.biometrics.fingerprint@2.1-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
index 5637aa4..9d2cf6e 100644
--- a/bluetooth/1.0/Android.bp
+++ b/bluetooth/1.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.bluetooth@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/boot/1.0/Android.bp b/boot/1.0/Android.bp
index ad9cfc7..e15b2d0 100644
--- a/boot/1.0/Android.bp
+++ b/boot/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.boot@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/boot/1.0/vts/Android.bp b/boot/1.0/vts/Android.bp
deleted file mode 100644
index 7aef46b..0000000
--- a/boot/1.0/vts/Android.bp
+++ /dev/null
@@ -1,3 +0,0 @@
-subdirs = [
- "*"
-]
diff --git a/boot/Android.bp b/boot/Android.bp
index 67af5bb..33f70eb 100644
--- a/boot/Android.bp
+++ b/boot/Android.bp
@@ -1,6 +1,5 @@
// This is an autogenerated file, do not edit.
subdirs = [
"1.0",
- "1.0/vts",
"1.0/vts/functional",
]
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
index 9b8c5b3..b394fdc 100644
--- a/broadcastradio/1.0/Android.bp
+++ b/broadcastradio/1.0/Android.bp
@@ -155,6 +155,7 @@
cc_test {
name: "android.hardware.broadcastradio@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/broadcastradio/1.1/Android.bp b/broadcastradio/1.1/Android.bp
index 2111c16..fa1c3e9 100644
--- a/broadcastradio/1.1/Android.bp
+++ b/broadcastradio/1.1/Android.bp
@@ -161,6 +161,7 @@
cc_test {
name: "android.hardware.broadcastradio@1.1-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
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
diff --git a/camera/device/1.0/Android.bp b/camera/device/1.0/Android.bp
index dfc58c9..5b2d4c0 100644
--- a/camera/device/1.0/Android.bp
+++ b/camera/device/1.0/Android.bp
@@ -154,6 +154,7 @@
cc_test {
name: "android.hardware.camera.device@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/camera/device/3.2/Android.bp b/camera/device/3.2/Android.bp
index d770964..15a7dcd 100644
--- a/camera/device/3.2/Android.bp
+++ b/camera/device/3.2/Android.bp
@@ -154,6 +154,7 @@
cc_test {
name: "android.hardware.camera.device@3.2-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/camera/provider/2.4/Android.bp b/camera/provider/2.4/Android.bp
index 71057ce..a71ee43 100644
--- a/camera/provider/2.4/Android.bp
+++ b/camera/provider/2.4/Android.bp
@@ -149,6 +149,7 @@
cc_test {
name: "android.hardware.camera.provider@2.4-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/configstore/1.0/Android.bp b/configstore/1.0/Android.bp
index bd11112..3e9c200 100644
--- a/configstore/1.0/Android.bp
+++ b/configstore/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.configstore@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/contexthub/1.0/Android.bp b/contexthub/1.0/Android.bp
index 74e028c..e8f7103 100644
--- a/contexthub/1.0/Android.bp
+++ b/contexthub/1.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.contexthub@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/drm/1.0/Android.bp b/drm/1.0/Android.bp
index c5f814c..502d10e 100644
--- a/drm/1.0/Android.bp
+++ b/drm/1.0/Android.bp
@@ -164,6 +164,7 @@
cc_test {
name: "android.hardware.drm@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
index 3966eac..4652c76 100644
--- a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
@@ -76,12 +76,14 @@
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
-static const uint8_t kCommonPsshBoxUUID[16] = {0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02,
- 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B};
+static const uint8_t kCommonPsshBoxUUID[16] = {
+ 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02,
+ 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B};
// To be used in mpd to specify drm scheme for players
-static const uint8_t kClearKeyUUID[16] = {0xE2, 0x71, 0x9D, 0x58, 0xA9, 0x85, 0xB3, 0xC9,
- 0x78, 0x1A, 0xB0, 0x30, 0xAF, 0x78, 0xD3, 0x0E};
+static const uint8_t kClearKeyUUID[16] = {
+ 0xE2, 0x71, 0x9D, 0x58, 0xA9, 0x85, 0xB3, 0xC9,
+ 0x78, 0x1A, 0xB0, 0x30, 0xAF, 0x78, 0xD3, 0x0E};
static const uint8_t kInvalidUUID[16] = {
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
@@ -111,7 +113,7 @@
};
/**
- * Ensure the factory supports the clearkey scheme UUID
+ * Ensure the factory supports both Common Pssh Box UUID and Clearkey Scheme UUID
*/
TEST_F(DrmHalClearkeyFactoryTest, ClearKeyPluginSupported) {
EXPECT_TRUE(drmFactory->isCryptoSchemeSupported(kCommonPsshBoxUUID));
@@ -164,9 +166,23 @@
}
/**
- * Ensure clearkey drm plugin can be created
+ * Ensure clearkey drm plugin can be created using Common Pssh Box UUID
*/
-TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyDrmPlugin) {
+TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyDrmPluginUsingCommonPsshBoxUuid) {
+ hidl_string packageName("android.hardware.drm.test");
+ auto res = drmFactory->createPlugin(
+ kCommonPsshBoxUUID, packageName,
+ [&](Status status, const sp<IDrmPlugin>& plugin) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_NE(nullptr, plugin.get());
+ });
+ EXPECT_OK(res);
+}
+
+/**
+ * Ensure clearkey drm plugin can be created using ClearKey UUID
+ */
+ TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyDrmPluginUsingClearKeyUuid) {
hidl_string packageName("android.hardware.drm.test");
auto res = drmFactory->createPlugin(
kClearKeyUUID, packageName,
@@ -178,9 +194,23 @@
}
/**
- * Ensure clearkey crypto plugin can be created
+ * Ensure clearkey crypto plugin can be created using Common Pssh Box UUID
*/
-TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyCryptoPlugin) {
+TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyCryptoPluginUsingCommonPsshBoxUuid) {
+ hidl_vec<uint8_t> initVec;
+ auto res = cryptoFactory->createPlugin(
+ kCommonPsshBoxUUID, initVec,
+ [&](Status status, const sp<ICryptoPlugin>& plugin) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_NE(nullptr, plugin.get());
+ });
+ EXPECT_OK(res);
+}
+
+/**
+ * Ensure clearkey crypto plugin can be created using ClearKey UUID
+ */
+TEST_F(DrmHalClearkeyFactoryTest, CreateClearKeyCryptoPluginUsingClearKeyUuid) {
hidl_vec<uint8_t> initVec;
auto res = cryptoFactory->createPlugin(
kClearKeyUUID, initVec,
@@ -332,32 +362,29 @@
// full box header (version = 1 flags = 0)
0x01, 0x00, 0x00, 0x00,
// system id
- 0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e,
- 0x52, 0xe2, 0xfb, 0x4b,
+ 0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c,
+ 0x1e, 0x52, 0xe2, 0xfb, 0x4b,
// number of key ids
0x00, 0x00, 0x00, 0x01,
// key id
- 0x60, 0x06, 0x1e, 0x01, 0x7e, 0x47, 0x7e, 0x87, 0x7e, 0x57, 0xd0, 0x0d,
- 0x1e, 0xd0, 0x0d, 0x1e,
+ 0x60, 0x06, 0x1e, 0x01, 0x7e, 0x47, 0x7e, 0x87, 0x7e, 0x57, 0xd0,
+ 0x0d, 0x1e, 0xd0, 0x0d, 0x1e,
// size of data, must be zero
0x00, 0x00, 0x00, 0x00};
hidl_vec<uint8_t> expectedKeyRequest = {
- 0x7b, 0x22, 0x6b, 0x69, 0x64, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x59,
- 0x41, 0x59, 0x65, 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2b,
- 0x56, 0x39, 0x41, 0x4e, 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22,
- 0x5d, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x74,
- 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x79, 0x22, 0x7d};
+ 0x7b, 0x22, 0x6b, 0x69, 0x64, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x59, 0x41, 0x59, 0x65,
+ 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2d, 0x56, 0x39, 0x41, 0x4e, 0x48, 0x74,
+ 0x41, 0x4e, 0x48, 0x67, 0x22, 0x5d, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a,
+ 0x22, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x79, 0x22, 0x7d};
hidl_vec<uint8_t> knownKeyResponse = {
- 0x7b, 0x22, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22,
- 0x6b, 0x74, 0x79, 0x22, 0x3a, 0x22, 0x6f, 0x63, 0x74, 0x22, 0x2c,
- 0x22, 0x6b, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x59, 0x41, 0x59, 0x65,
- 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2b, 0x56, 0x39, 0x41,
- 0x4e, 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22, 0x2c, 0x22, 0x6b,
- 0x22, 0x3a, 0x22, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x54, 0x65,
- 0x73, 0x74, 0x4b, 0x65, 0x79, 0x42, 0x61, 0x73, 0x65, 0x36, 0x34,
- 0x67, 0x67, 0x67, 0x22, 0x7d, 0x5d, 0x7d, 0x0a};
+ 0x7b, 0x22, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x6b, 0x74, 0x79, 0x22,
+ 0x3a, 0x22, 0x6f, 0x63, 0x74, 0x22, 0x2c, 0x22, 0x6b, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x59,
+ 0x41, 0x59, 0x65, 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2d, 0x56, 0x39, 0x41, 0x4e,
+ 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22, 0x2c, 0x22, 0x6b, 0x22, 0x3a, 0x22, 0x47, 0x6f,
+ 0x6f, 0x67, 0x6c, 0x65, 0x54, 0x65, 0x73, 0x74, 0x4b, 0x65, 0x79, 0x42, 0x61, 0x73, 0x65,
+ 0x36, 0x34, 0x67, 0x67, 0x67, 0x22, 0x7d, 0x5d, 0x7d, 0x0a};
hidl_string mimeType = "video/mp4";
KeyedVector optionalParameters;
@@ -1085,12 +1112,11 @@
*/
TEST_F(DrmHalClearkeyDecryptTest, TestQueryKeyStatus) {
auto sessionId = openSession();
- auto res = drmPlugin->queryKeyStatus(sessionId,
- [&](Status status, KeyedVector /* info */) {
- // clearkey doesn't support this method
- EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status);
- });
+ auto res = drmPlugin->queryKeyStatus(
+ sessionId, [&](Status status, KeyedVector /* info */) { EXPECT_EQ(Status::OK, status); });
EXPECT_OK(res);
+
+ closeSession(sessionId);
}
diff --git a/dumpstate/1.0/Android.bp b/dumpstate/1.0/Android.bp
index 684ab35..5a028a5 100644
--- a/dumpstate/1.0/Android.bp
+++ b/dumpstate/1.0/Android.bp
@@ -124,6 +124,7 @@
cc_test {
name: "android.hardware.dumpstate@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/gatekeeper/1.0/Android.bp b/gatekeeper/1.0/Android.bp
index b3cd75e..5692bf1 100644
--- a/gatekeeper/1.0/Android.bp
+++ b/gatekeeper/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.gatekeeper@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/gnss/1.0/Android.bp b/gnss/1.0/Android.bp
index f40e6e1..36b2095 100644
--- a/gnss/1.0/Android.bp
+++ b/gnss/1.0/Android.bp
@@ -299,6 +299,7 @@
cc_test {
name: "android.hardware.gnss@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/graphics/allocator/2.0/Android.bp b/graphics/allocator/2.0/Android.bp
index c24da12..6532065 100644
--- a/graphics/allocator/2.0/Android.bp
+++ b/graphics/allocator/2.0/Android.bp
@@ -135,6 +135,7 @@
cc_test {
name: "android.hardware.graphics.allocator@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/graphics/bufferqueue/1.0/Android.bp b/graphics/bufferqueue/1.0/Android.bp
index c96c3c3..44052c7 100644
--- a/graphics/bufferqueue/1.0/Android.bp
+++ b/graphics/bufferqueue/1.0/Android.bp
@@ -141,6 +141,7 @@
cc_test {
name: "android.hardware.graphics.bufferqueue@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/graphics/composer/2.1/Android.bp b/graphics/composer/2.1/Android.bp
index 9080781..3bdd0a6 100644
--- a/graphics/composer/2.1/Android.bp
+++ b/graphics/composer/2.1/Android.bp
@@ -150,6 +150,7 @@
cc_test {
name: "android.hardware.graphics.composer@2.1-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/graphics/mapper/2.0/Android.bp b/graphics/mapper/2.0/Android.bp
index f829840..6ab99b5 100644
--- a/graphics/mapper/2.0/Android.bp
+++ b/graphics/mapper/2.0/Android.bp
@@ -133,6 +133,7 @@
cc_test {
name: "android.hardware.graphics.mapper@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/health/1.0/Android.bp b/health/1.0/Android.bp
index 1b5661c..aff56a8 100644
--- a/health/1.0/Android.bp
+++ b/health/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.health@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/health/2.0/Android.bp b/health/2.0/Android.bp
new file mode 100644
index 0000000..f944471
--- /dev/null
+++ b/health/2.0/Android.bp
@@ -0,0 +1,157 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.health@2.0_hal",
+ srcs: [
+ "types.hal",
+ "IHealth.hal",
+ "IHealthInfoCallback.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.health@2.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
+ srcs: [
+ ":android.hardware.health@2.0_hal",
+ ],
+ out: [
+ "android/hardware/health/2.0/types.cpp",
+ "android/hardware/health/2.0/HealthAll.cpp",
+ "android/hardware/health/2.0/HealthInfoCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.health@2.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
+ srcs: [
+ ":android.hardware.health@2.0_hal",
+ ],
+ out: [
+ "android/hardware/health/2.0/types.h",
+ "android/hardware/health/2.0/hwtypes.h",
+ "android/hardware/health/2.0/IHealth.h",
+ "android/hardware/health/2.0/IHwHealth.h",
+ "android/hardware/health/2.0/BnHwHealth.h",
+ "android/hardware/health/2.0/BpHwHealth.h",
+ "android/hardware/health/2.0/BsHealth.h",
+ "android/hardware/health/2.0/IHealthInfoCallback.h",
+ "android/hardware/health/2.0/IHwHealthInfoCallback.h",
+ "android/hardware/health/2.0/BnHwHealthInfoCallback.h",
+ "android/hardware/health/2.0/BpHwHealthInfoCallback.h",
+ "android/hardware/health/2.0/BsHealthInfoCallback.h",
+ ],
+}
+
+cc_library {
+ name: "android.hardware.health@2.0",
+ defaults: ["hidl-module-defaults"],
+ generated_sources: ["android.hardware.health@2.0_genc++"],
+ generated_headers: ["android.hardware.health@2.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.health@2.0_genc++_headers"],
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.health@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.health@1.0",
+ ],
+}
+
+genrule {
+ name: "android.hardware.health@2.0-adapter-helper_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
+ srcs: [
+ ":android.hardware.health@2.0_hal",
+ ],
+ out: [
+ "android/hardware/health/2.0/AHealth.cpp",
+ "android/hardware/health/2.0/AHealthInfoCallback.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.health@2.0-adapter-helper_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
+ srcs: [
+ ":android.hardware.health@2.0_hal",
+ ],
+ out: [
+ "android/hardware/health/2.0/AHealth.h",
+ "android/hardware/health/2.0/AHealthInfoCallback.h",
+ ],
+}
+
+
+cc_library {
+ name: "android.hardware.health@2.0-adapter-helper",
+ defaults: ["hidl-module-defaults"],
+ generated_sources: ["android.hardware.health@2.0-adapter-helper_genc++"],
+ generated_headers: ["android.hardware.health@2.0-adapter-helper_genc++_headers"],
+ export_generated_headers: ["android.hardware.health@2.0-adapter-helper_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "libhidladapter",
+ "android.hardware.health@1.0",
+ "android.hardware.health@2.0",
+ "android.hardware.health@1.0-adapter-helper",
+ "android.hidl.base@1.0-adapter-helper",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "libhidladapter",
+ "android.hardware.health@1.0",
+ "android.hardware.health@2.0",
+ "android.hardware.health@1.0-adapter-helper",
+ "android.hidl.base@1.0-adapter-helper",
+ ],
+}
+
+genrule {
+ name: "android.hardware.health@2.0-adapter_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-main -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0",
+ out: ["main.cpp"]
+}
+
+cc_test {
+ name: "android.hardware.health@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
+ shared_libs: [
+ "libhidladapter",
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "android.hardware.health@1.0",
+ "android.hardware.health@2.0",
+ "android.hardware.health@2.0-adapter-helper",
+ ],
+ generated_sources: ["android.hardware.health@2.0-adapter_genc++"],
+}
diff --git a/health/2.0/Android.mk b/health/2.0/Android.mk
new file mode 100644
index 0000000..344c963
--- /dev/null
+++ b/health/2.0/Android.mk
@@ -0,0 +1,86 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.health-V2.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hardware.health-V1.0-java \
+ android.hidl.base-V1.0-java \
+
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES += core-oj hwbinder
+
+#
+# Build types.hal (Result)
+#
+GEN := $(intermediates)/android/hardware/health/V2_0/Result.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.health@2.0::types.Result
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IHealth.hal
+#
+GEN := $(intermediates)/android/hardware/health/V2_0/IHealth.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHealth.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IHealthInfoCallback.hal
+$(GEN): $(LOCAL_PATH)/IHealthInfoCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.health@2.0::IHealth
+
+$(GEN): $(LOCAL_PATH)/IHealth.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IHealthInfoCallback.hal
+#
+GEN := $(intermediates)/android/hardware/health/V2_0/IHealthInfoCallback.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHealthInfoCallback.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.health@2.0::IHealthInfoCallback
+
+$(GEN): $(LOCAL_PATH)/IHealthInfoCallback.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/health/2.0/IHealth.hal b/health/2.0/IHealth.hal
new file mode 100644
index 0000000..3e10701
--- /dev/null
+++ b/health/2.0/IHealth.hal
@@ -0,0 +1,140 @@
+/*
+ * 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.health@2.0;
+
+import @1.0::BatteryStatus;
+
+import IHealthInfoCallback;
+
+/**
+ * IHealth manages health info and posts events on registered callbacks.
+ */
+interface IHealth {
+
+ /**
+ * Register a callback for any health info events.
+ *
+ * Registering a new callback must not unregister the old one; the old
+ * callback remains registered until one of the following happens:
+ * - A client explicitly calls {@link unregisterCallback} to unregister it.
+ * - The client process that hosts the callback dies.
+ *
+ * @param callback the callback to register.
+ * @return result SUCCESS if successful,
+ * UNKNOWN for other errors.
+ */
+ registerCallback(IHealthInfoCallback callback) generates (Result result);
+
+ /**
+ * Explicitly unregister a callback that is previously registered through
+ * {@link registerCallback}.
+ *
+ * @param callback the callback to unregister
+ * @return result SUCCESS if successful,
+ * NOT_FOUND if callback is not registered previously,
+ * UNKNOWN for other errors.
+ */
+ unregisterCallback(IHealthInfoCallback callback) generates (Result result);
+
+ /**
+ * Schedule update.
+ *
+ * When update() is called, the service must notify all registered callbacks
+ * with the most recent health info.
+ *
+ * @return result SUCCESS if successful,
+ * CALLBACK_DIED if any registered callback is dead,
+ * UNKNOWN for other errors.
+ */
+ update() generates (Result result);
+
+ /**
+ * Get battery capacity in microampere-hours(µAh).
+ *
+ * @return result SUCCESS if successful,
+ * NOT_SUPPORTED if this property is not supported
+ * (e.g. the file that stores this property does not exist),
+ * UNKNOWN for other errors.
+ * @return value battery capacity, or INT32_MIN if not successful.
+ */
+ getChargeCounter() generates (Result result, int32_t value);
+
+ /**
+ * Get instantaneous battery current in microamperes(µA).
+ *
+ * Positive values indicate net current entering the battery from a charge
+ * source, negative values indicate net current discharging from the
+ * battery.
+ *
+ * @return result SUCCESS if successful,
+ * NOT_SUPPORTED if this property is not supported
+ * (e.g. the file that stores this property does not exist),
+ * UNKNOWN for other errors.
+ * @return value instantaneous battery current, or INT32_MIN if not
+ * successful.
+ */
+ getCurrentNow() generates (Result result, int32_t value);
+
+ /**
+ * Get average battery current in microamperes(µA).
+ *
+ * Positive values indicate net current entering the battery from a charge
+ * source, negative values indicate net current discharging from the
+ * battery. The time period over which the average is computed may depend on
+ * the fuel gauge hardware and its configuration.
+ *
+ * @return result SUCCESS if successful,
+ * NOT_SUPPORTED if this property is not supported
+ * (e.g. the file that stores this property does not exist),
+ * UNKNOWN for other errors.
+ * @return value average battery current, or INT32_MIN if not successful.
+ */
+ getCurrentAverage() generates (Result result, int32_t value);
+
+ /**
+ * Get remaining battery capacity percentage of total capacity
+ * (with no fractional part).
+ *
+ * @return result SUCCESS if successful,
+ * NOT_SUPPORTED if this property is not supported
+ * (e.g. the file that stores this property does not exist),
+ * UNKNOWN for other errors.
+ * @return value remaining battery capacity, or INT32_MIN if not successful.
+ */
+ getCapacity() generates (Result result, int32_t value);
+
+ /**
+ * Get battery remaining energy in nanowatt-hours.
+ *
+ * @return result SUCCESS if successful,
+ * NOT_SUPPORTED if this property is not supported,
+ * UNKNOWN for other errors.
+ * @return value remaining energy, or INT64_MIN if not successful.
+ */
+ getEnergyCounter() generates (Result result, int64_t value);
+
+ /**
+ * Get battery charge status.
+ *
+ * @return result SUCCESS if successful,
+ * NOT_SUPPORTED if this property is not supported
+ * (e.g. the file that stores this property does not exist),
+ * UNKNOWN other errors.
+ * @return value charge status, or UNKNOWN if not successful.
+ */
+ getChargeStatus() generates (Result result, BatteryStatus value);
+};
diff --git a/health/2.0/IHealthInfoCallback.hal b/health/2.0/IHealthInfoCallback.hal
new file mode 100644
index 0000000..8e17bb9
--- /dev/null
+++ b/health/2.0/IHealthInfoCallback.hal
@@ -0,0 +1,32 @@
+/*
+ * 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.health@2.0;
+
+import @1.0::HealthInfo;
+
+/**
+ * IHealthInfoCallback is the callback interface to
+ * {@link IHealthInfoBus.registerCallback}.
+ */
+interface IHealthInfoCallback {
+ /**
+ * An implementation of IHealthInfoBus must call healthInfoChanged on all
+ * registered callbacks after health info changes.
+ * @param info the updated HealthInfo
+ */
+ oneway healthInfoChanged(HealthInfo info);
+};
diff --git a/health/2.0/types.hal b/health/2.0/types.hal
new file mode 100644
index 0000000..89ea444
--- /dev/null
+++ b/health/2.0/types.hal
@@ -0,0 +1,27 @@
+/*
+ * 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.health@2.0;
+
+import @1.0::Result;
+
+/**
+ * Status values for HAL methods.
+ */
+enum Result : @1.0::Result {
+ NOT_FOUND,
+ CALLBACK_DIED,
+};
diff --git a/health/Android.bp b/health/Android.bp
index a6f6017..2c931e5 100644
--- a/health/Android.bp
+++ b/health/Android.bp
@@ -4,4 +4,5 @@
"1.0/default",
"1.0/default/libhealthd",
"1.0/vts/functional",
+ "2.0",
]
diff --git a/ir/1.0/Android.bp b/ir/1.0/Android.bp
index 6ca7701..e686d23 100644
--- a/ir/1.0/Android.bp
+++ b/ir/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.ir@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/keymaster/3.0/Android.bp b/keymaster/3.0/Android.bp
index 9019739..0e55133 100644
--- a/keymaster/3.0/Android.bp
+++ b/keymaster/3.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.keymaster@3.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/keymaster/3.0/default/Android.mk b/keymaster/3.0/default/Android.mk
index 87ad245..6b66f7d 100644
--- a/keymaster/3.0/default/Android.mk
+++ b/keymaster/3.0/default/Android.mk
@@ -13,6 +13,8 @@
libcrypto \
libkeymaster_portable \
libkeymaster_staging \
+ libpuresoftkeymasterdevice \
+ libkeymaster3device \
libhidlbase \
libhidltransport \
libutils \
diff --git a/keymaster/3.0/default/KeymasterDevice.cpp b/keymaster/3.0/default/KeymasterDevice.cpp
index d83963f..6fabbde 100644
--- a/keymaster/3.0/default/KeymasterDevice.cpp
+++ b/keymaster/3.0/default/KeymasterDevice.cpp
@@ -21,9 +21,11 @@
#include <cutils/log.h>
+#include <AndroidKeymaster3Device.h>
+#include <hardware/keymaster0.h>
+#include <hardware/keymaster1.h>
+#include <hardware/keymaster2.h>
#include <hardware/keymaster_defs.h>
-#include <keymaster/keymaster_configuration.h>
-#include <keymaster/soft_keymaster_device.h>
namespace android {
namespace hardware {
@@ -31,717 +33,77 @@
namespace V3_0 {
namespace implementation {
-using ::keymaster::SoftKeymasterDevice;
-
-class SoftwareOnlyHidlKeymasterEnforcement : public ::keymaster::KeymasterEnforcement {
- public:
- SoftwareOnlyHidlKeymasterEnforcement() : KeymasterEnforcement(64, 64) {}
-
- uint32_t get_current_time() const override {
- struct timespec tp;
- int err = clock_gettime(CLOCK_MONOTONIC, &tp);
- if (err || tp.tv_sec < 0) return 0;
- return static_cast<uint32_t>(tp.tv_sec);
- }
-
- bool activation_date_valid(uint64_t) const override { return true; }
- bool expiration_date_passed(uint64_t) const override { return false; }
- bool auth_token_timed_out(const hw_auth_token_t&, uint32_t) const override { return false; }
- bool ValidateTokenSignature(const hw_auth_token_t&) const override { return true; }
-};
-
-class SoftwareOnlyHidlKeymasterContext : public ::keymaster::SoftKeymasterContext {
- public:
- SoftwareOnlyHidlKeymasterContext() : enforcement_(new SoftwareOnlyHidlKeymasterEnforcement) {}
-
- ::keymaster::KeymasterEnforcement* enforcement_policy() override { return enforcement_.get(); }
-
- private:
- std::unique_ptr<::keymaster::KeymasterEnforcement> enforcement_;
-};
-
-static int keymaster0_device_initialize(const hw_module_t* mod, keymaster2_device_t** dev) {
- assert(mod->module_api_version < KEYMASTER_MODULE_API_VERSION_1_0);
- ALOGI("Found keymaster0 module %s, version %x", mod->name, mod->module_api_version);
-
- std::unique_ptr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
- keymaster0_device_t* km0_device = NULL;
- keymaster_error_t error = KM_ERROR_OK;
-
- int rc = keymaster0_open(mod, &km0_device);
+static int get_keymaster0_dev(keymaster0_device_t** dev, const hw_module_t* mod) {
+ int rc = keymaster0_open(mod, dev);
if (rc) {
ALOGE("Error opening keystore keymaster0 device.");
- goto err;
+ *dev = nullptr;
+ return rc;
}
-
- if (km0_device->flags & KEYMASTER_SOFTWARE_ONLY) {
- ALOGI("Keymaster0 module is software-only. Using SoftKeymasterDevice instead.");
- km0_device->common.close(&km0_device->common);
- km0_device = NULL;
- // SoftKeymasterDevice will be deleted by keymaster_device_release()
- *dev = soft_keymaster.release()->keymaster2_device();
- return 0;
- }
-
- ALOGD("Wrapping keymaster0 module %s with SoftKeymasterDevice", mod->name);
- error = soft_keymaster->SetHardwareDevice(km0_device);
- km0_device = NULL; // SoftKeymasterDevice has taken ownership.
- if (error != KM_ERROR_OK) {
- ALOGE("Got error %d from SetHardwareDevice", error);
- rc = error;
- goto err;
- }
-
- // SoftKeymasterDevice will be deleted by keymaster_device_release()
- *dev = soft_keymaster.release()->keymaster2_device();
return 0;
-
-err:
- if (km0_device) km0_device->common.close(&km0_device->common);
- *dev = NULL;
- return rc;
}
-static int keymaster1_device_initialize(const hw_module_t* mod, keymaster2_device_t** dev,
- bool* supports_all_digests) {
- assert(mod->module_api_version >= KEYMASTER_MODULE_API_VERSION_1_0);
- ALOGI("Found keymaster1 module %s, version %x", mod->name, mod->module_api_version);
-
- std::unique_ptr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
- keymaster1_device_t* km1_device = nullptr;
- keymaster_error_t error = KM_ERROR_OK;
-
- int rc = keymaster1_open(mod, &km1_device);
+static int get_keymaster1_dev(keymaster1_device_t** dev, const hw_module_t* mod) {
+ int rc = keymaster1_open(mod, dev);
if (rc) {
ALOGE("Error %d opening keystore keymaster1 device", rc);
- goto err;
+ if (*dev) {
+ (*dev)->common.close(&(*dev)->common);
+ *dev = nullptr;
+ }
}
-
- ALOGD("Wrapping keymaster1 module %s with SofKeymasterDevice", mod->name);
- error = soft_keymaster->SetHardwareDevice(km1_device);
- km1_device = nullptr; // SoftKeymasterDevice has taken ownership.
- if (error != KM_ERROR_OK) {
- ALOGE("Got error %d from SetHardwareDevice", error);
- rc = error;
- goto err;
- }
-
- // SoftKeymasterDevice will be deleted by keymaster_device_release()
- *supports_all_digests = soft_keymaster->supports_all_digests();
- *dev = soft_keymaster.release()->keymaster2_device();
- return 0;
-
-err:
- if (km1_device) km1_device->common.close(&km1_device->common);
- *dev = NULL;
return rc;
}
-static int keymaster2_device_initialize(const hw_module_t* mod, keymaster2_device_t** dev) {
- assert(mod->module_api_version >= KEYMASTER_MODULE_API_VERSION_2_0);
- ALOGI("Found keymaster2 module %s, version %x", mod->name, mod->module_api_version);
-
- keymaster2_device_t* km2_device = nullptr;
-
- int rc = keymaster2_open(mod, &km2_device);
+static int get_keymaster2_dev(keymaster2_device_t** dev, const hw_module_t* mod) {
+ int rc = keymaster2_open(mod, dev);
if (rc) {
ALOGE("Error %d opening keystore keymaster2 device", rc);
- goto err;
+ *dev = nullptr;
}
-
- *dev = km2_device;
- return 0;
-
-err:
- if (km2_device) km2_device->common.close(&km2_device->common);
- *dev = nullptr;
return rc;
}
-static int keymaster_device_initialize(keymaster2_device_t** dev, uint32_t* version,
- bool* supports_ec, bool* supports_all_digests) {
- const hw_module_t* mod;
-
- *supports_ec = true;
+static IKeymasterDevice* createKeymaster3Device() {
+ const hw_module_t* mod = nullptr;
int rc = hw_get_module_by_class(KEYSTORE_HARDWARE_MODULE_ID, NULL, &mod);
if (rc) {
ALOGI("Could not find any keystore module, using software-only implementation.");
// SoftKeymasterDevice will be deleted by keymaster_device_release()
- *dev = (new SoftKeymasterDevice(new SoftwareOnlyHidlKeymasterContext))->keymaster2_device();
- *version = -1;
- return 0;
+ return ::keymaster::ng::CreateKeymasterDevice();
}
if (mod->module_api_version < KEYMASTER_MODULE_API_VERSION_1_0) {
- *version = 0;
- *supports_all_digests = false;
- int rc = keymaster0_device_initialize(mod, dev);
- if (rc == 0 && ((*dev)->flags & KEYMASTER_SUPPORTS_EC) == 0) {
- *supports_ec = false;
+ keymaster0_device_t* dev = nullptr;
+ if (get_keymaster0_dev(&dev, mod)) {
+ return nullptr;
}
- return rc;
+ return ::keymaster::ng::CreateKeymasterDevice(dev);
} else if (mod->module_api_version == KEYMASTER_MODULE_API_VERSION_1_0) {
- *version = 1;
- return keymaster1_device_initialize(mod, dev, supports_all_digests);
+ keymaster1_device_t* dev = nullptr;
+ if (get_keymaster1_dev(&dev, mod)) {
+ return nullptr;
+ }
+ return ::keymaster::ng::CreateKeymasterDevice(dev);
} else {
- *version = 2;
- *supports_all_digests = true;
- return keymaster2_device_initialize(mod, dev);
- }
-}
-
-KeymasterDevice::~KeymasterDevice() {
- if (keymaster_device_) keymaster_device_->common.close(&keymaster_device_->common);
-}
-
-static inline keymaster_tag_type_t typeFromTag(const keymaster_tag_t tag) {
- return keymaster_tag_get_type(tag);
-}
-
-/**
- * legacy_enum_conversion converts enums from hidl to keymaster and back. Currently, this is just a
- * cast to make the compiler happy. One of two thigs should happen though:
- * TODO The keymaster enums should become aliases for the hidl generated enums so that we have a
- * single point of truth. Then this cast function can go away.
- */
-inline static keymaster_tag_t legacy_enum_conversion(const Tag value) {
- return keymaster_tag_t(value);
-}
-inline static Tag legacy_enum_conversion(const keymaster_tag_t value) {
- return Tag(value);
-}
-inline static keymaster_purpose_t legacy_enum_conversion(const KeyPurpose value) {
- return keymaster_purpose_t(value);
-}
-inline static keymaster_key_format_t legacy_enum_conversion(const KeyFormat value) {
- return keymaster_key_format_t(value);
-}
-inline static ErrorCode legacy_enum_conversion(const keymaster_error_t value) {
- return ErrorCode(value);
-}
-
-class KmParamSet : public keymaster_key_param_set_t {
- public:
- KmParamSet(const hidl_vec<KeyParameter>& keyParams) {
- params = new keymaster_key_param_t[keyParams.size()];
- length = keyParams.size();
- for (size_t i = 0; i < keyParams.size(); ++i) {
- auto tag = legacy_enum_conversion(keyParams[i].tag);
- switch (typeFromTag(tag)) {
- case KM_ENUM:
- case KM_ENUM_REP:
- params[i] = keymaster_param_enum(tag, keyParams[i].f.integer);
- break;
- case KM_UINT:
- case KM_UINT_REP:
- params[i] = keymaster_param_int(tag, keyParams[i].f.integer);
- break;
- case KM_ULONG:
- case KM_ULONG_REP:
- params[i] = keymaster_param_long(tag, keyParams[i].f.longInteger);
- break;
- case KM_DATE:
- params[i] = keymaster_param_date(tag, keyParams[i].f.dateTime);
- break;
- case KM_BOOL:
- if (keyParams[i].f.boolValue)
- params[i] = keymaster_param_bool(tag);
- else
- params[i].tag = KM_TAG_INVALID;
- break;
- case KM_BIGNUM:
- case KM_BYTES:
- params[i] =
- keymaster_param_blob(tag, &keyParams[i].blob[0], keyParams[i].blob.size());
- break;
- case KM_INVALID:
- default:
- params[i].tag = KM_TAG_INVALID;
- /* just skip */
- break;
- }
+ keymaster2_device_t* dev = nullptr;
+ if (get_keymaster2_dev(&dev, mod)) {
+ return nullptr;
}
+ return ::keymaster::ng::CreateKeymasterDevice(dev);
}
- KmParamSet(KmParamSet&& other) : keymaster_key_param_set_t{other.params, other.length} {
- other.length = 0;
- other.params = nullptr;
- }
- KmParamSet(const KmParamSet&) = delete;
- ~KmParamSet() { delete[] params; }
-};
-
-inline static KmParamSet hidlParams2KmParamSet(const hidl_vec<KeyParameter>& params) {
- return KmParamSet(params);
-}
-
-inline static keymaster_blob_t hidlVec2KmBlob(const hidl_vec<uint8_t>& blob) {
- /* hidl unmarshals funny pointers if the the blob is empty */
- if (blob.size()) return {&blob[0], blob.size()};
- return {nullptr, 0};
-}
-
-inline static keymaster_key_blob_t hidlVec2KmKeyBlob(const hidl_vec<uint8_t>& blob) {
- /* hidl unmarshals funny pointers if the the blob is empty */
- if (blob.size()) return {&blob[0], blob.size()};
- return {nullptr, 0};
-}
-
-inline static hidl_vec<uint8_t> kmBlob2hidlVec(const keymaster_key_blob_t& blob) {
- hidl_vec<uint8_t> result;
- result.setToExternal(const_cast<unsigned char*>(blob.key_material), blob.key_material_size);
- return result;
-}
-inline static hidl_vec<uint8_t> kmBlob2hidlVec(const keymaster_blob_t& blob) {
- hidl_vec<uint8_t> result;
- result.setToExternal(const_cast<unsigned char*>(blob.data), blob.data_length);
- return result;
-}
-
-inline static hidl_vec<hidl_vec<uint8_t>>
-kmCertChain2Hidl(const keymaster_cert_chain_t* cert_chain) {
- hidl_vec<hidl_vec<uint8_t>> result;
- if (!cert_chain || cert_chain->entry_count == 0 || !cert_chain->entries) return result;
-
- result.resize(cert_chain->entry_count);
- for (size_t i = 0; i < cert_chain->entry_count; ++i) {
- auto& entry = cert_chain->entries[i];
- result[i] = kmBlob2hidlVec(entry);
- }
-
- return result;
-}
-
-static inline hidl_vec<KeyParameter> kmParamSet2Hidl(const keymaster_key_param_set_t& set) {
- hidl_vec<KeyParameter> result;
- if (set.length == 0 || set.params == nullptr) return result;
-
- result.resize(set.length);
- keymaster_key_param_t* params = set.params;
- for (size_t i = 0; i < set.length; ++i) {
- auto tag = params[i].tag;
- result[i].tag = legacy_enum_conversion(tag);
- switch (typeFromTag(tag)) {
- case KM_ENUM:
- case KM_ENUM_REP:
- result[i].f.integer = params[i].enumerated;
- break;
- case KM_UINT:
- case KM_UINT_REP:
- result[i].f.integer = params[i].integer;
- break;
- case KM_ULONG:
- case KM_ULONG_REP:
- result[i].f.longInteger = params[i].long_integer;
- break;
- case KM_DATE:
- result[i].f.dateTime = params[i].date_time;
- break;
- case KM_BOOL:
- result[i].f.boolValue = params[i].boolean;
- break;
- case KM_BIGNUM:
- case KM_BYTES:
- result[i].blob.setToExternal(const_cast<unsigned char*>(params[i].blob.data),
- params[i].blob.data_length);
- break;
- case KM_INVALID:
- default:
- params[i].tag = KM_TAG_INVALID;
- /* just skip */
- break;
- }
- }
- return result;
-}
-
-// Methods from ::android::hardware::keymaster::V3_0::IKeymasterDevice follow.
-Return<void> KeymasterDevice::getHardwareFeatures(getHardwareFeatures_cb _hidl_cb) {
- bool is_secure = !(keymaster_device_->flags & KEYMASTER_SOFTWARE_ONLY);
- bool supports_symmetric_cryptography = false;
- bool supports_attestation = false;
-
- switch (hardware_version_) {
- case 2:
- supports_attestation = true;
- /* Falls through */
- case 1:
- supports_symmetric_cryptography = true;
- break;
- };
-
- _hidl_cb(is_secure, hardware_supports_ec_, supports_symmetric_cryptography,
- supports_attestation, hardware_supports_all_digests_,
- keymaster_device_->common.module->name, keymaster_device_->common.module->author);
- return Void();
-}
-
-Return<ErrorCode> KeymasterDevice::addRngEntropy(const hidl_vec<uint8_t>& data) {
- if (!data.size()) return ErrorCode::OK;
- return legacy_enum_conversion(
- keymaster_device_->add_rng_entropy(keymaster_device_, &data[0], data.size()));
-}
-
-Return<void> KeymasterDevice::generateKey(const hidl_vec<KeyParameter>& keyParams,
- generateKey_cb _hidl_cb) {
- // result variables for the wire
- KeyCharacteristics resultCharacteristics;
- hidl_vec<uint8_t> resultKeyBlob;
-
- // result variables the backend understands
- keymaster_key_blob_t key_blob{nullptr, 0};
- keymaster_key_characteristics_t key_characteristics{{nullptr, 0}, {nullptr, 0}};
-
- // convert the parameter set to something our backend understands
- auto kmParams = hidlParams2KmParamSet(keyParams);
-
- auto rc = keymaster_device_->generate_key(keymaster_device_, &kmParams, &key_blob,
- &key_characteristics);
-
- if (rc == KM_ERROR_OK) {
- // on success convert the result to wire format
- resultKeyBlob = kmBlob2hidlVec(key_blob);
- resultCharacteristics.softwareEnforced = kmParamSet2Hidl(key_characteristics.sw_enforced);
- resultCharacteristics.teeEnforced = kmParamSet2Hidl(key_characteristics.hw_enforced);
- }
-
- // send results off to the client
- _hidl_cb(legacy_enum_conversion(rc), resultKeyBlob, resultCharacteristics);
-
- // free buffers that we are responsible for
- if (key_blob.key_material) free(const_cast<uint8_t*>(key_blob.key_material));
- keymaster_free_characteristics(&key_characteristics);
-
- return Void();
-}
-
-Return<void> KeymasterDevice::getKeyCharacteristics(const hidl_vec<uint8_t>& keyBlob,
- const hidl_vec<uint8_t>& clientId,
- const hidl_vec<uint8_t>& appData,
- getKeyCharacteristics_cb _hidl_cb) {
- // result variables for the wire
- KeyCharacteristics resultCharacteristics;
-
- // result variables the backend understands
- keymaster_key_characteristics_t key_characteristics{{nullptr, 0}, {nullptr, 0}};
-
- auto kmKeyBlob = hidlVec2KmKeyBlob(keyBlob);
- auto kmClientId = hidlVec2KmBlob(clientId);
- auto kmAppData = hidlVec2KmBlob(appData);
-
- auto rc = keymaster_device_->get_key_characteristics(
- keymaster_device_, keyBlob.size() ? &kmKeyBlob : nullptr,
- clientId.size() ? &kmClientId : nullptr, appData.size() ? &kmAppData : nullptr,
- &key_characteristics);
-
- if (rc == KM_ERROR_OK) {
- resultCharacteristics.softwareEnforced = kmParamSet2Hidl(key_characteristics.sw_enforced);
- resultCharacteristics.teeEnforced = kmParamSet2Hidl(key_characteristics.hw_enforced);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultCharacteristics);
-
- keymaster_free_characteristics(&key_characteristics);
-
- return Void();
-}
-
-Return<void> KeymasterDevice::importKey(const hidl_vec<KeyParameter>& params, KeyFormat keyFormat,
- const hidl_vec<uint8_t>& keyData, importKey_cb _hidl_cb) {
- // result variables for the wire
- KeyCharacteristics resultCharacteristics;
- hidl_vec<uint8_t> resultKeyBlob;
-
- // result variables the backend understands
- keymaster_key_blob_t key_blob{nullptr, 0};
- keymaster_key_characteristics_t key_characteristics{{nullptr, 0}, {nullptr, 0}};
-
- auto kmParams = hidlParams2KmParamSet(params);
- auto kmKeyData = hidlVec2KmBlob(keyData);
-
- auto rc = keymaster_device_->import_key(keymaster_device_, &kmParams,
- legacy_enum_conversion(keyFormat), &kmKeyData,
- &key_blob, &key_characteristics);
-
- if (rc == KM_ERROR_OK) {
- // on success convert the result to wire format
- // (Can we assume that key_blob is {nullptr, 0} or a valid buffer description?)
- resultKeyBlob = kmBlob2hidlVec(key_blob);
- resultCharacteristics.softwareEnforced = kmParamSet2Hidl(key_characteristics.sw_enforced);
- resultCharacteristics.teeEnforced = kmParamSet2Hidl(key_characteristics.hw_enforced);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultKeyBlob, resultCharacteristics);
-
- // free buffers that we are responsible for
- if (key_blob.key_material) free(const_cast<uint8_t*>(key_blob.key_material));
- keymaster_free_characteristics(&key_characteristics);
-
- return Void();
-}
-
-Return<void> KeymasterDevice::exportKey(KeyFormat exportFormat, const hidl_vec<uint8_t>& keyBlob,
- const hidl_vec<uint8_t>& clientId,
- const hidl_vec<uint8_t>& appData, exportKey_cb _hidl_cb) {
-
- // result variables for the wire
- hidl_vec<uint8_t> resultKeyBlob;
-
- // result variables the backend understands
- keymaster_blob_t out_blob{nullptr, 0};
-
- auto kmKeyBlob = hidlVec2KmKeyBlob(keyBlob);
- auto kmClientId = hidlVec2KmBlob(clientId);
- auto kmAppData = hidlVec2KmBlob(appData);
-
- auto rc = keymaster_device_->export_key(keymaster_device_, legacy_enum_conversion(exportFormat),
- keyBlob.size() ? &kmKeyBlob : nullptr,
- clientId.size() ? &kmClientId : nullptr,
- appData.size() ? &kmAppData : nullptr, &out_blob);
-
- if (rc == KM_ERROR_OK) {
- // on success convert the result to wire format
- // (Can we assume that key_blob is {nullptr, 0} or a valid buffer description?)
- resultKeyBlob = kmBlob2hidlVec(out_blob);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultKeyBlob);
-
- // free buffers that we are responsible for
- if (out_blob.data) free(const_cast<uint8_t*>(out_blob.data));
-
- return Void();
-}
-
-Return<void> KeymasterDevice::attestKey(const hidl_vec<uint8_t>& keyToAttest,
- const hidl_vec<KeyParameter>& attestParams,
- attestKey_cb _hidl_cb) {
-
- hidl_vec<hidl_vec<uint8_t>> resultCertChain;
-
- bool foundAttestationApplicationId = false;
- for (size_t i = 0; i < attestParams.size(); ++i) {
- switch (attestParams[i].tag) {
- case Tag::ATTESTATION_ID_BRAND:
- case Tag::ATTESTATION_ID_DEVICE:
- case Tag::ATTESTATION_ID_PRODUCT:
- case Tag::ATTESTATION_ID_SERIAL:
- case Tag::ATTESTATION_ID_IMEI:
- case Tag::ATTESTATION_ID_MEID:
- case Tag::ATTESTATION_ID_MANUFACTURER:
- case Tag::ATTESTATION_ID_MODEL:
- // Device id attestation may only be supported if the device is able to permanently
- // destroy its knowledge of the ids. This device is unable to do this, so it must
- // never perform any device id attestation.
- _hidl_cb(ErrorCode::CANNOT_ATTEST_IDS, resultCertChain);
- return Void();
-
- case Tag::ATTESTATION_APPLICATION_ID:
- foundAttestationApplicationId = true;
- break;
-
- default:
- break;
- }
- }
-
- // KM3 devices reject missing attest application IDs. KM2 devices do not.
- if (!foundAttestationApplicationId) {
- _hidl_cb(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING,
- resultCertChain);
- return Void();
- }
-
- keymaster_cert_chain_t cert_chain{nullptr, 0};
-
- auto kmKeyToAttest = hidlVec2KmKeyBlob(keyToAttest);
- auto kmAttestParams = hidlParams2KmParamSet(attestParams);
-
- auto rc = keymaster_device_->attest_key(keymaster_device_, &kmKeyToAttest, &kmAttestParams,
- &cert_chain);
-
- if (rc == KM_ERROR_OK) {
- resultCertChain = kmCertChain2Hidl(&cert_chain);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultCertChain);
-
- keymaster_free_cert_chain(&cert_chain);
-
- return Void();
-}
-
-Return<void> KeymasterDevice::upgradeKey(const hidl_vec<uint8_t>& keyBlobToUpgrade,
- const hidl_vec<KeyParameter>& upgradeParams,
- upgradeKey_cb _hidl_cb) {
-
- // result variables for the wire
- hidl_vec<uint8_t> resultKeyBlob;
-
- // result variables the backend understands
- keymaster_key_blob_t key_blob{nullptr, 0};
-
- auto kmKeyBlobToUpgrade = hidlVec2KmKeyBlob(keyBlobToUpgrade);
- auto kmUpgradeParams = hidlParams2KmParamSet(upgradeParams);
-
- auto rc = keymaster_device_->upgrade_key(keymaster_device_, &kmKeyBlobToUpgrade,
- &kmUpgradeParams, &key_blob);
-
- if (rc == KM_ERROR_OK) {
- // on success convert the result to wire format
- resultKeyBlob = kmBlob2hidlVec(key_blob);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultKeyBlob);
-
- if (key_blob.key_material) free(const_cast<uint8_t*>(key_blob.key_material));
-
- return Void();
-}
-
-Return<ErrorCode> KeymasterDevice::deleteKey(const hidl_vec<uint8_t>& keyBlob) {
- if (keymaster_device_->delete_key == nullptr) {
- return ErrorCode::UNIMPLEMENTED;
- }
- auto kmKeyBlob = hidlVec2KmKeyBlob(keyBlob);
- auto rc = legacy_enum_conversion(
- keymaster_device_->delete_key(keymaster_device_, &kmKeyBlob));
- // Keymaster 3.0 requires deleteKey to return ErrorCode::OK if the key
- // blob is unusable after the call. This is equally true if the key blob was
- // unusable before.
- if (rc == ErrorCode::INVALID_KEY_BLOB) return ErrorCode::OK;
- return rc;
-}
-
-Return<ErrorCode> KeymasterDevice::deleteAllKeys() {
- if (keymaster_device_->delete_all_keys == nullptr) {
- return ErrorCode::UNIMPLEMENTED;
- }
- return legacy_enum_conversion(keymaster_device_->delete_all_keys(keymaster_device_));
-}
-
-Return<ErrorCode> KeymasterDevice::destroyAttestationIds() {
- return ErrorCode::UNIMPLEMENTED;
-}
-
-Return<void> KeymasterDevice::begin(KeyPurpose purpose, const hidl_vec<uint8_t>& key,
- const hidl_vec<KeyParameter>& inParams, begin_cb _hidl_cb) {
-
- // result variables for the wire
- hidl_vec<KeyParameter> resultParams;
- uint64_t resultOpHandle = 0;
-
- // result variables the backend understands
- keymaster_key_param_set_t out_params{nullptr, 0};
- keymaster_operation_handle_t& operation_handle = resultOpHandle;
-
- auto kmKey = hidlVec2KmKeyBlob(key);
- auto kmInParams = hidlParams2KmParamSet(inParams);
-
- auto rc = keymaster_device_->begin(keymaster_device_, legacy_enum_conversion(purpose), &kmKey,
- &kmInParams, &out_params, &operation_handle);
-
- if (rc == KM_ERROR_OK) resultParams = kmParamSet2Hidl(out_params);
-
- _hidl_cb(legacy_enum_conversion(rc), resultParams, resultOpHandle);
-
- keymaster_free_param_set(&out_params);
-
- return Void();
-}
-
-Return<void> KeymasterDevice::update(uint64_t operationHandle,
- const hidl_vec<KeyParameter>& inParams,
- const hidl_vec<uint8_t>& input, update_cb _hidl_cb) {
- // result variables for the wire
- uint32_t resultConsumed = 0;
- hidl_vec<KeyParameter> resultParams;
- hidl_vec<uint8_t> resultBlob;
-
- // result variables the backend understands
- size_t consumed = 0;
- keymaster_key_param_set_t out_params{nullptr, 0};
- keymaster_blob_t out_blob{nullptr, 0};
-
- auto kmInParams = hidlParams2KmParamSet(inParams);
- auto kmInput = hidlVec2KmBlob(input);
-
- auto rc = keymaster_device_->update(keymaster_device_, operationHandle, &kmInParams, &kmInput,
- &consumed, &out_params, &out_blob);
-
- if (rc == KM_ERROR_OK) {
- resultConsumed = consumed;
- resultParams = kmParamSet2Hidl(out_params);
- resultBlob = kmBlob2hidlVec(out_blob);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultConsumed, resultParams, resultBlob);
-
- keymaster_free_param_set(&out_params);
- if (out_blob.data) free(const_cast<uint8_t*>(out_blob.data));
-
- return Void();
-}
-
-Return<void> KeymasterDevice::finish(uint64_t operationHandle,
- const hidl_vec<KeyParameter>& inParams,
- const hidl_vec<uint8_t>& input,
- const hidl_vec<uint8_t>& signature, finish_cb _hidl_cb) {
- // result variables for the wire
- hidl_vec<KeyParameter> resultParams;
- hidl_vec<uint8_t> resultBlob;
-
- // result variables the backend understands
- keymaster_key_param_set_t out_params{nullptr, 0};
- keymaster_blob_t out_blob{nullptr, 0};
-
- auto kmInParams = hidlParams2KmParamSet(inParams);
- auto kmInput = hidlVec2KmBlob(input);
- auto kmSignature = hidlVec2KmBlob(signature);
-
- auto rc = keymaster_device_->finish(keymaster_device_, operationHandle, &kmInParams, &kmInput,
- &kmSignature, &out_params, &out_blob);
-
- if (rc == KM_ERROR_OK) {
- resultParams = kmParamSet2Hidl(out_params);
- resultBlob = kmBlob2hidlVec(out_blob);
- }
-
- _hidl_cb(legacy_enum_conversion(rc), resultParams, resultBlob);
-
- keymaster_free_param_set(&out_params);
- if (out_blob.data) free(const_cast<uint8_t*>(out_blob.data));
-
- return Void();
-}
-
-Return<ErrorCode> KeymasterDevice::abort(uint64_t operationHandle) {
- return legacy_enum_conversion(keymaster_device_->abort(keymaster_device_, operationHandle));
}
IKeymasterDevice* HIDL_FETCH_IKeymasterDevice(const char* name) {
- keymaster2_device_t* dev = nullptr;
-
ALOGI("Fetching keymaster device name %s", name);
- uint32_t version = -1;
- bool supports_ec = false;
- bool supports_all_digests = false;
-
if (name && strcmp(name, "softwareonly") == 0) {
- dev = (new SoftKeymasterDevice(new SoftwareOnlyHidlKeymasterContext))->keymaster2_device();
+ return ::keymaster::ng::CreateKeymasterDevice();
} else if (name && strcmp(name, "default") == 0) {
- auto rc = keymaster_device_initialize(&dev, &version, &supports_ec, &supports_all_digests);
- if (rc) return nullptr;
+ return createKeymaster3Device();
}
-
- auto kmrc = ::keymaster::ConfigureDevice(dev);
- if (kmrc != KM_ERROR_OK) {
- dev->common.close(&dev->common);
- return nullptr;
- }
-
- return new KeymasterDevice(dev, version, supports_ec, supports_all_digests);
+ return nullptr;
}
} // namespace implementation
diff --git a/keymaster/3.0/default/KeymasterDevice.h b/keymaster/3.0/default/KeymasterDevice.h
index e048d5b..267bf85 100644
--- a/keymaster/3.0/default/KeymasterDevice.h
+++ b/keymaster/3.0/default/KeymasterDevice.h
@@ -18,78 +18,14 @@
#ifndef HIDL_GENERATED_android_hardware_keymaster_V3_0_KeymasterDevice_H_
#define HIDL_GENERATED_android_hardware_keymaster_V3_0_KeymasterDevice_H_
-#include <hardware/keymaster2.h>
-
#include <android/hardware/keymaster/3.0/IKeymasterDevice.h>
-#include <hidl/Status.h>
-#include <hidl/MQDescriptor.h>
namespace android {
namespace hardware {
namespace keymaster {
namespace V3_0 {
namespace implementation {
-using ::android::hardware::keymaster::V3_0::ErrorCode;
-using ::android::hardware::keymaster::V3_0::IKeymasterDevice;
-using ::android::hardware::keymaster::V3_0::KeyCharacteristics;
-using ::android::hardware::keymaster::V3_0::KeyFormat;
-using ::android::hardware::keymaster::V3_0::KeyParameter;
-using ::android::hardware::keymaster::V3_0::KeyPurpose;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class KeymasterDevice : public IKeymasterDevice {
- public:
- KeymasterDevice(keymaster2_device_t* dev, uint32_t hardware_version, bool hardware_supports_ec,
- bool hardware_supports_all_digests)
- : keymaster_device_(dev), hardware_version_(hardware_version),
- hardware_supports_ec_(hardware_supports_ec),
- hardware_supports_all_digests_(hardware_supports_all_digests) {}
- virtual ~KeymasterDevice();
-
- // Methods from ::android::hardware::keymaster::V3_0::IKeymasterDevice follow.
- Return<void> getHardwareFeatures(getHardwareFeatures_cb _hidl_cb);
- Return<ErrorCode> addRngEntropy(const hidl_vec<uint8_t>& data) override;
- Return<void> generateKey(const hidl_vec<KeyParameter>& keyParams,
- generateKey_cb _hidl_cb) override;
- Return<void> getKeyCharacteristics(const hidl_vec<uint8_t>& keyBlob,
- const hidl_vec<uint8_t>& clientId,
- const hidl_vec<uint8_t>& appData,
- getKeyCharacteristics_cb _hidl_cb) override;
- Return<void> importKey(const hidl_vec<KeyParameter>& params, KeyFormat keyFormat,
- const hidl_vec<uint8_t>& keyData, importKey_cb _hidl_cb) override;
- Return<void> exportKey(KeyFormat exportFormat, const hidl_vec<uint8_t>& keyBlob,
- const hidl_vec<uint8_t>& clientId, const hidl_vec<uint8_t>& appData,
- exportKey_cb _hidl_cb) override;
- Return<void> attestKey(const hidl_vec<uint8_t>& keyToAttest,
- const hidl_vec<KeyParameter>& attestParams,
- attestKey_cb _hidl_cb) override;
- Return<void> upgradeKey(const hidl_vec<uint8_t>& keyBlobToUpgrade,
- const hidl_vec<KeyParameter>& upgradeParams,
- upgradeKey_cb _hidl_cb) override;
- Return<ErrorCode> deleteKey(const hidl_vec<uint8_t>& keyBlob) override;
- Return<ErrorCode> deleteAllKeys() override;
- Return<ErrorCode> destroyAttestationIds() override;
- Return<void> begin(KeyPurpose purpose, const hidl_vec<uint8_t>& key,
- const hidl_vec<KeyParameter>& inParams, begin_cb _hidl_cb) override;
- Return<void> update(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
- const hidl_vec<uint8_t>& input, update_cb _hidl_cb) override;
- Return<void> finish(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
- const hidl_vec<uint8_t>& input, const hidl_vec<uint8_t>& signature,
- finish_cb _hidl_cb) override;
- Return<ErrorCode> abort(uint64_t operationHandle) override;
-
- private:
- keymaster2_device_t* keymaster_device_;
- uint32_t hardware_version_;
- bool hardware_supports_ec_;
- bool hardware_supports_all_digests_;
-};
-
extern "C" IKeymasterDevice* HIDL_FETCH_IKeymasterDevice(const char* name);
} // namespace implementation
diff --git a/keymaster/3.0/default/OWNERS b/keymaster/3.0/default/OWNERS
new file mode 100644
index 0000000..335660d
--- /dev/null
+++ b/keymaster/3.0/default/OWNERS
@@ -0,0 +1,2 @@
+jdanis@google.com
+swillden@google.com
diff --git a/keymaster/3.0/vts/OWNERS b/keymaster/3.0/vts/OWNERS
new file mode 100644
index 0000000..d53aadd
--- /dev/null
+++ b/keymaster/3.0/vts/OWNERS
@@ -0,0 +1,4 @@
+jdanis@google.com
+swillden@google.com
+yim@google.com
+ryanjcampbell@google.com
diff --git a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
index ea98264..7948015 100644
--- a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
+++ b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -898,13 +898,20 @@
}
}
- void CheckOrigin() {
+ void CheckOrigin(bool asymmetric = false) {
SCOPED_TRACE("CheckOrigin");
if (is_secure_ && supports_symmetric_) {
EXPECT_TRUE(
contains(key_characteristics_.teeEnforced, TAG_ORIGIN, KeyOrigin::IMPORTED));
} else if (is_secure_) {
- EXPECT_TRUE(contains(key_characteristics_.teeEnforced, TAG_ORIGIN, KeyOrigin::UNKNOWN));
+ // wrapped KM0
+ if (asymmetric) {
+ EXPECT_TRUE(
+ contains(key_characteristics_.teeEnforced, TAG_ORIGIN, KeyOrigin::UNKNOWN));
+ } else {
+ EXPECT_TRUE(contains(key_characteristics_.softwareEnforced, TAG_ORIGIN,
+ KeyOrigin::IMPORTED));
+ }
} else {
EXPECT_TRUE(
contains(key_characteristics_.softwareEnforced, TAG_ORIGIN, KeyOrigin::IMPORTED));
@@ -993,8 +1000,8 @@
HidlBuf(app_id));
if (!KeymasterHidlTest::IsSecure()) {
- // SW is KM2
- EXPECT_EQ(att_keymaster_version, 2U);
+ // SW is KM3
+ EXPECT_EQ(att_keymaster_version, 3U);
}
if (KeymasterHidlTest::SupportsSymmetric()) {
@@ -1059,13 +1066,17 @@
class NewKeyGenerationTest : public KeymasterHidlTest {
protected:
- void CheckBaseParams(const KeyCharacteristics& keyCharacteristics) {
+ void CheckBaseParams(const KeyCharacteristics& keyCharacteristics, bool asymmetric = false) {
// TODO(swillden): Distinguish which params should be in which auth list.
AuthorizationSet auths(keyCharacteristics.teeEnforced);
auths.push_back(AuthorizationSet(keyCharacteristics.softwareEnforced));
- EXPECT_TRUE(auths.Contains(TAG_ORIGIN, KeyOrigin::GENERATED));
+ if (!SupportsSymmetric() && asymmetric) {
+ EXPECT_TRUE(auths.Contains(TAG_ORIGIN, KeyOrigin::UNKNOWN));
+ } else {
+ EXPECT_TRUE(auths.Contains(TAG_ORIGIN, KeyOrigin::GENERATED));
+ }
EXPECT_TRUE(auths.Contains(TAG_PURPOSE, KeyPurpose::SIGN));
EXPECT_TRUE(auths.Contains(TAG_PURPOSE, KeyPurpose::VERIFY));
@@ -1114,7 +1125,7 @@
&key_blob, &key_characteristics));
ASSERT_GT(key_blob.size(), 0U);
- CheckBaseParams(key_characteristics);
+ CheckBaseParams(key_characteristics, true /* asymmetric */);
AuthorizationSet crypto_params;
if (IsSecure()) {
@@ -1160,7 +1171,7 @@
.Authorizations(UserAuths()),
&key_blob, &key_characteristics));
ASSERT_GT(key_blob.size(), 0U);
- CheckBaseParams(key_characteristics);
+ CheckBaseParams(key_characteristics, true /* asymmetric */);
AuthorizationSet crypto_params;
if (IsSecure()) {
@@ -1565,7 +1576,9 @@
.Digest(Digest::NONE)
.Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
string result;
- EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+ ErrorCode finish_error_code = Finish(message, &result);
+ EXPECT_TRUE(finish_error_code == ErrorCode::INVALID_INPUT_LENGTH ||
+ finish_error_code == ErrorCode::INVALID_ARGUMENT);
// Very large message that should exceed the transfer buffer size of any reasonable TEE.
message = string(128 * 1024, 'a');
@@ -1573,7 +1586,9 @@
Begin(KeyPurpose::SIGN, AuthorizationSetBuilder()
.Digest(Digest::NONE)
.Padding(PaddingMode::RSA_PKCS1_1_5_SIGN)));
- EXPECT_EQ(ErrorCode::INVALID_INPUT_LENGTH, Finish(message, &result));
+ finish_error_code = Finish(message, &result);
+ EXPECT_TRUE(finish_error_code == ErrorCode::INVALID_INPUT_LENGTH ||
+ finish_error_code == ErrorCode::INVALID_ARGUMENT);
}
/*
@@ -2355,7 +2370,7 @@
CheckKm0CryptoParam(TAG_RSA_PUBLIC_EXPONENT, 65537U);
CheckKm1CryptoParam(TAG_DIGEST, Digest::SHA_2_256);
CheckKm1CryptoParam(TAG_PADDING, PaddingMode::RSA_PSS);
- CheckOrigin();
+ CheckOrigin(true /* asymmetric */);
string message(1024 / 8, 'a');
auto params = AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Padding(PaddingMode::RSA_PSS);
@@ -2411,7 +2426,7 @@
CheckKm1CryptoParam(TAG_DIGEST, Digest::SHA_2_256);
CheckKm2CryptoParam(TAG_EC_CURVE, EcCurve::P_256);
- CheckOrigin();
+ CheckOrigin(true /* asymmetric */);
string message(32, 'a');
auto params = AuthorizationSetBuilder().Digest(Digest::SHA_2_256);
@@ -2437,7 +2452,7 @@
CheckKm1CryptoParam(TAG_DIGEST, Digest::SHA_2_256);
CheckKm2CryptoParam(TAG_EC_CURVE, EcCurve::P_521);
- CheckOrigin();
+ CheckOrigin(true /* asymmetric */);
string message(32, 'a');
auto params = AuthorizationSetBuilder().Digest(Digest::SHA_2_256);
diff --git a/light/2.0/Android.bp b/light/2.0/Android.bp
index 3412fcc..f1ce520 100644
--- a/light/2.0/Android.bp
+++ b/light/2.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.light@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index 378c18e..7367409 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -187,6 +187,7 @@
cc_test {
name: "android.hardware.media.omx@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
index 3e09353..a2547e8 100644
--- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
+++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
@@ -857,20 +857,6 @@
status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount);
ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
- // Change the port modes arbitrarily at the start before finialising on the
- // desired values.
- PortMode dummyPM[] = {
- PortMode::PRESET_BYTE_BUFFER, PortMode::PRESET_ANW_BUFFER,
- PortMode::PRESET_SECURE_BUFFER, PortMode::DYNAMIC_ANW_BUFFER,
- PortMode::DYNAMIC_NATIVE_HANDLE,
- };
- for (size_t k = 0; k < sizeof(dummyPM) / sizeof(dummyPM[0]); k++) {
- // ports may or may not support these modes. These are not the final
- // values. This init is done to test if causes any problems.
- status = omxNode->setPortMode(kPortIndexInput, dummyPM[k]);
- status = omxNode->setPortMode(kPortIndexOutput, dummyPM[k]);
- }
-
// set port mode
portMode[0] = PortMode::PRESET_BYTE_BUFFER;
portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
diff --git a/memtrack/1.0/Android.bp b/memtrack/1.0/Android.bp
index fc6aa9d..fe88d0f 100644
--- a/memtrack/1.0/Android.bp
+++ b/memtrack/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.memtrack@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/minijail/Android.bp b/minijail/Android.bp
new file mode 100644
index 0000000..c01a12b
--- /dev/null
+++ b/minijail/Android.bp
@@ -0,0 +1,13 @@
+cc_library_shared {
+ name: "libhwminijail",
+ defaults: ["hidl_defaults"],
+ vendor: true,
+ export_include_dirs: ["include"],
+
+ srcs: ["HardwareMinijail.cpp"],
+
+ shared_libs: [
+ "libbase",
+ "libminijail",
+ ],
+}
diff --git a/minijail/Android.mk b/minijail/Android.mk
deleted file mode 100644
index 272bb0e..0000000
--- a/minijail/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libhwminijail
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_SRC_FILES := HardwareMinijail.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libminijail_vendor
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/neuralnetworks/1.0/Android.bp b/neuralnetworks/1.0/Android.bp
index d7c3bbb..ba32d0c 100644
--- a/neuralnetworks/1.0/Android.bp
+++ b/neuralnetworks/1.0/Android.bp
@@ -5,8 +5,9 @@
srcs: [
"types.hal",
"IDevice.hal",
- "IEvent.hal",
+ "IExecutionCallback.hal",
"IPreparedModel.hal",
+ "IPreparedModelCallback.hal",
],
}
@@ -20,8 +21,9 @@
out: [
"android/hardware/neuralnetworks/1.0/types.cpp",
"android/hardware/neuralnetworks/1.0/DeviceAll.cpp",
- "android/hardware/neuralnetworks/1.0/EventAll.cpp",
+ "android/hardware/neuralnetworks/1.0/ExecutionCallbackAll.cpp",
"android/hardware/neuralnetworks/1.0/PreparedModelAll.cpp",
+ "android/hardware/neuralnetworks/1.0/PreparedModelCallbackAll.cpp",
],
}
@@ -40,16 +42,21 @@
"android/hardware/neuralnetworks/1.0/BnHwDevice.h",
"android/hardware/neuralnetworks/1.0/BpHwDevice.h",
"android/hardware/neuralnetworks/1.0/BsDevice.h",
- "android/hardware/neuralnetworks/1.0/IEvent.h",
- "android/hardware/neuralnetworks/1.0/IHwEvent.h",
- "android/hardware/neuralnetworks/1.0/BnHwEvent.h",
- "android/hardware/neuralnetworks/1.0/BpHwEvent.h",
- "android/hardware/neuralnetworks/1.0/BsEvent.h",
+ "android/hardware/neuralnetworks/1.0/IExecutionCallback.h",
+ "android/hardware/neuralnetworks/1.0/IHwExecutionCallback.h",
+ "android/hardware/neuralnetworks/1.0/BnHwExecutionCallback.h",
+ "android/hardware/neuralnetworks/1.0/BpHwExecutionCallback.h",
+ "android/hardware/neuralnetworks/1.0/BsExecutionCallback.h",
"android/hardware/neuralnetworks/1.0/IPreparedModel.h",
"android/hardware/neuralnetworks/1.0/IHwPreparedModel.h",
"android/hardware/neuralnetworks/1.0/BnHwPreparedModel.h",
"android/hardware/neuralnetworks/1.0/BpHwPreparedModel.h",
"android/hardware/neuralnetworks/1.0/BsPreparedModel.h",
+ "android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h",
+ "android/hardware/neuralnetworks/1.0/IHwPreparedModelCallback.h",
+ "android/hardware/neuralnetworks/1.0/BnHwPreparedModelCallback.h",
+ "android/hardware/neuralnetworks/1.0/BpHwPreparedModelCallback.h",
+ "android/hardware/neuralnetworks/1.0/BsPreparedModelCallback.h",
],
}
diff --git a/neuralnetworks/1.0/IDevice.hal b/neuralnetworks/1.0/IDevice.hal
index 91a9555..49c2967 100644
--- a/neuralnetworks/1.0/IDevice.hal
+++ b/neuralnetworks/1.0/IDevice.hal
@@ -16,8 +16,7 @@
package android.hardware.neuralnetworks@1.0;
-import IEvent;
-import IPreparedModel;
+import IPreparedModelCallback;
/**
* This interface represents a device driver.
@@ -37,10 +36,9 @@
/**
* Gets the supported operations in a model.
*
- * getSupportedSubgraph provides a more nuanced indication on whether a
- * model is able to be compiled by the driver. Having the entire model
- * allows for additional information such as tensor shapes to inputs or
- * tensor strides, information which is not known in "initialize".
+ * getSupportedSubgraph indicates which operations of a model are fully
+ * supported by the vendor driver. If an operation may not be supported for
+ * any reason, getSupportedOperations must return false for that operation.
*
* @param model A model whose operations--and their corresponding
* operands--are to be verified by the driver.
@@ -48,7 +46,7 @@
* - NONE if successful
* - DEVICE_UNAVAILABLE if driver is offline or busy
* - GENERAL_FAILURE if there is an unspecified error
- * - INVALID_ARGUMENT when provided model is invalid
+ * - INVALID_ARGUMENT if provided model is invalid
* @return supportedOperations A list of supported operations, where true
* indicates the operation is supported and
* false indicates the operation is not
@@ -60,29 +58,60 @@
generates (ErrorStatus status, vec<bool> supportedOperations);
/**
- * Prepares a model for execution.
+ * Creates a prepared model for execution.
*
* prepareModel is used to make any necessary transformations or alternative
- * representations to a model for execution, possible including
+ * representations to a model for execution, possiblly including
* transformations on the constant data, optimization on the model's graph,
- * or compilation into the device's native binary format.
+ * or compilation into the device's native binary format. The model itself
+ * is not changed.
+ *
+ * The model is prepared asynchronously with respect to the caller. The
+ * prepareModel function must verify the inputs to the prepareModel function
+ * are correct. If there is an error, prepareModel must immediately invoke
+ * the callback with the appropriate ErrorStatus value and nullptr for the
+ * IPreparedModel, then return with the same ErrorStatus. If the inputs to
+ * the prepareModel function are valid and there is no error, prepareModel
+ * must launch an asynchronous task to prepare the model in the background,
+ * and immediately return from prepareModel with ErrorStatus::NONE. If the
+ * asynchronous task fails to launch, prepareModel must immediately invoke
+ * the callback with ErrorStatus::GENERAL_FAILURE and nullptr for the
+ * IPreparedModel, then return with ErrorStatus::GENERAL_FAILURE.
+ *
+ * When the asynchronous task has finished preparing the model, it must
+ * immediately invoke the callback function provided as an input to
+ * prepareModel. If the model was prepared successfully, the callback object
+ * must be invoked with an error status of ErrorStatus::NONE and the
+ * produced IPreparedModel object. If an error occurred preparing the model,
+ * the callback object must be invoked with the appropriate ErrorStatus
+ * value and nullptr for the IPreparedModel.
*
* The only information that may be unknown to the model at this stage is
- * the shape of the tensors, which may only be known at execution time.
+ * the shape of the tensors, which may only be known at execution time. As
+ * such, some driver services may return partially prepared models, where
+ * the prepared model can only be finished when it is paired with a set of
+ * inputs to the model. Note that the same prepared model object can be
+ * used with different shapes of inputs on different (possibly concurrent)
+ * executions.
+ *
+ * Multiple threads can call prepareModel on the same model concurrently.
*
* @param model The model to be prepared for execution.
- * @param event A synchronization callback that must be signaled once the
- * execution has finished.
- * @return status Error status of the call, must be:
+ * @param callback A callback object used to return the error status of
+ * preparing the model for execution and the prepared model
+ * if successful, nullptr otherwise. The callback object's
+ * notify function must be called exactly once, even if the
+ * model could not be prepared.
+ * @return status Error status of launching a task which prepares the model
+ * in the background; must be:
* - NONE if preparation task is successfully launched
* - DEVICE_UNAVAILABLE if driver is offline or busy
* - GENERAL_FAILURE if there is an unspecified error
- * - INVALID_ARGUMENT when one of the input arguments is
+ * - INVALID_ARGUMENT if one of the input arguments is
* invalid
- * @return preparedModel A handle to the resultant prepared model.
*/
- prepareModel(Model model, IEvent event)
- generates (ErrorStatus status, IPreparedModel preparedModel);
+ prepareModel(Model model, IPreparedModelCallback callback)
+ generates (ErrorStatus status);
/**
* Returns the current status of a driver.
diff --git a/neuralnetworks/1.0/IEvent.hal b/neuralnetworks/1.0/IEvent.hal
deleted file mode 100644
index 2fe454c..0000000
--- a/neuralnetworks/1.0/IEvent.hal
+++ /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.
- */
-
-package android.hardware.neuralnetworks@1.0;
-
-/**
- * The IEvent interface is a callback object passed by the
- * Neuralnetworks runtime to the vendor service. It is used as a
- * synchronization primitive between one or more runtime threads and a
- * single asynchronous vendor thread. An event object is passed as an
- * argument to a HIDL call that is expected to take a non-trivial
- * amount of time. When the asynchronous execution thread has
- * completed its computation, it must call "notify" on the event to
- * indicate to the Neuralnetworks runtime whether the computation was
- * successful or not, and that the corresponding output is ready to be
- * consumed if the execution was successful.
- */
-interface IEvent {
-
- /**
- * IEvent::notify is called by the server thread (i.e., the thread doing
- * the work) to mark the event as completed so that any threads requiring
- * the corresponding output can continue executing.
- *
- * @param status Error status returned from the asynchronous task, must be:
- * - NONE if asynchronous task was successful
- * - DEVICE_UNAVAILABLE if driver is offline or busy
- * - GENERAL_FAILURE if the asynchronous task resulted in an
- * unspecified error
- */
- oneway notify(ErrorStatus status);
-};
diff --git a/neuralnetworks/1.0/IExecutionCallback.hal b/neuralnetworks/1.0/IExecutionCallback.hal
new file mode 100644
index 0000000..ef0f454
--- /dev/null
+++ b/neuralnetworks/1.0/IExecutionCallback.hal
@@ -0,0 +1,44 @@
+/*
+ * 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.neuralnetworks@1.0;
+
+/**
+ * IExecutionCallback must be used to return the error status result from an
+ * execution asynchronously launched from IPreparedModel::execute.
+ */
+interface IExecutionCallback {
+
+ /**
+ * notify must be invoked immediately after the asynchronous task has
+ * finished performing the execution. notify must be provided with the
+ * ErrorStatus resulting from the execution. If the asynchronous task
+ * is not launched, notify must be invoked with the appropriate error.
+ *
+ * @return param Error status returned from launching the asynchronous task
+ * (if the launch fails) or from the asynchronous task itself
+ * (if the launch succeeds). Must be:
+ * - NONE if the asynchronous execution was successful
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if the asynchronous task resulted in an
+ * unspecified error
+ * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
+ * not large enough to store the resultant values
+ * - INVALID_ARGUMENT if one of the input arguments to
+ * prepareModel is invalid
+ */
+ oneway notify(ErrorStatus status);
+};
diff --git a/neuralnetworks/1.0/IPreparedModel.hal b/neuralnetworks/1.0/IPreparedModel.hal
index 5df883e..ee406fb 100644
--- a/neuralnetworks/1.0/IPreparedModel.hal
+++ b/neuralnetworks/1.0/IPreparedModel.hal
@@ -16,7 +16,7 @@
package android.hardware.neuralnetworks@1.0;
-import IEvent;
+import IExecutionCallback;
/**
* IPreparedModel describes a model that has been prepared for execution and
@@ -24,28 +24,42 @@
*/
interface IPreparedModel {
/**
- * Spawns an asynchronous execution on a prepared model.
+ * Launches an asynchronous execution on a prepared model.
*
- * Executions are asynchronous with respect to the Neuralnetworks runtime.
- * To support this, IPreparedModel::execute must spawn a new task and return
- * whether the task was successfully launched. The asynchronous task which
- * performs the execution must call event's IEvent::notify with the status
- * of the execution immediately after the execution has finished.
+ * The execution is performed asynchronously with respect to the caller.
+ * execute must verify the inputs to the function are correct. If there is
+ * an error, execute must immediately invoke the callback with the
+ * appropriate ErrorStatus value, then return with the same ErrorStatus. If
+ * the inputs to the function are valid and there is no error, execute must
+ * launch an asynchronous task to perform the execution in the background,
+ * and immediately return with ErrorStatus::NONE. If the asynchronous task
+ * fails to launch, execute must immediately invoke the callback with
+ * ErrorStatus::GENERAL_FAILURE, then return with
+ * ErrorStatus::GENERAL_FAILURE.
*
- * Multiple threads can call this execute function concurrently.
+ * When the asynchronous task has finished its execution, it must
+ * immediately invoke the callback object provided as an input to the
+ * execute function. This callback must be provided with the ErrorStatus of
+ * the execution.
+ *
+ * Multiple threads can call the execute function on the same IPreparedModel
+ * object concurrently with different requests.
*
* @param request The input and output information on which the prepared
* model is to be executed.
- * @param event A callback used for synchronization that must be signaled
- * once the execution has finished.
+ * @param callback A callback object used to return the error status of
+ * the execution. The callback object's notify function must
+ * be called exactly once, even if the execution was
+ * unsuccessful.
* @return status Error status of the call, must be:
* - NONE if task is successfully launched
* - DEVICE_UNAVAILABLE if driver is offline or busy
* - GENERAL_FAILURE if there is an unspecified error
* - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
* not large enough to store the resultant values
- * - INVALID_ARGUMENT when one of the input arguments is
+ * - INVALID_ARGUMENT if one of the input arguments is
* invalid
*/
- execute(Request request, IEvent event) generates (ErrorStatus status);
+ execute(Request request, IExecutionCallback callback)
+ generates (ErrorStatus status);
};
diff --git a/neuralnetworks/1.0/IPreparedModelCallback.hal b/neuralnetworks/1.0/IPreparedModelCallback.hal
new file mode 100644
index 0000000..fa1bf9d
--- /dev/null
+++ b/neuralnetworks/1.0/IPreparedModelCallback.hal
@@ -0,0 +1,53 @@
+/*
+ * 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.neuralnetworks@1.0;
+
+import IPreparedModel;
+
+/**
+ * IPreparedModelCallback must be used to return a prepared model produced by an
+ * asynchronous task launched from IDevice::prepareModel.
+ */
+interface IPreparedModelCallback {
+
+ /**
+ * notify must be invoked immediately after the asynchronous task holding
+ * this callback has finished preparing the model. If the model was
+ * successfully prepared, notify must be invoked with ErrorStatus::NONE and
+ * the prepared model. If the model was not able to be successfully
+ * prepared, notify must be invoked with the appropriate ErrorStatus and
+ * nullptr as the IPreparedModel. If the asynchronous task holding this
+ * callback fails to launch or if the model provided to
+ * IDevice::prepareModel is invalid, notify must be invoked with the
+ * appropriate error as well as nullptr for the IPreparedModel.
+ *
+ * @param status Error status returned from the asynchronous model
+ * preparation task; must be:
+ * - NONE if the asynchronous task successfully prepared the
+ * model
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if the asynchronous task resulted in an
+ * unspecified error
+ * - INVALID_ARGUMENT if one of the input arguments to
+ * prepareModel is invalid
+ * @param preparedModel A model that has been asynchronously prepared for
+ * execution. If the model was unable to be prepared
+ * due to an error, nullptr must be passed in place of
+ * the IPreparedModel object.
+ */
+ oneway notify(ErrorStatus status, IPreparedModel preparedModel);
+};
diff --git a/neuralnetworks/1.0/types.hal b/neuralnetworks/1.0/types.hal
index 54ed402..a645393 100644
--- a/neuralnetworks/1.0/types.hal
+++ b/neuralnetworks/1.0/types.hal
@@ -990,6 +990,12 @@
* The operand is a constant that was specified via a Memory object.
*/
CONSTANT_REFERENCE,
+
+ /**
+ * The operand does not have a value. This is valid only for optional arguments
+ * of operations.
+ */
+ NO_VALUE,
};
/**
@@ -1084,8 +1090,7 @@
/**
* Quantized zero-point offset of the operand.
*
- * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or
- * TENSOR_INT32.
+ * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM.
*/
int32_t zeroPoint;
@@ -1096,7 +1101,7 @@
/**
* Where to find the data for this operand.
- * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, or MODEL_OUTPUT:
+ * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or NO_VALUE:
* - All the fields will be 0.
* If the lifetime is CONSTANT_COPY:
* - location.poolIndex is 0.
@@ -1190,6 +1195,13 @@
*/
struct RequestArgument {
/**
+ * If true, the argument does not have a value. This can be used for operations
+ * that take optional arguments. If true, the fields of location are set to 0 and
+ * the dimensions vector is left empty.
+ */
+ bool hasNoValue;
+
+ /**
* The location within one of the memory pools passed in the Request.
*/
DataLocation location;
diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp
index 89e1021..e33ee77 100644
--- a/neuralnetworks/1.0/vts/functional/Android.bp
+++ b/neuralnetworks/1.0/vts/functional/Android.bp
@@ -17,7 +17,7 @@
cc_test {
name: "VtsHalNeuralnetworksV1_0TargetTest",
srcs: [
- "Event.cpp",
+ "Callbacks.cpp",
"GeneratedTestHarness.cpp",
"Models.cpp",
"VtsHalNeuralnetworksV1_0TargetTest.cpp",
diff --git a/neuralnetworks/1.0/vts/functional/Callbacks.cpp b/neuralnetworks/1.0/vts/functional/Callbacks.cpp
new file mode 100644
index 0000000..46bf243
--- /dev/null
+++ b/neuralnetworks/1.0/vts/functional/Callbacks.cpp
@@ -0,0 +1,127 @@
+#include "Callbacks.h"
+#include <android-base/logging.h>
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+namespace V1_0 {
+namespace implementation {
+
+CallbackBase::CallbackBase() : mNotified(false) {}
+
+CallbackBase::~CallbackBase() {
+ // Note that we cannot call CallbackBase::join_thread from here:
+ // CallbackBase is intended to be reference counted, and it is possible that
+ // the reference count drops to zero in the bound thread, causing the
+ // bound thread to call this destructor. If a thread tries to join
+ // itself, it throws an exception, producing a message like the
+ // following:
+ //
+ // terminating with uncaught exception of type std::__1::system_error:
+ // thread::join failed: Resource deadlock would occur
+}
+
+void CallbackBase::wait() {
+ std::unique_lock<std::mutex> lock(mMutex);
+ mCondition.wait(lock, [this]{return mNotified;});
+ join_thread_locked();
+}
+
+bool CallbackBase::on_finish(std::function<bool(void)> post_work) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (mPostWork != nullptr) {
+ LOG(ERROR) << "CallbackBase::on_finish -- a post-work function has already been bound to "
+ "this callback object";
+ return false;
+ }
+ if (post_work == nullptr) {
+ LOG(ERROR) << "CallbackBase::on_finish -- the new post-work function is invalid";
+ return false;
+ }
+ mPostWork = std::move(post_work);
+ return true;
+}
+
+bool CallbackBase::bind_thread(std::thread&& asyncThread) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (mThread.joinable()) {
+ LOG(ERROR) << "CallbackBase::bind_thread -- a thread has already been bound to this "
+ "callback object";
+ return false;
+ }
+ if (!asyncThread.joinable()) {
+ LOG(ERROR) << "CallbackBase::bind_thread -- the new thread is not joinable";
+ return false;
+ }
+ mThread = std::move(asyncThread);
+ return true;
+}
+
+void CallbackBase::join_thread() {
+ std::lock_guard<std::mutex> lock(mMutex);
+ join_thread_locked();
+}
+
+void CallbackBase::notify() {
+ {
+ std::lock_guard<std::mutex> lock(mMutex);
+ mNotified = true;
+ if (mPostWork != nullptr) {
+ bool success = mPostWork();
+ if (!success) {
+ LOG(ERROR) << "CallbackBase::notify -- post work failed";
+ }
+ }
+ }
+ mCondition.notify_all();
+}
+
+void CallbackBase::join_thread_locked() {
+ if (mThread.joinable()) {
+ mThread.join();
+ }
+}
+
+PreparedModelCallback::PreparedModelCallback() :
+ mErrorStatus(ErrorStatus::GENERAL_FAILURE), mPreparedModel(nullptr) {}
+
+PreparedModelCallback::~PreparedModelCallback() {}
+
+Return<void> PreparedModelCallback::notify(ErrorStatus errorStatus,
+ const sp<IPreparedModel>& preparedModel) {
+ mErrorStatus = errorStatus;
+ mPreparedModel = preparedModel;
+ CallbackBase::notify();
+ return Void();
+}
+
+ErrorStatus PreparedModelCallback::getStatus() {
+ wait();
+ return mErrorStatus;
+}
+
+sp<IPreparedModel> PreparedModelCallback::getPreparedModel() {
+ wait();
+ return mPreparedModel;
+}
+
+ExecutionCallback::ExecutionCallback() : mErrorStatus(ErrorStatus::GENERAL_FAILURE) {}
+
+ExecutionCallback::~ExecutionCallback() {}
+
+Return<void> ExecutionCallback::notify(ErrorStatus errorStatus) {
+ mErrorStatus = errorStatus;
+ CallbackBase::notify();
+ return Void();
+}
+
+ErrorStatus ExecutionCallback::getStatus() {
+ wait();
+ return mErrorStatus;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace neuralnetworks
+} // namespace hardware
+} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/Callbacks.h b/neuralnetworks/1.0/vts/functional/Callbacks.h
new file mode 100644
index 0000000..0e2ffb3
--- /dev/null
+++ b/neuralnetworks/1.0/vts/functional/Callbacks.h
@@ -0,0 +1,319 @@
+#ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_0_CALLBACKS_H
+#define ANDROID_HARDWARE_NEURALNETWORKS_V1_0_CALLBACKS_H
+
+#include <android/hardware/neuralnetworks/1.0/IExecutionCallback.h>
+#include <android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h>
+#include <chrono>
+#include <condition_variable>
+#include <functional>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <mutex>
+#include <thread>
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+/**
+ * The CallbackBase class is used internally by the NeuralNetworks runtime to
+ * synchronize between different threads. An asynchronous task is launched
+ * paired with a callback object. When a client thread requires the output being
+ * generated by the asynchronous task, the client thread can wait for the result
+ * and be blocked until it has completed or a timeout condition has been
+ * reached. Any wait* may safely be called concurrently, even on the same
+ * callback object. When the asynchronous task has finished its workload, it
+ * must immediately call "notify". If the asynchronous task has failed to launch,
+ * the function that tried to launch the asynchronous task must immediately call
+ * "notify". This "notify" call awakens any client threads waiting on the
+ * callback object.
+ *
+ * callback object. When the asynchronous task has finished its workload or has
+ * failed to launch, it must immediately call "notify", awakening any client
+ * threads waiting on the callback object.
+ *
+ * The CallbackBase class implements some of the base synchronization common to
+ * both PrepareModelCallback and ExecutionCallback. For consistency, any HIDL
+ * callback class must inherit from CallbackBase as well as the HIDL callback
+ * interface it implements.
+ *
+ * This class exists to enable synchronization across HIDL. When synchronization
+ * is only required in the same process, consider using std::future, std::mutex,
+ * std::condition_variable, or std::experimental::latch instead.
+ */
+class CallbackBase {
+ public:
+ CallbackBase();
+ ~CallbackBase();
+
+ /**
+ * CallbackBase::wait blocks until notify has been called on the callback
+ * object.
+ */
+ void wait();
+
+ /**
+ * CallbackBase::wait_for blocks until notify has been called on the
+ * callback object or the time duration from the time the wait_for function
+ * was called has expired, whichever comes first.
+ *
+ * @return Status std::cv_status::no_timeout if the callback was notified
+ * before the time duration expired, std::cv_status::timeout
+ * otherwise.
+ */
+ template<class Rep, class Period>
+ std::cv_status wait_for(const std::chrono::duration<Rep,Period>& timeout_duration);
+
+ /**
+ * CallbackBase::on_finish binds a function to the callback object. This
+ * bound function will be executed when CallbackBase::notify is called,
+ * before any calls to wait* return. (Note that CallbackBase::wait_for can
+ * return std::cv_status::timeout before CallbackBase::notify is called for
+ * the first time, and hence before the bound function is executed.)
+ *
+ * The bound function must not synchronize with or otherwise access the
+ * callback object it is bound to, as this could cause a deadlock.
+ *
+ * CallbackBase::on_finish can be called at most once on a given callback
+ * object, and the call to CallbackBase::on_finish must finish before
+ * CallbackBase::notify is called.
+ *
+ * @param post_work Function to be invoked the first time
+ * CallbackBase::notify is called. Must have a target --
+ * i.e., must not compare equal to nullptr. post_work
+ * returns true if it successfully completes, false if it
+ * fails.
+ * @return bool True if the function was successfully bound, false if
+ * unsuccessful.
+ *
+ * TODO: Why does the return value of the callback matter?
+ */
+ bool on_finish(std::function<bool(void)> post_work);
+
+ /**
+ * CallbackBase::bind_thread binds a thread to the event for later use by
+ * CallbackBase::join_thread.
+ *
+ * The thread must be passed using std::move.
+ *
+ * Once a thread is bound with CallbackBase::bind_thread, the client code
+ * should ensure that one of the following occurs before the event is
+ * destroyed:
+ * - CallbackBase::join_thread has been called.
+ * - CallbackBase::wait has been called.
+ * - CallbackBase::wait_for has been called and returned other than
+ * std::cv_status::no_timeout.
+ *
+ * The bound thread shall not call any CallbackBase method with the
+ * exception of CallbackBase::notify, which it must call when the thread has
+ * finished its computation.
+ *
+ * CallbackBase::bind_thread can be called at most once on a given callback
+ * object.
+ *
+ * @param asyncThread Thread to be bound to the callback object. The thread
+ * object must represent a thread of execution -- i.e.,
+ * asyncThread.joinable() must be true.
+ * @return bool True if successful, false if thread was not properly bound.
+ */
+ bool bind_thread(std::thread&& asyncThread);
+
+ /**
+ * CallbackBase::join_thread ensures that the thread (if any) bound to this
+ * event with CallbackBase::bind_thread has fully finished and cleaned its
+ * resources. It is legal to call this function multiple times, concurrently
+ * or sequentially.
+ */
+ void join_thread();
+
+ protected:
+ /**
+ * CallbackBase::notify enables all prior and future wait* calls on the
+ * callback object to proceed. The call to CallbackBase::notify happens
+ * before any wait* calls on this callback object return (except in the case
+ * of wait_for timing out). The asynchronous call the callback object is
+ * paired with must ensure that any update to state that should be visible
+ * to the caller of wait* happens before the call to CallbackBase::notify.
+ *
+ * CallbackBase::notify must be called exactly once on a given callback
+ * object.
+ */
+ void notify();
+
+ private:
+ // Same as CallbackBase::join_thread but assumes we already hold a lock on
+ // mMutex.
+ void join_thread_locked();
+
+ bool mNotified;
+ std::mutex mMutex;
+ std::condition_variable mCondition;
+ std::function<bool(void)> mPostWork;
+ std::thread mThread;
+};
+
+/**
+ * The PreparedModelCallback class is used to receive the error status of
+ * preparing a model as well as the prepared model from a task executing
+ * asynchronously with respect to the runtime. If a calling thread calls wait*
+ * or get* on a PreparedModelCallback object and the corresponding asynchronous
+ * task has not finished preparing the model, the calling thread will block
+ * until the asynchronous task has called notify. For more information on the
+ * synchronization behavior, refer to the CallbackBase class.
+ *
+ * This class inherits the basic blocking and signaling calls from
+ * CallbackBase, and implements the HIDL notify call from
+ * IPreparedModelCallback. This callback object is passed as an argument to
+ * IDevice::prepareModel.
+ */
+class PreparedModelCallback : public CallbackBase, public IPreparedModelCallback {
+ public:
+ PreparedModelCallback();
+ ~PreparedModelCallback() override;
+
+ /**
+ * IPreparedModelCallback::notify marks the callback object with the return
+ * status of the asynchronous model preparation along with the prepared
+ * model, and calls CallbackBase::notify, enabling all prior and future
+ * wait* calls on the PreparedModelCallback object to proceed. For more
+ * information on the synchronization behavior, refer to the CallbackBase
+ * class.
+ *
+ * IPreparedModelCallback::notify must be called exactly once on a given
+ * PreparedModelCallback object.
+ *
+ * @param status Error status returned from asynchronously preparing the
+ * model; will be:
+ * - NONE if the asynchronous preparation was successful
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - INVALID_ARGUMENT if the input model is invalid
+ * @param preparedModel Returned model that has been prepared for execution,
+ * nullptr if the model was unable to be prepared.
+ */
+ Return<void> notify(ErrorStatus status, const sp<IPreparedModel>& preparedModel) override;
+
+ /**
+ * Retrieves the error status returned from the asynchronous task launched
+ * by IDevice::prepareModel. If IDevice::prepareModel has not finished
+ * asynchronously preparing the model, this call will block until the
+ * asynchronous task notifies the object.
+ *
+ * @return status Error status returned from asynchronously preparing the
+ * model; will be:
+ * - NONE if the asynchronous preparation was successful
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - INVALID_ARGUMENT if the input model is invalid
+ */
+ ErrorStatus getStatus();
+
+ /**
+ * Retrieves the model that has been prepared for execution from the
+ * asynchronous task launched by IDevice::prepareModel. If
+ * IDevice::prepareModel has not finished asynchronously preparing the
+ * model, this call will block until the asynchronous task notifies the
+ * object.
+ *
+ * @return preparedModel Returned model that has been prepared for
+ * execution, nullptr if the model was unable to be
+ * prepared.
+ */
+ sp<IPreparedModel> getPreparedModel();
+
+ private:
+ ErrorStatus mErrorStatus;
+ sp<IPreparedModel> mPreparedModel;
+};
+
+/**
+ * The ExecutionCallback class is used to receive the error status of the
+ * execution from a task executing asynchronously with respect to the runtime.
+ * If a calling thread calls wait* or get* on a PreparedModelCallback object and
+ * the corresponding asynchronous task has not finished the execution, the
+ * calling thread will block until the asynchronous task has called notify. For
+ * more information on the synchronization behavior, refer to the CallbackBase
+ * class.
+ *
+ * This class inherits the basic blocking and signaling calls from
+ * CallbackBase, and implements the HIDL notify call from
+ * IExecutionCallback. This callback object is passed as an argument to
+ * IPreparedModel::execute.
+ */
+class ExecutionCallback : public CallbackBase, public IExecutionCallback {
+ public:
+ ExecutionCallback();
+ ~ExecutionCallback() override;
+
+ /**
+ * IExecutionCallback::notify marks the callback object with the return
+ * status of the asynchronous execution that held this callback and enables
+ * all prior and future wait* calls on the ExecutionCallback object to
+ * proceed. For more information on the synchronization behavior, refer to
+ * the CallbackBase class.
+ *
+ * IExecutionCallback::notify must be called exactly once on a given
+ * ExecutionCallback object.
+ *
+ * @param status Error status returned from asynchronously preparing the
+ * model; will be:
+ * - NONE if the asynchronous execution was successful
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
+ * not large enough to store the resultant values
+ * - INVALID_ARGUMENT if the input request is invalid
+ */
+ Return<void> notify(ErrorStatus status) override;
+
+ /**
+ * Retrieves the error status returned from the asynchronous task launched
+ * by IPreparedModel::execute. If IPreparedModel::execute has not finished
+ * asynchronously executing, this call will block until the asynchronous task
+ * notifies the object.
+ *
+ * @return status Error status returned from asynchronously preparing the
+ * model; will be:
+ * - NONE if the asynchronous execution was successful
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is
+ * not large enough to store the resultant values
+ * - INVALID_ARGUMENT if the input request is invalid
+ */
+ ErrorStatus getStatus();
+
+ private:
+ ErrorStatus mErrorStatus;
+};
+
+
+// template function implementation(s) below this point
+
+template<class Rep, class Period>
+std::cv_status CallbackBase::wait_for(const std::chrono::duration<Rep,Period>& timeout_duration) {
+ std::unique_lock<std::mutex> lock(mMutex);
+ std::cv_status status = mCondition.wait_for(lock, timeout_duration, [this]{return mNotified;});
+ if (status != std::cv_status::timeout) {
+ join_thread_locked();
+ }
+ return status;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace neuralnetworks
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_0_CALLBACKS_H
diff --git a/neuralnetworks/1.0/vts/functional/Event.cpp b/neuralnetworks/1.0/vts/functional/Event.cpp
deleted file mode 100644
index efaacb3..0000000
--- a/neuralnetworks/1.0/vts/functional/Event.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "Event.h"
-#include <android-base/logging.h>
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_0 {
-namespace implementation {
-
-Event::Event() : mStatus(Status::WAITING) {}
-
-Event::~Event() {
- // Note that we cannot call Event::join_thread from here: Event is
- // intended to be reference counted, and it is possible that the
- // reference count drops to zero in the bound thread, causing the
- // bound thread to call this destructor. If a thread tries to join
- // itself, it throws an exception, producing a message like the
- // following:
- //
- // terminating with uncaught exception of type std::__1::system_error:
- // thread::join failed: Resource deadlock would occur
-}
-
-Return<void> Event::notify(ErrorStatus status) {
- {
- std::lock_guard<std::mutex> lock(mMutex);
- mStatus = status == ErrorStatus::NONE ? Status::SUCCESS : Status::ERROR;
- if (mStatus == Status::SUCCESS && mCallback != nullptr) {
- bool success = mCallback();
- if (!success) {
- LOG(ERROR) << "Event::notify -- callback failed";
- }
- }
- }
- mCondition.notify_all();
- return Void();
-}
-
-Event::Status Event::poll() {
- std::lock_guard<std::mutex> lock(mMutex);
- return mStatus;
-}
-
-Event::Status Event::wait() {
- std::unique_lock<std::mutex> lock(mMutex);
- mCondition.wait(lock, [this]{return mStatus != Status::WAITING;});
- join_thread_locked();
- return mStatus;
-}
-
-bool Event::on_finish(std::function<bool(void)> callback) {
- std::lock_guard<std::mutex> lock(mMutex);
- if (mCallback != nullptr) {
- LOG(ERROR) << "Event::on_finish -- a callback has already been bound to this event";
- return false;
- }
- if (callback == nullptr) {
- LOG(ERROR) << "Event::on_finish -- the new callback is invalid";
- return false;
- }
- mCallback = std::move(callback);
- return true;
-}
-
-bool Event::bind_thread(std::thread&& asyncThread) {
- std::lock_guard<std::mutex> lock(mMutex);
- if (mThread.joinable()) {
- LOG(ERROR) << "Event::bind_thread -- a thread has already been bound to this event";
- return false;
- }
- if (!asyncThread.joinable()) {
- LOG(ERROR) << "Event::bind_thread -- the new thread is not joinable";
- return false;
- }
- mThread = std::move(asyncThread);
- return true;
-}
-
-void Event::join_thread() {
- std::lock_guard<std::mutex> lock(mMutex);
- join_thread_locked();
-}
-
-void Event::join_thread_locked() {
- if (mThread.joinable()) {
- mThread.join();
- }
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace neuralnetworks
-} // namespace hardware
-} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/Event.h b/neuralnetworks/1.0/vts/functional/Event.h
deleted file mode 100644
index 7dd4070..0000000
--- a/neuralnetworks/1.0/vts/functional/Event.h
+++ /dev/null
@@ -1,216 +0,0 @@
-#ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_0_EVENT_H
-#define ANDROID_HARDWARE_NEURALNETWORKS_V1_0_EVENT_H
-
-#include <android/hardware/neuralnetworks/1.0/IEvent.h>
-#include <chrono>
-#include <condition_variable>
-#include <functional>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-#include <mutex>
-#include <thread>
-
-namespace android {
-namespace hardware {
-namespace neuralnetworks {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-/**
- * The Event class is used internally by the Neuralnetworks runtime to
- * synchronize between different threads. An asynchronous task is launched
- * paired with an event object. When a client thread requires the output being
- * processed by the asynchronous task, the client thread can wait for the result
- * and be blocked until it has completed or a timeout condition has been
- * reached, or poll the result periodically. Both poll and wait* may safely be
- * called concurrently, even on the same event. When the server thread has
- * completed, it should immediately call "notify" to indicate the corresponding
- * output has been produced and awaken any client threads waiting on the event.
- *
- * This class exists to enable synchronization across HIDL. When synchronization
- * is only required in the same process, consider using std::future, std::mutex,
- * std::condition_variable, or std::experimental::latch instead.
- */
-struct Event : public IEvent {
- Event();
- ~Event() override;
-
- /**
- * Event::Status::WAITING -- The corresponding asynchronous execution has
- * not yet finished.
- * Event::Status::SUCCESS -- The corresponding asynchronous execution has
- * succeeded and the output is ready to be
- * consumed.
- * Event::Status::TIMEOUT -- The calling thread has waited longer than the
- * user has specified. This only applies to the
- * methods Event::wait_for and Event::wait_until.
- * Event::Status::ERROR -- The corresponding asynchronous execution has
- * failed to properly execute.
- */
- enum class Status : uint32_t {
- WAITING,
- SUCCESS,
- TIMEOUT,
- ERROR,
- };
-
- /**
- * IEvent::notify marks the event with the return status of the
- * asynchronous call the event is paired with and enables all
- * prior and future wait calls on the Event object to proceed. The
- * call to IEvent::notify happens before any wait* calls on
- * this event return (except in the case of TIMEOUT) and before
- * any poll calls that see the resulting status. The asynchronous
- * call the event is paired with must ensure that any update to
- * state that should be visible to the caller of wait* or poll
- * happens before the call to IEvent::notify.
- *
- * IEvent::notify can be called at most once on a given event.
- *
- * @param neuralnetworks::V1_0::ErrorStatus ErrorStatus::NONE on success
- */
- Return<void> notify(ErrorStatus status) override;
-
- /**
- * Event::poll returns the current status of the event.
- *
- * @return Status SUCCESS, ERROR, or WAITING
- */
- Event::Status poll();
-
- /**
- * Event::wait blocks until the event has been signaled.
- *
- * @return Status SUCCESS or ERROR
- */
- Event::Status wait();
-
- /**
- * Event::wait_for blocks until the event has been signaled or the time
- * duration from the time the wait_for function was called has expired,
- * whichever comes first.
- *
- * @return Status SUCCESS, ERROR, or TIMEOUT
- */
- template<class Rep, class Period>
- Event::Status wait_for(const std::chrono::duration<Rep,Period>& timeout_duration);
-
- /**
- * Event::wait_until blocks until the event has been signaled or a certain
- * time has been reached, whichever comes first.
- *
- * @return Status SUCCESS, ERROR, or TIMEOUT
- */
- template<class Clock, class Duration>
- Event::Status wait_until(const std::chrono::time_point<Clock,Duration>& timeout_duration);
-
- /**
- * Event::on_finish binds a callback function to the event. The
- * callback will be executed when IEvent::notify is called, before
- * any calls to wait* return. (Note that wait_for or wait_until
- * can return TIMEOUT before IEvent::notify is called for the
- * first time, and hence before the callback is executed.)
- *
- * The callback function must not synchronize with or otherwise
- * access the event object it is bound to.
- *
- * Event::on_finish can be called at most once on a given event.
- *
- * @param callback Function to be invoked the first time IEvent::notify is
- * called. Must have a target -- i.e., must not compare equal
- * to nullptr. Callback returns true if it successfully
- * completes, false if it fails.
- * @return bool True if the callback was successfully bound, false if
- * unsuccessful.
- *
- * TODO: What if notify has already been called before on_finish?
- * TODO: Why does the return value of the callback matter?
- */
- bool on_finish(std::function<bool(void)> callback);
-
- /**
- * Event::bind_thread binds a thread to the event for later use by
- * Event::join_thread.
- *
- * The thread must be passed using std::move.
- *
- * Once a thread is bound with Event::bind_thread, the client code
- * should ensure that one of the following occurs before the event is
- * destroyed:
- * - Event::join_thread has been called.
- * - Event::wait has been called.
- * - Event::wait_for has been called and returned other than TIMEOUT.
- * - Event::wait_until has been called and returned other than TIMEOUT.
- *
- * The bound thread shall not call any Event method with the exception of
- * IEvent::notify, which it will call when the thread has finished its
- * computation.
- *
- * Event::bind_thread can be called at most once on a given event.
- *
- * @param asyncThread Thread to be bound to the event. The thread object
- * must represent a thread of execution -- i.e.,
- * asyncThread.joinable() must be true.
- * @return bool True if successful, false if thread was not properly bound.
- */
- bool bind_thread(std::thread&& asyncThread);
-
- /**
- * Event::join_thread ensures that the thread (if any) bound to
- * this event with Event::bind_thread has fully finished and
- * cleaned its resources. It is legal to call this function
- * multiple times, concurrently or sequentially.
- */
- void join_thread();
-
- private:
- // Same as Event::join_thread but assumes we already hold a lock on mMutex.
- void join_thread_locked();
-
- Status mStatus;
- std::mutex mMutex;
- std::condition_variable mCondition;
- std::function<bool(void)> mCallback;
- std::thread mThread;
-};
-
-
-// template function implementations
-
-template<class Rep, class Period>
-Event::Status Event::wait_for(const std::chrono::duration<Rep,Period>& timeout_duration) {
- std::unique_lock<std::mutex> lock(mMutex);
- std::cv_status status = mCondition.wait_for(lock, timeout_duration,
- [this]{return mStatus != Status::WAITING;});
- if (status != std::cv_status::timeout) {
- join_thread_locked();
- }
- return status != std::cv_status::timeout ? mStatus : Status::TIMEOUT;
-}
-
-template<class Clock, class Duration>
-Event::Status Event::wait_until(const std::chrono::time_point<Clock,Duration>& timeout_time) {
- std::unique_lock<std::mutex> lock(mMutex);
- std::cv_status status = mCondition.wait_until(lock, timeout_time,
- [this]{return mStatus != Status::WAITING;});
- if (status != std::cv_status::timeout) {
- join_thread_locked();
- }
- return status != std::cv_status::timeout ? mStatus : Status::TIMEOUT;
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace neuralnetworks
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_0_EVENT_H
diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
index 4b8daec..735528b 100644
--- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-#include "Event.h"
+#include "Callbacks.h"
#include "TestHarness.h"
#include "VtsHalNeuralnetworksV1_0TargetTest.h"
#include <android-base/logging.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>
+#include <iostream>
namespace android {
namespace hardware {
@@ -32,7 +33,8 @@
hidl_memory allocateSharedMemory(int64_t size, const std::string& type = "ashmem");
namespace generated_tests {
-using ::android::hardware::neuralnetworks::V1_0::implementation::Event;
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
using ::generated_tests::filter;
using ::generated_tests::for_all;
using ::generated_tests::for_each;
@@ -65,22 +67,51 @@
void Execute(const sp<IDevice>& device, std::function<Model(void)> create_model,
std::function<bool(int)> is_ignored,
const std::vector<MixedTypedExampleType>& examples) {
- Model model = create_model();
- sp<IPreparedModel> preparedModel;
- sp<Event> preparationEvent = new Event();
- ASSERT_NE(nullptr, preparationEvent.get());
- Return<void> prepareRet = device->prepareModel(
- model, preparationEvent, [&](ErrorStatus status, const sp<IPreparedModel>& prepared) {
- EXPECT_EQ(ErrorStatus::NONE, status);
- preparedModel = prepared;
- });
- ASSERT_TRUE(prepareRet.isOk());
- ASSERT_NE(nullptr, preparedModel.get());
- Event::Status preparationStatus = preparationEvent->wait();
- EXPECT_EQ(Event::Status::SUCCESS, preparationStatus);
-
const uint32_t INPUT = 0;
const uint32_t OUTPUT = 1;
+ Model model = create_model();
+
+ // see if service can handle model
+ ErrorStatus supportedStatus;
+ bool fullySupportsModel = false;
+ Return<void> supportedCall = device->getSupportedOperations(
+ model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
+ supportedStatus = status;
+ ASSERT_NE(0ul, supported.size());
+ fullySupportsModel =
+ std::all_of(supported.begin(), supported.end(), [](bool valid) { return valid; });
+ });
+ ASSERT_TRUE(supportedCall.isOk());
+ ASSERT_EQ(ErrorStatus::NONE, supportedStatus);
+
+ // launch prepare model
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+
+ // retrieve prepared model
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ if (fullySupportsModel) {
+ EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
+ } else {
+ EXPECT_TRUE(prepareReturnStatus == ErrorStatus::NONE ||
+ prepareReturnStatus == ErrorStatus::GENERAL_FAILURE);
+ }
+
+ // early termination if vendor service cannot fully prepare model
+ if (!fullySupportsModel && prepareReturnStatus == ErrorStatus::GENERAL_FAILURE) {
+ ASSERT_EQ(nullptr, preparedModel.get());
+ LOG(INFO) << "NN VTS: Early termination of test because vendor service cannot "
+ "prepare model that it does not support.";
+ std::cout << "[ ] Early termination of test because vendor service cannot "
+ "prepare model that it does not support."
+ << std::endl;
+ return;
+ }
+ ASSERT_NE(nullptr, preparedModel.get());
int example_no = 1;
for (auto& example : examples) {
@@ -100,14 +131,17 @@
.location = {.poolIndex = INPUT, .offset = 0, .length = static_cast<uint32_t>(s)},
.dimensions = {},
};
- inputs_info[index] = arg;
+ RequestArgument arg_empty = {
+ .hasNoValue = true,
+ };
+ inputs_info[index] = s ? arg : arg_empty;
inputSize += s;
});
// Compute offset for inputs 1 and so on
{
size_t offset = 0;
for (auto& i : inputs_info) {
- i.location.offset = offset;
+ if (!i.hasNoValue) i.location.offset = offset;
offset += i.location.length;
}
}
@@ -160,15 +194,19 @@
inputMemory->commit();
outputMemory->commit();
- // execute request
- sp<Event> executionEvent = new Event();
- ASSERT_NE(nullptr, executionEvent.get());
- Return<ErrorStatus> executeStatus = preparedModel->execute(
- {.inputs = inputs_info, .outputs = outputs_info, .pools = pools}, executionEvent);
- ASSERT_TRUE(executeStatus.isOk());
- EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(executeStatus));
- Event::Status eventStatus = executionEvent->wait();
- EXPECT_EQ(Event::Status::SUCCESS, eventStatus);
+
+ // launch execution
+ sp<ExecutionCallback> executionCallback = new ExecutionCallback();
+ ASSERT_NE(nullptr, executionCallback.get());
+ Return<ErrorStatus> executionLaunchStatus = preparedModel->execute(
+ {.inputs = inputs_info, .outputs = outputs_info, .pools = pools}, executionCallback);
+ ASSERT_TRUE(executionLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(executionLaunchStatus));
+
+ // retrieve execution status
+ executionCallback->wait();
+ ErrorStatus executionReturnStatus = executionCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::NONE, executionReturnStatus);
// validate results
outputMemory->read();
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
index 0f354d1..b99e20e 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
@@ -17,7 +17,8 @@
#define LOG_TAG "neuralnetworks_hidl_hal_test"
#include "VtsHalNeuralnetworksV1_0TargetTest.h"
-#include "Event.h"
+
+#include "Callbacks.h"
#include "Models.h"
#include "TestHarness.h"
@@ -32,8 +33,10 @@
namespace vts {
namespace functional {
-using ::android::hardware::neuralnetworks::V1_0::implementation::Event;
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
using ::generated_tests::MixedTypedExampleType;
+
namespace generated_tests {
extern void Execute(const sp<IDevice>&, std::function<Model(void)>, std::function<bool(int)>,
const std::vector<MixedTypedExampleType>&);
@@ -66,26 +69,22 @@
void NeuralnetworksHidlTest::TearDown() {}
-sp<IPreparedModel> NeuralnetworksHidlTest::doPrepareModelShortcut(const Model& model) {
- sp<IPreparedModel> preparedModel;
- ErrorStatus prepareStatus;
- sp<Event> preparationEvent = new Event();
- if (preparationEvent.get() == nullptr) {
+sp<IPreparedModel> NeuralnetworksHidlTest::doPrepareModelShortcut() {
+ Model model = createValidTestModel();
+
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ if (preparedModelCallback == nullptr) {
+ return nullptr;
+ }
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ if (!prepareLaunchStatus.isOk() || prepareLaunchStatus != ErrorStatus::NONE) {
return nullptr;
}
- Return<void> prepareRet = device->prepareModel(
- model, preparationEvent, [&](ErrorStatus status, const sp<IPreparedModel>& prepared) {
- prepareStatus = status;
- preparedModel = prepared;
- });
-
- if (!prepareRet.isOk() || prepareStatus != ErrorStatus::NONE ||
- preparedModel.get() == nullptr) {
- return nullptr;
- }
- Event::Status eventStatus = preparationEvent->wait();
- if (eventStatus != Event::Status::SUCCESS) {
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ if (prepareReturnStatus != ErrorStatus::NONE || preparedModel == nullptr) {
return nullptr;
}
@@ -151,99 +150,121 @@
// prepare simple model positive test
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelPositiveTest) {
Model model = createValidTestModel();
- sp<Event> preparationEvent = new Event();
- ASSERT_NE(nullptr, preparationEvent.get());
- Return<void> prepareRet = device->prepareModel(
- model, preparationEvent, [&](ErrorStatus status, const sp<IPreparedModel>& prepared) {
- EXPECT_EQ(ErrorStatus::NONE, status);
- (void)prepared;
- });
- ASSERT_TRUE(prepareRet.isOk());
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus));
+
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ EXPECT_NE(nullptr, preparedModel.get());
}
// prepare simple model negative test 1
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelNegativeTest1) {
Model model = createInvalidTestModel1();
- sp<Event> preparationEvent = new Event();
- ASSERT_NE(nullptr, preparationEvent.get());
- Return<void> prepareRet = device->prepareModel(
- model, preparationEvent, [&](ErrorStatus status, const sp<IPreparedModel>& prepared) {
- EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, status);
- (void)prepared;
- });
- ASSERT_TRUE(prepareRet.isOk());
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(prepareLaunchStatus));
+
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, prepareReturnStatus);
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ EXPECT_EQ(nullptr, preparedModel.get());
}
// prepare simple model negative test 2
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelNegativeTest2) {
Model model = createInvalidTestModel2();
- sp<Event> preparationEvent = new Event();
- ASSERT_NE(nullptr, preparationEvent.get());
- Return<void> prepareRet = device->prepareModel(
- model, preparationEvent, [&](ErrorStatus status, const sp<IPreparedModel>& prepared) {
- EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, status);
- (void)prepared;
- });
- ASSERT_TRUE(prepareRet.isOk());
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(prepareLaunchStatus));
+
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, prepareReturnStatus);
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ EXPECT_EQ(nullptr, preparedModel.get());
}
// execute simple graph positive test
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphPositiveTest) {
- Model model = createValidTestModel();
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut(model);
- ASSERT_NE(nullptr, preparedModel.get());
- Request request = createValidTestRequest();
-
- sp<Event> executionEvent = new Event();
- ASSERT_NE(nullptr, executionEvent.get());
- Return<ErrorStatus> executeStatus = preparedModel->execute(request, executionEvent);
- ASSERT_TRUE(executeStatus.isOk());
- EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(executeStatus));
- Event::Status eventStatus = executionEvent->wait();
- EXPECT_EQ(Event::Status::SUCCESS, eventStatus);
-
std::vector<float> outputData = {-1.0f, -1.0f, -1.0f, -1.0f};
std::vector<float> expectedData = {6.0f, 8.0f, 10.0f, 12.0f};
const uint32_t OUTPUT = 1;
- sp<IMemory> outputMemory = mapMemory(request.pools[OUTPUT]);
- ASSERT_NE(nullptr, outputMemory.get());
- float* outputPtr = reinterpret_cast<float*>(static_cast<void*>(outputMemory->getPointer()));
- ASSERT_NE(nullptr, outputPtr);
- outputMemory->read();
- std::copy(outputPtr, outputPtr + outputData.size(), outputData.begin());
- outputMemory->commit();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ ASSERT_NE(nullptr, preparedModel.get());
+ Request request = createValidTestRequest();
+
+ auto postWork = [&] {
+ sp<IMemory> outputMemory = mapMemory(request.pools[OUTPUT]);
+ if (outputMemory == nullptr) {
+ return false;
+ }
+ float* outputPtr = reinterpret_cast<float*>(static_cast<void*>(outputMemory->getPointer()));
+ if (outputPtr == nullptr) {
+ return false;
+ }
+ outputMemory->read();
+ std::copy(outputPtr, outputPtr + outputData.size(), outputData.begin());
+ outputMemory->commit();
+ return true;
+ };
+
+ sp<ExecutionCallback> executionCallback = new ExecutionCallback();
+ ASSERT_NE(nullptr, executionCallback.get());
+ executionCallback->on_finish(postWork);
+ Return<ErrorStatus> executeLaunchStatus = preparedModel->execute(request, executionCallback);
+ ASSERT_TRUE(executeLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(executeLaunchStatus));
+
+ executionCallback->wait();
+ ErrorStatus executionReturnStatus = executionCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::NONE, executionReturnStatus);
EXPECT_EQ(expectedData, outputData);
}
// execute simple graph negative test 1
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphNegativeTest1) {
- Model model = createValidTestModel();
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut(model);
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
ASSERT_NE(nullptr, preparedModel.get());
Request request = createInvalidTestRequest1();
- sp<Event> executionEvent = new Event();
- ASSERT_NE(nullptr, executionEvent.get());
- Return<ErrorStatus> executeStatus = preparedModel->execute(request, executionEvent);
- ASSERT_TRUE(executeStatus.isOk());
- EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(executeStatus));
- executionEvent->wait();
+ sp<ExecutionCallback> executionCallback = new ExecutionCallback();
+ ASSERT_NE(nullptr, executionCallback.get());
+ Return<ErrorStatus> executeLaunchStatus = preparedModel->execute(request, executionCallback);
+ ASSERT_TRUE(executeLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(executeLaunchStatus));
+
+ executionCallback->wait();
+ ErrorStatus executionReturnStatus = executionCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, executionReturnStatus);
}
// execute simple graph negative test 2
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphNegativeTest2) {
- Model model = createValidTestModel();
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut(model);
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
ASSERT_NE(nullptr, preparedModel.get());
Request request = createInvalidTestRequest2();
- sp<Event> executionEvent = new Event();
- ASSERT_NE(nullptr, executionEvent.get());
- Return<ErrorStatus> executeStatus = preparedModel->execute(request, executionEvent);
- ASSERT_TRUE(executeStatus.isOk());
- EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(executeStatus));
- executionEvent->wait();
+ sp<ExecutionCallback> executionCallback = new ExecutionCallback();
+ ASSERT_NE(nullptr, executionCallback.get());
+ Return<ErrorStatus> executeLaunchStatus = preparedModel->execute(request, executionCallback);
+ ASSERT_TRUE(executeLaunchStatus.isOk());
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(executeLaunchStatus));
+
+ executionCallback->wait();
+ ErrorStatus executionReturnStatus = executionCallback->getStatus();
+ EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, executionReturnStatus);
}
// Mixed-typed examples
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
index 1b3b334..5cd209a 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
@@ -18,7 +18,9 @@
#define VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H
#include <android/hardware/neuralnetworks/1.0/IDevice.h>
+#include <android/hardware/neuralnetworks/1.0/IExecutionCallback.h>
#include <android/hardware/neuralnetworks/1.0/IPreparedModel.h>
+#include <android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h>
#include <android/hardware/neuralnetworks/1.0/types.h>
#include <android/hidl/allocator/1.0/IAllocator.h>
@@ -72,13 +74,28 @@
void SetUp() override;
void TearDown() override;
- sp<IPreparedModel> doPrepareModelShortcut(const Model& model);
+ sp<IPreparedModel> doPrepareModelShortcut();
sp<IDevice> device;
};
} // namespace functional
} // namespace vts
+
+// pretty-print values for error messages
+
+template<typename CharT, typename Traits>
+::std::basic_ostream<CharT, Traits>& operator<<(::std::basic_ostream<CharT, Traits>& os,
+ ErrorStatus errorStatus) {
+ return os << toString(errorStatus);
+}
+
+template<typename CharT, typename Traits>
+::std::basic_ostream<CharT, Traits>& operator<<(::std::basic_ostream<CharT, Traits>& os,
+ DeviceStatus deviceStatus) {
+ return os << toString(deviceStatus);
+}
+
} // namespace V1_0
} // namespace neuralnetworks
} // namespace hardware
diff --git a/nfc/1.0/Android.bp b/nfc/1.0/Android.bp
index ac02e44..ad84683 100644
--- a/nfc/1.0/Android.bp
+++ b/nfc/1.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.nfc@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/nfc/1.0/default/Android.bp b/nfc/1.0/default/Android.bp
index d7f7203..3b53d16 100644
--- a/nfc/1.0/default/Android.bp
+++ b/nfc/1.0/default/Android.bp
@@ -19,6 +19,7 @@
cc_binary {
name: "android.hardware.nfc@1.0-service",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
init_rc: ["android.hardware.nfc@1.0-service.rc"],
diff --git a/power/1.0/Android.bp b/power/1.0/Android.bp
index 5cc4ae0..789fdcc 100644
--- a/power/1.0/Android.bp
+++ b/power/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.power@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/radio/1.0/Android.bp b/radio/1.0/Android.bp
index 4485e74..da496e7 100644
--- a/radio/1.0/Android.bp
+++ b/radio/1.0/Android.bp
@@ -164,6 +164,7 @@
cc_test {
name: "android.hardware.radio@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index 82a8a72..61136ae 100644
--- a/radio/1.0/vts/functional/Android.bp
+++ b/radio/1.0/vts/functional/Android.bp
@@ -50,6 +50,7 @@
cc_library_static {
name: "RadioVtsTestUtilBase",
+ defaults: ["hidl_defaults"],
srcs : [
"vts_test_util.cpp"
],
diff --git a/radio/1.1/Android.bp b/radio/1.1/Android.bp
index d89211b..462bd85 100644
--- a/radio/1.1/Android.bp
+++ b/radio/1.1/Android.bp
@@ -161,6 +161,7 @@
cc_test {
name: "android.hardware.radio@1.1-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/radio/deprecated/1.0/Android.bp b/radio/deprecated/1.0/Android.bp
index 82a7c8d..7b0c01e 100644
--- a/radio/deprecated/1.0/Android.bp
+++ b/radio/deprecated/1.0/Android.bp
@@ -148,6 +148,7 @@
cc_test {
name: "android.hardware.radio.deprecated@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/renderscript/1.0/Android.bp b/renderscript/1.0/Android.bp
index c687ea9..0fd5186 100644
--- a/renderscript/1.0/Android.bp
+++ b/renderscript/1.0/Android.bp
@@ -138,6 +138,7 @@
cc_test {
name: "android.hardware.renderscript@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/sensors/1.0/Android.bp b/sensors/1.0/Android.bp
index 8a91ee6..d3ec0be 100644
--- a/sensors/1.0/Android.bp
+++ b/sensors/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.sensors@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/soundtrigger/2.0/Android.bp b/soundtrigger/2.0/Android.bp
index 173aa75..d902dd0 100644
--- a/soundtrigger/2.0/Android.bp
+++ b/soundtrigger/2.0/Android.bp
@@ -141,6 +141,7 @@
cc_test {
name: "android.hardware.soundtrigger@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/bar/1.0/Android.bp b/tests/bar/1.0/Android.bp
index ce4b4fc..b862c9b 100644
--- a/tests/bar/1.0/Android.bp
+++ b/tests/bar/1.0/Android.bp
@@ -167,6 +167,7 @@
cc_test {
name: "android.hardware.tests.bar@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index 3a208a8..41b6ef2 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -152,6 +152,7 @@
cc_test {
name: "android.hardware.tests.baz@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/expression/1.0/Android.bp b/tests/expression/1.0/Android.bp
index a54538c..bbb6f33 100644
--- a/tests/expression/1.0/Android.bp
+++ b/tests/expression/1.0/Android.bp
@@ -130,6 +130,7 @@
cc_test {
name: "android.hardware.tests.expression@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/extension/light/2.0/Android.bp b/tests/extension/light/2.0/Android.bp
index 5220630..07dcea3 100644
--- a/tests/extension/light/2.0/Android.bp
+++ b/tests/extension/light/2.0/Android.bp
@@ -131,6 +131,7 @@
cc_test {
name: "android.hardware.tests.extension.light@2.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index acf4fdd..51b5dc6 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -161,6 +161,7 @@
cc_test {
name: "android.hardware.tests.foo@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/hash/1.0/Android.bp b/tests/hash/1.0/Android.bp
index 3f7205e..ffff051 100644
--- a/tests/hash/1.0/Android.bp
+++ b/tests/hash/1.0/Android.bp
@@ -121,6 +121,7 @@
cc_test {
name: "android.hardware.tests.hash@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/hash/1.0/default/Android.bp b/tests/hash/1.0/default/Android.bp
index ae44876..67f9097 100644
--- a/tests/hash/1.0/default/Android.bp
+++ b/tests/hash/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.tests.hash@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
srcs: [
"Hash.cpp",
diff --git a/tests/inheritance/1.0/Android.bp b/tests/inheritance/1.0/Android.bp
index e693082..bd34512 100644
--- a/tests/inheritance/1.0/Android.bp
+++ b/tests/inheritance/1.0/Android.bp
@@ -148,6 +148,7 @@
cc_test {
name: "android.hardware.tests.inheritance@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/inheritance/1.0/default/Parent.cpp b/tests/inheritance/1.0/default/Parent.cpp
index d3f1932..1fabf1b 100644
--- a/tests/inheritance/1.0/default/Parent.cpp
+++ b/tests/inheritance/1.0/default/Parent.cpp
@@ -1,8 +1,10 @@
#define LOG_TAG "hidl_test"
+#include "Parent.h"
+
#include <log/log.h>
-#include "Parent.h"
+#include "Child.h"
namespace android {
namespace hardware {
@@ -23,8 +25,11 @@
return Void();
}
+IParent* HIDL_FETCH_IParent(const char* name) {
+ if (name == std::string("child")) {
+ return new Child();
+ }
-IParent* HIDL_FETCH_IParent(const char* /* name */) {
return new Parent();
}
diff --git a/tests/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index 0a84abb..139aec5 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -130,6 +130,7 @@
cc_test {
name: "android.hardware.tests.libhwbinder@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
index f1f99a6..3d18720 100644
--- a/tests/libhwbinder/1.0/default/Android.bp
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.tests.libhwbinder@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
srcs: [
"Benchmark.cpp",
diff --git a/tests/libhwbinder/aidl/Android.bp b/tests/libhwbinder/aidl/Android.bp
index a662085..6d49704 100644
--- a/tests/libhwbinder/aidl/Android.bp
+++ b/tests/libhwbinder/aidl/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.tests.libbinder",
+ defaults: ["hidl_defaults"],
srcs: ["android/tests/binder/IBenchmark.aidl"],
diff --git a/tests/memory/1.0/Android.bp b/tests/memory/1.0/Android.bp
index 7a36c0e..5653e97 100644
--- a/tests/memory/1.0/Android.bp
+++ b/tests/memory/1.0/Android.bp
@@ -121,6 +121,7 @@
cc_test {
name: "android.hardware.tests.memory@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index 0af5420..39a34cb 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -130,6 +130,7 @@
cc_test {
name: "android.hardware.tests.msgq@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
index eb25ac2..be4fe94 100644
--- a/tests/msgq/1.0/default/Android.bp
+++ b/tests/msgq/1.0/default/Android.bp
@@ -35,6 +35,7 @@
cc_test {
name: "android.hardware.tests.msgq@1.0-service-benchmark",
+ defaults: ["hidl_defaults"],
srcs: ["mq_benchmark_service.cpp"],
gtest: false,
@@ -51,6 +52,7 @@
cc_test {
name: "android.hardware.tests.msgq@1.0-service-test",
+ defaults: ["hidl_defaults"],
srcs: ["mq_test_service.cpp"],
gtest: false,
diff --git a/tests/multithread/1.0/Android.bp b/tests/multithread/1.0/Android.bp
index df38695..98cbd5e 100644
--- a/tests/multithread/1.0/Android.bp
+++ b/tests/multithread/1.0/Android.bp
@@ -121,6 +121,7 @@
cc_test {
name: "android.hardware.tests.multithread@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/pointer/1.0/Android.bp b/tests/pointer/1.0/Android.bp
index 1644186..2c13cb1 100644
--- a/tests/pointer/1.0/Android.bp
+++ b/tests/pointer/1.0/Android.bp
@@ -130,6 +130,7 @@
cc_test {
name: "android.hardware.tests.pointer@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tests/trie/1.0/Android.bp b/tests/trie/1.0/Android.bp
index 27b5ea5..73f1b0b 100644
--- a/tests/trie/1.0/Android.bp
+++ b/tests/trie/1.0/Android.bp
@@ -125,6 +125,7 @@
cc_test {
name: "android.hardware.tests.trie@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tetheroffload/config/1.0/Android.bp b/tetheroffload/config/1.0/Android.bp
index 705253d..5cafb5d 100644
--- a/tetheroffload/config/1.0/Android.bp
+++ b/tetheroffload/config/1.0/Android.bp
@@ -124,6 +124,7 @@
cc_test {
name: "android.hardware.tetheroffload.config@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tetheroffload/control/1.0/Android.bp b/tetheroffload/control/1.0/Android.bp
index 75750f0..f4f120a 100644
--- a/tetheroffload/control/1.0/Android.bp
+++ b/tetheroffload/control/1.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.tetheroffload.control@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/thermal/1.0/Android.bp b/thermal/1.0/Android.bp
index da1e641..199da79 100644
--- a/thermal/1.0/Android.bp
+++ b/thermal/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.thermal@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tv/cec/1.0/Android.bp b/tv/cec/1.0/Android.bp
index 10902ef..f333777 100644
--- a/tv/cec/1.0/Android.bp
+++ b/tv/cec/1.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.tv.cec@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/tv/input/1.0/Android.bp b/tv/input/1.0/Android.bp
index 36b2f13..b07b2c7 100644
--- a/tv/input/1.0/Android.bp
+++ b/tv/input/1.0/Android.bp
@@ -141,6 +141,7 @@
cc_test {
name: "android.hardware.tv.input@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/usb/1.0/Android.bp b/usb/1.0/Android.bp
index e97dbf9..ce4bc25 100644
--- a/usb/1.0/Android.bp
+++ b/usb/1.0/Android.bp
@@ -137,6 +137,7 @@
cc_test {
name: "android.hardware.usb@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/vibrator/1.0/Android.bp b/vibrator/1.0/Android.bp
index 0a48e00..9289657 100644
--- a/vibrator/1.0/Android.bp
+++ b/vibrator/1.0/Android.bp
@@ -128,6 +128,7 @@
cc_test {
name: "android.hardware.vibrator@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/vr/1.0/Android.bp b/vr/1.0/Android.bp
index 5da5857..6fda0e6 100644
--- a/vr/1.0/Android.bp
+++ b/vr/1.0/Android.bp
@@ -124,6 +124,7 @@
cc_test {
name: "android.hardware.vr@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/wifi/1.0/Android.bp b/wifi/1.0/Android.bp
index 088591a..c61d989 100644
--- a/wifi/1.0/Android.bp
+++ b/wifi/1.0/Android.bp
@@ -236,6 +236,7 @@
cc_test {
name: "android.hardware.wifi@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",
diff --git a/wifi/1.0/vts/functional/Android.bp b/wifi/1.0/vts/functional/Android.bp
index 0cebbfc..ea27f02 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_library_static {
name: "VtsHalWifiV1_0TargetTestUtil",
+ defaults: ["hidl_defaults"],
srcs: [
"wifi_hidl_call_util_selftest.cpp",
"wifi_hidl_test.cpp",
diff --git a/wifi/1.2/default/wifi_legacy_hal.cpp b/wifi/1.2/default/wifi_legacy_hal.cpp
index 9176fde..54d9ca0 100644
--- a/wifi/1.2/default/wifi_legacy_hal.cpp
+++ b/wifi/1.2/default/wifi_legacy_hal.cpp
@@ -35,7 +35,7 @@
static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128;
static constexpr uint32_t kMaxWakeReasonStatsArraySize = 32;
static constexpr uint32_t kMaxRingBuffers = 10;
-static constexpr uint32_t kMaxStopCompleteWaitMs = 50;
+static constexpr uint32_t kMaxStopCompleteWaitMs = 100;
// Helper function to create a non-const char* for legacy Hal API's.
std::vector<char> makeCharVec(const std::string& str) {
diff --git a/wifi/supplicant/1.0/Android.bp b/wifi/supplicant/1.0/Android.bp
index 4bf8e68..8a0b802 100644
--- a/wifi/supplicant/1.0/Android.bp
+++ b/wifi/supplicant/1.0/Android.bp
@@ -227,6 +227,7 @@
cc_test {
name: "android.hardware.wifi.supplicant@1.0-adapter",
+ defaults: ["hidl-module-defaults"],
shared_libs: [
"libhidladapter",
"libhidlbase",