Merge "Add layered image support to gralloc1 hal."
diff --git a/audio/Android.bp b/audio/Android.bp
index 4117288..3121a36 100644
--- a/audio/Android.bp
+++ b/audio/Android.bp
@@ -3,4 +3,5 @@
"2.0",
"common/2.0",
"effect/2.0",
+ "effect/2.0/vts/functional",
]
diff --git a/audio/effect/2.0/vts/functional/Android.bp b/audio/effect/2.0/vts/functional/Android.bp
new file mode 100644
index 0000000..fc198e5
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+ name: "audio_effect_hidl_hal_test",
+ gtest: true,
+ srcs: ["audio_effect_hidl_hal_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidl",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.audio.effect@2.0",
+ ],
+ static_libs: ["libgtest"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
diff --git a/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp b/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp
new file mode 100644
index 0000000..ddd5eac
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2016 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 "AudioEffectHidlHalTest"
+#include <android-base/logging.h>
+#include <cutils/native_handle.h>
+
+#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
+#include <android/hardware/audio/effect/2.0/types.h>
+
+#include <gtest/gtest.h>
+
+using ::android::hardware::audio::common::V2_0::Uuid;
+using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
+using ::android::hardware::audio::effect::V2_0::IEffect;
+using ::android::hardware::audio::effect::V2_0::IEffectsFactory;
+using ::android::hardware::audio::effect::V2_0::Result;
+using ::android::hardware::Return;
+using ::android::hardware::Status;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::sp;
+
+// The main test class for Audio Effect HIDL HAL.
+class AudioEffectHidlTest : public ::testing::Test {
+ public:
+ virtual void SetUp() override {
+ // currently test passthrough mode only
+ effectsFactory = IEffectsFactory::getService("audio_effects_factory", true);
+ ASSERT_NE(effectsFactory, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ sp<IEffectsFactory> effectsFactory;
+};
+
+// A class for test environment setup (kept since this file is a template).
+class AudioEffectHidlEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ private:
+};
+
+TEST_F(AudioEffectHidlTest, EnumerateEffects) {
+ Result retval = Result::NOT_INITIALIZED;
+ size_t effectCount = 0;
+ Return<void> ret = effectsFactory->getAllDescriptors(
+ [&](Result r, const hidl_vec<EffectDescriptor>& result) {
+ retval = r;
+ effectCount = result.size();
+ });
+ EXPECT_EQ(ret.getStatus().exceptionCode(), Status::EX_NONE);
+ EXPECT_EQ(retval, Result::OK);
+ EXPECT_GT(effectCount, 0u);
+}
+
+TEST_F(AudioEffectHidlTest, CreateEffect) {
+ bool gotEffect = false;
+ Uuid effectUuid;
+ Return<void> ret = effectsFactory->getAllDescriptors(
+ [&](Result r, const hidl_vec<EffectDescriptor>& result) {
+ if (r == Result::OK && result.size() > 0) {
+ gotEffect = true;
+ effectUuid = result[0].uuid;
+ }
+ });
+ ASSERT_EQ(ret.getStatus().exceptionCode(), Status::EX_NONE);
+ ASSERT_TRUE(gotEffect);
+ Result retval = Result::NOT_INITIALIZED;
+ sp<IEffect> effect;
+ ret = effectsFactory->createEffect(effectUuid, 1, 1,
+ [&](Result r, const sp<IEffect>& result) {
+ retval = r;
+ if (r == Result::OK) {
+ effect = result;
+ }
+ });
+ EXPECT_EQ(ret.getStatus().exceptionCode(), Status::EX_NONE);
+ EXPECT_EQ(retval, Result::OK);
+ EXPECT_NE(effect, nullptr);
+}
+
+// See b/32834072 -- we should have those operator== generated by hidl-gen.
+
+namespace android {
+namespace hardware {
+namespace audio {
+namespace common {
+namespace V2_0 {
+
+static bool operator==(const Uuid& lhs, const Uuid& rhs) {
+ return lhs.timeLow == rhs.timeLow && lhs.timeMid == rhs.timeMid &&
+ lhs.versionAndTimeHigh == rhs.versionAndTimeHigh &&
+ lhs.variantAndClockSeqHigh == rhs.variantAndClockSeqHigh &&
+ memcmp(lhs.node.data(), rhs.node.data(), lhs.node.size()) == 0;
+}
+
+} // namespace V2_0
+} // namespace common
+} // namespace audio
+} // namespace hardware
+} // namespace android
+
+namespace android {
+namespace hardware {
+namespace audio {
+namespace effect {
+namespace V2_0 {
+
+static bool operator==(const EffectDescriptor& lhs,
+ const EffectDescriptor& rhs) {
+ return lhs.type == rhs.type && lhs.uuid == rhs.uuid &&
+ lhs.flags == rhs.flags && lhs.cpuLoad == rhs.cpuLoad &&
+ lhs.memoryUsage == rhs.memoryUsage &&
+ memcmp(lhs.name.data(), rhs.name.data(), lhs.name.size()) == 0 &&
+ memcmp(lhs.implementor.data(), rhs.implementor.data(),
+ lhs.implementor.size()) == 0;
+}
+
+} // namespace V2_0
+} // namespace effect
+} // namespace audio
+} // namespace hardware
+} // namespace android
+
+TEST_F(AudioEffectHidlTest, GetDescriptor) {
+ hidl_vec<EffectDescriptor> allDescriptors;
+ Return<void> ret = effectsFactory->getAllDescriptors(
+ [&](Result r, const hidl_vec<EffectDescriptor>& result) {
+ if (r == Result::OK) {
+ allDescriptors = result;
+ }
+ });
+ ASSERT_EQ(ret.getStatus().exceptionCode(), Status::EX_NONE);
+ ASSERT_GT(allDescriptors.size(), 0u);
+ for (size_t i = 0; i < allDescriptors.size(); ++i) {
+ ret = effectsFactory->getDescriptor(
+ allDescriptors[i].uuid, [&](Result r, const EffectDescriptor& result) {
+ EXPECT_EQ(r, Result::OK);
+ EXPECT_EQ(result, allDescriptors[i]);
+ });
+ }
+ EXPECT_EQ(ret.getStatus().exceptionCode(), Status::EX_NONE);
+}
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(new AudioEffectHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
diff --git a/contexthub/1.0/Android.bp b/contexthub/1.0/Android.bp
new file mode 100644
index 0000000..23c44de
--- /dev/null
+++ b/contexthub/1.0/Android.bp
@@ -0,0 +1,59 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.contexthub@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.contexthub@1.0",
+ srcs: [
+ "types.hal",
+ "IContexthub.hal",
+ "IContexthubCallback.hal",
+ ],
+ out: [
+ "android/hardware/contexthub/1.0/types.cpp",
+ "android/hardware/contexthub/1.0/ContexthubAll.cpp",
+ "android/hardware/contexthub/1.0/ContexthubCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.contexthub@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.contexthub@1.0",
+ srcs: [
+ "types.hal",
+ "IContexthub.hal",
+ "IContexthubCallback.hal",
+ ],
+ out: [
+ "android/hardware/contexthub/1.0/types.h",
+ "android/hardware/contexthub/1.0/IContexthub.h",
+ "android/hardware/contexthub/1.0/IHwContexthub.h",
+ "android/hardware/contexthub/1.0/BnContexthub.h",
+ "android/hardware/contexthub/1.0/BpContexthub.h",
+ "android/hardware/contexthub/1.0/BsContexthub.h",
+ "android/hardware/contexthub/1.0/IContexthubCallback.h",
+ "android/hardware/contexthub/1.0/IHwContexthubCallback.h",
+ "android/hardware/contexthub/1.0/BnContexthubCallback.h",
+ "android/hardware/contexthub/1.0/BpContexthubCallback.h",
+ "android/hardware/contexthub/1.0/BsContexthubCallback.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.contexthub@1.0",
+ generated_sources: ["android.hardware.contexthub@1.0_genc++"],
+ generated_headers: ["android.hardware.contexthub@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.contexthub@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidl",
+ "libhwbinder",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidl",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/contexthub/1.0/Android.mk b/contexthub/1.0/Android.mk
new file mode 100644
index 0000000..72291e6
--- /dev/null
+++ b/contexthub/1.0/Android.mk
@@ -0,0 +1,552 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.contexthub@1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (AsyncEventType)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/AsyncEventType.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 \
+ android.hardware.contexthub@1.0::types.AsyncEventType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ContextHub)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/ContextHub.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 \
+ android.hardware.contexthub@1.0::types.ContextHub
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ContextHubMsg)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/ContextHubMsg.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 \
+ android.hardware.contexthub@1.0::types.ContextHubMsg
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (HubAppInfo)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/HubAppInfo.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 \
+ android.hardware.contexthub@1.0::types.HubAppInfo
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (HubMemoryFlag)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/HubMemoryFlag.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 \
+ android.hardware.contexthub@1.0::types.HubMemoryFlag
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (HubMemoryType)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/HubMemoryType.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 \
+ android.hardware.contexthub@1.0::types.HubMemoryType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (MemRange)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/MemRange.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 \
+ android.hardware.contexthub@1.0::types.MemRange
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (NanoAppBinary)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/NanoAppBinary.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 \
+ android.hardware.contexthub@1.0::types.NanoAppBinary
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (NanoAppFlags)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/NanoAppFlags.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 \
+ android.hardware.contexthub@1.0::types.NanoAppFlags
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PhysicalSensor)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/PhysicalSensor.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 \
+ android.hardware.contexthub@1.0::types.PhysicalSensor
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Result)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.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 \
+ android.hardware.contexthub@1.0::types.Result
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (SensorType)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/SensorType.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 \
+ android.hardware.contexthub@1.0::types.SensorType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (TransactionResult)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/TransactionResult.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 \
+ android.hardware.contexthub@1.0::types.TransactionResult
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IContexthub.hal
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/IContexthub.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IContexthub.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IContexthubCallback.hal
+$(GEN): $(LOCAL_PATH)/IContexthubCallback.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 \
+ android.hardware.contexthub@1.0::IContexthub
+
+$(GEN): $(LOCAL_PATH)/IContexthub.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IContexthubCallback.hal
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/IContexthubCallback.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IContexthubCallback.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 \
+ android.hardware.contexthub@1.0::IContexthubCallback
+
+$(GEN): $(LOCAL_PATH)/IContexthubCallback.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.contexthub@1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (AsyncEventType)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/AsyncEventType.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 \
+ android.hardware.contexthub@1.0::types.AsyncEventType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ContextHub)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/ContextHub.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 \
+ android.hardware.contexthub@1.0::types.ContextHub
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ContextHubMsg)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/ContextHubMsg.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 \
+ android.hardware.contexthub@1.0::types.ContextHubMsg
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (HubAppInfo)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/HubAppInfo.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 \
+ android.hardware.contexthub@1.0::types.HubAppInfo
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (HubMemoryFlag)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/HubMemoryFlag.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 \
+ android.hardware.contexthub@1.0::types.HubMemoryFlag
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (HubMemoryType)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/HubMemoryType.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 \
+ android.hardware.contexthub@1.0::types.HubMemoryType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (MemRange)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/MemRange.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 \
+ android.hardware.contexthub@1.0::types.MemRange
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (NanoAppBinary)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/NanoAppBinary.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 \
+ android.hardware.contexthub@1.0::types.NanoAppBinary
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (NanoAppFlags)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/NanoAppFlags.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 \
+ android.hardware.contexthub@1.0::types.NanoAppFlags
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PhysicalSensor)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/PhysicalSensor.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 \
+ android.hardware.contexthub@1.0::types.PhysicalSensor
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Result)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.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 \
+ android.hardware.contexthub@1.0::types.Result
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (SensorType)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/SensorType.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 \
+ android.hardware.contexthub@1.0::types.SensorType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (TransactionResult)
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/TransactionResult.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 \
+ android.hardware.contexthub@1.0::types.TransactionResult
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IContexthub.hal
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/IContexthub.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IContexthub.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IContexthubCallback.hal
+$(GEN): $(LOCAL_PATH)/IContexthubCallback.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 \
+ android.hardware.contexthub@1.0::IContexthub
+
+$(GEN): $(LOCAL_PATH)/IContexthub.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IContexthubCallback.hal
+#
+GEN := $(intermediates)/android/hardware/contexthub/1.0/IContexthubCallback.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IContexthubCallback.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 \
+ android.hardware.contexthub@1.0::IContexthubCallback
+
+$(GEN): $(LOCAL_PATH)/IContexthubCallback.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/contexthub/1.0/IContexthub.hal b/contexthub/1.0/IContexthub.hal
new file mode 100644
index 0000000..8d19aeb
--- /dev/null
+++ b/contexthub/1.0/IContexthub.hal
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2016 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.contexthub@1.0;
+
+import IContexthubCallback;
+
+interface IContexthub {
+ /*
+ * Enumerate all available context hubs on the system.
+ *
+ * @return hubs list of hubs on this system.
+ */
+ getHubs() generates (vec<ContextHub> hubs);
+
+ /*
+ * Register a callback for the HAL implementation to send asynchronous
+ * messages to the service from a context hub. There can be a maximum of
+ * one callback registered with the HAL. A call to this function when a
+ * callback has already been registered must override the previous
+ * registration.
+ *
+ * @param hubId identifier for the hub
+ * callback an implementation of the IContextHubCallbacks
+ *
+ * @return result OK on success
+ * BAD_VALUE if parameters are not sane
+ *
+ */
+ registerCallback(uint32_t hubId, IContexthubCallback cb) generates (Result result);
+
+ /**
+ * Send a message to a hub
+ *
+ * @param hubId identifier for hub to send message to
+ * msg message to be sent
+ *
+ * @return result OK if successful, error code otherwise
+ * BAD_VALUE if parameters are not sane
+ * TRANSACTION_FAILED if message send failed
+ */
+ sendMessageToHub(uint32_t hubId, ContextHubMsg msg)
+ generates (Result result);
+
+ /**
+ * Loads a nanoApp. After loading, the nanoApp's init method must be called.
+ * After the init method for nanoApp returns success, this must be indicated
+ * to the service by an asynchronous call to handleTxnResult.
+ *
+ * @param hubId identifer of the contextHub
+ * appBinary binary for the nanoApp
+ * msg message to be sent
+ *
+ * @return result OK if transation started
+ * BAD_VALUE if parameters are not sane
+ * TRANSACTION_PENDING if hub is busy with another
+ * load/unload transaction
+ * TRANSACTION_FAILED if load failed synchronously
+ *
+ */
+ loadNanoApp(uint32_t hubId, NanoAppBinary appBinary, uint32_t transactionId)
+ generates (Result result);
+
+ /**
+ * Unloads a nanoApp. Before the unload, the apps deinit method is called.
+ * After this, success must be indicated to the service through an
+ * asynchronous call to handleTxnResult.
+ *
+ * @param hubId identifer of the contextHub
+ * appId appIdentifier returned by the HAL
+ * msg message to be sent
+ *
+ * @return result OK if transation started
+ * BAD_VALUE if parameters are not sane
+ * TRANSACTION_PENDING if hub is busy with another
+ * load/unload transaction
+ * TRANSACTION_FAILED if unload failed synchronously
+ *
+ */
+ unloadNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
+ generates (Result result);
+
+ /**
+ * Enables a nanoApp. The app's init method is called.
+ * After this, success must be indicated to the service through an
+ * asynchronous message.
+ *
+ * @param hubId identifer of the contextHub
+ * appId appIdentifier returned by the HAL
+ * msg message to be sent
+ *
+ * @return result OK if transation started
+ * BAD_VALUE if parameters are not sane
+ * TRANSACTION_PENDING if hub is busy with another
+ * load/unload transaction
+ * FAILED_TRANSACTION if load fails immediately
+ *
+ */
+ enableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
+ generates (Result result);
+
+ /**
+ * Disables a nanoApp. The app's deinit method is called.
+ * After this, success must be indicated to the service through an
+ * asynchronous message.
+ *
+ * @param hubId identifer of the contextHub
+ * appId appIdentifier returned by the HAL
+ * msg message to be sent
+ *
+ * @return result OK if transation started
+ * BAD_VALUE if parameters are not sane
+ * TRANSACTION_PENDING if hub is busy with another
+ * load/unload transaction
+ * FAILED_TRANSACTION if load fails immediately
+ *
+ */
+ disableNanoApp(uint32_t hubId, uint64_t appId, uint32_t transactionId)
+ generates (Result result);
+
+ /**
+ * Queries for Loaded apps on the hub
+ *
+ * @param hubId identifer of the contextHub
+ *
+ * @return apps all nanoApps on the hub
+ *
+ */
+ queryApps(uint32_t hubId) generates (Result result);
+
+ /**
+ * Reboots context hub OS, restarts all the nanoApps.
+ * No reboot notification is sent to nanoApps; reboot happens immediately
+ * and unconditionally; all volatile contexthub state and any data is lost
+ * as a result.
+ *
+ * @param hubId identifer of the contextHub
+ *
+ * @return result OK on success
+ * BAD_VALUE if parameters are not sane
+ *
+ */
+ reboot(uint32_t hubId) generates (Result result);
+};
diff --git a/contexthub/1.0/IContexthubCallback.hal b/contexthub/1.0/IContexthubCallback.hal
new file mode 100644
index 0000000..29c41ce
--- /dev/null
+++ b/contexthub/1.0/IContexthubCallback.hal
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 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.contexthub@1.0;
+
+interface IContexthubCallback {
+ /*
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send asynchronous messages back
+ * to the service and registered clients of the ContextHub service.
+ *
+ * @params hubId : identifier of the hub calling callback
+ * msg : message
+ *
+ */
+ handleClientMsg(uint32_t hubId, ContextHubMsg msg);
+
+ /*
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send the response for a
+ * transaction.
+ *
+ * @params hubId : identifier of the hub calling callback
+ * txnId : transaction id whose result is being sent
+ * passed in by the service at start of transacation.
+ * result: result of transaction.
+ *
+ */
+ handleTxnResult(uint32_t hubId, uint32_t txnId,
+ TransactionResult result);
+
+ /*
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send an asynchronous event
+ * to the ContextHub service.
+ *
+ * @params hubId : identifier of the hub calling callback
+ * msg : message
+ *
+ */
+ handleHubEvent(uint32_t hubId, AsyncEventType evt);
+
+ /*
+ * This callback is passed by the Contexthub service to the HAL
+ * implementation to allow the HAL to send information about the
+ * currently loaded and active nanoapps on the hub.
+ */
+ handleAppsInfo(uint32_t hubId, vec<HubAppInfo> appInfo);
+};
diff --git a/contexthub/1.0/types.hal b/contexthub/1.0/types.hal
new file mode 100644
index 0000000..7d5a1ac
--- /dev/null
+++ b/contexthub/1.0/types.hal
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2016 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.contexthub@1.0;
+
+enum Result : uint32_t {
+ OK, // Success
+ BAD_PARAMS, // Parameters not sane
+ NOT_INIT, // not initialized
+ TRANSACTION_FAILED, // transaction failed
+ TRANSACTION_PENDING, // Pending transaction, cannot accept a new request
+};
+
+
+enum NanoAppFlags : uint32_t {
+ SIGNED = (1<<0), // Signed nanoapp
+ ENCRYPTED = (1<<1),// Encrypted nanoapp
+};
+
+struct NanoAppBinary {
+ uint32_t headerVersion; // 0x1 for this version
+ uint32_t magic; // "NANO"
+ uint64_t appId; // App Id contains vendor id
+ uint32_t appVersion; // Version of the app
+ uint32_t flags; // mask of NanoAppFlags
+ uint64_t hwHubType; // which hub type is this compiled for
+ // a unique UUID for each h/w + toolchain
+ // combination.
+ vec<uint8_t> customBinary; // start of custom binary data
+};
+
+enum SensorType : uint32_t {
+ RESERVED,
+ ACCELEROMETER,
+ GYROSCOPE,
+ MAGNETOMETER,
+ BAROMETER,
+ PROXIMITY_SENSOR,
+ AMBIENT_LIGHT_SENSOR,
+
+ GPS = 0x100,
+ // Reserving this space for variants on GPS
+
+ WIFI = 0x200,
+ // Reserving this space for variants on WIFI
+
+ AUDIO = 0x300,
+ // Reserving this space for variants on Audio
+
+ CAMERA = 0x400,
+ // Reserving this space for variants on Camera
+
+ BLE = 0x500,
+
+ PRIVATE_SENSOR_BASE = 0x10000,
+ // Sensor types beyond PRIVATE_SENSOR_BASE are custom types
+};
+
+struct PhysicalSensor{
+ SensorType sensorType; // From the definitions above eg: 100
+ string type; // Type as a string. eg: "GPS"
+ string name; // Identifier eg: "Bosch BMI160"
+ string vendor; // Vendor : eg "STM"
+ uint32_t version; // Version : eg 0x1001
+ uint32_t fifoReservedCount; // Batching possible in hardware. Please
+ // note that here hardware does not include
+ // the context hub itself. Thus, this
+ // definition may be different from say the
+ // number advertised in the sensors HAL
+ // which allows for batching in a hub.
+ uint32_t fifoMaxCount; // maximum number of batchable events.
+ uint64_t minDelayMs; // in milliseconds, corresponding to highest
+ // sampling freq.
+ uint64_t maxDelayMs; // in milliseconds, corresponds to minimum
+ // sampling frequency
+ float peakPowerMw; // At max frequency & no batching, power
+ // in milliwatts
+};
+
+struct ContextHub {
+ string name; // descriptive name eg: "Awesome Hub #1"
+ string vendor; // hub hardware vendor eg: "Qualcomm"
+ string toolchain; // toolchain to make binaries eg: "gcc ARM"
+ uint32_t platformVersion; // Version of the hardware : eg 0x20
+ uint32_t toolchainVersion; // Version of the toolchain : eg: 0x484
+ uint32_t hubId; // a device unique id for this hub
+
+ float peakMips; // Peak MIPS platform can deliver
+ float stoppedPowerDrawMw; // if stopped, retention power, milliwatts
+ float sleepPowerDrawMw; // if sleeping, retention power, milliwatts
+ float peakPowerDrawMw; // for a busy CPUm power in milliwatts
+
+ vec<PhysicalSensor> connectedSensors; // array of connected sensors
+
+ uint32_t maxSupportedMsgLen;// This is the maximum size of the message that can
+ // be sent to the hub in one chunk (in bytes)
+};
+
+struct ContextHubMsg {
+ uint64_t appName; // intended recipient
+ uint32_t msgType; // identifier for message
+ vec<uint8_t> msg; // message body
+};
+
+enum HubMemoryType : uint32_t {
+ MAIN = 0, // Main memory
+ SECONDARY = 1, // Secondary memory
+ TCM = 2, // Tightly coupled memory
+};
+
+enum HubMemoryFlag : uint32_t {
+ READ = (1<<0), // Readable
+ WRITE = (1<<1), // Writable
+ EXEC = (1<<2), // Executable
+};
+
+struct MemRange {
+ uint32_t totalBytes; // total capacity in bytes
+ uint32_t freeBytes; // free capacity in bytes
+ HubMemoryType type; // type of memory, see HubMemoryType
+ uint32_t flags; // mask of HubMemoryFlag
+};
+
+enum AsyncEventType : uint32_t {
+ RESTARTED = 1, // Hub restarted unexpectedly
+};
+
+enum TransactionResult {
+ SUCCESS, // successful completion of transaction
+ FAILURE, // failed transaction
+};
+
+struct HubAppInfo {
+ uint64_t appId; // Identifier of the app
+ uint32_t version; // version of the app
+ vec<MemRange> memUsage; // Memory used by this app
+};
+
diff --git a/contexthub/Android.bp b/contexthub/Android.bp
new file mode 100644
index 0000000..bbb3e4b
--- /dev/null
+++ b/contexthub/Android.bp
@@ -0,0 +1,4 @@
+// This is an autogenerated file, do not edit.
+subdirs = [
+ "1.0",
+]
diff --git a/memtrack/1.0/vts/Android.mk b/memtrack/1.0/vts/Android.mk
new file mode 100644
index 0000000..c0fe968
--- /dev/null
+++ b/memtrack/1.0/vts/Android.mk
@@ -0,0 +1,87 @@
+#
+# Copyright (C) 2016 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+# build VTS driver for memtrack v1.0.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libvts_driver_hidl_memtrack@1.0
+
+LOCAL_SRC_FILES := \
+ Memtrack.vts \
+ types.vts \
+
+LOCAL_C_INCLUDES := \
+ android.hardware.memtrack@1.0 \
+ system/core/base/include \
+ system/core/include \
+
+LOCAL_SHARED_LIBRARIES += \
+ android.hardware.memtrack@1.0 \
+ libbase \
+ libutils \
+ libcutils \
+ liblog \
+ libhidl \
+ libhwbinder \
+ libprotobuf-cpp-full \
+ libvts_common \
+ libvts_datatype \
+ libvts_measurement \
+ libvts_multidevice_proto \
+
+LOCAL_CFLAGS += -DENABLE_TREBLE
+
+LOCAL_STATIC_LIBRARIES := \
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := full
+
+LOCAL_MULTILIB := both
+
+include $(BUILD_SHARED_LIBRARY)
+
+# build profiler for memtrack.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libvts_profiler_hidl_memtrack@1.0
+
+LOCAL_SRC_FILES := \
+ Memtrack.vts \
+ types.vts \
+
+LOCAL_C_INCLUDES += \
+ test/vts/drivers/libprofiling \
+
+LOCAL_VTS_MODE := PROFILER
+
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.memtrack@1.0 \
+ libbase \
+ libcutils \
+ liblog \
+ libhidl \
+ libhwbinder \
+ libprotobuf-cpp-full \
+ libvts_common \
+ libvts_multidevice_proto \
+ libvts_profiling \
+ libutils \
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := full
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/memtrack/1.0/vts/Memtrack.vts b/memtrack/1.0/vts/Memtrack.vts
new file mode 100644
index 0000000..9fce2a0
--- /dev/null
+++ b/memtrack/1.0/vts/Memtrack.vts
@@ -0,0 +1,33 @@
+component_class: HAL_HIDL
+component_type_version: 1.0
+component_name: "IMemtrack"
+
+package: "android.hardware.memtrack"
+
+import: "android.hardware.memtrack@1.0::types"
+
+interface: {
+ api: {
+ name: "getMemory"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::memtrack::V1_0::MemtrackStatus"
+ }
+ return_type_hidl: {
+ type: TYPE_VECTOR
+ vector_value: {
+ type: TYPE_STRUCT
+ predefined_type: "::android::hardware::memtrack::V1_0::MemtrackRecord"
+ }
+ }
+ arg: {
+ type: TYPE_SCALAR
+ scalar_type: "int32_t"
+ }
+ arg: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::memtrack::V1_0::MemtrackType"
+ }
+ }
+
+}
diff --git a/memtrack/1.0/vts/types.vts b/memtrack/1.0/vts/types.vts
new file mode 100644
index 0000000..bec090f
--- /dev/null
+++ b/memtrack/1.0/vts/types.vts
@@ -0,0 +1,121 @@
+component_class: HAL_HIDL
+component_type_version: 1.0
+component_name: "types"
+
+package: "android.hardware.memtrack"
+
+
+attribute: {
+ name: "::android::hardware::memtrack::V1_0::MemtrackFlag"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "uint32_t"
+
+ enumerator: "SMAPS_ACCOUNTED"
+ scalar_value: {
+ uint32_t: 2
+ }
+ enumerator: "SMAPS_UNACCOUNTED"
+ scalar_value: {
+ uint32_t: 4
+ }
+ enumerator: "SHARED"
+ scalar_value: {
+ uint32_t: 8
+ }
+ enumerator: "SHARED_PSS"
+ scalar_value: {
+ uint32_t: 16
+ }
+ enumerator: "PRIVATE"
+ scalar_value: {
+ uint32_t: 32
+ }
+ enumerator: "SYSTEM"
+ scalar_value: {
+ uint32_t: 64
+ }
+ enumerator: "DEDICATED"
+ scalar_value: {
+ uint32_t: 128
+ }
+ enumerator: "NONSECURE"
+ scalar_value: {
+ uint32_t: 256
+ }
+ enumerator: "SECURE"
+ scalar_value: {
+ uint32_t: 512
+ }
+ }
+}
+
+attribute: {
+ name: "::android::hardware::memtrack::V1_0::MemtrackType"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "uint32_t"
+
+ enumerator: "OTHER"
+ scalar_value: {
+ uint32_t: 0
+ }
+ enumerator: "GL"
+ scalar_value: {
+ uint32_t: 1
+ }
+ enumerator: "GRAPHICS"
+ scalar_value: {
+ uint32_t: 2
+ }
+ enumerator: "MULTIMEDIA"
+ scalar_value: {
+ uint32_t: 3
+ }
+ enumerator: "CAMERA"
+ scalar_value: {
+ uint32_t: 4
+ }
+ enumerator: "NUM_TYPES"
+ scalar_value: {
+ uint32_t: 5
+ }
+ }
+}
+
+attribute: {
+ name: "::android::hardware::memtrack::V1_0::MemtrackStatus"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "uint32_t"
+
+ enumerator: "SUCCESS"
+ scalar_value: {
+ uint32_t: 0
+ }
+ enumerator: "MEMORY_TRACKING_NOT_SUPPORTED"
+ scalar_value: {
+ uint32_t: 1
+ }
+ enumerator: "TYPE_NOT_SUPPORTED"
+ scalar_value: {
+ uint32_t: 2
+ }
+ }
+}
+
+attribute: {
+ name: "::android::hardware::memtrack::V1_0::MemtrackRecord"
+ type: TYPE_STRUCT
+ struct_value: {
+ name: "sizeInBytes"
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ struct_value: {
+ name: "flags"
+ type: TYPE_SCALAR
+ scalar_type: "uint32_t"
+ }
+}
+
diff --git a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp
index 0d2180f..910413e 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp
+++ b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp
@@ -40,7 +40,7 @@
}
float updatedRate = std::max(oldOpts.sampleRate, newOpts.sampleRate);
- SubscribeFlags updatedFlags = oldOpts.flags | newOpts.flags;
+ SubscribeFlags updatedFlags = SubscribeFlags(oldOpts.flags | newOpts.flags);
bool updated = updatedRate > oldOpts.sampleRate
|| updatedAreas != oldOpts.vehicleAreas