Merge "NFC: vts: Update VTS driver files as per HAL changes"
diff --git a/audio/2.0/Android.bp b/audio/2.0/Android.bp
index 254c939..debed27 100644
--- a/audio/2.0/Android.bp
+++ b/audio/2.0/Android.bp
@@ -89,6 +89,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.audio.common@2.0",
diff --git a/audio/2.0/default/Android.mk b/audio/2.0/default/Android.mk
index 5108448..2b1aa4f 100644
--- a/audio/2.0/default/Android.mk
+++ b/audio/2.0/default/Android.mk
@@ -66,6 +66,7 @@
android.hardware.audio.common@2.0 \
android.hardware.audio.effect@2.0 \
android.hardware.soundtrigger@2.0 \
+ android.hardware.broadcastradio@1.0
ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
LOCAL_MULTILIB := 32
diff --git a/audio/2.0/default/Device.cpp b/audio/2.0/default/Device.cpp
index 05824c7..339f371 100644
--- a/audio/2.0/default/Device.cpp
+++ b/audio/2.0/default/Device.cpp
@@ -520,7 +520,7 @@
return setParametersImpl(parameters);
}
-Return<void> Device::debugDump(const native_handle_t* fd) {
+Return<void> Device::debugDump(const hidl_handle& fd) {
if (fd->numFds == 1) {
analyzeStatus("dump", mDevice->dump(mDevice, fd->data[0]));
}
diff --git a/audio/2.0/default/Device.h b/audio/2.0/default/Device.h
index d7b3128..3fd67e3 100644
--- a/audio/2.0/default/Device.h
+++ b/audio/2.0/default/Device.h
@@ -102,7 +102,7 @@
Return<void> getParameters(
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
- Return<void> debugDump(const native_handle_t* fd) override;
+ Return<void> debugDump(const hidl_handle& fd) override;
// Utility methods for extending interfaces.
Result analyzeStatus(const char* funcName, int status);
diff --git a/audio/2.0/default/PrimaryDevice.cpp b/audio/2.0/default/PrimaryDevice.cpp
index 9f5180c..a8aa5ec 100644
--- a/audio/2.0/default/PrimaryDevice.cpp
+++ b/audio/2.0/default/PrimaryDevice.cpp
@@ -119,7 +119,7 @@
return mDevice->setParameters(parameters);
}
-Return<void> PrimaryDevice::debugDump(const native_handle_t* fd) {
+Return<void> PrimaryDevice::debugDump(const hidl_handle& fd) {
return mDevice->debugDump(fd);
}
diff --git a/audio/2.0/default/PrimaryDevice.h b/audio/2.0/default/PrimaryDevice.h
index 4c5b590..968c208 100644
--- a/audio/2.0/default/PrimaryDevice.h
+++ b/audio/2.0/default/PrimaryDevice.h
@@ -88,7 +88,7 @@
Return<void> getParameters(
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
- Return<void> debugDump(const native_handle_t* fd) override;
+ Return<void> debugDump(const hidl_handle& fd) override;
// Methods from ::android::hardware::audio::V2_0::IPrimaryDevice follow.
Return<Result> setVoiceVolume(float volume) override;
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index 7616bec..6d68f55 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -222,7 +222,7 @@
return setParametersImpl(parameters);
}
-Return<void> Stream::debugDump(const native_handle_t* fd) {
+Return<void> Stream::debugDump(const hidl_handle& fd) {
if (fd->numFds == 1) {
analyzeStatus("dump", mStream->dump(mStream, fd->data[0]));
}
diff --git a/audio/2.0/default/Stream.h b/audio/2.0/default/Stream.h
index f28fbff..3893af4 100644
--- a/audio/2.0/default/Stream.h
+++ b/audio/2.0/default/Stream.h
@@ -70,7 +70,7 @@
Return<void> getParameters(
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
- Return<void> debugDump(const native_handle_t* fd) override;
+ Return<void> debugDump(const hidl_handle& fd) override;
// Utility methods for extending interfaces.
Result analyzeStatus(const char* funcName, int status);
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index b590d1a..791e519 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -126,7 +126,7 @@
return mStreamCommon->setParameters(parameters);
}
-Return<void> StreamIn::debugDump(const native_handle_t* fd) {
+Return<void> StreamIn::debugDump(const hidl_handle& fd) {
return mStreamCommon->debugDump(fd);
}
diff --git a/audio/2.0/default/StreamIn.h b/audio/2.0/default/StreamIn.h
index 83f620c..c2a7ea2 100644
--- a/audio/2.0/default/StreamIn.h
+++ b/audio/2.0/default/StreamIn.h
@@ -72,7 +72,7 @@
Return<void> getParameters(
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
- Return<void> debugDump(const native_handle_t* fd) override;
+ Return<void> debugDump(const hidl_handle& fd) override;
// Methods from ::android::hardware::audio::V2_0::IStreamIn follow.
Return<void> getAudioSource(getAudioSource_cb _hidl_cb) override;
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index 34bae29..2106256 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -128,7 +128,7 @@
return mStreamCommon->setParameters(parameters);
}
-Return<void> StreamOut::debugDump(const native_handle_t* fd) {
+Return<void> StreamOut::debugDump(const hidl_handle& fd) {
return mStreamCommon->debugDump(fd);
}
diff --git a/audio/2.0/default/StreamOut.h b/audio/2.0/default/StreamOut.h
index 51b7df8..ca33b2d 100644
--- a/audio/2.0/default/StreamOut.h
+++ b/audio/2.0/default/StreamOut.h
@@ -74,7 +74,7 @@
Return<void> getParameters(
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override;
Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override;
- Return<void> debugDump(const native_handle_t* fd) override;
+ Return<void> debugDump(const hidl_handle& fd) override;
// Methods from ::android::hardware::audio::V2_0::IStreamOut follow.
Return<uint32_t> getLatency() override;
diff --git a/audio/2.0/default/service.cpp b/audio/2.0/default/service.cpp
index 147f7b9..28ef660 100644
--- a/audio/2.0/default/service.cpp
+++ b/audio/2.0/default/service.cpp
@@ -20,6 +20,7 @@
#include <android/hardware/audio/2.0/IDevicesFactory.h>
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
+#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
@@ -27,10 +28,12 @@
using android::hardware::audio::V2_0::IDevicesFactory;
using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
using android::hardware::registerPassthroughServiceImplementation;
+using android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
int main(int /* argc */, char* /* argv */ []) {
registerPassthroughServiceImplementation<IDevicesFactory>("audio_devices_factory");
registerPassthroughServiceImplementation<IEffectsFactory>("audio_effects_factory");
registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
+ registerPassthroughServiceImplementation<IBroadcastRadioFactory>("broadcastradio");
return android::hardware::launchRpcServer(16);
}
diff --git a/audio/Android.mk b/audio/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/common/2.0/Android.bp b/audio/common/2.0/Android.bp
index c539c3c..88f7921 100644
--- a/audio/common/2.0/Android.bp
+++ b/audio/common/2.0/Android.bp
@@ -33,6 +33,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/audio/effect/2.0/Android.bp b/audio/effect/2.0/Android.bp
index 11ea604..9edbb2a 100644
--- a/audio/effect/2.0/Android.bp
+++ b/audio/effect/2.0/Android.bp
@@ -145,6 +145,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.audio.common@2.0",
diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp
index 30fcb26..2b5d70b 100644
--- a/audio/effect/2.0/default/EffectsFactory.cpp
+++ b/audio/effect/2.0/default/EffectsFactory.cpp
@@ -182,7 +182,7 @@
return Void();
}
-Return<void> EffectsFactory::debugDump(const native_handle_t* fd) {
+Return<void> EffectsFactory::debugDump(const hidl_handle& fd) {
if (fd->numFds == 1) {
EffectDumpEffects(fd->data[0]);
}
diff --git a/audio/effect/2.0/default/EffectsFactory.h b/audio/effect/2.0/default/EffectsFactory.h
index 229356f..d934c93 100644
--- a/audio/effect/2.0/default/EffectsFactory.h
+++ b/audio/effect/2.0/default/EffectsFactory.h
@@ -47,7 +47,7 @@
Return<void> getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override;
Return<void> createEffect(
const Uuid& uid, int32_t session, int32_t ioHandle, createEffect_cb _hidl_cb) override;
- Return<void> debugDump(const native_handle_t* fd) override;
+ Return<void> debugDump(const hidl_handle& fd) override;
private:
static sp<IEffect> dispatchEffectInstanceCreation(
diff --git a/audio/effect/2.0/vts/Android.mk b/audio/effect/2.0/vts/Android.mk
new file mode 100644
index 0000000..abdd5bf
--- /dev/null
+++ b/audio/effect/2.0/vts/Android.mk
@@ -0,0 +1,21 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/audio/effect/2.0/vts/functional/Android.mk b/audio/effect/2.0/vts/functional/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/Android.mk b/audio/effect/2.0/vts/functional/vts/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/Android.mk b/audio/effect/2.0/vts/functional/vts/testcases/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/hal/Android.mk b/audio/effect/2.0/vts/functional/vts/testcases/hal/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/hal/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/Android.mk b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/Android.mk b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/Android.mk b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/target/Android.mk b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/target/Android.mk
new file mode 100644
index 0000000..fe5ea0f
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/target/Android.mk
@@ -0,0 +1,25 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := HalAudioEffectHidlTargetBasicTest
+VTS_CONFIG_SRC_DIR := testcases/hal/audio/effect/hidl/target
+include test/vts/tools/build/Android.host_config.mk
diff --git a/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/target/AndroidTest.xml b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/target/AndroidTest.xml
new file mode 100644
index 0000000..f0af67a
--- /dev/null
+++ b/audio/effect/2.0/vts/functional/vts/testcases/hal/audio/effect/hidl/target/AndroidTest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS Audio Effect HIDL HAL's basic target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="HalAudioEffectHidlTargetBasicTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/audio_effect_hidl_hal_test/audio_effect_hidl_hal_test,
+ _64bit::DATA/nativetest64/audio_effect_hidl_hal_test/audio_effect_hidl_hal_test,
+ "/>
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
diff --git a/audio/effect/Android.mk b/audio/effect/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/audio/effect/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/benchmarks/msgq/1.0/Android.bp b/benchmarks/msgq/1.0/Android.bp
index 06ec3da..146227b 100644
--- a/benchmarks/msgq/1.0/Android.bp
+++ b/benchmarks/msgq/1.0/Android.bp
@@ -37,6 +37,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/biometrics/fingerprint/2.1/Android.bp b/biometrics/fingerprint/2.1/Android.bp
index cea7200..9ddcd2a 100644
--- a/biometrics/fingerprint/2.1/Android.bp
+++ b/biometrics/fingerprint/2.1/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
index 67417fb..c7ccaaf 100644
--- a/bluetooth/1.0/Android.bp
+++ b/bluetooth/1.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/boot/1.0/Android.bp b/boot/1.0/Android.bp
index 835d358..501542b 100644
--- a/boot/1.0/Android.bp
+++ b/boot/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/boot/1.0/default/BootControl.h b/boot/1.0/default/BootControl.h
index 73af4f4..be8a814 100644
--- a/boot/1.0/default/BootControl.h
+++ b/boot/1.0/default/BootControl.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_
-#define HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_
+#ifndef ANDROID_HARDWARE_BOOT_V1_0_BOOTCONTROL_H
+#define ANDROID_HARDWARE_BOOT_V1_0_BOOTCONTROL_H
#include <android/hardware/boot/1.0/IBootControl.h>
#include <hidl/Status.h>
@@ -43,4 +43,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_boot_V1_0_BootControl_H_
+#endif // ANDROID_HARDWARE_BOOT_V1_0_BOOTCONTROL_H
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
index a876ac2..1b40acf 100644
--- a/broadcastradio/1.0/Android.bp
+++ b/broadcastradio/1.0/Android.bp
@@ -65,6 +65,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/broadcastradio/1.0/ITunerCallback.hal b/broadcastradio/1.0/ITunerCallback.hal
index f805472..a7e1260 100644
--- a/broadcastradio/1.0/ITunerCallback.hal
+++ b/broadcastradio/1.0/ITunerCallback.hal
@@ -72,7 +72,9 @@
/*
* Method called by the HAL when metadata for current station
* are updated.
- * @param metadatas A list of all updated metada.
+ * @param channel The channel the metadata is associated with.
+ * @param subChannel The sub channel the metadata is associated with.
+ * @param metadata A list of all updated metada.
*/
- oneway newMetadata(vec<MetaData> metadatas);
+ oneway newMetadata(uint32_t channel, uint32_t subChannel, vec<MetaData> metadata);
};
\ No newline at end of file
diff --git a/broadcastradio/1.0/default/Android.mk b/broadcastradio/1.0/default/Android.mk
new file mode 100644
index 0000000..734a0e1
--- /dev/null
+++ b/broadcastradio/1.0/default/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.broadcastradio@1.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+ BroadcastRadio.cpp \
+ BroadcastRadioFactory.cpp \
+ Tuner.cpp \
+ Utils.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ libutils \
+ liblog \
+ libhardware \
+ android.hardware.broadcastradio@1.0 \
+ libradio_metadata
+
+ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
+LOCAL_MULTILIB := 32
+else
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/broadcastradio/1.0/default/BroadcastRadio.cpp b/broadcastradio/1.0/default/BroadcastRadio.cpp
new file mode 100644
index 0000000..b97b609
--- /dev/null
+++ b/broadcastradio/1.0/default/BroadcastRadio.cpp
@@ -0,0 +1,141 @@
+/*
+ * 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 "BroadcastRadio"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <hardware/radio.h>
+
+#include "BroadcastRadio.h"
+#include "Tuner.h"
+#include "Utils.h"
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+BroadcastRadio::BroadcastRadio(Class classId)
+ : mStatus(Result::NOT_INITIALIZED), mClassId(classId), mHwDevice(NULL)
+{
+}
+
+BroadcastRadio::~BroadcastRadio()
+{
+ if (mHwDevice != NULL) {
+ radio_hw_device_close(mHwDevice);
+ }
+}
+
+void BroadcastRadio::onFirstRef()
+{
+ const hw_module_t *mod;
+ int rc;
+ ALOGI("%s mClassId %d", __FUNCTION__, mClassId);
+
+ mHwDevice = NULL;
+ const char *classString = Utils::getClassString(mClassId);
+ if (classString == NULL) {
+ ALOGE("invalid class ID %d", mClassId);
+ mStatus = Result::INVALID_ARGUMENTS;
+ return;
+ }
+
+ ALOGI("%s RADIO_HARDWARE_MODULE_ID %s %s",
+ __FUNCTION__, RADIO_HARDWARE_MODULE_ID, classString);
+
+ rc = hw_get_module_by_class(RADIO_HARDWARE_MODULE_ID, classString, &mod);
+ if (rc != 0) {
+ ALOGE("couldn't load radio module %s.%s (%s)",
+ RADIO_HARDWARE_MODULE_ID, classString, strerror(-rc));
+ return;
+ }
+ rc = radio_hw_device_open(mod, &mHwDevice);
+ if (rc != 0) {
+ ALOGE("couldn't open radio hw device in %s.%s (%s)",
+ RADIO_HARDWARE_MODULE_ID, "primary", strerror(-rc));
+ mHwDevice = NULL;
+ return;
+ }
+ if (mHwDevice->common.version != RADIO_DEVICE_API_VERSION_CURRENT) {
+ ALOGE("wrong radio hw device version %04x", mHwDevice->common.version);
+ radio_hw_device_close(mHwDevice);
+ mHwDevice = NULL;
+ } else {
+ mStatus = Result::OK;
+ }
+}
+
+int BroadcastRadio::closeHalTuner(const struct radio_tuner *halTuner)
+{
+ ALOGV("%s", __FUNCTION__);
+ if (mHwDevice == NULL) {
+ return -ENODEV;
+ }
+ if (halTuner == 0) {
+ return -EINVAL;
+ }
+ return mHwDevice->close_tuner(mHwDevice, halTuner);
+}
+
+
+// Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadio follow.
+Return<void> BroadcastRadio::getProperties(getProperties_cb _hidl_cb)
+{
+ int rc;
+ radio_hal_properties_t halProperties;
+ Properties properties;
+
+ if (mHwDevice == NULL) {
+ rc = -ENODEV;
+ goto exit;
+ }
+ rc = mHwDevice->get_properties(mHwDevice, &halProperties);
+ if (rc == 0) {
+ Utils::convertPropertiesFromHal(&properties, &halProperties);
+ }
+
+exit:
+ _hidl_cb(Utils::convertHalResult(rc), properties);
+ return Void();
+}
+
+Return<void> BroadcastRadio::openTuner(const BandConfig& config, bool audio,
+ const sp<ITunerCallback>& callback, openTuner_cb _hidl_cb)
+{
+ sp<Tuner> tunerImpl = new Tuner(callback, this);
+
+ radio_hal_band_config_t halConfig;
+ const struct radio_tuner *halTuner;
+ Utils::convertBandConfigToHal(&halConfig, &config);
+ int rc = mHwDevice->open_tuner(mHwDevice, &halConfig, audio,
+ Tuner::callback, tunerImpl.get(),
+ &halTuner);
+ if (rc == 0) {
+ tunerImpl->setHalTuner(halTuner);
+ }
+
+ _hidl_cb(Utils::convertHalResult(rc), tunerImpl);
+ return Void();
+}
+
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
diff --git a/broadcastradio/1.0/default/BroadcastRadio.h b/broadcastradio/1.0/default/BroadcastRadio.h
new file mode 100644
index 0000000..dbd6e07
--- /dev/null
+++ b/broadcastradio/1.0/default/BroadcastRadio.h
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+#ifndef HIDL_GENERATED_android_hardware_broadcastradio_V1_0_BroadcastRadio_H_
+#define HIDL_GENERATED_android_hardware_broadcastradio_V1_0_BroadcastRadio_H_
+
+#include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
+#include <hidl/Status.h>
+#include <hardware/radio.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+struct BroadcastRadio : public IBroadcastRadio {
+
+ BroadcastRadio(Class classId);
+
+ // Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadio follow.
+ Return<void> getProperties(getProperties_cb _hidl_cb) override;
+ Return<void> openTuner(const BandConfig& config, bool audio,
+ const sp<ITunerCallback>& callback,
+ openTuner_cb _hidl_cb) override;
+
+
+ // RefBase
+ virtual void onFirstRef();
+
+ Result initCheck() { return mStatus; }
+ int closeHalTuner(const struct radio_tuner *halTuner);
+
+private:
+ virtual ~BroadcastRadio();
+
+ static const char * sClassModuleNames[];
+
+ Result convertHalResult(int rc);
+ void convertBandConfigFromHal(BandConfig *config,
+ const radio_hal_band_config_t *halConfig);
+ void convertPropertiesFromHal(Properties *properties,
+ const radio_hal_properties_t *halProperties);
+ void convertBandConfigToHal(radio_hal_band_config_t *halConfig,
+ const BandConfig *config);
+
+ Result mStatus;
+ Class mClassId;
+ struct radio_hw_device *mHwDevice;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_GENERATED_android_hardware_broadcastradio_V1_0_BroadcastRadio_H_
diff --git a/broadcastradio/1.0/default/BroadcastRadioFactory.cpp b/broadcastradio/1.0/default/BroadcastRadioFactory.cpp
new file mode 100644
index 0000000..d5d214c
--- /dev/null
+++ b/broadcastradio/1.0/default/BroadcastRadioFactory.cpp
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+#include "BroadcastRadioFactory.h"
+#include "BroadcastRadio.h"
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory follow.
+Return<void> BroadcastRadioFactory::connectModule(Class classId, connectModule_cb _hidl_cb) {
+ sp<BroadcastRadio> impl = new BroadcastRadio(classId);
+ Result retval = Result::NOT_INITIALIZED;
+ if (impl != 0) {
+ retval = impl->initCheck();
+ }
+ _hidl_cb(retval, impl);
+ return Void();
+}
+
+
+IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* /* name */) {
+ return new BroadcastRadioFactory();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
diff --git a/broadcastradio/1.0/default/BroadcastRadioFactory.h b/broadcastradio/1.0/default/BroadcastRadioFactory.h
new file mode 100644
index 0000000..9b2ca17
--- /dev/null
+++ b/broadcastradio/1.0/default/BroadcastRadioFactory.h
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+#ifndef HIDL_GENERATED_android_hardware_broadcastradio_V1_0_BroadcastRadioFactory_H_
+#define HIDL_GENERATED_android_hardware_broadcastradio_V1_0_BroadcastRadioFactory_H_
+
+#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+struct BroadcastRadioFactory : public IBroadcastRadioFactory {
+ // Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory follow.
+ Return<void> connectModule(Class classId, connectModule_cb _hidl_cb) override;
+
+};
+
+extern "C" IBroadcastRadioFactory* HIDL_FETCH_IBroadcastRadioFactory(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_GENERATED_android_hardware_broadcastradio_V1_0_BroadcastRadioFactory_H_
diff --git a/broadcastradio/1.0/default/Tuner.cpp b/broadcastradio/1.0/default/Tuner.cpp
new file mode 100644
index 0000000..0c1d8ab
--- /dev/null
+++ b/broadcastradio/1.0/default/Tuner.cpp
@@ -0,0 +1,199 @@
+/*
+ * 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 "Tuner"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+
+#include "BroadcastRadio.h"
+#include "Tuner.h"
+#include "Utils.h"
+#include <system/radio_metadata.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+void Tuner::onCallback(radio_hal_event_t *halEvent)
+{
+ BandConfig config;
+ ProgramInfo info;
+ hidl_vec<MetaData> metadata;
+
+ if (mCallback != 0) {
+ switch(halEvent->type) {
+ case RADIO_EVENT_CONFIG:
+ Utils::convertBandConfigFromHal(&config, &halEvent->config);
+ mCallback->configChange(Utils::convertHalResult(halEvent->status), config);
+ break;
+ case RADIO_EVENT_ANTENNA:
+ mCallback->antennaStateChange(halEvent->on);
+ break;
+ case RADIO_EVENT_TUNED:
+ Utils::convertProgramInfoFromHal(&info, &halEvent->info, true);
+ mCallback->tuneComplete(Utils::convertHalResult(halEvent->status), info);
+ break;
+ case RADIO_EVENT_METADATA: {
+ uint32_t channel;
+ uint32_t sub_channel;
+ if (radio_metadata_get_channel(halEvent->metadata, &channel, &sub_channel) == 0) {
+ Utils::convertMetaDataFromHal(metadata, halEvent->metadata);
+ mCallback->newMetadata(channel, sub_channel, metadata);
+ }
+ } break;
+ case RADIO_EVENT_TA:
+ mCallback->trafficAnnouncement(halEvent->on);
+ break;
+ case RADIO_EVENT_AF_SWITCH:
+ Utils::convertProgramInfoFromHal(&info, &halEvent->info, true);
+ mCallback->afSwitch(info);
+ break;
+ case RADIO_EVENT_EA:
+ mCallback->emergencyAnnouncement(halEvent->on);
+ break;
+ case RADIO_EVENT_HW_FAILURE:
+ default:
+ mCallback->hardwareFailure();
+ break;
+ }
+ }
+}
+
+//static
+void Tuner::callback(radio_hal_event_t *halEvent, void *cookie)
+{
+ wp<Tuner> weak(reinterpret_cast<Tuner*>(cookie));
+ sp<Tuner> tuner = weak.promote();
+ if (tuner == 0) return;
+ tuner->onCallback(halEvent);
+}
+
+Tuner::Tuner(const sp<ITunerCallback>& callback, const wp<BroadcastRadio>& parentDevice)
+ : mHalTuner(NULL), mCallback(callback), mParentDevice(parentDevice)
+{
+ ALOGV("%s", __FUNCTION__);
+}
+
+
+Tuner::~Tuner()
+{
+ ALOGV("%s", __FUNCTION__);
+ const sp<BroadcastRadio> parentDevice = mParentDevice.promote();
+ if (parentDevice != 0) {
+ parentDevice->closeHalTuner(mHalTuner);
+ }
+}
+
+// Methods from ::android::hardware::broadcastradio::V1_0::ITuner follow.
+Return<Result> Tuner::setConfiguration(const BandConfig& config) {
+ ALOGV("%s", __FUNCTION__);
+ if (mHalTuner == NULL) {
+ return Utils::convertHalResult(-ENODEV);
+ }
+ radio_hal_band_config_t halConfig;
+ Utils::convertBandConfigToHal(&halConfig, &config);
+ int rc = mHalTuner->set_configuration(mHalTuner, &halConfig);
+ return Utils::convertHalResult(rc);
+}
+
+Return<void> Tuner::getConfiguration(getConfiguration_cb _hidl_cb) {
+ int rc;
+ radio_hal_band_config_t halConfig;
+ BandConfig config;
+
+ ALOGV("%s", __FUNCTION__);
+ if (mHalTuner == NULL) {
+ rc = -ENODEV;
+ goto exit;
+ }
+ rc = mHalTuner->get_configuration(mHalTuner, &halConfig);
+ if (rc == 0) {
+ Utils::convertBandConfigFromHal(&config, &halConfig);
+ }
+
+exit:
+ _hidl_cb(Utils::convertHalResult(rc), config);
+ return Void();
+}
+
+Return<Result> Tuner::scan(Direction direction, bool skipSubChannel) {
+ if (mHalTuner == NULL) {
+ return Utils::convertHalResult(-ENODEV);
+ }
+ int rc = mHalTuner->scan(mHalTuner, static_cast<radio_direction_t>(direction), skipSubChannel);
+ return Utils::convertHalResult(rc);
+}
+
+Return<Result> Tuner::step(Direction direction, bool skipSubChannel) {
+ if (mHalTuner == NULL) {
+ return Utils::convertHalResult(-ENODEV);
+ }
+ int rc = mHalTuner->step(mHalTuner, static_cast<radio_direction_t>(direction), skipSubChannel);
+ return Utils::convertHalResult(rc);
+}
+
+Return<Result> Tuner::tune(uint32_t channel, uint32_t subChannel) {
+ if (mHalTuner == NULL) {
+ return Utils::convertHalResult(-ENODEV);
+ }
+ int rc = mHalTuner->tune(mHalTuner, channel, subChannel);
+ return Utils::convertHalResult(rc);
+}
+
+Return<Result> Tuner::cancel() {
+ if (mHalTuner == NULL) {
+ return Utils::convertHalResult(-ENODEV);
+ }
+ int rc = mHalTuner->cancel(mHalTuner);
+ return Utils::convertHalResult(rc);
+}
+
+Return<void> Tuner::getProgramInformation(bool withMetadata, getProgramInformation_cb _hidl_cb) {
+ int rc;
+ radio_program_info_t halInfo;
+ ProgramInfo info;
+
+ ALOGV("%s", __FUNCTION__);
+ if (mHalTuner == NULL) {
+ rc = -ENODEV;
+ goto exit;
+ }
+ if (withMetadata) {
+ radio_metadata_allocate(&halInfo.metadata, 0, 0);
+ } else {
+ halInfo.metadata = NULL;
+ }
+ rc = mHalTuner->get_program_information(mHalTuner, &halInfo);
+ if (rc == 0) {
+ Utils::convertProgramInfoFromHal(&info, &halInfo, withMetadata);
+ }
+ if (withMetadata) {
+ radio_metadata_deallocate(halInfo.metadata);
+ }
+
+exit:
+ _hidl_cb(Utils::convertHalResult(rc), info);
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
diff --git a/broadcastradio/1.0/default/Tuner.h b/broadcastradio/1.0/default/Tuner.h
new file mode 100644
index 0000000..94e216e
--- /dev/null
+++ b/broadcastradio/1.0/default/Tuner.h
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+#ifndef HIDL_GENERATED_android_hardware_broadcastradio_V1_0_Tuner_H_
+#define HIDL_GENERATED_android_hardware_broadcastradio_V1_0_Tuner_H_
+
+#include <android/hardware/broadcastradio/1.0/ITuner.h>
+#include <android/hardware/broadcastradio/1.0/ITunerCallback.h>
+#include <hidl/Status.h>
+#include <hardware/radio.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+struct BroadcastRadio;
+
+struct Tuner : public ITuner {
+
+ Tuner(const sp<ITunerCallback>& callback, const wp<BroadcastRadio>& mParentDevice);
+
+ // Methods from ::android::hardware::broadcastradio::V1_0::ITuner follow.
+ Return<Result> setConfiguration(const BandConfig& config) override;
+ Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
+ Return<Result> scan(Direction direction, bool skipSubChannel) override;
+ Return<Result> step(Direction direction, bool skipSubChannel) override;
+ Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
+ Return<Result> cancel() override;
+ Return<void> getProgramInformation(bool withMetadata,
+ getProgramInformation_cb _hidl_cb) override;
+
+ static void callback(radio_hal_event_t *halEvent, void *cookie);
+ void onCallback(radio_hal_event_t *halEvent);
+
+ void setHalTuner(const struct radio_tuner *halTuner) { mHalTuner = halTuner; }
+ const struct radio_tuner *getHalTuner() { return mHalTuner; }
+
+ private:
+ ~Tuner();
+
+ const struct radio_tuner *mHalTuner;
+ const sp<ITunerCallback> mCallback;
+ const wp<BroadcastRadio> mParentDevice;
+};
+
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_GENERATED_android_hardware_broadcastradio_V1_0_Tuner_H_
diff --git a/broadcastradio/1.0/default/Utils.cpp b/broadcastradio/1.0/default/Utils.cpp
new file mode 100644
index 0000000..bdaae00
--- /dev/null
+++ b/broadcastradio/1.0/default/Utils.cpp
@@ -0,0 +1,297 @@
+/*
+ * 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 "BroadcastRadioHalUtils"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/misc.h>
+#include <system/radio_metadata.h>
+
+#include "Utils.h"
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+const char *Utils::sClassModuleNames[] = {
+ RADIO_HARDWARE_MODULE_ID_FM, /* corresponds to RADIO_CLASS_AM_FM */
+ RADIO_HARDWARE_MODULE_ID_SAT, /* corresponds to RADIO_CLASS_SAT */
+ RADIO_HARDWARE_MODULE_ID_DT, /* corresponds to RADIO_CLASS_DT */
+};
+
+// make sure HIDL enum values are aligned with legacy values
+static_assert(RADIO_CLASS_AM_FM == static_cast<int>(Class::AM_FM),
+ "AM/FM class mismatch with legacy");
+static_assert(RADIO_CLASS_SAT == static_cast<int>(Class::SAT),
+ "SAT class mismatch with legacy");
+static_assert(RADIO_CLASS_DT == static_cast<int>(Class::DT),
+ "DT class mismatch with legacy");
+
+static_assert(RADIO_BAND_AM == static_cast<int>(Band::AM),
+ "AM band mismatch with legacy");
+static_assert(RADIO_BAND_FM == static_cast<int>(Band::FM),
+ "FM band mismatch with legacy");
+static_assert(RADIO_BAND_AM_HD == static_cast<int>(Band::AM_HD),
+ "AM HD band mismatch with legacy");
+static_assert(RADIO_BAND_FM_HD == static_cast<int>(Band::FM_HD),
+ "FM HD band mismatch with legacy");
+
+static_assert(RADIO_RDS_NONE == static_cast<int>(Rds::NONE),
+ "RDS NONE mismatch with legacy");
+static_assert(RADIO_RDS_WORLD == static_cast<int>(Rds::WORLD),
+ "RDS WORLD mismatch with legacy");
+static_assert(RADIO_RDS_US == static_cast<int>(Rds::US),
+ "RDS US mismatch with legacy");
+
+static_assert(RADIO_DEEMPHASIS_50 == static_cast<int>(Deemphasis::D50),
+ "De-emphasis 50 mismatch with legacy");
+static_assert(RADIO_DEEMPHASIS_75 == static_cast<int>(Deemphasis::D75),
+ "De-emphasis 75 mismatch with legacy");
+
+static_assert(RADIO_DIRECTION_UP == static_cast<int>(Direction::UP),
+ "Direction Up mismatch with legacy");
+static_assert(RADIO_DIRECTION_DOWN == static_cast<int>(Direction::DOWN),
+ "Direction Up mismatch with legacy");
+
+static_assert(RADIO_METADATA_TYPE_INVALID == static_cast<int>(MetadataType::INVALID),
+ "Metadata type INVALID mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_INT == static_cast<int>(MetadataType::INT),
+ "Metadata type INT mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_TEXT == static_cast<int>(MetadataType::TEXT),
+ "Metadata type TEXT mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_RAW == static_cast<int>(MetadataType::RAW),
+ "Metadata type RAW mismatch with legacy");
+static_assert(RADIO_METADATA_TYPE_CLOCK == static_cast<int>(MetadataType::CLOCK),
+ "Metadata type CLOCK mismatch with legacy");
+
+static_assert(RADIO_METADATA_KEY_INVALID == static_cast<int>(MetadataKey::INVALID),
+ "Metadata key INVALID mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_PI == static_cast<int>(MetadataKey::RDS_PI),
+ "Metadata key RDS_PI mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_PS == static_cast<int>(MetadataKey::RDS_PS),
+ "Metadata key RDS_PS mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_PTY == static_cast<int>(MetadataKey::RDS_PTY),
+ "Metadata key RDS_PTY mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RBDS_PTY == static_cast<int>(MetadataKey::RBDS_PTY),
+ "Metadata key RBDS_PTY mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_RDS_RT == static_cast<int>(MetadataKey::RDS_RT),
+ "Metadata key RDS_RT mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_TITLE == static_cast<int>(MetadataKey::TITLE),
+ "Metadata key TITLE mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ARTIST == static_cast<int>(MetadataKey::ARTIST),
+ "Metadata key ARTIST mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ALBUM == static_cast<int>(MetadataKey::ALBUM),
+ "Metadata key ALBUM mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_GENRE == static_cast<int>(MetadataKey::GENRE),
+ "Metadata key GENRE mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ICON == static_cast<int>(MetadataKey::ICON),
+ "Metadata key ICON mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_ART == static_cast<int>(MetadataKey::ART),
+ "Metadata key ART mismatch with legacy");
+static_assert(RADIO_METADATA_KEY_CLOCK == static_cast<int>(MetadataKey::CLOCK),
+ "Metadata key CLOCK mismatch with legacy");
+
+
+//static
+const char * Utils::getClassString(Class ClassId)
+{
+ int id = static_cast<int>(ClassId);
+
+ if ((id < 0) ||
+ (id >= NELEM(sClassModuleNames))) {
+ ALOGE("invalid class ID %d", id);
+ return NULL;
+ }
+ return sClassModuleNames[id];
+}
+
+//static
+Result Utils::convertHalResult(int rc)
+{
+ switch (rc) {
+ case 0:
+ return Result::OK;
+ case -EINVAL:
+ return Result::INVALID_ARGUMENTS;
+ case -ENOSYS:
+ return Result::INVALID_STATE;
+ case -ETIMEDOUT:
+ return Result::TIMEOUT;
+ case -ENODEV:
+ default:
+ return Result::NOT_INITIALIZED;
+ }
+}
+
+//static
+void Utils::convertBandConfigFromHal(
+ BandConfig *config,
+ const radio_hal_band_config_t *halConfig)
+{
+
+ config->type = static_cast<Band>(halConfig->type);
+ config->antennaConnected = halConfig->antenna_connected;
+ config->lowerLimit = halConfig->lower_limit;
+ config->upperLimit = halConfig->upper_limit;
+ config->spacings.setToExternal(const_cast<unsigned int *>(&halConfig->spacings[0]),
+ halConfig->num_spacings * sizeof(uint32_t));
+ // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+ config->spacings.resize(halConfig->num_spacings);
+
+ if (config->type == Band::FM) {
+ config->ext.fm.deemphasis = static_cast<Deemphasis>(halConfig->fm.deemphasis);
+ config->ext.fm.stereo = halConfig->fm.stereo;
+ config->ext.fm.rds = static_cast<Rds>(halConfig->fm.rds);
+ config->ext.fm.ta = halConfig->fm.ta;
+ config->ext.fm.af = halConfig->fm.af;
+ config->ext.fm.ea = halConfig->fm.ea;
+ } else {
+ config->ext.am.stereo = halConfig->am.stereo;
+ }
+}
+
+//static
+void Utils::convertPropertiesFromHal(
+ Properties *properties,
+ const radio_hal_properties_t *halProperties)
+{
+ properties->classId = static_cast<Class>(halProperties->class_id);
+ properties->implementor.setToExternal(halProperties->implementor, strlen(halProperties->implementor));
+ properties->product.setToExternal(halProperties->product, strlen(halProperties->product));
+ properties->version.setToExternal(halProperties->version, strlen(halProperties->version));
+ properties->serial.setToExternal(halProperties->serial, strlen(halProperties->serial));
+ properties->numTuners = halProperties->num_tuners;
+ properties->numAudioSources = halProperties->num_audio_sources;
+ properties->supportsCapture = halProperties->supports_capture;
+
+ BandConfig *bands =
+ new BandConfig[halProperties->num_bands];
+ for (size_t i = 0; i < halProperties->num_bands; i++) {
+ convertBandConfigFromHal(&bands[i], &halProperties->bands[i]);
+ }
+ properties->bands.setToExternal(bands, halProperties->num_bands);
+ // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+ properties->bands.resize(halProperties->num_bands);
+ delete[] bands;
+}
+
+//static
+void Utils::convertBandConfigToHal(
+ radio_hal_band_config_t *halConfig,
+ const BandConfig *config)
+{
+
+ halConfig->type = static_cast<radio_band_t>(config->type);
+ halConfig->antenna_connected = config->antennaConnected;
+ halConfig->lower_limit = config->lowerLimit;
+ halConfig->upper_limit = config->upperLimit;
+ halConfig->num_spacings = config->spacings.size();
+ if (halConfig->num_spacings > RADIO_NUM_SPACINGS_MAX) {
+ halConfig->num_spacings = RADIO_NUM_SPACINGS_MAX;
+ }
+ memcpy(halConfig->spacings, config->spacings.data(),
+ sizeof(uint32_t) * halConfig->num_spacings);
+
+ if (config->type == Band::FM) {
+ halConfig->fm.deemphasis = static_cast<radio_deemphasis_t>(config->ext.fm.deemphasis);
+ halConfig->fm.stereo = config->ext.fm.stereo;
+ halConfig->fm.rds = static_cast<radio_rds_t>(config->ext.fm.rds);
+ halConfig->fm.ta = config->ext.fm.ta;
+ halConfig->fm.af = config->ext.fm.af;
+ halConfig->fm.ea = config->ext.fm.ea;
+ } else {
+ halConfig->am.stereo = config->ext.am.stereo;
+ }
+}
+
+
+//static
+void Utils::convertProgramInfoFromHal(ProgramInfo *info,
+ radio_program_info_t *halInfo,
+ bool withMetadata)
+{
+ info->channel = halInfo->channel;
+ info->subChannel = halInfo->sub_channel;
+ info->tuned = halInfo->tuned;
+ info->stereo = halInfo->stereo;
+ info->digital = halInfo->digital;
+ info->signalStrength = halInfo->signal_strength;
+ if (withMetadata && halInfo->metadata != NULL) {
+ convertMetaDataFromHal(info->metadata, halInfo->metadata);
+ }
+}
+
+//static
+int Utils::convertMetaDataFromHal(hidl_vec<MetaData>& metadata,
+ radio_metadata_t *halMetadata)
+{
+ if (halMetadata == NULL) {
+ return 0;
+ }
+
+ int count = radio_metadata_get_count(halMetadata);
+ if (count <= 0) {
+ return count;
+ }
+ MetaData *newMetadata =
+ new MetaData[count];
+ int outCount = 0;
+ for (int i = 0; i < count; i++) {
+ radio_metadata_key_t key;
+ radio_metadata_type_t type;
+ void *value;
+ size_t size;
+ if (radio_metadata_get_at_index(halMetadata, i , &key, &type, &value, &size) != 0 ||
+ size == 0) {
+ continue;
+ }
+ switch (type) {
+ case RADIO_METADATA_TYPE_INT: {
+ newMetadata[outCount].intValue = *(static_cast<int32_t *>(value));
+ } break;
+ case RADIO_METADATA_TYPE_TEXT: {
+ newMetadata[outCount].stringValue = static_cast<char *>(value);
+ } break;
+ case RADIO_METADATA_TYPE_RAW: {
+ newMetadata[outCount].rawValue.setToExternal(static_cast<uint8_t *>(value), size);
+ // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+ newMetadata[outCount].rawValue.resize(size);
+ } break;
+ case RADIO_METADATA_TYPE_CLOCK: {
+ radio_metadata_clock_t *clock = static_cast<radio_metadata_clock_t *>(value);
+ newMetadata[outCount].clockValue.utcSecondsSinceEpoch =
+ clock->utc_seconds_since_epoch;
+ newMetadata[outCount].clockValue.timezoneOffsetInMinutes =
+ clock->timezone_offset_in_minutes;
+ } break;
+ }
+ newMetadata[outCount].type = static_cast<MetadataType>(type);
+ newMetadata[outCount].key = static_cast<MetadataKey>(key);
+ outCount++;
+ }
+ metadata.setToExternal(newMetadata, outCount);
+ // FIXME: transfer buffer ownership. should have a method for that in hidl_vec
+ metadata.resize(outCount);
+ return outCount;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
diff --git a/broadcastradio/1.0/default/Utils.h b/broadcastradio/1.0/default/Utils.h
new file mode 100644
index 0000000..25eb6ee
--- /dev/null
+++ b/broadcastradio/1.0/default/Utils.h
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_0_UTILS_H
+#define ANDROID_HARDWARE_BROADCASTRADIO_V1_0_UTILS_H
+
+#include <android/hardware/broadcastradio/1.0/types.h>
+#include <hardware/radio.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+namespace implementation {
+
+class Utils {
+public:
+ static const char * getClassString(Class ClassId);
+ static Result convertHalResult(int rc);
+ static void convertBandConfigFromHal(BandConfig *config,
+ const radio_hal_band_config_t *halConfig);
+ static void convertPropertiesFromHal(Properties *properties,
+ const radio_hal_properties_t *halProperties);
+ static void convertBandConfigToHal(radio_hal_band_config_t *halConfig,
+ const BandConfig *config);
+ static void convertProgramInfoFromHal(ProgramInfo *info,
+ radio_program_info_t *halInfo,
+ bool withMetadata);
+ static int convertMetaDataFromHal(hidl_vec<MetaData>& metadata,
+ radio_metadata_t *halMetadata);
+private:
+ static const char * sClassModuleNames[];
+
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_0_UTILS_H
diff --git a/broadcastradio/1.0/types.hal b/broadcastradio/1.0/types.hal
index c5b4411..d04359c 100644
--- a/broadcastradio/1.0/types.hal
+++ b/broadcastradio/1.0/types.hal
@@ -54,7 +54,7 @@
enum Rds : uint32_t {
NONE = 0,
WORLD = (1<<0),
- RDS_US = (1<<1),
+ US = (1<<1),
};
@@ -111,7 +111,7 @@
union Ext {
FmBandConfig fm;
AmBandConfig am;
- };
+ } ext;
};
/* Exposes properties of a given hardware radio module.
diff --git a/contexthub/1.0/Android.bp b/contexthub/1.0/Android.bp
index f13ef5b..f380c6f 100644
--- a/contexthub/1.0/Android.bp
+++ b/contexthub/1.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/dumpstate/1.0/Android.bp b/dumpstate/1.0/Android.bp
new file mode 100644
index 0000000..ab34af2
--- /dev/null
+++ b/dumpstate/1.0/Android.bp
@@ -0,0 +1,50 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.dumpstate@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.dumpstate@1.0",
+ srcs: [
+ "IDumpstateDevice.hal",
+ ],
+ out: [
+ "android/hardware/dumpstate/1.0/DumpstateDeviceAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.dumpstate@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.dumpstate@1.0",
+ srcs: [
+ "IDumpstateDevice.hal",
+ ],
+ out: [
+ "android/hardware/dumpstate/1.0/IDumpstateDevice.h",
+ "android/hardware/dumpstate/1.0/IHwDumpstateDevice.h",
+ "android/hardware/dumpstate/1.0/BnDumpstateDevice.h",
+ "android/hardware/dumpstate/1.0/BpDumpstateDevice.h",
+ "android/hardware/dumpstate/1.0/BsDumpstateDevice.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.dumpstate@1.0",
+ generated_sources: ["android.hardware.dumpstate@1.0_genc++"],
+ generated_headers: ["android.hardware.dumpstate@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.dumpstate@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/dumpstate/1.0/IDumpstateDevice.hal b/dumpstate/1.0/IDumpstateDevice.hal
new file mode 100644
index 0000000..fec3eb4
--- /dev/null
+++ b/dumpstate/1.0/IDumpstateDevice.hal
@@ -0,0 +1,24 @@
+/*
+ * 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.dumpstate@1.0;
+
+interface IDumpstateDevice {
+ /*
+ * Dumps device-specific state into the given file descriptor.
+ */
+ dumpstateBoard(handle h);
+};
diff --git a/dumpstate/1.0/default/Android.mk b/dumpstate/1.0/default/Android.mk
new file mode 100644
index 0000000..4d5c908
--- /dev/null
+++ b/dumpstate/1.0/default/Android.mk
@@ -0,0 +1,22 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.dumpstate@1.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+ DumpstateDevice.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.dumpstate@1.0 \
+ libbase \
+ libcutils \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ liblog \
+ libutils
+
+LOCAL_STATIC_LIBRARIES := \
+ libdumpstateutil
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/dumpstate/1.0/default/DumpstateDevice.cpp b/dumpstate/1.0/default/DumpstateDevice.cpp
new file mode 100644
index 0000000..a279b89
--- /dev/null
+++ b/dumpstate/1.0/default/DumpstateDevice.cpp
@@ -0,0 +1,51 @@
+#define LOG_TAG "dumpstate"
+
+#include "DumpstateDevice.h"
+
+#include <log/log.h>
+
+#include "DumpstateUtil.h"
+
+namespace android {
+namespace hardware {
+namespace dumpstate {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
+Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
+ if (handle->numFds < 1) {
+ ALOGE("no FDs\n");
+ return Void();
+ }
+
+ int fd = handle->data[0];
+ if (fd < 0) {
+ ALOGE("invalid FD: %d\n", handle->data[0]);
+ return Void();
+ }
+ ALOGD("DumpstateDevice::dumpstateBoard() FD: %d\n", fd);
+ ALOGI("Dumpstate HIDL not provided by device\n");
+ dprintf(fd, "Dumpstate HIDL not provided by device; providing bogus data.\n");
+
+ // Shows some examples on how to use the libdumpstateutils API.
+ dprintf(fd, "Time now is: ");
+ RunCommandToFd(fd, {"/system/bin/date"});
+ dprintf(fd, "Contents of a small file (/system/etc/hosts):\n");
+ DumpFileToFd(fd, "/system/etc/hosts");
+
+ return Void();
+}
+
+
+IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* /* name */) {
+ // TODO: temporary returning nullptr until it's implemented on master devices
+ return nullptr;
+// return new DumpstateDevice();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
diff --git a/dumpstate/1.0/default/DumpstateDevice.h b/dumpstate/1.0/default/DumpstateDevice.h
new file mode 100644
index 0000000..6f860c0
--- /dev/null
+++ b/dumpstate/1.0/default/DumpstateDevice.h
@@ -0,0 +1,37 @@
+#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
+#define ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
+
+#include <android/hardware/dumpstate/1.0/IDumpstateDevice.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace dumpstate {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct DumpstateDevice : public IDumpstateDevice {
+ // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
+ Return<void> dumpstateBoard(const hidl_handle& h) override;
+
+};
+
+extern "C" IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
diff --git a/dumpstate/Android.bp b/dumpstate/Android.bp
new file mode 100644
index 0000000..bbb3e4b
--- /dev/null
+++ b/dumpstate/Android.bp
@@ -0,0 +1,4 @@
+// This is an autogenerated file, do not edit.
+subdirs = [
+ "1.0",
+]
diff --git a/example/extension/light/2.0/Android.bp b/example/extension/light/2.0/Android.bp
index ae93a6b..2257c35 100644
--- a/example/extension/light/2.0/Android.bp
+++ b/example/extension/light/2.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.light@2.0",
diff --git a/gatekeeper/1.0/Android.bp b/gatekeeper/1.0/Android.bp
new file mode 100644
index 0000000..c841510
--- /dev/null
+++ b/gatekeeper/1.0/Android.bp
@@ -0,0 +1,54 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.gatekeeper@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.gatekeeper@1.0",
+ srcs: [
+ "types.hal",
+ "IGatekeeper.hal",
+ ],
+ out: [
+ "android/hardware/gatekeeper/1.0/types.cpp",
+ "android/hardware/gatekeeper/1.0/GatekeeperAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.gatekeeper@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.gatekeeper@1.0",
+ srcs: [
+ "types.hal",
+ "IGatekeeper.hal",
+ ],
+ out: [
+ "android/hardware/gatekeeper/1.0/types.h",
+ "android/hardware/gatekeeper/1.0/IGatekeeper.h",
+ "android/hardware/gatekeeper/1.0/IHwGatekeeper.h",
+ "android/hardware/gatekeeper/1.0/BnGatekeeper.h",
+ "android/hardware/gatekeeper/1.0/BpGatekeeper.h",
+ "android/hardware/gatekeeper/1.0/BsGatekeeper.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.gatekeeper@1.0",
+ generated_sources: ["android.hardware.gatekeeper@1.0_genc++"],
+ generated_headers: ["android.hardware.gatekeeper@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.gatekeeper@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/gatekeeper/1.0/IGatekeeper.hal b/gatekeeper/1.0/IGatekeeper.hal
new file mode 100644
index 0000000..999a311
--- /dev/null
+++ b/gatekeeper/1.0/IGatekeeper.hal
@@ -0,0 +1,108 @@
+package android.hardware.gatekeeper@1.0;
+
+interface IGatekeeper {
+
+/**
+ * Enrolls desiredPassword, which may be derived from a user selected pin
+ * or password, with the private key used only for enrolling authentication
+ * factor data.
+ *
+ * If there was already a password enrolled, current password handle must be
+ * passed in currentPasswordHandle, and current password must be passed in
+ * currentPassword. Valid currentPassword must verify() against
+ * currentPasswordHandle.
+ *
+ * @param uid The Android user identifier
+ *
+ * @param currentPasswordHandle The currently enrolled password handle the user
+ * wants to replace. May be empty only if there's no currently enrolled
+ * password. Otherwise must be non-empty.
+ *
+ * @param currentPassword The user's current password in plain text.
+ * it MUST verify against current_password_handle if the latter is not-empty
+ *
+ * @param desiredPassword The new password the user wishes to enroll in
+ * plaintext.
+ *
+ * @return response
+ * On success, data buffer must contain the new password handle referencing
+ * the password provided in desiredPassword.
+ * This buffer can be used on subsequent calls to enroll or
+ * verify. On error, this buffer must be empty.
+ * response.code must always contain operation completion status.
+ * This method may return ERROR_GENERAL_FAILURE or ERROR_RETRY_TIMEOUT on
+ * failure. It must return STATUS_OK on success.
+ * If ERROR_RETRY_TIMEOUT is returned, response.timeout must be non-zero.
+ */
+enroll(uint32_t uid,
+ vec<uint8_t> currentPasswordHandle,
+ vec<uint8_t> currentPassword,
+ vec<uint8_t> desiredPassword)
+ generates (GatekeeperResponse response);
+
+/**
+ * Verifies that providedPassword matches enrolledPasswordHandle.
+ *
+ * Implementations of this module may retain the result of this call
+ * to attest to the recency of authentication.
+ *
+ * On success, returns verification token in response.data, which shall be
+ * usable to attest password verification to other trusted services.
+ *
+ * @param uid The Android user identifier
+ *
+ * @param challenge An optional challenge to authenticate against, or 0.
+ * Used when a separate authenticator requests password verification,
+ * or for transactional password authentication.
+ *
+ * @param enrolledPasswordHandle The currently enrolled password handle that
+ * user wishes to verify against. Must be non-empty.
+ *
+ * @param providedPassword The plaintext password to be verified against the
+ * enrolledPasswordHandle
+ *
+ * @return response
+ * On success, a non-empty data buffer containing the
+ * authentication token resulting from this verification is returned.
+ * On error, data buffer must be empty.
+ * response.code must always contain operation completion status.
+ * This method may return ERROR_GENERAL_FAILURE or ERROR_RETRY_TIMEOUT on
+ * failure. It must return STATUS_OK on success.
+ * If password re-enrollment is necessary, it must return STATUS_REENROLL.
+ * If ERROR_RETRY_TIMEOUT is returned, response.timeout must be non-zero.
+ */
+verify(uint32_t uid, uint64_t challenge,
+ vec<uint8_t> enrolledPasswordHandle,
+ vec<uint8_t> providedPassword)
+ generates (GatekeeperResponse response);
+
+/*
+ * Deletes the enrolledPasswordHandle associated with the uid. Once deleted
+ * the user cannot be verified anymore.
+ * This is an optional method.
+ *
+ * @param uid The Android user identifier
+ *
+ * @return response
+ * response.code must always contain operation completion status.
+ * This method may return ERROR_GENERAL_FAILURE or ERROR_RETRY_TIMEOUT on
+ * failure. It must return STATUS_OK on success.
+ * If not implemented, it must return ERROR_NOT_IMPLEMENTED.
+ * If ERROR_RETRY_TIMEOUT is returned, response.timeout must be non-zero.
+ */
+deleteUser(uint32_t uid) generates (GatekeeperResponse response);
+
+/*
+ * Deletes all the enrolled_password_handles for all uid's. Once called,
+ * no users must be enrolled on the device.
+ * This is an optional method.
+ *
+ * @return response
+ * response.code must always contain operation completion status.
+ * This method may return ERROR_GENERAL_FAILURE or ERROR_RETRY_TIMEOUT on
+ * failure. It must return STATUS_OK on success.
+ * If not implemented, it must return ERROR_NOT_IMPLEMENTED.
+ * If ERROR_RETRY_TIMEOUT is returned, response.timeout must be non-zero.
+ */
+deleteAllUsers() generates (GatekeeperResponse response);
+};
diff --git a/gatekeeper/1.0/default/Android.mk b/gatekeeper/1.0/default/Android.mk
new file mode 100644
index 0000000..e3b7d10
--- /dev/null
+++ b/gatekeeper/1.0/default/Android.mk
@@ -0,0 +1,40 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE := android.hardware.gatekeeper@1.0-impl
+
+LOCAL_SRC_FILES := \
+ Gatekeeper.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.gatekeeper@1.0 \
+ libhardware \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ libutils \
+ liblog \
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE := android.hardware.gatekeeper@1.0-service
+LOCAL_INIT_RC := android.hardware.gatekeeper@1.0-service.rc
+
+LOCAL_SRC_FILES := \
+ service.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.gatekeeper@1.0 \
+ libhardware \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ libutils \
+ liblog \
+
+include $(BUILD_EXECUTABLE)
diff --git a/gatekeeper/1.0/default/Gatekeeper.cpp b/gatekeeper/1.0/default/Gatekeeper.cpp
new file mode 100644
index 0000000..8fcd8ca
--- /dev/null
+++ b/gatekeeper/1.0/default/Gatekeeper.cpp
@@ -0,0 +1,149 @@
+#define LOG_TAG "android.hardware.gatekeeper@1.0-service"
+
+#include <utils/Log.h>
+#include <dlfcn.h>
+
+#include "Gatekeeper.h"
+
+namespace android {
+namespace hardware {
+namespace gatekeeper {
+namespace V1_0 {
+namespace implementation {
+
+Gatekeeper::Gatekeeper()
+{
+ int ret = hw_get_module_by_class(GATEKEEPER_HARDWARE_MODULE_ID, NULL, &module);
+ device = NULL;
+
+ if (!ret) {
+ ret = gatekeeper_open(module, &device);
+ }
+ if (ret < 0) {
+ LOG_ALWAYS_FATAL_IF(ret < 0, "Unable to open GateKeeper HAL");
+ }
+}
+
+Gatekeeper::~Gatekeeper()
+{
+ if (device != nullptr) {
+ int ret = gatekeeper_close(device);
+ if (ret < 0) {
+ ALOGE("Unable to close GateKeeper HAL");
+ }
+ }
+ dlclose(module->dso);
+}
+
+// Methods from ::android::hardware::gatekeeper::V1_0::IGatekeeper follow.
+Return<void> Gatekeeper::enroll(uint32_t uid,
+ const hidl_vec<uint8_t>& currentPasswordHandle,
+ const hidl_vec<uint8_t>& currentPassword,
+ const hidl_vec<uint8_t>& desiredPassword,
+ enroll_cb cb)
+{
+ GatekeeperResponse rsp;
+ uint8_t *enrolled_password_handle = nullptr;
+ uint32_t enrolled_password_handle_length = 0;
+
+ int ret = device->enroll(device, uid,
+ currentPasswordHandle.data(), currentPasswordHandle.size(),
+ currentPassword.data(), currentPassword.size(),
+ desiredPassword.data(), desiredPassword.size(),
+ &enrolled_password_handle, &enrolled_password_handle_length);
+ if (!ret) {
+ rsp.data.setToExternal(enrolled_password_handle,
+ enrolled_password_handle_length,
+ true);
+ rsp.code = GatekeeperStatusCode::STATUS_OK;
+ } else if (ret > 0) {
+ rsp.timeout = ret;
+ rsp.code = GatekeeperStatusCode::ERROR_RETRY_TIMEOUT;
+ } else {
+ rsp.code = GatekeeperStatusCode::ERROR_GENERAL_FAILURE;
+ }
+ cb(rsp);
+ return Void();
+}
+
+Return<void> Gatekeeper::verify(uint32_t uid,
+ uint64_t challenge,
+ const hidl_vec<uint8_t>& enrolledPasswordHandle,
+ const hidl_vec<uint8_t>& providedPassword,
+ verify_cb cb)
+{
+ GatekeeperResponse rsp;
+ uint8_t *auth_token = nullptr;
+ uint32_t auth_token_length = 0;
+ bool request_reenroll = false;
+
+ int ret = device->verify(device, uid, challenge,
+ enrolledPasswordHandle.data(), enrolledPasswordHandle.size(),
+ providedPassword.data(), providedPassword.size(),
+ &auth_token, &auth_token_length,
+ &request_reenroll);
+ if (!ret) {
+ rsp.data.setToExternal(auth_token, auth_token_length, true);
+ if (request_reenroll) {
+ rsp.code = GatekeeperStatusCode::STATUS_REENROLL;
+ } else {
+ rsp.code = GatekeeperStatusCode::STATUS_OK;
+ }
+ } else if (ret > 0) {
+ rsp.timeout = ret;
+ rsp.code = GatekeeperStatusCode::ERROR_RETRY_TIMEOUT;
+ } else {
+ rsp.code = GatekeeperStatusCode::ERROR_GENERAL_FAILURE;
+ }
+ cb(rsp);
+ return Void();
+}
+
+Return<void> Gatekeeper::deleteUser(uint32_t uid, deleteUser_cb cb) {
+ GatekeeperResponse rsp;
+
+ if (device->delete_user != nullptr) {
+ int ret = device->delete_user(device, uid);
+ if (!ret) {
+ rsp.code = GatekeeperStatusCode::STATUS_OK;
+ } else if (ret > 0) {
+ rsp.timeout = ret;
+ rsp.code = GatekeeperStatusCode::ERROR_RETRY_TIMEOUT;
+ } else {
+ rsp.code = GatekeeperStatusCode::ERROR_GENERAL_FAILURE;
+ }
+ } else {
+ rsp.code = GatekeeperStatusCode::ERROR_NOT_IMPLEMENTED;
+ }
+ cb(rsp);
+ return Void();
+}
+
+Return<void> Gatekeeper::deleteAllUsers(deleteAllUsers_cb cb) {
+ GatekeeperResponse rsp;
+ if (device->delete_all_users != nullptr) {
+ int ret = device->delete_all_users(device);
+ if (!ret) {
+ rsp.code = GatekeeperStatusCode::STATUS_OK;
+ } else if (ret > 0) {
+ rsp.timeout = ret;
+ rsp.code = GatekeeperStatusCode::ERROR_RETRY_TIMEOUT;
+ } else {
+ rsp.code = GatekeeperStatusCode::ERROR_GENERAL_FAILURE;
+ }
+ } else {
+ rsp.code = GatekeeperStatusCode::ERROR_NOT_IMPLEMENTED;
+ }
+ cb(rsp);
+ return Void();
+}
+
+IGatekeeper* HIDL_FETCH_IGatekeeper(const char* /* name */) {
+ return new Gatekeeper();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gatekeeper
+} // namespace hardware
+} // namespace android
diff --git a/gatekeeper/1.0/default/Gatekeeper.h b/gatekeeper/1.0/default/Gatekeeper.h
new file mode 100644
index 0000000..a2188d4
--- /dev/null
+++ b/gatekeeper/1.0/default/Gatekeeper.h
@@ -0,0 +1,57 @@
+#ifndef HIDL_GENERATED_android_hardware_gatekeeper_V1_0_Gatekeeper_H_
+#define HIDL_GENERATED_android_hardware_gatekeeper_V1_0_Gatekeeper_H_
+
+#include <android/hardware/gatekeeper/1.0/IGatekeeper.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+
+#include <hardware/hardware.h>
+#include <hardware/gatekeeper.h>
+
+namespace android {
+namespace hardware {
+namespace gatekeeper {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gatekeeper::V1_0::GatekeeperResponse;
+using ::android::hardware::gatekeeper::V1_0::IGatekeeper;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+class Gatekeeper : public IGatekeeper {
+public:
+ Gatekeeper();
+ ~Gatekeeper();
+
+ // Methods from ::android::hardware::gatekeeper::V1_0::IGatekeeper follow.
+ Return<void> enroll(uint32_t uid,
+ const hidl_vec<uint8_t>& currentPasswordHandle,
+ const hidl_vec<uint8_t>& currentPassword,
+ const hidl_vec<uint8_t>& desiredPassword,
+ enroll_cb _hidl_cb) override;
+ Return<void> verify(uint32_t uid,
+ uint64_t challenge,
+ const hidl_vec<uint8_t>& enrolledPasswordHandle,
+ const hidl_vec<uint8_t>& providedPassword,
+ verify_cb _hidl_cb) override;
+ Return<void> deleteUser(uint32_t uid, deleteUser_cb _hidl_cb) override;
+ Return<void> deleteAllUsers(deleteAllUsers_cb _hidl_cb) override;
+private:
+ gatekeeper_device_t *device;
+ const hw_module_t *module;
+};
+
+extern "C" IGatekeeper* HIDL_FETCH_IGatekeeper(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gatekeeper
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_GENERATED_android_hardware_gatekeeper_V1_0_Gatekeeper_H_
diff --git a/gatekeeper/1.0/default/android.hardware.gatekeeper@1.0-service.rc b/gatekeeper/1.0/default/android.hardware.gatekeeper@1.0-service.rc
new file mode 100644
index 0000000..ac15e23
--- /dev/null
+++ b/gatekeeper/1.0/default/android.hardware.gatekeeper@1.0-service.rc
@@ -0,0 +1,4 @@
+service gatekeeper-1-0 /system/bin/hw/android.hardware.gatekeeper@1.0-service
+ class hal
+ user system
+ group system
diff --git a/gatekeeper/1.0/default/service.cpp b/gatekeeper/1.0/default/service.cpp
new file mode 100644
index 0000000..c3fc25c
--- /dev/null
+++ b/gatekeeper/1.0/default/service.cpp
@@ -0,0 +1,13 @@
+#define LOG_TAG "android.hardware.gatekeeper@1.0-service"
+
+#include <android/hardware/gatekeeper/1.0/IGatekeeper.h>
+
+#include <hidl/LegacySupport.h>
+
+// Generated HIDL files
+using android::hardware::gatekeeper::V1_0::IGatekeeper;
+using android::hardware::defaultPassthroughServiceImplementation;
+
+int main() {
+ return defaultPassthroughServiceImplementation<IGatekeeper>("gatekeeper");
+}
diff --git a/gatekeeper/1.0/types.hal b/gatekeeper/1.0/types.hal
new file mode 100644
index 0000000..9ab1152
--- /dev/null
+++ b/gatekeeper/1.0/types.hal
@@ -0,0 +1,27 @@
+package android.hardware.gatekeeper@1.0;
+
+/**
+ * Gatekeeper response codes; success >= 0; error < 0
+ */
+enum GatekeeperStatusCode : int32_t {
+ STATUS_REENROLL = 1, // success, but upper layers should re-enroll
+ // the verified password due to a version change
+ STATUS_OK = 0, // operation is successful
+ ERROR_GENERAL_FAILURE = -1, // operation failed
+ ERROR_RETRY_TIMEOUT = -2, // operation should be retried after timeout
+ ERROR_NOT_IMPLEMENTED = -3, // operation is not implemented
+};
+
+/**
+ * Gatekeeper response to any/all requests has this structure as mandatory part
+ */
+struct GatekeeperResponse {
+ /* request completion status */
+ GatekeeperStatusCode code;
+ /* retry timeout in ms, if code == ERROR_RETRY_TIMEOUT
+ * otherwise unused (0)
+ */
+ uint32_t timeout;
+ /* optional crypto blob */
+ vec<uint8_t> data;
+};
diff --git a/gatekeeper/Android.bp b/gatekeeper/Android.bp
new file mode 100644
index 0000000..bbb3e4b
--- /dev/null
+++ b/gatekeeper/Android.bp
@@ -0,0 +1,4 @@
+// This is an autogenerated file, do not edit.
+subdirs = [
+ "1.0",
+]
diff --git a/gnss/1.0/Android.bp b/gnss/1.0/Android.bp
index f33f1c6..adac05f 100644
--- a/gnss/1.0/Android.bp
+++ b/gnss/1.0/Android.bp
@@ -169,6 +169,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/graphics/Android.bp b/graphics/Android.bp
index 4ac7766..796ef41 100644
--- a/graphics/Android.bp
+++ b/graphics/Android.bp
@@ -2,6 +2,7 @@
subdirs = [
"allocator/2.0",
"allocator/2.0/default",
+ "allocator/2.0/vts/functional",
"common/1.0",
"composer/2.1",
"composer/2.1/default",
diff --git a/graphics/allocator/2.0/Android.bp b/graphics/allocator/2.0/Android.bp
index 4cf1e7f..f823570 100644
--- a/graphics/allocator/2.0/Android.bp
+++ b/graphics/allocator/2.0/Android.bp
@@ -7,10 +7,12 @@
srcs: [
"types.hal",
"IAllocator.hal",
+ "IAllocatorClient.hal",
],
out: [
"android/hardware/graphics/allocator/2.0/types.cpp",
"android/hardware/graphics/allocator/2.0/AllocatorAll.cpp",
+ "android/hardware/graphics/allocator/2.0/AllocatorClientAll.cpp",
],
}
@@ -21,6 +23,7 @@
srcs: [
"types.hal",
"IAllocator.hal",
+ "IAllocatorClient.hal",
],
out: [
"android/hardware/graphics/allocator/2.0/types.h",
@@ -29,6 +32,11 @@
"android/hardware/graphics/allocator/2.0/BnAllocator.h",
"android/hardware/graphics/allocator/2.0/BpAllocator.h",
"android/hardware/graphics/allocator/2.0/BsAllocator.h",
+ "android/hardware/graphics/allocator/2.0/IAllocatorClient.h",
+ "android/hardware/graphics/allocator/2.0/IHwAllocatorClient.h",
+ "android/hardware/graphics/allocator/2.0/BnAllocatorClient.h",
+ "android/hardware/graphics/allocator/2.0/BpAllocatorClient.h",
+ "android/hardware/graphics/allocator/2.0/BsAllocatorClient.h",
],
}
@@ -41,13 +49,16 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
+ "android.hardware.graphics.common@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
+ "android.hardware.graphics.common@1.0",
],
}
diff --git a/graphics/allocator/2.0/Android.mk b/graphics/allocator/2.0/Android.mk
deleted file mode 100644
index 3165fed..0000000
--- a/graphics/allocator/2.0/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# This file is autogenerated by hidl-gen. Do not edit manually.
-
-LOCAL_PATH := $(call my-dir)
-
-################################################################################
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.graphics.allocator@2.0-java-constants
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-
-intermediates := $(local-generated-sources-dir)
-
-HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
-#
-GEN := $(intermediates)/android/hardware/graphics/allocator/2.0/Constants.java
-$(GEN): $(HIDL)
-$(GEN): $(LOCAL_PATH)/types.hal
-$(GEN): $(LOCAL_PATH)/IAllocator.hal
-
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
- $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
- -Ljava-constants -randroid.hardware:hardware/interfaces \
- android.hardware.graphics.allocator@2.0
-
-$(GEN):
- $(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-# Avoid dependency cycle of framework.jar -> this-library -> framework.jar
-LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core-oj
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/graphics/allocator/2.0/IAllocator.hal b/graphics/allocator/2.0/IAllocator.hal
index ff08a7e..00d07d5 100644
--- a/graphics/allocator/2.0/IAllocator.hal
+++ b/graphics/allocator/2.0/IAllocator.hal
@@ -16,59 +16,26 @@
package android.hardware.graphics.allocator@2.0;
+import IAllocatorClient;
+
interface IAllocator {
enum Capability : int32_t {
/* reserved */
INVALID = 0,
/*
- * testAllocate will always return UNDEFINED unless this capability
- * is supported.
+ * IAllocatorClient::testAllocate must always return UNDEFINED unless
+ * this capability is supported.
*/
TEST_ALLOCATE = 1,
/*
- * layerCount must be 1 unless this capability is supported.
+ * IAllocatorClient::BufferDescriptorInfo::layerCount must be 1 unless
+ * this capability is supported.
*/
LAYERED_BUFFERS = 2,
};
- struct BufferDescriptorInfo {
- /*
- * The width specifies how many columns of pixels must be in the
- * allocated buffer, but does not necessarily represent the offset in
- * columns between the same column in adjacent rows. The rows may be
- * padded.
- */
- uint32_t width;
-
- /*
- * The height specifies how many rows of pixels must be in the
- * allocated buffer.
- */
- uint32_t height;
-
- /*
- * The number of image layers that must be in the allocated buffer.
- */
- uint32_t layerCount;
-
- /* Buffer pixel format. */
- PixelFormat format;
-
- /*
- * Buffer producer usage mask; valid flags can be found in the
- * definition of ProducerUsage.
- */
- uint64_t producerUsageMask;
-
- /*
- * Buffer consumer usage mask; valid flags can be found in the
- * definition of ConsumerUsage.
- */
- uint64_t consumerUsageMask;
- };
-
/*
* Provides a list of supported capabilities (as described in the
* definition of Capability above). This list must not change after
@@ -76,6 +43,9 @@
*
* @return capabilities is a list of supported capabilities.
*/
+ @entry
+ @exit
+ @callflow(next="*")
getCapabilities() generates (vec<Capability> capabilities);
/*
@@ -84,104 +54,21 @@
*
* @return debugInfo is a string of debug information.
*/
+ @entry
+ @exit
+ @callflow(next="*")
dumpDebugInfo() generates (string debugInfo);
/*
- * Creates a new, opaque buffer descriptor.
+ * Creates a client of the allocator. All resources created by the client
+ * are owned by the client and are only visible to the client, unless they
+ * are exported by exportHandle.
*
- * @param descriptorInfo specifies the attributes of the buffer
- * descriptor.
* @return error is NONE upon success. Otherwise,
- * BAD_VALUE when any attribute in descriptorInfo is invalid.
- * NO_RESOURCES when no more descriptors can currently be created.
- * @return descriptor is the newly created buffer descriptor.
+ * NO_RESOURCES when no more client can currently be created.
+ * @return client is the newly created client.
*/
- createDescriptor(BufferDescriptorInfo descriptorInfo)
- generates (Error error,
- BufferDescriptor descriptor);
-
- /*
- * Destroys an existing buffer descriptor.
- *
- * @param descriptor is the descriptor to destroy.
- * @return error is either NONE or BAD_DESCRIPTOR.
- */
- destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
-
- /*
- * Tests whether a buffer allocation can succeed, ignoring potential
- * resource contention which might lead to a NO_RESOURCES error.
- *
- * @param descriptors is a list of buffer descriptors.
- * @return error is NONE or NOT_SHARED upon success;
- * NONE when buffers can be created and share a backing store.
- * NOT_SHARED when buffers can be created but require more than a
- * backing store.
- * Otherwise,
- * BAD_DESCRIPTOR when any of the descriptors is invalid.
- * UNSUPPORTED when any of the descriptors can never be satisfied.
- * UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
- */
- testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
-
- /*
- * Attempts to allocate a list of buffers sharing a backing store.
- *
- * Each buffer will correspond to one of the descriptors passed into the
- * function and will hold a reference to its backing store. If the device
- * is unable to share the backing store between the buffers, it must
- * attempt to allocate the buffers with different backing stores and
- * return NOT_SHARED if it is successful.
- *
- * @param descriptors is the buffer descriptors to attempt to allocate.
- * @return error is NONE or NOT_SHARED upon success;
- * NONE when buffers can be created and share a backing store.
- * NOT_SHARED when buffers can be created but require more than a
- * backing store.
- * Otherwise,
- * BAD_DESCRIPTOR when any of the descriptors is invalid.
- * UNSUPPORTED when any of the descriptors can never be satisfied.
- * NO_RESOURCES when any of the buffers cannot be created at this
- * time.
- * @return buffers is the allocated buffers.
- */
- allocate(vec<BufferDescriptor> descriptors)
- generates (Error error,
- vec<Buffer> buffers);
-
- /*
- * Frees a buffer.
- *
- * @param buffer is the buffer to be freed.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer is invalid.
- */
- free(Buffer buffer) generates (Error error);
-
- /*
- * Exports a buffer for use in other client libraries or for cross-process
- * sharing.
- *
- * The exported handle is a handle to the backing store of the buffer, not
- * to the buffer itself. It however may not hold any reference to the
- * backing store and may be considered invalid by client libraries. To use
- * it and, in most cases, to save it for later use, a client must make a
- * clone of the handle and have the cloned handle hold a reference to the
- * backing store. Such a cloned handle will stay valid even after the
- * original buffer is freed. Refer to native_handle_clone and IMapper for
- * how a handle is cloned and how a reference is added.
- *
- * @param descriptor is the descriptor used to allocate the buffer.
- * @param buffer is the buffer to be exported.
- * @return error is NONE upon success. Otherwise,
- * BAD_DESCRIPTOR when the descriptor is invalid.
- * BAD_BUFFER when the buffer is invalid.
- * BAD_VALUE when descriptor and buffer do not match.
- * NO_RESOURCES when the buffer cannot be exported at this time.
- * @return bufferHandle is the exported handle.
- */
- exportHandle(BufferDescriptor descriptor,
- Buffer buffer)
- generates (Error error,
- handle bufferHandle);
+ @entry
+ @callflow(next="*")
+ createClient() generates (Error error, IAllocatorClient client);
};
diff --git a/graphics/allocator/2.0/IAllocatorClient.hal b/graphics/allocator/2.0/IAllocatorClient.hal
new file mode 100644
index 0000000..080e3ea
--- /dev/null
+++ b/graphics/allocator/2.0/IAllocatorClient.hal
@@ -0,0 +1,165 @@
+/*
+ * 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.graphics.allocator@2.0;
+
+import android.hardware.graphics.common@1.0::PixelFormat;
+
+interface IAllocatorClient {
+ struct BufferDescriptorInfo {
+ /*
+ * The width specifies how many columns of pixels must be in the
+ * allocated buffer, but does not necessarily represent the offset in
+ * columns between the same column in adjacent rows. The rows may be
+ * padded.
+ */
+ uint32_t width;
+
+ /*
+ * The height specifies how many rows of pixels must be in the
+ * allocated buffer.
+ */
+ uint32_t height;
+
+ /*
+ * The number of image layers that must be in the allocated buffer.
+ */
+ uint32_t layerCount;
+
+ /* Buffer pixel format. */
+ PixelFormat format;
+
+ /*
+ * Buffer producer usage mask; valid flags can be found in the
+ * definition of ProducerUsage.
+ */
+ uint64_t producerUsageMask;
+
+ /*
+ * Buffer consumer usage mask; valid flags can be found in the
+ * definition of ConsumerUsage.
+ */
+ uint64_t consumerUsageMask;
+ };
+
+ /*
+ * Creates a new, opaque buffer descriptor.
+ *
+ * @param descriptorInfo specifies the attributes of the buffer
+ * descriptor.
+ * @return error is NONE upon success. Otherwise,
+ * BAD_VALUE when any attribute in descriptorInfo is invalid.
+ * NO_RESOURCES when no more descriptors can currently be created.
+ * @return descriptor is the newly created buffer descriptor.
+ */
+ @entry
+ @callflow(next="*")
+ createDescriptor(BufferDescriptorInfo descriptorInfo)
+ generates (Error error,
+ BufferDescriptor descriptor);
+
+ /*
+ * Destroys an existing buffer descriptor.
+ *
+ * @param descriptor is the descriptor to destroy.
+ * @return error is either NONE or BAD_DESCRIPTOR.
+ */
+ @exit
+ @callflow(next="*")
+ destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
+
+ /*
+ * Tests whether a buffer allocation can succeed, ignoring potential
+ * resource contention which might lead to a NO_RESOURCES error.
+ *
+ * @param descriptors is a list of buffer descriptors.
+ * @return error is NONE or NOT_SHARED upon success;
+ * NONE when buffers can be created and share a backing store.
+ * NOT_SHARED when buffers can be created but require more than a
+ * backing store.
+ * Otherwise,
+ * BAD_DESCRIPTOR when any of the descriptors is invalid.
+ * UNSUPPORTED when any of the descriptors can never be satisfied.
+ * UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
+ */
+ @callflow(next="allocate")
+ testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
+
+ /*
+ * Attempts to allocate a list of buffers sharing a backing store.
+ *
+ * Each buffer must correspond to one of the descriptors passed into the
+ * function and must hold a reference to its backing store. If the device
+ * is unable to share the backing store between the buffers, it must
+ * attempt to allocate the buffers with different backing stores and
+ * return NOT_SHARED if it is successful.
+ *
+ * @param descriptors is the buffer descriptors to attempt to allocate.
+ * @return error is NONE or NOT_SHARED upon success;
+ * NONE when buffers can be created and share a backing store.
+ * NOT_SHARED when buffers can be created but require more than a
+ * backing store.
+ * Otherwise,
+ * BAD_DESCRIPTOR when any of the descriptors is invalid.
+ * UNSUPPORTED when any of the descriptors can never be satisfied.
+ * NO_RESOURCES when any of the buffers cannot be created at this
+ * time.
+ * @return buffers is the allocated buffers.
+ */
+ @callflow(next="exportHandle")
+ allocate(vec<BufferDescriptor> descriptors)
+ generates (Error error,
+ vec<Buffer> buffers);
+
+ /*
+ * Frees a buffer.
+ *
+ * @param buffer is the buffer to be freed.
+ * @return error is NONE upon success. Otherwise,
+ * BAD_BUFFER when the buffer is invalid.
+ */
+ @exit
+ @callflow(next="*")
+ free(Buffer buffer) generates (Error error);
+
+ /*
+ * Exports a buffer for use in other client libraries or for cross-process
+ * sharing.
+ *
+ * The exported handle is a handle to the backing store of the buffer, not
+ * to the buffer itself. It however may not hold any reference to the
+ * backing store and may be considered invalid by client libraries. To use
+ * it and, in most cases, to save it for later use, a client must make a
+ * clone of the handle and have the cloned handle hold a reference to the
+ * backing store. Such a cloned handle will stay valid even after the
+ * original buffer is freed. Refer to native_handle_clone and IMapper for
+ * how a handle is cloned and how a reference is added.
+ *
+ * @param descriptor is the descriptor used to allocate the buffer.
+ * @param buffer is the buffer to be exported.
+ * @return error is NONE upon success. Otherwise,
+ * BAD_DESCRIPTOR when the descriptor is invalid.
+ * BAD_BUFFER when the buffer is invalid.
+ * BAD_VALUE when descriptor and buffer do not match.
+ * NO_RESOURCES when the buffer cannot be exported at this time.
+ * @return bufferHandle is the exported handle.
+ */
+ @callflow(next="free")
+ exportHandle(BufferDescriptor descriptor,
+ Buffer buffer)
+ generates (Error error,
+ handle bufferHandle);
+};
diff --git a/graphics/allocator/2.0/default/Gralloc.cpp b/graphics/allocator/2.0/default/Gralloc.cpp
index 8a74661..e3d2703 100644
--- a/graphics/allocator/2.0/default/Gralloc.cpp
+++ b/graphics/allocator/2.0/default/Gralloc.cpp
@@ -16,6 +16,7 @@
#define LOG_TAG "GrallocPassthrough"
+#include <mutex>
#include <type_traits>
#include <unordered_set>
#include <vector>
@@ -42,18 +43,19 @@
// IAllocator interface
Return<void> getCapabilities(getCapabilities_cb hidl_cb) override;
Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
- Return<void> createDescriptor(const BufferDescriptorInfo& descriptorInfo,
- createDescriptor_cb hidl_cb) override;
- Return<Error> destroyDescriptor(BufferDescriptor descriptor) override;
+ Return<void> createClient(createClient_cb hidl_cb) override;
- Return<Error> testAllocate(
- const hidl_vec<BufferDescriptor>& descriptors) override;
- Return<void> allocate(const hidl_vec<BufferDescriptor>& descriptors,
- allocate_cb hidl_cb) override;
- Return<Error> free(Buffer buffer) override;
+ Error createDescriptor(
+ const IAllocatorClient::BufferDescriptorInfo& descriptorInfo,
+ BufferDescriptor& outDescriptor);
+ Error destroyDescriptor(BufferDescriptor descriptor);
- Return<void> exportHandle(BufferDescriptor descriptor,
- Buffer buffer, exportHandle_cb hidl_cb) override;
+ Error testAllocate(const hidl_vec<BufferDescriptor>& descriptors);
+ Error allocate(const hidl_vec<BufferDescriptor>& descriptors,
+ hidl_vec<Buffer>& outBuffers);
+ Error free(Buffer buffer);
+
+ Error exportHandle(Buffer buffer, const native_handle_t*& outHandle);
private:
void initCapabilities();
@@ -79,12 +81,36 @@
GRALLOC1_PFN_SET_PRODUCER_USAGE setProducerUsage;
GRALLOC1_PFN_ALLOCATE allocate;
GRALLOC1_PFN_RELEASE release;
- GRALLOC1_PFN_GET_BACKING_STORE getBackingStore;
- GRALLOC1_PFN_GET_STRIDE getStride;
- GRALLOC1_PFN_GET_NUM_FLEX_PLANES getNumFlexPlanes;
} mDispatch;
};
+class GrallocClient : public IAllocatorClient {
+public:
+ GrallocClient(GrallocHal& hal);
+ virtual ~GrallocClient();
+
+ // IAllocatorClient interface
+ Return<void> createDescriptor(const BufferDescriptorInfo& descriptorInfo,
+ createDescriptor_cb hidl_cb) override;
+ Return<Error> destroyDescriptor(BufferDescriptor descriptor) override;
+
+ Return<Error> testAllocate(
+ const hidl_vec<BufferDescriptor>& descriptors) override;
+ Return<void> allocate(const hidl_vec<BufferDescriptor>& descriptors,
+ allocate_cb hidl_cb) override;
+ Return<Error> free(Buffer buffer) override;
+
+ Return<void> exportHandle(BufferDescriptor descriptor,
+ Buffer buffer, exportHandle_cb hidl_cb) override;
+
+private:
+ GrallocHal& mHal;
+
+ std::mutex mMutex;
+ std::unordered_set<BufferDescriptor> mDescriptors;
+ std::unordered_set<Buffer> mBuffers;
+};
+
GrallocHal::GrallocHal(const hw_module_t* module)
: mDevice(nullptr), mDispatch()
{
@@ -182,24 +208,37 @@
return Void();
}
-Return<void> GrallocHal::createDescriptor(
- const BufferDescriptorInfo& descriptorInfo,
- createDescriptor_cb hidl_cb)
+Return<void> GrallocHal::createClient(createClient_cb hidl_cb)
{
- BufferDescriptor descriptor;
+ sp<IAllocatorClient> client = new GrallocClient(*this);
+ hidl_cb(Error::NONE, client);
+
+ return Void();
+}
+
+Error GrallocHal::createDescriptor(
+ const IAllocatorClient::BufferDescriptorInfo& descriptorInfo,
+ BufferDescriptor& outDescriptor)
+{
+ gralloc1_buffer_descriptor_t descriptor;
int32_t err = mDispatch.createDescriptor(mDevice, &descriptor);
- if (err == GRALLOC1_ERROR_NONE) {
- err = mDispatch.setDimensions(mDevice, descriptor,
- descriptorInfo.width, descriptorInfo.height);
+ if (err != GRALLOC1_ERROR_NONE) {
+ return static_cast<Error>(err);
}
+
+ err = mDispatch.setDimensions(mDevice, descriptor,
+ descriptorInfo.width, descriptorInfo.height);
if (err == GRALLOC1_ERROR_NONE) {
err = mDispatch.setFormat(mDevice, descriptor,
static_cast<int32_t>(descriptorInfo.format));
}
- if (err == GRALLOC1_ERROR_NONE &&
- hasCapability(Capability::LAYERED_BUFFERS)) {
- err = mDispatch.setLayerCount(mDevice, descriptor,
- descriptorInfo.layerCount);
+ if (err == GRALLOC1_ERROR_NONE) {
+ if (hasCapability(Capability::LAYERED_BUFFERS)) {
+ err = mDispatch.setLayerCount(mDevice, descriptor,
+ descriptorInfo.layerCount);
+ } else if (descriptorInfo.layerCount != 1) {
+ err = GRALLOC1_ERROR_BAD_VALUE;
+ }
}
if (err == GRALLOC1_ERROR_NONE) {
uint64_t producerUsageMask = descriptorInfo.producerUsageMask;
@@ -221,64 +260,189 @@
consumerUsageMask);
}
- hidl_cb(static_cast<Error>(err), descriptor);
+ if (err == GRALLOC1_ERROR_NONE) {
+ outDescriptor = descriptor;
+ } else {
+ mDispatch.destroyDescriptor(mDevice, descriptor);
+ }
- return Void();
+ return static_cast<Error>(err);
}
-Return<Error> GrallocHal::destroyDescriptor(
- BufferDescriptor descriptor)
+Error GrallocHal::destroyDescriptor(BufferDescriptor descriptor)
{
int32_t err = mDispatch.destroyDescriptor(mDevice, descriptor);
return static_cast<Error>(err);
}
-Return<Error> GrallocHal::testAllocate(
- const hidl_vec<BufferDescriptor>& descriptors)
+Error GrallocHal::testAllocate(const hidl_vec<BufferDescriptor>& descriptors)
{
if (!hasCapability(Capability::TEST_ALLOCATE)) {
return Error::UNDEFINED;
}
int32_t err = mDispatch.allocate(mDevice, descriptors.size(),
- &descriptors[0], nullptr);
+ descriptors.data(), nullptr);
return static_cast<Error>(err);
}
-Return<void> GrallocHal::allocate(
- const hidl_vec<BufferDescriptor>& descriptors,
- allocate_cb hidl_cb) {
+Error GrallocHal::allocate(const hidl_vec<BufferDescriptor>& descriptors,
+ hidl_vec<Buffer>& outBuffers)
+{
std::vector<buffer_handle_t> buffers(descriptors.size());
int32_t err = mDispatch.allocate(mDevice, descriptors.size(),
- &descriptors[0], buffers.data());
- if (err != GRALLOC1_ERROR_NONE && err != GRALLOC1_ERROR_NOT_SHARED) {
- buffers.clear();
+ descriptors.data(), buffers.data());
+ if (err == GRALLOC1_ERROR_NONE || err == GRALLOC1_ERROR_NOT_SHARED) {
+ outBuffers.resize(buffers.size());
+ for (size_t i = 0; i < outBuffers.size(); i++) {
+ outBuffers[i] = static_cast<Buffer>(
+ reinterpret_cast<uintptr_t>(buffers[i]));
+ }
}
- hidl_vec<Buffer> reply;
- reply.setToExternal(
- reinterpret_cast<Buffer*>(buffers.data()),
- buffers.size());
- hidl_cb(static_cast<Error>(err), reply);
-
- return Void();
+ return static_cast<Error>(err);
}
-Return<Error> GrallocHal::free(Buffer buffer)
+Error GrallocHal::free(Buffer buffer)
{
- buffer_handle_t handle = reinterpret_cast<buffer_handle_t>(buffer);
+ buffer_handle_t handle = reinterpret_cast<buffer_handle_t>(
+ static_cast<uintptr_t>(buffer));
+
int32_t err = mDispatch.release(mDevice, handle);
return static_cast<Error>(err);
}
-Return<void> GrallocHal::exportHandle(BufferDescriptor /*descriptor*/,
+Error GrallocHal::exportHandle(Buffer buffer,
+ const native_handle_t*& outHandle)
+{
+ // we rely on the caller to validate buffer here
+ outHandle = reinterpret_cast<buffer_handle_t>(
+ static_cast<uintptr_t>(buffer));
+ return Error::NONE;
+}
+
+GrallocClient::GrallocClient(GrallocHal& hal)
+ : mHal(hal)
+{
+}
+
+GrallocClient::~GrallocClient()
+{
+ if (!mBuffers.empty()) {
+ ALOGW("client destroyed with valid buffers");
+ for (auto buf : mBuffers) {
+ mHal.free(buf);
+ }
+ }
+
+ if (!mDescriptors.empty()) {
+ ALOGW("client destroyed with valid buffer descriptors");
+ for (auto desc : mDescriptors) {
+ mHal.destroyDescriptor(desc);
+ }
+ }
+}
+
+Return<void> GrallocClient::createDescriptor(
+ const BufferDescriptorInfo& descriptorInfo,
+ createDescriptor_cb hidl_cb)
+{
+ BufferDescriptor descriptor;
+ Error err = mHal.createDescriptor(descriptorInfo, descriptor);
+
+ if (err == Error::NONE) {
+ std::lock_guard<std::mutex> lock(mMutex);
+
+ auto result = mDescriptors.insert(descriptor);
+ if (!result.second) {
+ ALOGW("duplicated buffer descriptor id returned");
+ mHal.destroyDescriptor(descriptor);
+ err = Error::NO_RESOURCES;
+ }
+ }
+
+ hidl_cb(err, descriptor);
+ return Void();
+}
+
+Return<Error> GrallocClient::destroyDescriptor(BufferDescriptor descriptor)
+{
+ {
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (!mDescriptors.erase(descriptor)) {
+ return Error::BAD_DESCRIPTOR;
+ }
+ }
+
+ return mHal.destroyDescriptor(descriptor);
+}
+
+Return<Error> GrallocClient::testAllocate(
+ const hidl_vec<BufferDescriptor>& descriptors)
+{
+ return mHal.testAllocate(descriptors);
+}
+
+Return<void> GrallocClient::allocate(
+ const hidl_vec<BufferDescriptor>& descriptors,
+ allocate_cb hidl_cb) {
+ hidl_vec<Buffer> buffers;
+ Error err = mHal.allocate(descriptors, buffers);
+
+ if (err == Error::NONE || err == Error::NOT_SHARED) {
+ std::lock_guard<std::mutex> lock(mMutex);
+
+ for (size_t i = 0; i < buffers.size(); i++) {
+ auto result = mBuffers.insert(buffers[i]);
+ if (!result.second) {
+ ALOGW("duplicated buffer id returned");
+
+ for (size_t j = 0; j < buffers.size(); j++) {
+ if (j < i) {
+ mBuffers.erase(buffers[i]);
+ }
+ mHal.free(buffers[i]);
+ }
+
+ buffers = hidl_vec<Buffer>();
+ err = Error::NO_RESOURCES;
+ break;
+ }
+ }
+ }
+
+ hidl_cb(err, buffers);
+ return Void();
+}
+
+Return<Error> GrallocClient::free(Buffer buffer)
+{
+ {
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (!mBuffers.erase(buffer)) {
+ return Error::BAD_BUFFER;
+ }
+ }
+
+ return mHal.free(buffer);
+}
+
+Return<void> GrallocClient::exportHandle(BufferDescriptor /*descriptor*/,
Buffer buffer, exportHandle_cb hidl_cb)
{
- // do we want to validate?
- buffer_handle_t handle = reinterpret_cast<buffer_handle_t>(buffer);
+ const native_handle_t* handle = nullptr;
- hidl_cb(Error::NONE, handle);
+ {
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (mBuffers.count(buffer) == 0) {
+ hidl_cb(Error::BAD_BUFFER, handle);
+ return Void();
+ }
+ }
+ Error err = mHal.exportHandle(buffer, handle);
+
+ hidl_cb(err, handle);
return Void();
}
diff --git a/graphics/allocator/2.0/types.hal b/graphics/allocator/2.0/types.hal
index 23b7345..6081db9 100644
--- a/graphics/allocator/2.0/types.hal
+++ b/graphics/allocator/2.0/types.hal
@@ -136,36 +136,5 @@
/* bits 48-63 are reserved for vendor extensions */
};
-/*
- * Copied from android_pixel_format_t.
- *
- * TODO(olv) copy comments as well and have android_pixel_format_t generated
- */
-@export(name="android_pixel_format", value_prefix="HAL_PIXEL_FORMAT_")
-enum PixelFormat : int32_t {
- RGBA_8888 = 1,
- RGBX_8888 = 2,
- RGB_888 = 3,
- RGB_565 = 4,
- BGRA_8888 = 5,
- YV12 = 0x32315659,
- Y8 = 0x20203859,
- Y16 = 0x20363159,
- RAW16 = 0x20,
- RAW10 = 0x25,
- RAW12 = 0x26,
- RAW_OPAQUE = 0x24,
- BLOB = 0x21,
- IMPLEMENTATION_DEFINED = 0x22,
- YCbCr_420_888 = 0x23,
- YCbCr_422_888 = 0x27,
- YCbCr_444_888 = 0x28,
- FLEX_RGB_888 = 0x29,
- FLEX_RGBA_8888 = 0x2A,
- YCbCr_422_SP = 0x10,
- YCrCb_420_SP = 0x11,
- YCbCr_422_I = 0x14,
-};
-
typedef uint64_t BufferDescriptor;
typedef uint64_t Buffer;
diff --git a/graphics/allocator/2.0/vts/Allocator.vts b/graphics/allocator/2.0/vts/Allocator.vts
new file mode 100644
index 0000000..04d4314
--- /dev/null
+++ b/graphics/allocator/2.0/vts/Allocator.vts
@@ -0,0 +1,215 @@
+component_class: HAL_HIDL
+component_type_version: 2.0
+component_name: "IAllocator"
+
+package: "android.hardware.graphics.allocator"
+
+import: "android.hardware.graphics.allocator@2.0::types"
+
+interface: {
+ attribute: {
+ name: "::android::hardware::graphics::allocator::V2_0::IAllocator::Capability"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "int32_t"
+
+ enumerator: "INVALID"
+ scalar_value: {
+ int32_t: 0
+ }
+ enumerator: "TEST_ALLOCATE"
+ scalar_value: {
+ int32_t: 1
+ }
+ }
+ }
+
+ attribute: {
+ name: "::android::hardware::graphics::allocator::V2_0::IAllocator::BufferDescriptorInfo"
+ type: TYPE_STRUCT
+ struct_value: {
+ name: "width"
+ type: TYPE_SCALAR
+ scalar_type: "uint32_t"
+ }
+ struct_value: {
+ name: "height"
+ type: TYPE_SCALAR
+ scalar_type: "uint32_t"
+ }
+ struct_value: {
+ name: "format"
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::PixelFormat"
+ }
+ struct_value: {
+ name: "producerUsageMask"
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ struct_value: {
+ name: "consumerUsageMask"
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ }
+
+ api: {
+ name: "getCapabilities"
+ return_type_hidl: {
+ type: TYPE_VECTOR
+ vector_value: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::IAllocator::Capability"
+ }
+ }
+ callflow: {
+ entry: true
+ }
+ callflow: {
+ exit: true
+ }
+ callflow: {
+ next: "*"
+ }
+ }
+
+ api: {
+ name: "dumpDebugInfo"
+ return_type_hidl: {
+ type: TYPE_STRING
+ }
+ callflow: {
+ entry: true
+ }
+ callflow: {
+ exit: true
+ }
+ callflow: {
+ next: "*"
+ }
+ }
+
+ api: {
+ name: "createDescriptor"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::Error"
+ }
+ return_type_hidl: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ arg: {
+ type: TYPE_STRUCT
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::IAllocator::BufferDescriptorInfo"
+ }
+ callflow: {
+ entry: true
+ }
+ callflow: {
+ next: "*"
+ }
+ }
+
+ api: {
+ name: "destroyDescriptor"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::Error"
+ }
+ arg: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ callflow: {
+ exit: true
+ }
+ callflow: {
+ next: "*"
+ }
+ }
+
+ api: {
+ name: "testAllocate"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::Error"
+ }
+ arg: {
+ type: TYPE_VECTOR
+ vector_value: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ }
+ callflow: {
+ next: "allocate"
+ }
+ }
+
+ api: {
+ name: "allocate"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::Error"
+ }
+ return_type_hidl: {
+ type: TYPE_VECTOR
+ vector_value: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ }
+ arg: {
+ type: TYPE_VECTOR
+ vector_value: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ }
+ callflow: {
+ next: "exportHandle"
+ }
+ }
+
+ api: {
+ name: "free"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::Error"
+ }
+ arg: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ callflow: {
+ exit: true
+ }
+ callflow: {
+ next: "*"
+ }
+ }
+
+ api: {
+ name: "exportHandle"
+ return_type_hidl: {
+ type: TYPE_ENUM
+ predefined_type: "::android::hardware::graphics::allocator::V2_0::Error"
+ }
+ return_type_hidl: {
+ }
+ arg: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ arg: {
+ type: TYPE_SCALAR
+ scalar_type: "uint64_t"
+ }
+ callflow: {
+ next: "free"
+ }
+ }
+
+}
diff --git a/graphics/allocator/2.0/vts/functional/Android.bp b/graphics/allocator/2.0/vts/functional/Android.bp
new file mode 100644
index 0000000..e1966dc
--- /dev/null
+++ b/graphics/allocator/2.0/vts/functional/Android.bp
@@ -0,0 +1,37 @@
+//
+// 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: "graphics_allocator_hidl_hal_test",
+ gtest: true,
+ srcs: ["graphics_allocator_hidl_hal_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.graphics.allocator@2.0",
+ ],
+ static_libs: ["libgtest"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
diff --git a/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp b/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp
new file mode 100644
index 0000000..bd846c4
--- /dev/null
+++ b/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp
@@ -0,0 +1,313 @@
+/*
+ * 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 "graphics_allocator_hidl_hal_test"
+
+#include <unordered_set>
+
+#include <android-base/logging.h>
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <gtest/gtest.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace tests {
+namespace {
+
+using android::hardware::graphics::common::V1_0::PixelFormat;
+
+#define CHECK_FEATURE_OR_SKIP(FEATURE_NAME) \
+ do { \
+ if (!hasCapability(FEATURE_NAME)) { \
+ std::cout << "[ SKIPPED ] Feature " << #FEATURE_NAME \
+ << " not supported" << std::endl; \
+ return; \
+ } \
+ } while (0)
+
+class TempDescriptor {
+ public:
+ TempDescriptor(const sp<IAllocatorClient>& client,
+ const IAllocatorClient::BufferDescriptorInfo& info)
+ : mClient(client), mError(Error::NO_RESOURCES) {
+ mClient->createDescriptor(
+ info, [&](const auto& tmpError, const auto& tmpDescriptor) {
+ mError = tmpError;
+ mDescriptor = tmpDescriptor;
+ });
+ }
+
+ ~TempDescriptor() {
+ if (mError == Error::NONE) {
+ mClient->destroyDescriptor(mDescriptor);
+ }
+ }
+
+ bool isValid() const { return (mError == Error::NONE); }
+
+ operator BufferDescriptor() const { return mDescriptor; }
+
+ private:
+ sp<IAllocatorClient> mClient;
+ Error mError;
+ BufferDescriptor mDescriptor;
+};
+
+class GraphicsAllocatorHidlTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ mAllocator = IAllocator::getService("gralloc");
+ ASSERT_NE(mAllocator, nullptr);
+
+ mAllocator->createClient([this](const auto& error, const auto& client) {
+ if (error == Error::NONE) {
+ mClient = client;
+ }
+ });
+ ASSERT_NE(mClient, nullptr);
+
+ initCapabilities();
+
+ mDummyDescriptorInfo.width = 64;
+ mDummyDescriptorInfo.height = 64;
+ mDummyDescriptorInfo.layerCount = 1;
+ mDummyDescriptorInfo.format = PixelFormat::RGBA_8888;
+ mDummyDescriptorInfo.producerUsageMask =
+ static_cast<uint64_t>(ProducerUsage::CPU_WRITE);
+ mDummyDescriptorInfo.consumerUsageMask =
+ static_cast<uint64_t>(ConsumerUsage::CPU_READ);
+ }
+
+ void TearDown() override {}
+
+ /**
+ * Initialize the set of supported capabilities.
+ */
+ void initCapabilities() {
+ mAllocator->getCapabilities([this](const auto& capabilities) {
+ std::vector<IAllocator::Capability> caps = capabilities;
+ mCapabilities.insert(caps.cbegin(), caps.cend());
+ });
+ }
+
+ /**
+ * Test whether a capability is supported.
+ */
+ bool hasCapability(IAllocator::Capability capability) const {
+ return (mCapabilities.count(capability) > 0);
+ }
+
+ sp<IAllocator> mAllocator;
+ sp<IAllocatorClient> mClient;
+ IAllocatorClient::BufferDescriptorInfo mDummyDescriptorInfo{};
+
+ private:
+ std::unordered_set<IAllocator::Capability> mCapabilities;
+};
+
+TEST_F(GraphicsAllocatorHidlTest, GetCapabilities) {
+ auto ret = mAllocator->getCapabilities([](const auto& capabilities) {
+ std::vector<IAllocator::Capability> caps = capabilities;
+ for (auto cap : caps) {
+ EXPECT_NE(IAllocator::Capability::INVALID, cap);
+ }
+ });
+
+ ASSERT_TRUE(ret.getStatus().isOk());
+}
+
+TEST_F(GraphicsAllocatorHidlTest, DumpDebugInfo) {
+ auto ret = mAllocator->dumpDebugInfo([](const auto&) {
+ // nothing to do
+ });
+
+ ASSERT_TRUE(ret.getStatus().isOk());
+}
+
+TEST_F(GraphicsAllocatorHidlTest, CreateDestroyDescriptor) {
+ Error error;
+ BufferDescriptor descriptor;
+ auto ret = mClient->createDescriptor(
+ mDummyDescriptorInfo,
+ [&](const auto& tmpError, const auto& tmpDescriptor) {
+ error = tmpError;
+ descriptor = tmpDescriptor;
+ });
+
+ ASSERT_TRUE(ret.getStatus().isOk());
+ ASSERT_EQ(Error::NONE, error);
+
+ auto err_ret = mClient->destroyDescriptor(descriptor);
+ ASSERT_TRUE(err_ret.getStatus().isOk());
+ ASSERT_EQ(Error::NONE, static_cast<Error>(err_ret));
+}
+
+/**
+ * Test testAllocate with a single buffer descriptor.
+ */
+TEST_F(GraphicsAllocatorHidlTest, TestAllocateBasic) {
+ CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
+
+ TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
+ ASSERT_TRUE(descriptor.isValid());
+
+ hidl_vec<BufferDescriptor> descriptors;
+ descriptors.resize(1);
+ descriptors[0] = descriptor;
+
+ auto ret = mClient->testAllocate(descriptors);
+ ASSERT_TRUE(ret.getStatus().isOk());
+
+ auto error = static_cast<Error>(ret);
+ ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
+}
+
+/**
+ * Test testAllocate with two buffer descriptors.
+ */
+TEST_F(GraphicsAllocatorHidlTest, TestAllocateArray) {
+ CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
+
+ TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
+ ASSERT_TRUE(descriptor.isValid());
+
+ hidl_vec<BufferDescriptor> descriptors;
+ descriptors.resize(2);
+ descriptors[0] = descriptor;
+ descriptors[1] = descriptor;
+
+ auto ret = mClient->testAllocate(descriptors);
+ ASSERT_TRUE(ret.getStatus().isOk());
+
+ auto error = static_cast<Error>(ret);
+ ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
+}
+
+/**
+ * Test allocate/free with a single buffer descriptor.
+ */
+TEST_F(GraphicsAllocatorHidlTest, AllocateFreeBasic) {
+ TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
+ ASSERT_TRUE(descriptor.isValid());
+
+ hidl_vec<BufferDescriptor> descriptors;
+ descriptors.resize(1);
+ descriptors[0] = descriptor;
+
+ Error error;
+ std::vector<Buffer> buffers;
+ auto ret = mClient->allocate(
+ descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
+ error = tmpError;
+ buffers = tmpBuffers;
+ });
+
+ ASSERT_TRUE(ret.getStatus().isOk());
+ ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
+ EXPECT_EQ(1u, buffers.size());
+
+ if (!buffers.empty()) {
+ auto err_ret = mClient->free(buffers[0]);
+ EXPECT_TRUE(err_ret.getStatus().isOk());
+ EXPECT_EQ(Error::NONE, static_cast<Error>(err_ret));
+ }
+}
+
+/**
+ * Test allocate/free with an array of buffer descriptors.
+ */
+TEST_F(GraphicsAllocatorHidlTest, AllocateFreeArray) {
+ TempDescriptor descriptor1(mClient, mDummyDescriptorInfo);
+ ASSERT_TRUE(descriptor1.isValid());
+
+ TempDescriptor descriptor2(mClient, mDummyDescriptorInfo);
+ ASSERT_TRUE(descriptor2.isValid());
+
+ hidl_vec<BufferDescriptor> descriptors;
+ descriptors.resize(3);
+ descriptors[0] = descriptor1;
+ descriptors[1] = descriptor1;
+ descriptors[2] = descriptor2;
+
+ Error error;
+ std::vector<Buffer> buffers;
+ auto ret = mClient->allocate(
+ descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
+ error = tmpError;
+ buffers = tmpBuffers;
+ });
+
+ ASSERT_TRUE(ret.getStatus().isOk());
+ ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
+ EXPECT_EQ(descriptors.size(), buffers.size());
+
+ for (auto buf : buffers) {
+ auto err_ret = mClient->free(buf);
+ EXPECT_TRUE(err_ret.getStatus().isOk());
+ EXPECT_EQ(Error::NONE, static_cast<Error>(err_ret));
+ }
+}
+
+TEST_F(GraphicsAllocatorHidlTest, ExportHandle) {
+ TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
+ ASSERT_TRUE(descriptor.isValid());
+
+ hidl_vec<BufferDescriptor> descriptors;
+ descriptors.resize(1);
+ descriptors[0] = descriptor;
+
+ Error error;
+ std::vector<Buffer> buffers;
+ auto ret = mClient->allocate(
+ descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
+ error = tmpError;
+ buffers = tmpBuffers;
+ });
+
+ ASSERT_TRUE(ret.getStatus().isOk());
+ ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
+ ASSERT_EQ(1u, buffers.size());
+
+ ret = mClient->exportHandle(
+ descriptors[0], buffers[0],
+ [&](const auto& tmpError, const auto&) { error = tmpError; });
+ EXPECT_TRUE(ret.getStatus().isOk());
+ EXPECT_EQ(Error::NONE, error);
+
+ auto err_ret = mClient->free(buffers[0]);
+ EXPECT_TRUE(err_ret.getStatus().isOk());
+ EXPECT_EQ(Error::NONE, static_cast<Error>(err_ret));
+}
+
+} // namespace anonymous
+} // namespace tests
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // 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/graphics/allocator/2.0/vts/types.vts b/graphics/allocator/2.0/vts/types.vts
new file mode 100644
index 0000000..ac1bf3f
--- /dev/null
+++ b/graphics/allocator/2.0/vts/types.vts
@@ -0,0 +1,231 @@
+component_class: HAL_HIDL
+component_type_version: 2.0
+component_name: "types"
+
+package: "android.hardware.graphics.allocator"
+
+
+attribute: {
+ name: "::android::hardware::graphics::allocator::V2_0::Error"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "int32_t"
+
+ enumerator: "NONE"
+ scalar_value: {
+ int32_t: 0
+ }
+ enumerator: "BAD_DESCRIPTOR"
+ scalar_value: {
+ int32_t: 1
+ }
+ enumerator: "BAD_BUFFER"
+ scalar_value: {
+ int32_t: 2
+ }
+ enumerator: "BAD_VALUE"
+ scalar_value: {
+ int32_t: 3
+ }
+ enumerator: "NOT_SHARED"
+ scalar_value: {
+ int32_t: 4
+ }
+ enumerator: "NO_RESOURCES"
+ scalar_value: {
+ int32_t: 5
+ }
+ enumerator: "UNDEFINED"
+ scalar_value: {
+ int32_t: 6
+ }
+ enumerator: "UNSUPPORTED"
+ scalar_value: {
+ int32_t: 7
+ }
+ }
+}
+
+attribute: {
+ name: "::android::hardware::graphics::allocator::V2_0::ProducerUsage"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "uint64_t"
+
+ enumerator: "CPU_READ"
+ scalar_value: {
+ uint64_t: 2
+ }
+ enumerator: "CPU_READ_OFTEN"
+ scalar_value: {
+ uint64_t: 4
+ }
+ enumerator: "CPU_WRITE"
+ scalar_value: {
+ uint64_t: 32
+ }
+ enumerator: "CPU_WRITE_OFTEN"
+ scalar_value: {
+ uint64_t: 64
+ }
+ enumerator: "GPU_RENDER_TARGET"
+ scalar_value: {
+ uint64_t: 512
+ }
+ enumerator: "PROTECTED"
+ scalar_value: {
+ uint64_t: 16384
+ }
+ enumerator: "CAMERA"
+ scalar_value: {
+ uint64_t: 131072
+ }
+ enumerator: "VIDEO_DECODER"
+ scalar_value: {
+ uint64_t: 4194304
+ }
+ }
+}
+
+attribute: {
+ name: "::android::hardware::graphics::allocator::V2_0::ConsumerUsage"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "uint64_t"
+
+ enumerator: "CPU_READ"
+ scalar_value: {
+ uint64_t: 2
+ }
+ enumerator: "CPU_READ_OFTEN"
+ scalar_value: {
+ uint64_t: 4
+ }
+ enumerator: "GPU_TEXTURE"
+ scalar_value: {
+ uint64_t: 256
+ }
+ enumerator: "HWCOMPOSER"
+ scalar_value: {
+ uint64_t: 2048
+ }
+ enumerator: "CLIENT_TARGET"
+ scalar_value: {
+ uint64_t: 4096
+ }
+ enumerator: "CURSOR"
+ scalar_value: {
+ uint64_t: 32768
+ }
+ enumerator: "VIDEO_ENCODER"
+ scalar_value: {
+ uint64_t: 65536
+ }
+ enumerator: "CAMERA"
+ scalar_value: {
+ uint64_t: 262144
+ }
+ enumerator: "RENDERSCRIPT"
+ scalar_value: {
+ uint64_t: 1048576
+ }
+ }
+}
+
+attribute: {
+ name: "::android::hardware::graphics::allocator::V2_0::PixelFormat"
+ type: TYPE_ENUM
+ enum_value: {
+ scalar_type: "int32_t"
+
+ enumerator: "RGBA_8888"
+ scalar_value: {
+ int32_t: 1
+ }
+ enumerator: "RGBX_8888"
+ scalar_value: {
+ int32_t: 2
+ }
+ enumerator: "RGB_888"
+ scalar_value: {
+ int32_t: 3
+ }
+ enumerator: "RGB_565"
+ scalar_value: {
+ int32_t: 4
+ }
+ enumerator: "BGRA_8888"
+ scalar_value: {
+ int32_t: 5
+ }
+ enumerator: "YV12"
+ scalar_value: {
+ int32_t: 842094169
+ }
+ enumerator: "Y8"
+ scalar_value: {
+ int32_t: 538982489
+ }
+ enumerator: "Y16"
+ scalar_value: {
+ int32_t: 540422489
+ }
+ enumerator: "RAW16"
+ scalar_value: {
+ int32_t: 32
+ }
+ enumerator: "RAW10"
+ scalar_value: {
+ int32_t: 37
+ }
+ enumerator: "RAW12"
+ scalar_value: {
+ int32_t: 38
+ }
+ enumerator: "RAW_OPAQUE"
+ scalar_value: {
+ int32_t: 36
+ }
+ enumerator: "BLOB"
+ scalar_value: {
+ int32_t: 33
+ }
+ enumerator: "IMPLEMENTATION_DEFINED"
+ scalar_value: {
+ int32_t: 34
+ }
+ enumerator: "YCbCr_420_888"
+ scalar_value: {
+ int32_t: 35
+ }
+ enumerator: "YCbCr_422_888"
+ scalar_value: {
+ int32_t: 39
+ }
+ enumerator: "YCbCr_444_888"
+ scalar_value: {
+ int32_t: 40
+ }
+ enumerator: "FLEX_RGB_888"
+ scalar_value: {
+ int32_t: 41
+ }
+ enumerator: "FLEX_RGBA_8888"
+ scalar_value: {
+ int32_t: 42
+ }
+ enumerator: "YCbCr_422_SP"
+ scalar_value: {
+ int32_t: 16
+ }
+ enumerator: "YCrCb_420_SP"
+ scalar_value: {
+ int32_t: 17
+ }
+ enumerator: "YCbCr_422_I"
+ scalar_value: {
+ int32_t: 20
+ }
+ }
+}
+
diff --git a/graphics/common/1.0/Android.bp b/graphics/common/1.0/Android.bp
index 6c6ebbe..812cf50 100644
--- a/graphics/common/1.0/Android.bp
+++ b/graphics/common/1.0/Android.bp
@@ -33,6 +33,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/graphics/composer/2.1/Android.bp b/graphics/composer/2.1/Android.bp
index 8742e88..a2e15f4 100644
--- a/graphics/composer/2.1/Android.bp
+++ b/graphics/composer/2.1/Android.bp
@@ -49,15 +49,16 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
- "android.hardware.graphics.allocator@2.0",
+ "android.hardware.graphics.common@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
- "android.hardware.graphics.allocator@2.0",
+ "android.hardware.graphics.common@1.0",
],
}
diff --git a/graphics/composer/2.1/IComposer.hal b/graphics/composer/2.1/IComposer.hal
index 7bfa22b..dd61c11 100644
--- a/graphics/composer/2.1/IComposer.hal
+++ b/graphics/composer/2.1/IComposer.hal
@@ -16,7 +16,7 @@
package android.hardware.graphics.composer@2.1;
-import android.hardware.graphics.allocator@2.0::PixelFormat;
+import android.hardware.graphics.common@1.0;
import IComposerCallback;
interface IComposer {
@@ -845,7 +845,7 @@
*/
/*
- * Asynchonously sets the position of a cursor layer.
+ * Asynchronously sets the position of a cursor layer.
*
* Prior to validateDisplay, a layer may be marked as Composition::CURSOR.
* If validation succeeds (i.e., the device does not request a composition
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
index d45a955..36c6e54 100644
--- a/graphics/composer/2.1/default/Hwc.cpp
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -37,7 +37,12 @@
namespace V2_1 {
namespace implementation {
-using android::hardware::graphics::allocator::V2_0::PixelFormat;
+using android::hardware::graphics::common::V1_0::PixelFormat;
+using android::hardware::graphics::common::V1_0::Transform;
+using android::hardware::graphics::common::V1_0::Dataspace;
+using android::hardware::graphics::common::V1_0::ColorMode;
+using android::hardware::graphics::common::V1_0::ColorTransform;
+using android::hardware::graphics::common::V1_0::Hdr;
namespace {
@@ -313,15 +318,15 @@
presentDisplay_cb hidl_cb) override;
Return<Error> setActiveConfig(Display display, Config config) override;
Return<Error> setClientTarget(Display display,
- const native_handle_t* target,
- const native_handle_t* acquireFence,
+ const hidl_handle& target,
+ const hidl_handle& acquireFence,
Dataspace dataspace, const hidl_vec<Rect>& damage) override;
Return<Error> setColorMode(Display display, ColorMode mode) override;
Return<Error> setColorTransform(Display display,
const hidl_vec<float>& matrix, ColorTransform hint) override;
Return<Error> setOutputBuffer(Display display,
- const native_handle_t* buffer,
- const native_handle_t* releaseFence) override;
+ const hidl_handle& buffer,
+ const hidl_handle& releaseFence) override;
Return<Error> setPowerMode(Display display, PowerMode mode) override;
Return<Error> setVsyncEnabled(Display display, Vsync enabled) override;
Return<void> validateDisplay(Display display,
@@ -329,8 +334,8 @@
Return<Error> setCursorPosition(Display display,
Layer layer, int32_t x, int32_t y) override;
Return<Error> setLayerBuffer(Display display,
- Layer layer, const native_handle_t* buffer,
- const native_handle_t* acquireFence) override;
+ Layer layer, const hidl_handle& buffer,
+ const hidl_handle& acquireFence) override;
Return<Error> setLayerSurfaceDamage(Display display,
Layer layer, const hidl_vec<Rect>& damage) override;
Return<Error> setLayerBlendMode(Display display,
@@ -346,7 +351,7 @@
Return<Error> setLayerPlaneAlpha(Display display,
Layer layer, float alpha) override;
Return<Error> setLayerSidebandStream(Display display,
- Layer layer, const native_handle_t* stream) override;
+ Layer layer, const hidl_handle& stream) override;
Return<Error> setLayerSourceCrop(Display display,
Layer layer, const FRect& crop) override;
Return<Error> setLayerTransform(Display display,
@@ -1022,17 +1027,18 @@
}
Return<Error> HwcHal::setClientTarget(Display display,
- const native_handle_t* target,
- const native_handle_t* acquireFence,
+ const hidl_handle& target,
+ const hidl_handle& acquireFence,
Dataspace dataspace, const hidl_vec<Rect>& damage)
{
- if (!sHandleImporter.importBuffer(target)) {
+ const native_handle_t* targetHandle = target.getNativeHandle();
+ if (!sHandleImporter.importBuffer(targetHandle)) {
return Error::NO_RESOURCES;
}
int32_t fence;
if (!sHandleImporter.importFence(acquireFence, fence)) {
- sHandleImporter.freeBuffer(target);
+ sHandleImporter.freeBuffer(targetHandle);
return Error::NO_RESOURCES;
}
@@ -1040,13 +1046,13 @@
reinterpret_cast<const hwc_rect_t*>(&damage[0]) };
int32_t error = mDispatch.setClientTarget(mDevice, display,
- target, fence, static_cast<int32_t>(dataspace),
+ targetHandle, fence, static_cast<int32_t>(dataspace),
damage_region);
if (error == HWC2_ERROR_NONE) {
std::lock_guard<std::mutex> lock(mDisplayMutex);
auto dpy = mDisplays.find(display);
- dpy->second.ClientTarget = target;
+ dpy->second.ClientTarget = targetHandle;
} else {
sHandleImporter.freeBuffer(target);
sHandleImporter.closeFence(fence);
@@ -1071,28 +1077,29 @@
}
Return<Error> HwcHal::setOutputBuffer(Display display,
- const native_handle_t* buffer,
- const native_handle_t* releaseFence)
+ const hidl_handle& buffer,
+ const hidl_handle& releaseFence)
{
- if (!sHandleImporter.importBuffer(buffer)) {
+ const native_handle_t* bufferHandle = buffer.getNativeHandle();
+ if (!sHandleImporter.importBuffer(bufferHandle)) {
return Error::NO_RESOURCES;
}
int32_t fence;
if (!sHandleImporter.importFence(releaseFence, fence)) {
- sHandleImporter.freeBuffer(buffer);
+ sHandleImporter.freeBuffer(bufferHandle);
return Error::NO_RESOURCES;
}
int32_t error = mDispatch.setOutputBuffer(mDevice,
- display, buffer, fence);
+ display, bufferHandle, fence);
if (error == HWC2_ERROR_NONE) {
std::lock_guard<std::mutex> lock(mDisplayMutex);
auto dpy = mDisplays.find(display);
- dpy->second.OutputBuffer = buffer;
+ dpy->second.OutputBuffer = bufferHandle;
} else {
- sHandleImporter.freeBuffer(buffer);
+ sHandleImporter.freeBuffer(bufferHandle);
}
// unlike in setClientTarget, fence is owned by us and is always closed
@@ -1137,28 +1144,29 @@
}
Return<Error> HwcHal::setLayerBuffer(Display display,
- Layer layer, const native_handle_t* buffer,
- const native_handle_t* acquireFence)
+ Layer layer, const hidl_handle& buffer,
+ const hidl_handle& acquireFence)
{
- if (!sHandleImporter.importBuffer(buffer)) {
+ const native_handle_t* bufferHandle = buffer.getNativeHandle();
+ if (!sHandleImporter.importBuffer(bufferHandle)) {
return Error::NO_RESOURCES;
}
int32_t fence;
if (!sHandleImporter.importFence(acquireFence, fence)) {
- sHandleImporter.freeBuffer(buffer);
+ sHandleImporter.freeBuffer(bufferHandle);
return Error::NO_RESOURCES;
}
int32_t error = mDispatch.setLayerBuffer(mDevice,
- display, layer, buffer, fence);
+ display, layer, bufferHandle, fence);
if (error == HWC2_ERROR_NONE) {
std::lock_guard<std::mutex> lock(mDisplayMutex);
auto dpy = mDisplays.find(display);
- dpy->second.LayerBuffers[layer] = buffer;
+ dpy->second.LayerBuffers[layer] = bufferHandle;
} else {
- sHandleImporter.freeBuffer(buffer);
+ sHandleImporter.freeBuffer(bufferHandle);
sHandleImporter.closeFence(fence);
}
@@ -1225,21 +1233,22 @@
}
Return<Error> HwcHal::setLayerSidebandStream(Display display,
- Layer layer, const native_handle_t* stream)
+ Layer layer, const hidl_handle& stream)
{
- if (!sHandleImporter.importBuffer(stream)) {
+ const native_handle_t* streamHandle = stream.getNativeHandle();
+ if (!sHandleImporter.importBuffer(streamHandle)) {
return Error::NO_RESOURCES;
}
int32_t error = mDispatch.setLayerSidebandStream(mDevice,
- display, layer, stream);
+ display, layer, streamHandle);
if (error == HWC2_ERROR_NONE) {
std::lock_guard<std::mutex> lock(mDisplayMutex);
auto dpy = mDisplays.find(display);
- dpy->second.LayerSidebandStreams[layer] = stream;
+ dpy->second.LayerSidebandStreams[layer] = streamHandle;
} else {
- sHandleImporter.freeBuffer(stream);
+ sHandleImporter.freeBuffer(streamHandle);
}
return static_cast<Error>(error);
diff --git a/graphics/composer/2.1/types.hal b/graphics/composer/2.1/types.hal
index 3c591b3..9c2e1d7 100644
--- a/graphics/composer/2.1/types.hal
+++ b/graphics/composer/2.1/types.hal
@@ -32,132 +32,3 @@
typedef uint32_t Config;
typedef uint64_t Display;
typedef uint64_t Layer;
-
-/*
- * Copied from android_transform_t
- *
- * TODO(olv) copy comments over and generate android_transform_t
- */
-enum Transform : int32_t {
- FLIP_H = 0x1,
- FLIP_V = 0x2,
- ROT_90 = 0x4,
- ROT_180 = 0x3,
- ROT_270 = 0x7,
- RESERVED = 0x8,
-};
-
-/*
- * Copied from android_color_mode_t
- *
- * TODO(olv) copy comments over and generate android_color_mode_t
- */
-enum ColorMode : int32_t {
- NATIVE = 0,
- STANDARD_BT601_625 = 1,
- STANDARD_BT601_625_UNADJUSTED = 2,
- STANDARD_BT601_525 = 3,
- STANDARD_BT601_525_UNADJUSTED = 4,
- STANDARD_BT709 = 5,
- DCI_P3 = 6,
- SRGB = 7,
- ADOBE_RGB = 8,
-};
-
-/*
- * Copied from android_color_transform_t
- *
- * TODO(olv) copy comments over and generate android_color_transform_t
- */
-enum ColorTransform : int32_t {
- IDENTITY = 0,
- ARBITRARY_MATRIX = 1,
- VALUE_INVERSE = 2,
- GRAYSCALE = 3,
- CORRECT_PROTANOPIA = 4,
- CORRECT_DEUTERANOPIA = 5,
- CORRECT_TRITANOPIA = 6
-};
-
-/*
- * Copied from android_dataspace_t
- *
- * TODO(olv) copy comments over and generate android_dataspace_t
- */
-enum Dataspace : int32_t {
- UNKNOWN = 0x0,
- ARBITRARY = 0x1,
-
- STANDARD_SHIFT = 16,
- STANDARD_MASK = 63 << STANDARD_SHIFT,
- STANDARD_UNSPECIFIED = 0 << STANDARD_SHIFT,
- STANDARD_BT709 = 1 << STANDARD_SHIFT,
- STANDARD_BT601_625 = 2 << STANDARD_SHIFT,
- STANDARD_BT601_625_UNADJUSTED = 3 << STANDARD_SHIFT,
- STANDARD_BT601_525 = 4 << STANDARD_SHIFT,
- STANDARD_BT601_525_UNADJUSTED = 5 << STANDARD_SHIFT,
- STANDARD_BT2020 = 6 << STANDARD_SHIFT,
- STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << STANDARD_SHIFT,
- STANDARD_BT470M = 8 << STANDARD_SHIFT,
- STANDARD_FILM = 9 << STANDARD_SHIFT,
-
- TRANSFER_SHIFT = 22,
- TRANSFER_MASK = 31 << TRANSFER_SHIFT,
- TRANSFER_UNSPECIFIED = 0 << TRANSFER_SHIFT,
- TRANSFER_LINEAR = 1 << TRANSFER_SHIFT,
- TRANSFER_SRGB = 2 << TRANSFER_SHIFT,
- TRANSFER_SMPTE_170M = 3 << TRANSFER_SHIFT,
- TRANSFER_GAMMA2_2 = 4 << TRANSFER_SHIFT,
- TRANSFER_GAMMA2_8 = 5 << TRANSFER_SHIFT,
- TRANSFER_ST2084 = 6 << TRANSFER_SHIFT,
- TRANSFER_HLG = 7 << TRANSFER_SHIFT,
-
- RANGE_SHIFT = 27,
- RANGE_MASK = 7 << RANGE_SHIFT,
- RANGE_UNSPECIFIED = 0 << RANGE_SHIFT,
- RANGE_FULL = 1 << RANGE_SHIFT,
- RANGE_LIMITED = 2 << RANGE_SHIFT,
-
- SRGB_LINEAR = 0x200,
- V0_SRGB_LINEAR = STANDARD_BT709 |
- TRANSFER_LINEAR |
- RANGE_FULL,
-
- SRGB = 0x201,
- V0_SRGB = STANDARD_BT709 |
- TRANSFER_SRGB |
- RANGE_FULL,
-
- JFIF = 0x101,
- V0_JFIF = STANDARD_BT601_625 |
- TRANSFER_SMPTE_170M |
- RANGE_FULL,
-
- BT601_625 = 0x102,
- V0_BT601_625 = STANDARD_BT601_625 |
- TRANSFER_SMPTE_170M |
- RANGE_LIMITED,
-
- BT601_525 = 0x103,
- V0_BT601_525 = STANDARD_BT601_525 |
- TRANSFER_SMPTE_170M |
- RANGE_LIMITED,
-
- BT709 = 0x104,
- V0_BT709 = STANDARD_BT709 |
- TRANSFER_SMPTE_170M |
- RANGE_LIMITED,
-
- DEPTH = 0x1000,
-};
-
-/*
- * Copied from android_hdr_t
- *
- * TODO(olv) copy comments over and generate android_hdr_t
- */
-enum Hdr : int32_t {
- DOLBY_VISION = 1,
- HDR10 = 2,
- HLG = 3,
-};
diff --git a/graphics/mapper/2.0/include/android/hardware/graphics/mapper/2.0/types.h b/graphics/mapper/2.0/include/android/hardware/graphics/mapper/2.0/types.h
index 63a6b16..4054b82 100644
--- a/graphics/mapper/2.0/include/android/hardware/graphics/mapper/2.0/types.h
+++ b/graphics/mapper/2.0/include/android/hardware/graphics/mapper/2.0/types.h
@@ -20,6 +20,7 @@
#include <type_traits>
#include <android/hardware/graphics/allocator/2.0/types.h>
+#include <android/hardware/graphics/common/1.0/types.h>
namespace android {
namespace hardware {
@@ -28,9 +29,9 @@
namespace V2_0 {
using android::hardware::graphics::allocator::V2_0::Error;
-using android::hardware::graphics::allocator::V2_0::PixelFormat;
using android::hardware::graphics::allocator::V2_0::ProducerUsage;
using android::hardware::graphics::allocator::V2_0::ConsumerUsage;
+using android::hardware::graphics::common::V1_0::PixelFormat;
/*
* Structures for describing flexible YUVA/RGBA formats for consumption by
diff --git a/health/1.0/Android.bp b/health/1.0/Android.bp
index 81793d5..fb92306 100644
--- a/health/1.0/Android.bp
+++ b/health/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/health/Android.mk b/health/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/health/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/light/2.0/Android.bp b/light/2.0/Android.bp
index 23c7c9c..5d01b3c 100644
--- a/light/2.0/Android.bp
+++ b/light/2.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
new file mode 100644
index 0000000..c3475a6
--- /dev/null
+++ b/light/2.0/vts/functional/Android.bp
@@ -0,0 +1,32 @@
+//
+// 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: "light_hidl_hal_test",
+ gtest: true,
+ srcs: ["light_hidl_hal_test.cpp"],
+ shared_libs: [
+ "liblog",
+ "libutils",
+ "android.hardware.light@2.0",
+ ],
+ static_libs: ["libgtest"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
+
diff --git a/light/2.0/vts/functional/light_hidl_hal_test.cpp b/light/2.0/vts/functional/light_hidl_hal_test.cpp
new file mode 100644
index 0000000..db67467
--- /dev/null
+++ b/light/2.0/vts/functional/light_hidl_hal_test.cpp
@@ -0,0 +1,103 @@
+/*
+ * 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 "light_hidl_hal_test"
+
+#include <android-base/logging.h>
+#include <android/hardware/light/2.0/ILight.h>
+#include <android/hardware/light/2.0/types.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+
+using ::android::hardware::light::V2_0::Brightness;
+using ::android::hardware::light::V2_0::Flash;
+using ::android::hardware::light::V2_0::ILight;
+using ::android::hardware::light::V2_0::LightState;
+using ::android::hardware::light::V2_0::Status;
+using ::android::hardware::light::V2_0::Type;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+#define LIGHT_SERVICE_NAME "light"
+
+#define EXPECT_OK(ret) EXPECT_TRUE(ret.getStatus().isOk())
+
+// The main test class for VIBRATOR HIDL HAL.
+class LightHidlTest : public ::testing::Test {
+public:
+ virtual void SetUp() override {
+ light = ILight::getService(LIGHT_SERVICE_NAME);
+
+ ASSERT_NE(light, nullptr);
+ ALOGI("Test is remote: %d", light->isRemote());
+ }
+
+ virtual void TearDown() override {}
+
+ sp<ILight> light;
+};
+
+// A class for test environment setup (kept since this file is a template).
+class LightHidlEnvironment : public ::testing::Environment {
+public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+private:
+};
+
+const static LightState kWhite = {
+ .color = 0xFFFFFFFF,
+ .flashMode = Flash::TIMED,
+ .flashOnMs = 100,
+ .flashOffMs = 50,
+ .brightnessMode = Brightness::USER,
+};
+
+const static LightState kOff = {
+ .color = 0x00000000,
+ .flashMode = Flash::NONE,
+ .flashOnMs = 0,
+ .flashOffMs = 0,
+ .brightnessMode = Brightness::USER,
+};
+
+/**
+ * Ensure all lights which are reported as supported work.
+ */
+TEST_F(LightHidlTest, TestSupported) {
+ EXPECT_OK(light->getSupportedTypes([this](const hidl_vec<Type> &supportedTypes) {
+ for (size_t i = 0; i < supportedTypes.size(); i++) {
+ EXPECT_OK(light->setLight(supportedTypes[i], kWhite));
+ }
+
+ usleep(500000);
+
+ for (size_t i = 0; i < supportedTypes.size(); i++) {
+ EXPECT_OK(light->setLight(supportedTypes[i], kOff));
+ }
+ }));
+}
+
+int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(new LightHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
diff --git a/light/Android.bp b/light/Android.bp
index c12cd4f..8d2c986 100644
--- a/light/Android.bp
+++ b/light/Android.bp
@@ -1,4 +1,5 @@
// This is an autogenerated file, do not edit.
subdirs = [
"2.0",
+ "2.0/vts/functional",
]
diff --git a/light/Android.mk b/light/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/light/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/media/1.0/Android.bp b/media/1.0/Android.bp
index 5a63cac..0bc002f 100644
--- a/media/1.0/Android.bp
+++ b/media/1.0/Android.bp
@@ -33,6 +33,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.graphics.common@1.0",
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index b8afb98..23b09a8b 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -73,6 +73,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.graphics.common@1.0",
diff --git a/memtrack/1.0/Android.bp b/memtrack/1.0/Android.bp
index c5727c1..f942367 100644
--- a/memtrack/1.0/Android.bp
+++ b/memtrack/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/memtrack/Android.mk b/memtrack/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/memtrack/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/Android.bp b/nfc/1.0/Android.bp
index 9584636..9b8b095 100644
--- a/nfc/1.0/Android.bp
+++ b/nfc/1.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/nfc/1.0/INfc.hal b/nfc/1.0/INfc.hal
index f003b2c..1c952db 100644
--- a/nfc/1.0/INfc.hal
+++ b/nfc/1.0/INfc.hal
@@ -33,6 +33,8 @@
* If open() returns any other value, the NCI stack will stop.
*
*/
+ @entry
+ @callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"})
open(INfcClientCallback clientCallback) generates (int32_t retval);
/*
@@ -41,6 +43,8 @@
* This method may queue writes and return immediately. The only
* requirement is that the writes are executed in order.
*/
+ @callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle",
+ "controlGranted"})
write(NfcData data) generates (int32_t retval);
/*
@@ -53,6 +57,7 @@
* If coreInitialized() returns any other value, the NCI stack will continue
* immediately.
*/
+ @callflow(next={"write", "prediscover", "close"})
coreInitialized(NfcData data) generates (int32_t retval);
/*
@@ -66,11 +71,13 @@
* If prediscover() returns any other value, the NCI stack will start
* RF discovery immediately.
*/
+ @callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"})
prediscover() generates (int32_t retval);
/*
* Close the NFC controller. Should free all resources.
*/
+ @exit
close() generates (int32_t retval);
/*
@@ -79,11 +86,13 @@
* Must only be called when there are no NCI commands pending.
* NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
*/
+ @callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"})
controlGranted() generates (int32_t retval);
/*
* Restart controller by power cyle;
* NfcEvent.OPEN_CPLT will notify when operation is complete.
*/
+ @callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"})
powerCycle() generates (int32_t retval);
};
diff --git a/nfc/1.0/default/Nfc.h b/nfc/1.0/default/Nfc.h
index e596495..5257636 100644
--- a/nfc/1.0/default/Nfc.h
+++ b/nfc/1.0/default/Nfc.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_nfc_V1_0_Nfc_H_
-#define HIDL_GENERATED_android_hardware_nfc_V1_0_Nfc_H_
+#ifndef ANDROID_HARDWARE_NFC_V1_0_NFC_H
+#define ANDROID_HARDWARE_NFC_V1_0_NFC_H
#include <android/hardware/nfc/1.0/INfc.h>
#include <hidl/Status.h>
@@ -56,4 +56,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_nfc_V1_0_Nfc_H_
+#endif // ANDROID_HARDWARE_NFC_V1_0_NFC_H
diff --git a/nfc/1.0/vts/Android.mk b/nfc/1.0/vts/Android.mk
index 04884b7..b008b63 100644
--- a/nfc/1.0/vts/Android.mk
+++ b/nfc/1.0/vts/Android.mk
@@ -110,3 +110,5 @@
LOCAL_PROTOC_OPTIMIZE_TYPE := full
include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/nfc/1.0/vts/functional/Android.mk b/nfc/1.0/vts/functional/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
index e215704..4d7c557 100644
--- a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
+++ b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
@@ -17,63 +17,145 @@
#define LOG_TAG "nfc_hidl_hal_test"
#include <android-base/logging.h>
-#include <hardware/nfc.h>
-#include <android/hardware/nfc/1.0/types.h>
#include <android/hardware/nfc/1.0/INfc.h>
#include <android/hardware/nfc/1.0/INfcClientCallback.h>
+#include <android/hardware/nfc/1.0/types.h>
+#include <hardware/nfc.h>
+#include <hwbinder/ProcessState.h>
#include <gtest/gtest.h>
+#include <chrono>
+#include <condition_variable>
+#include <mutex>
+using ::android::hardware::ProcessState;
using ::android::hardware::nfc::V1_0::INfc;
using ::android::hardware::nfc::V1_0::INfcClientCallback;
+using ::android::hardware::nfc::V1_0::NfcEvent;
+using ::android::hardware::nfc::V1_0::NfcStatus;
+using ::android::hardware::nfc::V1_0::NfcData;
using ::android::hardware::Return;
using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
using ::android::sp;
#define NFC_NCI_SERVICE_NAME "nfc_nci"
+/* NCI Commands */
+#define CORE_RESET_CMD \
+ { 0x20, 0x00, 0x01, 0x00 }
+#define CORE_CONN_CREATE_CMD \
+ { 0x20, 0x04, 0x02, 0x01, 0x00 }
+#define INVALID_COMMAND \
+ { 0x20, 0x00, 0x00 }
+#define FAULTY_DATA_PACKET \
+ { 0x00, 0x00, 0xFF }
-// Simple NfcClientCallback used as part of testing.
-class NfcClientCallback : public INfcClientCallback {
- public:
- NfcClientCallback() {};
+#define LOOP_BACK_HEADER_SIZE 3
+#define SYNTAX_ERROR 5
+#define NUMBER_LOOPS 3922
+#define VERSION 0x11
+#define TIMEOUT_PERIOD 5
- virtual ~NfcClientCallback() = default;
-
- // sendEvent callback function - currently no-op.
- Return<void> sendEvent(
- ::android::hardware::nfc::V1_0::NfcEvent event,
- ::android::hardware::nfc::V1_0::NfcStatus event_status) override {
- return Void();
- };
-
- // sendData callback function - currently no-op.
- Return<void> sendData(const ::android::hardware::nfc::V1_0::NfcData &data ) override {
- ::android::hardware::nfc::V1_0::NfcData copy = data;
- return Void();
- };
-};
-
+static bool passthrough = true;
// The main test class for NFC HIDL HAL.
class NfcHidlTest : public ::testing::Test {
public:
virtual void SetUp() override {
- // currently test passthrough mode only
- nfc = INfc::getService(NFC_NCI_SERVICE_NAME, true);
- ASSERT_NE(nfc, nullptr);
+ nfc_ = INfc::getService(NFC_NCI_SERVICE_NAME, passthrough);
+ ASSERT_NE(nfc_, nullptr);
- nfc_cb = new NfcClientCallback();
- ASSERT_NE(nfc_cb, nullptr);
+ // TODO:b/31748996
+ if (nfc_->isRemote()) {
+ ProcessState::self()->setThreadPoolMaxThreadCount(1);
+ ProcessState::self()->startThreadPool();
+ }
+
+ nfc_cb_ = new NfcClientCallback(*this);
+ ASSERT_NE(nfc_cb_, nullptr);
+
+ count = 0;
+ last_event_ = NfcEvent::ERROR;
+ last_status_ = NfcStatus::FAILED;
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+ // Wait for OPEN_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
}
- virtual void TearDown() override {}
+ virtual void TearDown() override {
+ EXPECT_EQ(NfcStatus::OK, nfc_->close());
+ // Wait for CLOSE_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+ }
- sp<INfc> nfc;
- sp<INfcClientCallback> nfc_cb;
+ /* Used as a mechanism to inform the test about data/event callback */
+ inline void notify() {
+ std::unique_lock<std::mutex> lock(mtx);
+ count++;
+ cv.notify_one();
+ }
+
+ /* Test code calls this function to wait for data/event callback */
+ inline std::cv_status wait() {
+ std::unique_lock<std::mutex> lock(mtx);
+
+ std::cv_status status = std::cv_status::no_timeout;
+ auto now = std::chrono::system_clock::now();
+ while (count == 0) {
+ status = cv.wait_until(lock, now + std::chrono::seconds(TIMEOUT_PERIOD));
+ if (status == std::cv_status::timeout) return status;
+ }
+ count--;
+ return status;
+ }
+
+ /* Callback class for data & Event. */
+ class NfcClientCallback : public INfcClientCallback {
+ NfcHidlTest& parent_;
+
+ public:
+ NfcClientCallback(NfcHidlTest& parent) : parent_(parent){};
+
+ virtual ~NfcClientCallback() = default;
+
+ /* sendEvent callback function - Records the Event & Status
+ * and notifies the TEST
+ **/
+ Return<void> sendEvent(NfcEvent event, NfcStatus event_status) override {
+ parent_.last_event_ = event;
+ parent_.last_status_ = event_status;
+ parent_.notify();
+ return Void();
+ };
+
+ /* sendData callback function. Records the data and notifies the TEST*/
+ Return<void> sendData(const NfcData& data) override {
+ size_t size = parent_.last_data_.size();
+ parent_.last_data_.resize(size + 1);
+ parent_.last_data_[size] = data;
+ parent_.notify();
+ return Void();
+ };
+ };
+
+ sp<INfc> nfc_;
+ sp<INfcClientCallback> nfc_cb_;
+ NfcEvent last_event_;
+ NfcStatus last_status_;
+ hidl_vec<NfcData> last_data_;
+
+ private:
+ std::mutex mtx;
+ std::condition_variable cv;
+ int count;
};
-
// A class for test environment setup (kept since this file is a template).
class NfcHidlEnvironment : public ::testing::Environment {
public:
@@ -83,15 +165,201 @@
private:
};
-TEST_F(NfcHidlTest, OpenAndClose) {
- EXPECT_EQ(0, (int)nfc->open(nfc_cb));
- EXPECT_EQ(0, (int)nfc->close());
+/*
+ * OpenAndClose:
+ * Makes an open call, waits for NfcEvent.OPEN_CPLT
+ * Immediately calls close() and waits for NfcEvent.CLOSE_CPLT
+ * Since open and close calls are a part of SetUp() and TearDown(),
+ * the function definition is intentionally kept empty
+ */
+TEST_F(NfcHidlTest, OpenAndClose) {}
+
+/*
+ * WriteCoreReset:
+ * Sends CORE_RESET_CMD
+ * Waits for CORE_RESET_RSP
+ * Checks the status and the version number
+ */
+TEST_F(NfcHidlTest, WriteCoreReset) {
+ std::vector<uint8_t> cmd = CORE_RESET_CMD;
+ NfcData data = cmd;
+ EXPECT_EQ(data.size(), nfc_->write(data));
+ // Wait for CORE_RESET_RSP
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(1ul, last_data_.size());
+ EXPECT_EQ(6ul, last_data_[0].size());
+ EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
+ EXPECT_GE(VERSION, last_data_[0][4]);
}
-int main(int argc, char **argv) {
+/*
+ * WriteInvalidCommand:
+ * Sends an invalid command
+ * Waits for response
+ * Checks SYNTAX_ERROR status
+ */
+TEST_F(NfcHidlTest, WriteInvalidCommand) {
+ // Send an Error Command
+ std::vector<uint8_t> cmd = INVALID_COMMAND;
+ NfcData data = cmd;
+ EXPECT_EQ(data.size(), nfc_->write(data));
+ // Wait for RSP
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(1ul, last_data_.size());
+ EXPECT_EQ(4ul, last_data_[0].size());
+ EXPECT_EQ(SYNTAX_ERROR, last_data_[0][3]);
+}
+
+/*
+ * WriteInvalidAndThenValidCommand:
+ * Sends an Faulty Data Packet
+ * Waits for CORE_INTERFACE_ERROR_NTF
+ * Checks SYNTAX_ERROR status
+ * Repeat for 100 times appending 0xFF each time to the packet
+ * Send CORE_CONN_CREATE_CMD for loop-back mode
+ * Check the response
+ */
+TEST_F(NfcHidlTest, WriteInvalidAndThenValidCommand) {
+ // Send an Error Data Packet
+ std::vector<uint8_t> cmd = FAULTY_DATA_PACKET;
+ NfcData data = cmd;
+ size_t size = data.size();
+
+ for (int i = 0; i < 100; i++) {
+ last_data_.resize(0);
+ data.resize(++size);
+ data[size - 1] = 0xFF;
+ EXPECT_EQ(data.size(), nfc_->write(data));
+ // Wait for CORE_INTERFACE_ERROR_NTF
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(1ul, last_data_.size());
+ EXPECT_EQ(5ul, last_data_[0].size());
+ EXPECT_EQ(0x60, last_data_[0][0]);
+ EXPECT_EQ(0x08, last_data_[0][1]);
+ EXPECT_EQ(0x02, last_data_[0][2]);
+ EXPECT_EQ(SYNTAX_ERROR, last_data_[0][3]);
+ }
+
+ cmd = CORE_CONN_CREATE_CMD;
+ data = cmd;
+ last_data_.resize(0);
+ EXPECT_EQ(data.size(), nfc_->write(data));
+ // Wait for CORE_CONN_CREATE_RSP
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(1ul, last_data_.size());
+ EXPECT_EQ(7ul, last_data_[0].size());
+ EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
+}
+/*
+ * Bandwidth:
+ * Sets the loop-back mode using CORE_CONN_CREATE_CMD
+ * Sends max payload size data
+ * Waits for the response
+ * Checks the data received
+ * Repeat to send total of 1Mb data
+ */
+TEST_F(NfcHidlTest, Bandwidth) {
+ std::vector<uint8_t> cmd = CORE_CONN_CREATE_CMD;
+ NfcData data = cmd;
+ EXPECT_EQ(data.size(), nfc_->write(data));
+ // Wait for CORE_CONN_CREATE_RSP
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(1ul, last_data_.size());
+ EXPECT_EQ(7ul, last_data_[0].size());
+ EXPECT_EQ((int)NfcStatus::OK, last_data_[0][3]);
+ uint8_t conn_id = last_data_[0][6];
+ uint32_t max_payload_size = last_data_[0][4];
+
+ for (int loops = 0; loops < NUMBER_LOOPS; loops++) {
+ last_data_.resize(0);
+ data.resize(max_payload_size + LOOP_BACK_HEADER_SIZE);
+ data[0] = conn_id;
+ data[1] = 0x00;
+ data[2] = max_payload_size;
+ for (uint32_t i = 0; i < max_payload_size; i++) {
+ data[i + LOOP_BACK_HEADER_SIZE] = i;
+ }
+ EXPECT_EQ(max_payload_size + LOOP_BACK_HEADER_SIZE, nfc_->write(data));
+ // Wait for data and CORE_CONN_CREDITS_NTF
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ // Check if the same data was recieved back
+ EXPECT_EQ(2ul, last_data_.size());
+ EXPECT_EQ(data.size(), last_data_[0].size());
+ for (size_t i = 0; i < data.size(); i++) {
+ EXPECT_EQ(data[i], last_data_[0][i]);
+ }
+
+ EXPECT_EQ(6ul, last_data_[1].size());
+ // Check if the credit is refilled to 1
+ EXPECT_EQ(1, last_data_[1][5]);
+ }
+}
+
+/*
+ * PowerCycle:
+ * Calls powerCycle()
+ * Waits for NfcEvent.OPEN_CPLT
+ * Checks status
+ */
+TEST_F(NfcHidlTest, PowerCycle) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->powerCycle());
+ // Wait for NfcEvent.OPEN_CPLT
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+}
+
+/*
+ * CoreInitialized:
+ * Calls coreInitialized()
+ * Waits for NfcEvent.POST_INIT_CPLT
+ */
+TEST_F(NfcHidlTest, CoreInitialized) {
+ NfcData data;
+ data.resize(1);
+ data[0] = 0;
+ EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
+ // Wait for NfcEvent.POST_INIT_CPLT
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::POST_INIT_CPLT, last_event_);
+}
+
+/*
+ * ControlGranted:
+ * Calls controlGranted()
+ * Checks the return value
+ */
+TEST_F(NfcHidlTest, ControlGranted) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->controlGranted());
+}
+
+/* PreDiscover:
+ * Calls prediscover()
+ * Checks the return value
+ */
+TEST_F(NfcHidlTest, PreDiscover) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->prediscover());
+}
+
+int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);
+
+ for (int i = 0; i < argc; i++) {
+ if (strstr(argv[i], "passthrough=false") != nullptr) {
+ passthrough = false;
+ break;
+ }
+ }
+ std::system("svc nfc disable"); /* Turn off NFC */
+ sleep(5);
+
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
+
+ std::system("svc nfc enable"); /* Turn on NFC */
+ sleep(5);
+
return status;
}
diff --git a/nfc/1.0/vts/functional/vts/Android.mk b/nfc/1.0/vts/functional/vts/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/vts/testcases/Android.mk b/nfc/1.0/vts/functional/vts/testcases/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/__init__.py b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/__init__.py
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/__init__.py b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/__init__.py
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/NfcHidlBasicTest.py b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/NfcHidlBasicTest.py
new file mode 100644
index 0000000..ede7897
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/NfcHidlBasicTest.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python3.4
+#
+# 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.
+#
+
+import logging
+import time
+
+from vts.runners.host import asserts
+from vts.runners.host import base_test_with_webdb
+from vts.runners.host import test_runner
+from vts.utils.python.controllers import android_device
+
+PASSTHROUGH_MODE_KEY = "passthrough_mode"
+
+
+class NfcHidlBasicTest(base_test_with_webdb.BaseTestWithWebDbClass):
+ """A simple testcase for the NFC HIDL HAL."""
+
+ def setUpClass(self):
+ """Creates a mirror and turns on the framework-layer NFC service."""
+ self.dut = self.registerController(android_device)[0]
+
+ self.getUserParams(opt_param_names=[PASSTHROUGH_MODE_KEY])
+
+ self.dut.shell.InvokeTerminal("one")
+ self.dut.shell.one.Execute("setenforce 0") # SELinux permissive mode
+ self.dut.shell.one.Execute("svc nfc disable") # Turn off
+ time.sleep(5)
+
+ if getattr(self, PASSTHROUGH_MODE_KEY, True):
+ self.dut.shell.one.Execute(
+ "setprop vts.hal.vts.hidl.get_stub true")
+ else:
+ self.dut.shell.one.Execute(
+ "setprop vts.hal.vts.hidl.get_stub false")
+
+ self.dut.hal.InitHidlHal(target_type="nfc",
+ target_basepaths=["/system/lib64"],
+ target_version=1.0,
+ target_package="android.hardware.nfc",
+ target_component_name="INfc",
+ bits=64)
+
+ def tearDownClass(self):
+ """Turns off the framework-layer NFC service."""
+ # Ideally, we would want to store the nfc service's state before
+ # turning that off in setUpClass and restore the original state.
+ self.dut.shell.one.Execute("svc nfc disable") # make sure it's off
+
+ def testBase(self):
+ """A simple test case which just calls each registered function."""
+ # TODO: extend to make realistic testcases
+ # For example, call after CORE_INIT_RSP is received.
+ # result = self.dut.hal.nfc.coreInitialized([1])
+ # logging.info("coreInitialized result: %s", result)
+
+ def send_event(NfcEvent, NfcStatus):
+ logging.info("callback send_event")
+ logging.info("arg0 %s", NfcEvent)
+ logging.info("arg1 %s", NfcStatus)
+
+ def send_data(NfcData):
+ logging.info("callback send_data")
+ logging.info("arg0 %s", NfcData)
+
+ client_callback = self.dut.hal.nfc.GetHidlCallbackInterface(
+ "INfcClientCallback",
+ sendEvent=send_event,
+ sendData=send_data)
+
+ result = self.dut.hal.nfc.open(client_callback)
+ logging.info("open result: %s", result)
+
+ result = self.dut.hal.nfc.prediscover()
+ logging.info("prediscover result: %s", result)
+
+ result = self.dut.hal.nfc.controlGranted()
+ logging.info("controlGranted result: %s", result)
+
+ result = self.dut.hal.nfc.powerCycle()
+ logging.info("powerCycle result: %s", result)
+
+ nfc_types = self.dut.hal.nfc.GetHidlTypeInterface("types")
+ logging.info("nfc_types: %s", nfc_types)
+
+ result = self.dut.hal.nfc.write([0, 1, 2, 3, 4, 5])
+ logging.info("write result: %s", result)
+
+ result = self.dut.hal.nfc.close()
+ logging.info("close result: %s", result)
+
+ self.SetCoverageData(self.dut.hal.nfc.GetRawCodeCoverage())
+
+if __name__ == "__main__":
+ test_runner.main()
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/__init__.py b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/__init__.py
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/Android.mk
new file mode 100644
index 0000000..cd58d32
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/Android.mk
@@ -0,0 +1,23 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := NfcHidlBinderizeBasicTest
+VTS_CONFIG_SRC_DIR := testcases/hal/nfc/hidl/host/binderize
+include test/vts/tools/build/Android.host_config.mk
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/AndroidTest.xml b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/AndroidTest.xml
new file mode 100644
index 0000000..9671977
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/AndroidTest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS HAL NFC (Binder Mode) test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ <option name="cleanup" value="true" />
+ <option name="push" value="spec/hardware/interfaces/nfc/1.0/vts/Nfc.vts->/data/local/tmp/spec/Nfc.vts" />
+ <option name="push" value="spec/hardware/interfaces/nfc/1.0/vts/NfcClientCallback.vts->/data/local/tmp/spec/NfcClientCallback.vts" />
+ <option name="push" value="spec/hardware/interfaces/nfc/1.0/vts/types.vts->/data/local/tmp/spec/types.vts" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="NfcHidlBinderizeBasicTest" />
+ <option name="test-case-path" value="vts/testcases/hal/nfc/hidl/host/NfcHidlBasicTest" />
+ <option name="test-config-path" value="vts/testcases/hal/nfc/hidl/host/binderize/NfcHidlBinderizeBasicTest.config" />
+ </test>
+</configuration>
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/NfcHidlBinderizeBasicTest.config b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/NfcHidlBinderizeBasicTest.config
new file mode 100644
index 0000000..5a94c6f
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/NfcHidlBinderizeBasicTest.config
@@ -0,0 +1,3 @@
+{
+ "passthrough_mode": False
+}
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/__init__.py b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/binderize/__init__.py
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/Android.mk
new file mode 100644
index 0000000..e274107
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/Android.mk
@@ -0,0 +1,23 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := NfcHidlPassthroughBasicTest
+VTS_CONFIG_SRC_DIR := testcases/hal/nfc/hidl/host/passthrough
+include test/vts/tools/build/Android.host_config.mk
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/AndroidTest.xml b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/AndroidTest.xml
new file mode 100644
index 0000000..2f5fdfa
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/AndroidTest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS HAL NFC (Passthrough) test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ <option name="cleanup" value="true" />
+ <option name="push" value="spec/hardware/interfaces/nfc/1.0/vts/Nfc.vts->/data/local/tmp/spec/Nfc.vts" />
+ <option name="push" value="spec/hardware/interfaces/nfc/1.0/vts/NfcClientCallback.vts->/data/local/tmp/spec/NfcClientCallback.vts" />
+ <option name="push" value="spec/hardware/interfaces/nfc/1.0/vts/types.vts->/data/local/tmp/spec/types.vts" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="NfcHidlPassthroughBasicTest" />
+ <option name="test-case-path" value="vts/testcases/hal/nfc/hidl/host/NfcHidlBasicTest" />
+ <option name="test-config-path" value="vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config" />
+ </test>
+</configuration>
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config
new file mode 100644
index 0000000..be540a5
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config
@@ -0,0 +1,6 @@
+{
+ "passthrough_mode": True,
+ "modules": ["system/lib64/hw/nfc_nci.bullhead"],
+ "git_project_path": "external/libnfc-nci",
+ "git_project_name": "platform/external/libnfc-nci"
+}
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/Android.mk
new file mode 100644
index 0000000..da9b6af
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/Android.mk
@@ -0,0 +1,25 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := HalNfcHidlTargetBasicTest
+VTS_CONFIG_SRC_DIR := testcases/hal/nfc/hidl/target
+include test/vts/tools/build/Android.host_config.mk
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/AndroidTest.xml b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/AndroidTest.xml
new file mode 100644
index 0000000..f692011
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/AndroidTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS NFC HIDL HAL's basic target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="HalNfcHidlTargetBasicTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/nfc_hidl_hal_test/nfc_hidl_hal_test,
+ _64bit::DATA/nativetest64/nfc_hidl_hal_test/nfc_hidl_hal_test,
+ "/>
+ <option name="test-config-path" value="vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config" />
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config
new file mode 100644
index 0000000..65009e4
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config
@@ -0,0 +1,5 @@
+{
+ "modules": ["system/lib64/hw/nfc_nci.bullhead"],
+ "git_project_path": "external/libnfc-nci",
+ "git_project_name": "platform/external/libnfc-nci"
+}
\ No newline at end of file
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/Android.mk b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/Android.mk
new file mode 100644
index 0000000..c7bf853
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/Android.mk
@@ -0,0 +1,23 @@
+#
+## 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := NfcHidlTargetProfilingTest
+VTS_CONFIG_SRC_DIR := testcases/hal/nfc/hidl/target_profiling
+include test/vts/tools/build/Android.host_config.mk
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/AndroidTest.xml b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/AndroidTest.xml
new file mode 100644
index 0000000..e442c7c
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/AndroidTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS NFC HIDL HAL's target-side profiling test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="NfcHidlTargetProfilingTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/nfc_hidl_hal_test/nfc_hidl_hal_test,
+ _64bit::DATA/nativetest64/nfc_hidl_hal_test/nfc_hidl_hal_test,
+ "/>
+ <option name="test-config-path" value="vts/testcases/hal/nfc/hidl/target_profiling/NfcHidlTargetProfilingTest.config" />
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/NfcHidlTargetProfilingTest.config b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/NfcHidlTargetProfilingTest.config
new file mode 100644
index 0000000..912d8d5
--- /dev/null
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target_profiling/NfcHidlTargetProfilingTest.config
@@ -0,0 +1,3 @@
+{
+ "enable_profiling": true
+}
\ No newline at end of file
diff --git a/nfc/Android.mk b/nfc/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/nfc/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/power/1.0/Android.bp b/power/1.0/Android.bp
index 777bb85..a487377 100644
--- a/power/1.0/Android.bp
+++ b/power/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/power/Android.mk b/power/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/power/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/radio/1.0/Android.bp b/radio/1.0/Android.bp
index 1bb8fe5..8da9716 100644
--- a/radio/1.0/Android.bp
+++ b/radio/1.0/Android.bp
@@ -73,6 +73,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/radio/Android.mk b/radio/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/radio/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/sensors/1.0/Android.bp b/sensors/1.0/Android.bp
index 7f25a62..9d440a7 100644
--- a/sensors/1.0/Android.bp
+++ b/sensors/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/sensors/Android.mk b/sensors/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/sensors/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/soundtrigger/2.0/Android.bp b/soundtrigger/2.0/Android.bp
index 4eab0bf..5cb1dea 100644
--- a/soundtrigger/2.0/Android.bp
+++ b/soundtrigger/2.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.audio.common@2.0",
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/bar/1.0/Android.bp b/tests/bar/1.0/Android.bp
index 08947ad..82e55ca 100644
--- a/tests/bar/1.0/Android.bp
+++ b/tests/bar/1.0/Android.bp
@@ -45,6 +45,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.tests.foo@1.0",
diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp
index 2158cd8..c07e2fa 100644
--- a/tests/bar/1.0/default/Bar.cpp
+++ b/tests/bar/1.0/default/Bar.cpp
@@ -153,8 +153,8 @@
return Void();
}
-Return<void> Bar::expectNullHandle(const native_handle_t* h, const Abc& xyz, expectNullHandle_cb _hidl_cb) {
- ALOGI("SERVER(Bar) h = %p, xyz.z = %p", h, static_cast<void*>(xyz.z));
+Return<void> Bar::expectNullHandle(const hidl_handle& h, const Abc& xyz, expectNullHandle_cb _hidl_cb) {
+ ALOGI("SERVER(Bar) h = %p, xyz.z = %p", h.getNativeHandle(), xyz.z.getNativeHandle());
_hidl_cb(h == nullptr, xyz.z == nullptr);
return Void();
}
diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h
index 4e22b61..d23c1e1 100644
--- a/tests/bar/1.0/default/Bar.h
+++ b/tests/bar/1.0/default/Bar.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_bar_V1_0_Bar_H_
-#define HIDL_GENERATED_android_hardware_tests_bar_V1_0_Bar_H_
+#ifndef ANDROID_HARDWARE_TESTS_BAR_V1_0_BAR_H
+#define ANDROID_HARDWARE_TESTS_BAR_V1_0_BAR_H
#include <android/hardware/tests/bar/1.0/IBar.h>
#include <hidl/Status.h>
@@ -64,7 +64,7 @@
// Methods from ::android::hardware::tests::bar::V1_0::IBar follow.
Return<void> thisIsNew() override;
- Return<void> expectNullHandle(const native_handle_t* h, const Abc& xyz, expectNullHandle_cb _hidl_cb) override;
+ Return<void> expectNullHandle(const hidl_handle& h, const Abc& xyz, expectNullHandle_cb _hidl_cb) override;
private:
sp<IFoo> mFoo;
@@ -79,4 +79,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_bar_V1_0_Bar_H_
+#endif // ANDROID_HARDWARE_TESTS_BAR_V1_0_BAR_H
diff --git a/tests/bar/1.0/default/ImportTypes.h b/tests/bar/1.0/default/ImportTypes.h
index b43be70..59c7bea 100644
--- a/tests/bar/1.0/default/ImportTypes.h
+++ b/tests/bar/1.0/default/ImportTypes.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_bar_V1_0_ImportTypes_H_
-#define HIDL_GENERATED_android_hardware_tests_bar_V1_0_ImportTypes_H_
+#ifndef ANDROID_HARDWARE_TESTS_BAR_V1_0_IMPORTTYPES_H
+#define ANDROID_HARDWARE_TESTS_BAR_V1_0_IMPORTTYPES_H
#include <android/hardware/tests/bar/1.0/IImportTypes.h>
#include <hidl/Status.h>
@@ -33,4 +33,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_bar_V1_0_ImportTypes_H_
+#endif // ANDROID_HARDWARE_TESTS_BAR_V1_0_IMPORTTYPES_H
diff --git a/tests/bar/Android.mk b/tests/bar/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/bar/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index 98d3e84..9c5e88c 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -57,6 +57,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/baz/Android.mk b/tests/baz/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/baz/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/expression/1.0/Android.bp b/tests/expression/1.0/Android.bp
index 60754d3..064bbf9 100644
--- a/tests/expression/1.0/Android.bp
+++ b/tests/expression/1.0/Android.bp
@@ -45,6 +45,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/expression/Android.mk b/tests/expression/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/expression/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index 4064e74..85c7a94 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -73,6 +73,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp
index f7cc7c0..7053b44 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -108,7 +108,13 @@
"should block for %" PRId64 " seconds", cb.get(),
DELAY_S);
c[1] = systemTime();
- bool answer = cb->heyItsYouIsntIt(cb);
+ Return<bool> ret = cb->heyItsYouIsntIt(cb);
+ if (!ret.isOk()) {
+ ALOGE("SERVER(Foo) callMe %p encountered transport error (%d).",
+ cb.get(), ret.getStatus().exceptionCode());
+ return Void();
+ }
+ bool answer = ret.get();
c[1] = systemTime() - c[1];
ALOGI("SERVER(Foo) callMe %p IFooCallback::heyItsYouIsntIt " \
"responded with %d after %" PRId64 "ns", cb.get(), answer, c[1]);
@@ -309,7 +315,7 @@
}
Return<void> Foo::createHandles(uint32_t size, createHandles_cb _hidl_cb) {
- hidl_vec<const native_handle_t*> handles;
+ hidl_vec<hidl_handle> handles;
handles.resize(size);
for(uint32_t i = 0; i < size; ++i) {
createMyHandle([&](const MyHandle& h) {
diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h
index 703c210..84629db 100644
--- a/tests/foo/1.0/default/Foo.h
+++ b/tests/foo/1.0/default/Foo.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_Foo_H_
-#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_Foo_H_
+#ifndef ANDROID_HARDWARE_TESTS_FOO_V1_0_FOO_H
+#define ANDROID_HARDWARE_TESTS_FOO_V1_0_FOO_H
#include <android/hardware/tests/foo/1.0/IFoo.h>
#include <hidl/Status.h>
@@ -71,4 +71,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_foo_V1_0_Foo_H_
+#endif // ANDROID_HARDWARE_TESTS_FOO_V1_0_FOO_H
diff --git a/tests/foo/1.0/default/FooCallback.h b/tests/foo/1.0/default/FooCallback.h
index 00233b5..3164a9d 100644
--- a/tests/foo/1.0/default/FooCallback.h
+++ b/tests/foo/1.0/default/FooCallback.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_foo_V1_0_FooCallback_H_
-#define HIDL_GENERATED_android_hardware_tests_foo_V1_0_FooCallback_H_
+#ifndef ANDROID_HARDWARE_TESTS_FOO_V1_0_FOOCALLBACK_H
+#define ANDROID_HARDWARE_TESTS_FOO_V1_0_FOOCALLBACK_H
#include <android/hardware/tests/foo/1.0/IFooCallback.h>
#include <hidl/Status.h>
@@ -43,4 +43,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_foo_V1_0_FooCallback_H_
+#endif // ANDROID_HARDWARE_TESTS_FOO_V1_0_FOOCALLBACK_H
diff --git a/tests/foo/Android.mk b/tests/foo/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/foo/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/inheritance/1.0/Android.bp b/tests/inheritance/1.0/Android.bp
index cfd10ac..7ddaa7e 100644
--- a/tests/inheritance/1.0/Android.bp
+++ b/tests/inheritance/1.0/Android.bp
@@ -61,6 +61,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/inheritance/1.0/default/Child.h b/tests/inheritance/1.0/default/Child.h
index 0d34e83..268dfeb 100644
--- a/tests/inheritance/1.0/default/Child.h
+++ b/tests/inheritance/1.0/default/Child.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Child_H_
-#define HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Child_H_
+#ifndef ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_CHILD_H
+#define ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_CHILD_H
#include <android/hardware/tests/inheritance/1.0/IChild.h>
#include <hidl/Status.h>
@@ -41,4 +41,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Child_H_
+#endif // ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_CHILD_H
diff --git a/tests/inheritance/1.0/default/Fetcher.h b/tests/inheritance/1.0/default/Fetcher.h
index d389853..da9b153 100644
--- a/tests/inheritance/1.0/default/Fetcher.h
+++ b/tests/inheritance/1.0/default/Fetcher.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Fetcher_H_
-#define HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Fetcher_H_
+#ifndef ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_FETCHER_H
+#define ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_FETCHER_H
#include "Child.h"
#include <android/hardware/tests/inheritance/1.0/IFetcher.h>
@@ -42,4 +42,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Fetcher_H_
+#endif // ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_FETCHER_H
diff --git a/tests/inheritance/1.0/default/Grandparent.h b/tests/inheritance/1.0/default/Grandparent.h
index e1113bf..5458b01 100644
--- a/tests/inheritance/1.0/default/Grandparent.h
+++ b/tests/inheritance/1.0/default/Grandparent.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Grandparent_H_
-#define HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Grandparent_H_
+#ifndef ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_GRANDPARENT_H
+#define ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_GRANDPARENT_H
#include <android/hardware/tests/inheritance/1.0/IGrandparent.h>
#include <hidl/Status.h>
@@ -34,4 +34,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Grandparent_H_
+#endif // ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_GRANDPARENT_H
diff --git a/tests/inheritance/1.0/default/Parent.h b/tests/inheritance/1.0/default/Parent.h
index 2e07fdc..48085fd 100644
--- a/tests/inheritance/1.0/default/Parent.h
+++ b/tests/inheritance/1.0/default/Parent.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Parent_H_
-#define HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Parent_H_
+#ifndef ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_PARENT_H
+#define ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_PARENT_H
#include <android/hardware/tests/inheritance/1.0/IParent.h>
#include <hidl/Status.h>
@@ -37,4 +37,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_inheritance_V1_0_Parent_H_
+#endif // ANDROID_HARDWARE_TESTS_INHERITANCE_V1_0_PARENT_H
diff --git a/tests/inheritance/Android.mk b/tests/inheritance/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/inheritance/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index ca02cc7..a828d55 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -37,6 +37,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/libhwbinder/1.0/default/Benchmark.h b/tests/libhwbinder/1.0/default/Benchmark.h
index 454fdf2..74b3745 100644
--- a/tests/libhwbinder/1.0/default/Benchmark.h
+++ b/tests/libhwbinder/1.0/default/Benchmark.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
-#define HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
+#ifndef ANDROID_HARDWARE_BENCHMARK_V1_0_BENCHMARK_H
+#define ANDROID_HARDWARE_BENCHMARK_V1_0_BENCHMARK_H
#include <android/hardware/tests/libhwbinder/1.0/IBenchmark.h>
#include <hidl/Status.h>
@@ -28,4 +28,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
+#endif // ANDROID_HARDWARE_BENCHMARK_V1_0_BENCHMARK_H
diff --git a/tests/libhwbinder/Android.mk b/tests/libhwbinder/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/libhwbinder/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index 914c93f..1b35e14 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -37,6 +37,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/msgq/Android.mk b/tests/msgq/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/msgq/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tests/pointer/1.0/Android.bp b/tests/pointer/1.0/Android.bp
index bbd0eaa..f7ae4ae 100644
--- a/tests/pointer/1.0/Android.bp
+++ b/tests/pointer/1.0/Android.bp
@@ -45,6 +45,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tests/pointer/1.0/default/Graph.h b/tests/pointer/1.0/default/Graph.h
index cbd5a8a..03bd163 100644
--- a/tests/pointer/1.0/default/Graph.h
+++ b/tests/pointer/1.0/default/Graph.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Graph_H_
-#define HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Graph_H_
+#ifndef ANDROID_HARDWARE_TESTS_POINTER_V1_0_GRAPH_H
+#define ANDROID_HARDWARE_TESTS_POINTER_V1_0_GRAPH_H
#include <android/hardware/tests/pointer/1.0/IGraph.h>
#include <hidl/Status.h>
@@ -44,4 +44,4 @@
} // namespace hardware
} // namespace android
-#endif // HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Graph_H_
+#endif // ANDROID_HARDWARE_TESTS_POINTER_V1_0_GRAPH_H
diff --git a/tests/pointer/1.0/default/Pointer.h b/tests/pointer/1.0/default/Pointer.h
index 41d96fd..87b0f56 100644
--- a/tests/pointer/1.0/default/Pointer.h
+++ b/tests/pointer/1.0/default/Pointer.h
@@ -1,5 +1,5 @@
-#ifndef HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Pointer_H_
-#define HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Pointer_H_
+#ifndef ANDROID_HARDWARE_TESTS_POINTER_V1_0_POINTER_H
+#define ANDROID_HARDWARE_TESTS_POINTER_V1_0_POINTER_H
#include <android/hardware/tests/pointer/1.0/IPointer.h>
#include <android-base/logging.h>
@@ -345,4 +345,4 @@
#undef PUSH_ERROR_IF
-#endif // HIDL_GENERATED_android_hardware_tests_pointer_V1_0_Pointer_H_
+#endif // ANDROID_HARDWARE_TESTS_POINTER_V1_0_POINTER_H
diff --git a/tests/pointer/Android.mk b/tests/pointer/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tests/pointer/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/Android.bp b/thermal/1.0/Android.bp
index 3b6ef06..c950aac 100644
--- a/thermal/1.0/Android.bp
+++ b/thermal/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/thermal/1.0/vts/Android.mk b/thermal/1.0/vts/Android.mk
index c4655b4..ef926fe 100644
--- a/thermal/1.0/vts/Android.mk
+++ b/thermal/1.0/vts/Android.mk
@@ -84,3 +84,5 @@
LOCAL_PROTOC_OPTIMIZE_TYPE := full
include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/thermal/1.0/vts/functional/Android.mk b/thermal/1.0/vts/functional/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/1.0/vts/functional/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/vts/functional/vts/Android.mk b/thermal/1.0/vts/functional/vts/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/vts/functional/vts/testcases/Android.mk b/thermal/1.0/vts/functional/vts/testcases/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/Android.mk b/thermal/1.0/vts/functional/vts/testcases/hal/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/Android.mk b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/__init__.py b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/__init__.py
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/Android.mk b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/__init__.py b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/__init__.py
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target/Android.mk b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target/Android.mk
new file mode 100644
index 0000000..1c3ceb3
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target/Android.mk
@@ -0,0 +1,25 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := ThermalHidlTargetTest
+VTS_CONFIG_SRC_DIR := testcases/hal/thermal/hidl/target
+include test/vts/tools/build/Android.host_config.mk
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target/AndroidTest.xml b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target/AndroidTest.xml
new file mode 100644
index 0000000..169264d
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target/AndroidTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS VIBRATOR HIDL HAL's target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="ThermalHidlTargetTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/thermal_hidl_hal_test/thermal_hidl_hal_test,
+ _64bit::DATA/nativetest64/thermal_hidl_hal_test/thermal_hidl_hal_test,
+ "/>
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="5m" />
+ </test>
+</configuration>
+
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/Android.mk b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/Android.mk
new file mode 100644
index 0000000..1f937fa
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/Android.mk
@@ -0,0 +1,23 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := ThermalHidlTargetProfilingTest
+VTS_CONFIG_SRC_DIR := testcases/hal/thermal/hidl/target_profiling
+include test/vts/tools/build/Android.host_config.mk
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/AndroidTest.xml b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/AndroidTest.xml
new file mode 100644
index 0000000..3790c56
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/AndroidTest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS THERMAL HIDL HAL's target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="ThermalHidlTargetProfilingTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/thermal_hidl_hal_test/thermal_hidl_hal_test,
+ _64bit::DATA/nativetest64/thermal_hidl_hal_test/thermal_hidl_hal_test,
+ "/>
+ <option name="test-config-path" value="vts/testcases/hal/thermal/hidl/target_profiling/ThermalHidlTargetProfilingTest.config" />
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="5m" />
+ </test>
+</configuration>
+
diff --git a/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/ThermalHidlTargetProfilingTest.config b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/ThermalHidlTargetProfilingTest.config
new file mode 100644
index 0000000..912d8d5
--- /dev/null
+++ b/thermal/1.0/vts/functional/vts/testcases/hal/thermal/hidl/target_profiling/ThermalHidlTargetProfilingTest.config
@@ -0,0 +1,3 @@
+{
+ "enable_profiling": true
+}
\ No newline at end of file
diff --git a/thermal/Android.mk b/thermal/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/thermal/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tv/Android.mk b/tv/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tv/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tv/cec/1.0/Android.bp b/tv/cec/1.0/Android.bp
index 02a4247..24e9d57 100644
--- a/tv/cec/1.0/Android.bp
+++ b/tv/cec/1.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/tv/cec/Android.mk b/tv/cec/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tv/cec/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/tv/input/1.0/Android.bp b/tv/input/1.0/Android.bp
index 7f9bb7c..58c1c5a 100644
--- a/tv/input/1.0/Android.bp
+++ b/tv/input/1.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
"android.hardware.audio.common@2.0",
diff --git a/tv/input/Android.mk b/tv/input/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/tv/input/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vehicle/2.0/Android.bp b/vehicle/2.0/Android.bp
index 09025b9..3515896 100644
--- a/vehicle/2.0/Android.bp
+++ b/vehicle/2.0/Android.bp
@@ -49,6 +49,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/vehicle/Android.mk b/vehicle/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vehicle/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/Android.bp b/vibrator/1.0/Android.bp
index bd88241..7559389 100644
--- a/vibrator/1.0/Android.bp
+++ b/vibrator/1.0/Android.bp
@@ -41,6 +41,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/vibrator/1.0/vts/Android.mk b/vibrator/1.0/vts/Android.mk
index 2f612d5..080eb88 100644
--- a/vibrator/1.0/vts/Android.mk
+++ b/vibrator/1.0/vts/Android.mk
@@ -77,3 +77,5 @@
LOCAL_PROTOC_OPTIMIZE_TYPE := full
include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/vibrator/1.0/vts/functional/Android.mk b/vibrator/1.0/vts/functional/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/1.0/vts/functional/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/vts/functional/vts/Android.mk b/vibrator/1.0/vts/functional/vts/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/vts/functional/vts/testcases/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/__init__.py b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/__init__.py
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/__init__.py b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/__init__.py
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/Android.mk
new file mode 100644
index 0000000..d005450
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/Android.mk
@@ -0,0 +1,23 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VibratorHidlTest
+VTS_CONFIG_SRC_DIR := testcases/hal/vibrator/hidl/host
+include test/vts/tools/build/Android.host_config.mk
\ No newline at end of file
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/AndroidTest.xml b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/AndroidTest.xml
new file mode 100644
index 0000000..c5074ee
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/AndroidTest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS HAL vibrator test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ <option name="cleanup" value="true" />
+ <option name="push" value="spec/hardware/interfaces/vibrator/1.0/vts/Vibrator.vts->/data/local/tmp/spec/Vibrator.vts" />
+ <option name="push" value="spec/hardware/interfaces/vibrator/1.0/vts/types.vts->/data/local/tmp/spec/types.vts" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="VibratorHidlTest" />
+ <option name="test-case-path" value="vts/testcases/hal/vibrator/hidl/host/VibratorHidlTest" />
+ </test>
+</configuration>
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/VibratorHidlTest.py b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/VibratorHidlTest.py
new file mode 100644
index 0000000..0007d89
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/VibratorHidlTest.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3.4
+#
+# 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.
+#
+
+import logging
+import time
+
+from vts.runners.host import asserts
+from vts.runners.host import base_test_with_webdb
+from vts.runners.host import test_runner
+from vts.utils.python.controllers import android_device
+from vts.utils.python.profiling import profiling_utils
+
+
+class VibratorHidlTest(base_test_with_webdb.BaseTestWithWebDbClass):
+ """A simple testcase for the VIBRATOR HIDL HAL."""
+
+ def setUpClass(self):
+ """Creates a mirror and turns on the framework-layer VIBRATOR service."""
+ self.dut = self.registerController(android_device)[0]
+
+ self.dut.shell.InvokeTerminal("one")
+ self.dut.shell.one.Execute("setenforce 0") # SELinux permissive mode
+
+ # Test using the binderized mode
+ self.dut.shell.one.Execute(
+ "setprop vts.hal.vts.hidl.get_stub true")
+
+ if getattr(self, self.ENABLE_PROFILING, False):
+ profiling_utils.EnableVTSProfiling(self.dut.shell.one)
+
+ self.dut.hal.InitHidlHal(
+ target_type="vibrator",
+ target_basepaths=["/system/lib64"],
+ target_version=1.0,
+ target_package="android.hardware.vibrator",
+ target_component_name="IVibrator",
+ bits=64)
+
+ def tearDownClass(self):
+ """ If profiling is enabled for the test, collect the profiling data
+ and disable profiling after the test is done.
+ """
+ if getattr(self, self.ENABLE_PROFILING, False):
+ profiling_trace_path = getattr(
+ self, self.VTS_PROFILING_TRACING_PATH, "")
+ self.ProcessAndUploadTraceData(self.dut, profiling_trace_path)
+ profiling_utils.DisableVTSProfiling(self.dut.shell.one)
+
+ def testVibratorBasic(self):
+ """A simple test case which just calls each registered function."""
+ vibrator_types = self.dut.hal.vibrator.GetHidlTypeInterface("types")
+ logging.info("vibrator_types: %s", vibrator_types)
+ logging.info("OK: %s", vibrator_types.OK)
+ logging.info("ERR: %s", vibrator_types.ERR)
+
+ result = self.dut.hal.vibrator.on(10000)
+ logging.info("on result: %s", result)
+ asserts.assertEqual(vibrator_types.OK, result)
+
+ time.sleep(1)
+
+ result = self.dut.hal.vibrator.off()
+ logging.info("off result: %s", result)
+ asserts.assertEqual(vibrator_types.OK, result)
+
+if __name__ == "__main__":
+ test_runner.main()
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/__init__.py b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host/__init__.py
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/Android.mk
new file mode 100644
index 0000000..ec73e06
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/Android.mk
@@ -0,0 +1,23 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VibratorHidlProfilingTest
+VTS_CONFIG_SRC_DIR := testcases/hal/vibrator/hidl/host_profiling
+include test/vts/tools/build/Android.host_config.mk
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/AndroidTest.xml b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/AndroidTest.xml
new file mode 100644
index 0000000..713e9d0
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/AndroidTest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS HAL vibrator test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ <option name="cleanup" value="true" />
+ <option name="push" value="spec/hardware/interfaces/vibrator/1.0/vts/Vibrator.vts->/data/local/tmp/spec/Vibrator.vts" />
+ <option name="push" value="spec/hardware/interfaces/vibrator/1.0/vts/types.vts->/data/local/tmp/spec/types.vts" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="VibratorHidlProfilingTest" />
+ <option name="test-case-path" value="vts/testcases/hal/vibrator/hidl/host/VibratorHidlTest" />
+ <option name="test-config-path" value="vts/testcases/hal/vibrator/hidl/host_profiling/VibratorHidlProfilingTest.config" />
+ </test>
+</configuration>
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/VibratorHidlProfilingTest.config b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/VibratorHidlProfilingTest.config
new file mode 100644
index 0000000..912d8d5
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/host_profiling/VibratorHidlProfilingTest.config
@@ -0,0 +1,3 @@
+{
+ "enable_profiling": true
+}
\ No newline at end of file
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/Android.bp b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/Android.bp
new file mode 100644
index 0000000..b6ee3a3
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/Android.bp
@@ -0,0 +1,33 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VibratorHidlTargetTest
+VTS_CONFIG_SRC_DIR := testcases/hal/vibrator/hidl/target
+LOCAL_MODULE_CLASS := FAKE
+LOCAL_IS_HOST_MODULE := true
+LOCAL_COMPATIBILITY_SUITE := vts
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE):
+ @echo "VTS host-driven test target: $(LOCAL_MODULE)"
+ $(hide) touch $@
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/Android.mk
new file mode 100644
index 0000000..704d985
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/Android.mk
@@ -0,0 +1,25 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VibratorHidlTargetTest
+VTS_CONFIG_SRC_DIR := testcases/hal/vibrator/hidl/target
+include test/vts/tools/build/Android.host_config.mk
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/AndroidTest.xml b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/AndroidTest.xml
new file mode 100644
index 0000000..7948c86
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target/AndroidTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS VIBRATOR HIDL HAL's target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="VibratorHidlTargetTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/vibrator_hidl_hal_test/vibrator_hidl_hal_test,
+ _64bit::DATA/nativetest64/vibrator_hidl_hal_test/vibrator_hidl_hal_test,
+ "/>
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
+
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/Android.mk b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/Android.mk
new file mode 100644
index 0000000..a1f43e4
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/Android.mk
@@ -0,0 +1,23 @@
+#
+# 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)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VibratorHidlTargetProfilingTest
+VTS_CONFIG_SRC_DIR := testcases/hal/vibrator/hidl/target_profiling
+include test/vts/tools/build/Android.host_config.mk
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/AndroidTest.xml b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/AndroidTest.xml
new file mode 100644
index 0000000..addd67e
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/AndroidTest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for VTS VIBRATOR HIDL HAL's target-side test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HidlHalTest.push" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="VibratorHidlTargetProfilingTest" />
+ <option name="binary-test-sources" value="
+ _32bit::DATA/nativetest/vibrator_hidl_hal_test/vibrator_hidl_hal_test,
+ _64bit::DATA/nativetest64/vibrator_hidl_hal_test/vibrator_hidl_hal_test,
+ "/>
+ <option name="test-config-path" value="vts/testcases/hal/vibrator/hidl/target_profiling/VibratorHidlTargetProfilingTest.config" />
+ <option name="binary-test-type" value="gtest" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
+
diff --git a/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/VibratorHidlTargetProfilingTest.config b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/VibratorHidlTargetProfilingTest.config
new file mode 100644
index 0000000..912d8d5
--- /dev/null
+++ b/vibrator/1.0/vts/functional/vts/testcases/hal/vibrator/hidl/target_profiling/VibratorHidlTargetProfilingTest.config
@@ -0,0 +1,3 @@
+{
+ "enable_profiling": true
+}
\ No newline at end of file
diff --git a/vibrator/Android.mk b/vibrator/Android.mk
new file mode 100644
index 0000000..f9e3276
--- /dev/null
+++ b/vibrator/Android.mk
@@ -0,0 +1,19 @@
+#
+# 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)
+
+include $(call all-subdir-makefiles)
diff --git a/vr/1.0/Android.bp b/vr/1.0/Android.bp
index 5cbd333..8582a11 100644
--- a/vr/1.0/Android.bp
+++ b/vr/1.0/Android.bp
@@ -37,6 +37,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/wifi/1.0/Android.bp b/wifi/1.0/Android.bp
index d353e4b..bbe75eb 100644
--- a/wifi/1.0/Android.bp
+++ b/wifi/1.0/Android.bp
@@ -137,6 +137,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index 28b7f9a..15b6bfc 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -28,8 +28,14 @@
namespace V1_0 {
namespace implementation {
namespace legacy_hal {
-// Constants used in the class.
+// Constants ported over from the legacy HAL calling code
+// (com_android_server_wifi_WifiNative.cpp). This will all be thrown
+// away when this shim layer is replaced by the real vendor
+// implementation.
static constexpr uint32_t kMaxVersionStringLength = 256;
+static constexpr uint32_t kMaxCachedGscanResults = 64;
+static constexpr uint32_t kMaxGscanFrequenciesForBand = 64;
+static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128;
// Legacy HAL functions accept "C" style function pointers, so use global
// functions to pass to the legacy HAL function and store the corresponding
@@ -57,6 +63,40 @@
on_firmware_memory_dump_internal_callback(buffer, buffer_size);
}
}
+
+// Callback to be invoked for Gscan events.
+std::function<void(wifi_request_id, wifi_scan_event)>
+ on_gscan_event_internal_callback;
+void onGscanEvent(wifi_request_id id, wifi_scan_event event) {
+ if (on_gscan_event_internal_callback) {
+ on_gscan_event_internal_callback(id, event);
+ }
+}
+
+// Callback to be invoked for Gscan full results.
+std::function<void(wifi_request_id, wifi_scan_result*, uint32_t)>
+ on_gscan_full_result_internal_callback;
+void onGscanFullResult(wifi_request_id id,
+ wifi_scan_result* result,
+ uint32_t buckets_scanned) {
+ if (on_gscan_full_result_internal_callback) {
+ on_gscan_full_result_internal_callback(id, result, buckets_scanned);
+ }
+}
+
+// Callback to be invoked for link layer stats results.
+std::function<void((wifi_request_id, wifi_iface_stat*, int, wifi_radio_stat*))>
+ on_link_layer_stats_result_internal_callback;
+void onLinkLayerStatsDataResult(wifi_request_id id,
+ wifi_iface_stat* iface_stat,
+ int num_radios,
+ wifi_radio_stat* radio_stat) {
+ if (on_link_layer_stats_result_internal_callback) {
+ on_link_layer_stats_result_internal_callback(
+ id, iface_stat, num_radios, radio_stat);
+ }
+}
+
// End of the free-standing "C" style callbacks.
WifiLegacyHal::WifiLegacyHal()
@@ -206,6 +246,162 @@
wlan_interface_handle_, program.data(), program.size());
}
+std::pair<wifi_error, wifi_gscan_capabilities>
+WifiLegacyHal::getGscanCapabilities() {
+ wifi_gscan_capabilities caps;
+ wifi_error status = global_func_table_.wifi_get_gscan_capabilities(
+ wlan_interface_handle_, &caps);
+ return {status, caps};
+}
+
+wifi_error WifiLegacyHal::startGscan(
+ wifi_request_id id,
+ const wifi_scan_cmd_params& params,
+ const std::function<void(wifi_request_id)>& on_failure_user_callback,
+ const on_gscan_results_callback& on_results_user_callback,
+ const on_gscan_full_result_callback& on_full_result_user_callback) {
+ // If there is already an ongoing background scan, reject new scan requests.
+ if (on_gscan_event_internal_callback ||
+ on_gscan_full_result_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+
+ // This callback will be used to either trigger |on_results_user_callback| or
+ // |on_failure_user_callback|.
+ on_gscan_event_internal_callback =
+ [on_failure_user_callback, on_results_user_callback, this](
+ wifi_request_id id, wifi_scan_event event) {
+ switch (event) {
+ case WIFI_SCAN_RESULTS_AVAILABLE:
+ case WIFI_SCAN_THRESHOLD_NUM_SCANS:
+ case WIFI_SCAN_THRESHOLD_PERCENT: {
+ wifi_error status;
+ std::vector<wifi_cached_scan_results> cached_scan_results;
+ std::tie(status, cached_scan_results) = getGscanCachedResults();
+ if (status == WIFI_SUCCESS) {
+ on_results_user_callback(id, cached_scan_results);
+ return;
+ }
+ }
+ // Fall through if failed. Failure to retrieve cached scan results
+ // should trigger a background scan failure.
+ case WIFI_SCAN_FAILED:
+ on_failure_user_callback(id);
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ return;
+ }
+ LOG(FATAL) << "Unexpected gscan event received: " << event;
+ };
+
+ on_gscan_full_result_internal_callback = [on_full_result_user_callback](
+ wifi_request_id id, wifi_scan_result* result, uint32_t buckets_scanned) {
+ if (result) {
+ on_full_result_user_callback(id, result, buckets_scanned);
+ }
+ };
+
+ wifi_scan_result_handler handler = {onGscanFullResult, onGscanEvent};
+ wifi_error status = global_func_table_.wifi_start_gscan(
+ id, wlan_interface_handle_, params, handler);
+ if (status != WIFI_SUCCESS) {
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ }
+ return status;
+}
+
+wifi_error WifiLegacyHal::stopGscan(wifi_request_id id) {
+ // If there is no an ongoing background scan, reject stop requests.
+ // TODO(b/32337212): This needs to be handled by the HIDL object because we
+ // need to return the NOT_STARTED error code.
+ if (!on_gscan_event_internal_callback &&
+ !on_gscan_full_result_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ wifi_error status =
+ global_func_table_.wifi_stop_gscan(id, wlan_interface_handle_);
+ // If the request Id is wrong, don't stop the ongoing background scan. Any
+ // other error should be treated as the end of background scan.
+ if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ }
+ return status;
+}
+
+std::pair<wifi_error, std::vector<uint32_t>>
+WifiLegacyHal::getValidFrequenciesForGscan(wifi_band band) {
+ static_assert(sizeof(uint32_t) >= sizeof(wifi_channel),
+ "Wifi Channel cannot be represented in output");
+ std::vector<uint32_t> freqs;
+ freqs.resize(kMaxGscanFrequenciesForBand);
+ int32_t num_freqs = 0;
+ wifi_error status = global_func_table_.wifi_get_valid_channels(
+ wlan_interface_handle_,
+ band,
+ freqs.size(),
+ reinterpret_cast<wifi_channel*>(freqs.data()),
+ &num_freqs);
+ CHECK(num_freqs >= 0 &&
+ static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand);
+ freqs.resize(num_freqs);
+ return {status, std::move(freqs)};
+}
+
+wifi_error WifiLegacyHal::enableLinkLayerStats(bool debug) {
+ wifi_link_layer_params params;
+ params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold;
+ params.aggressive_statistics_gathering = debug;
+ return global_func_table_.wifi_set_link_stats(wlan_interface_handle_, params);
+}
+
+wifi_error WifiLegacyHal::disableLinkLayerStats() {
+ // TODO: Do we care about these responses?
+ uint32_t clear_mask_rsp;
+ uint8_t stop_rsp;
+ return global_func_table_.wifi_clear_link_stats(
+ wlan_interface_handle_, 0xFFFFFFFF, &clear_mask_rsp, 1, &stop_rsp);
+}
+
+std::pair<wifi_error, LinkLayerStats> WifiLegacyHal::getLinkLayerStats() {
+ LinkLayerStats link_stats{};
+ LinkLayerStats* link_stats_ptr = &link_stats;
+
+ on_link_layer_stats_result_internal_callback = [&link_stats_ptr](
+ wifi_request_id /* id */,
+ wifi_iface_stat* iface_stats_ptr,
+ int num_radios,
+ wifi_radio_stat* radio_stats_ptr) {
+ if (iface_stats_ptr != nullptr) {
+ link_stats_ptr->iface = *iface_stats_ptr;
+ link_stats_ptr->iface.num_peers = 0;
+ } else {
+ LOG(ERROR) << "Invalid iface stats in link layer stats";
+ }
+ if (num_radios == 1 && radio_stats_ptr != nullptr) {
+ link_stats_ptr->radio = *radio_stats_ptr;
+ // Copy over the tx level array to the separate vector.
+ if (radio_stats_ptr->num_tx_levels > 0 &&
+ radio_stats_ptr->tx_time_per_levels != nullptr) {
+ link_stats_ptr->radio_tx_time_per_levels.assign(
+ radio_stats_ptr->tx_time_per_levels,
+ radio_stats_ptr->tx_time_per_levels +
+ radio_stats_ptr->num_tx_levels);
+ }
+ link_stats_ptr->radio.num_tx_levels = 0;
+ link_stats_ptr->radio.tx_time_per_levels = nullptr;
+ } else {
+ LOG(ERROR) << "Invalid radio stats in link layer stats";
+ }
+ };
+
+ wifi_error status = global_func_table_.wifi_get_link_stats(
+ 0, wlan_interface_handle_, {onLinkLayerStatsDataResult});
+ on_link_layer_stats_result_internal_callback = nullptr;
+ return {status, link_stats};
+}
+
wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
const std::string& ifname_to_find = getStaIfaceName();
wifi_interface_handle* iface_handles = nullptr;
@@ -245,12 +441,44 @@
if_tool.SetWifiUpState(false);
}
+std::pair<wifi_error, std::vector<wifi_cached_scan_results>>
+WifiLegacyHal::getGscanCachedResults() {
+ std::vector<wifi_cached_scan_results> cached_scan_results;
+ cached_scan_results.resize(kMaxCachedGscanResults);
+ int32_t num_results = 0;
+ wifi_error status = global_func_table_.wifi_get_cached_gscan_results(
+ wlan_interface_handle_,
+ true /* always flush */,
+ cached_scan_results.size(),
+ cached_scan_results.data(),
+ &num_results);
+ CHECK(num_results >= 0 &&
+ static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults);
+ cached_scan_results.resize(num_results);
+ // Check for invalid IE lengths in these cached scan results and correct it.
+ for (auto& cached_scan_result : cached_scan_results) {
+ int num_scan_results = cached_scan_result.num_results;
+ for (int i = 0; i < num_scan_results; i++) {
+ auto& scan_result = cached_scan_result.results[i];
+ if (scan_result.ie_length > 0) {
+ LOG(ERROR) << "Cached scan result has non-zero IE length "
+ << scan_result.ie_length;
+ scan_result.ie_length = 0;
+ }
+ }
+ }
+ return {status, std::move(cached_scan_results)};
+}
+
void WifiLegacyHal::invalidate() {
global_handle_ = nullptr;
wlan_interface_handle_ = nullptr;
on_stop_complete_internal_callback = nullptr;
on_driver_memory_dump_internal_callback = nullptr;
on_firmware_memory_dump_internal_callback = nullptr;
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ on_link_layer_stats_result_internal_callback = nullptr;
}
} // namespace legacy_hal
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
index 8bd146a..df1c3d6 100644
--- a/wifi/1.0/default/wifi_legacy_hal.h
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -39,6 +39,31 @@
uint32_t max_len;
};
+// WARNING: We don't care about the variable sized members of either
+// |wifi_iface_stat|, |wifi_radio_stat| structures. So, using the pragma
+// to escape the compiler warnings regarding this.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
+// The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in
+// |wifi_radio_stat| structure in the legacy HAL API. Separate that out
+// into a separate return element to avoid passing pointers around.
+struct LinkLayerStats {
+ wifi_iface_stat iface;
+ wifi_radio_stat radio;
+ std::vector<uint32_t> radio_tx_time_per_levels;
+};
+#pragma GCC diagnostic pop
+
+// Full scan results contain IE info and are hence passed by reference, to
+// preserve the variable length array member |ie_data|. Callee must not retain
+// the pointer.
+using on_gscan_full_result_callback =
+ std::function<void(wifi_request_id, const wifi_scan_result*, uint32_t)>;
+// These scan results don't contain any IE info, so no need to pass by
+// reference.
+using on_gscan_results_callback = std::function<void(
+ wifi_request_id, const std::vector<wifi_cached_scan_results>&)>;
+
/**
* Class that encapsulates all legacy HAL interactions.
* This class manages the lifetime of the event loop thread used by legacy HAL.
@@ -65,12 +90,41 @@
// APF functions.
std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities();
wifi_error setPacketFilter(const std::vector<uint8_t>& program);
+ // Gscan functions.
+ std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities();
+ // These API's provides a simplified interface over the legacy Gscan API's:
+ // a) All scan events from the legacy HAL API other than the
+ // |WIFI_SCAN_FAILED| are treated as notification of results.
+ // This method then retrieves the cached scan results from the legacy
+ // HAL API and triggers the externally provided |on_results_user_callback|
+ // on success.
+ // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan results
+ // triggers the externally provided |on_failure_user_callback|.
+ // c) Full scan result event triggers the externally provided
+ // |on_full_result_user_callback|.
+ wifi_error startGscan(
+ wifi_request_id id,
+ const wifi_scan_cmd_params& params,
+ const std::function<void(wifi_request_id)>& on_failure_callback,
+ const on_gscan_results_callback& on_results_callback,
+ const on_gscan_full_result_callback& on_full_result_callback);
+ wifi_error stopGscan(wifi_request_id id);
+ std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForGscan(
+ wifi_band band);
+ // Link layer stats functions.
+ wifi_error enableLinkLayerStats(bool debug);
+ wifi_error disableLinkLayerStats();
+ std::pair<wifi_error, LinkLayerStats> getLinkLayerStats();
private:
// Retrieve the interface handle to be used for the "wlan" interface.
wifi_error retrieveWlanInterfaceHandle();
// Run the legacy HAL event loop thread.
void runEventLoop();
+ // Retrieve the cached gscan results to pass the results back to the external
+ // callbacks.
+ std::pair<wifi_error, std::vector<wifi_cached_scan_results>>
+ getGscanCachedResults();
void invalidate();
// Event loop thread used by legacy HAL.
diff --git a/wifi/supplicant/1.0/Android.bp b/wifi/supplicant/1.0/Android.bp
index 0f399a0..e66f973 100644
--- a/wifi/supplicant/1.0/Android.bp
+++ b/wifi/supplicant/1.0/Android.bp
@@ -129,6 +129,7 @@
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "liblog",
"libutils",
"libcutils",
],