Camera: Silence log spam am: 207867716a
am: 6ccc129e91
Change-Id: Ida70914135764b034aff9c09b288df5a31cb9c60
diff --git a/CleanSpec.mk b/CleanSpec.mk
index c557635..01b5e7b 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -54,3 +54,5 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/android.hardware.bluetooth*)
$(call add-clean-step, rm -rf $(OUT)/soong/.intermediates/)
$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates/hardware/interfaces/)
+$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates/hardware/interfaces/)
+$(call add-clean-step, find $(PRODUCT_OUT)/system $(PRODUCT_OUT)/vendor -type f -name "android\.hardware\.configstore*" -print0 | xargs -0 rm -f)
\ No newline at end of file
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index 671f171..effdd28 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -44,8 +44,20 @@
}
// static
-Result Stream::analyzeStatus(const char* funcName, int status, int ignoreError, int ignoreError2) {
- if (status != 0 && status != -ignoreError && status != -ignoreError2) {
+Result Stream::analyzeStatus(const char* funcName, int status) {
+ static const std::vector<int> empty;
+ return analyzeStatus(funcName, status, empty);
+}
+
+template <typename T>
+inline bool element_in(T e, const std::vector<T>& v) {
+ return std::find(v.begin(), v.end(), e) != v.end();
+}
+
+// static
+Result Stream::analyzeStatus(const char* funcName, int status,
+ const std::vector<int>& ignoreErrors) {
+ if (status != 0 && (ignoreErrors.empty() || !element_in(-status, ignoreErrors))) {
ALOGW("Error from HAL stream in function %s: %s", funcName, strerror(-status));
}
switch (status) {
diff --git a/audio/2.0/default/Stream.h b/audio/2.0/default/Stream.h
index b49e658..82f05a7 100644
--- a/audio/2.0/default/Stream.h
+++ b/audio/2.0/default/Stream.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
+#include <vector>
+
#include <android/hardware/audio/2.0/IStream.h>
#include <hardware/audio.h>
#include <hidl/Status.h>
@@ -79,10 +81,11 @@
Return<Result> close() override;
// Utility methods for extending interfaces.
- static Result analyzeStatus(
- const char* funcName, int status, int ignoreError = OK, int ignoreError2 = OK);
+ static Result analyzeStatus(const char* funcName, int status);
+ static Result analyzeStatus(const char* funcName, int status,
+ const std::vector<int>& ignoreErrors);
- private:
+ private:
audio_stream_t *mStream;
virtual ~Stream();
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index abd0497..b81cbb9 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -416,15 +416,15 @@
// static
Result StreamIn::getCapturePositionImpl(audio_stream_in_t* stream,
uint64_t* frames, uint64_t* time) {
+ // HAL may have a stub function, always returning ENOSYS, don't
+ // spam the log in this case.
+ static const std::vector<int> ignoredErrors{ENOSYS};
Result retval(Result::NOT_SUPPORTED);
if (stream->get_capture_position != NULL) return retval;
int64_t halFrames, halTime;
- retval = Stream::analyzeStatus(
- "get_capture_position",
- stream->get_capture_position(stream, &halFrames, &halTime),
- // HAL may have a stub function, always returning ENOSYS, don't
- // spam the log in this case.
- ENOSYS);
+ retval = Stream::analyzeStatus("get_capture_position",
+ stream->get_capture_position(stream, &halFrames, &halTime),
+ ignoredErrors);
if (retval == Result::OK) {
*frames = halFrames;
*time = halTime;
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index e48497f..290d0b1 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -487,16 +487,17 @@
Result StreamOut::getPresentationPositionImpl(audio_stream_out_t* stream,
uint64_t* frames,
TimeSpec* timeStamp) {
+ // Don't logspam on EINVAL--it's normal for get_presentation_position
+ // to return it sometimes. EAGAIN may be returned by A2DP audio HAL
+ // implementation. ENODATA can also be reported while the writer is
+ // continuously querying it, but the stream has been stopped.
+ static const std::vector<int> ignoredErrors{EINVAL, EAGAIN, ENODATA};
Result retval(Result::NOT_SUPPORTED);
if (stream->get_presentation_position == NULL) return retval;
struct timespec halTimeStamp;
- retval = Stream::analyzeStatus(
- "get_presentation_position",
- stream->get_presentation_position(stream, frames, &halTimeStamp),
- // Don't logspam on EINVAL--it's normal for get_presentation_position
- // to return it sometimes. EAGAIN may be returned by A2DP audio HAL
- // implementation.
- EINVAL, EAGAIN);
+ retval = Stream::analyzeStatus("get_presentation_position",
+ stream->get_presentation_position(stream, frames, &halTimeStamp),
+ ignoredErrors);
if (retval == Result::OK) {
timeStamp->tvSec = halTimeStamp.tv_sec;
timeStamp->tvNSec = halTimeStamp.tv_nsec;
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 8ac8a29..90fec01 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -557,8 +557,7 @@
TEST_F(AudioPrimaryHidlTest, DebugDump) {
doc::test("Check that the hal can dump its state without error");
- testDebugDump(
- [this](const auto& handle) { return device->debugDump(handle); });
+ testDebugDump([](const auto& handle) { return device->debugDump(handle); });
}
TEST_F(AudioPrimaryHidlTest, DebugDumpInvalidArguments) {
@@ -1341,8 +1340,7 @@
TEST_F(AudioPrimaryHidlTest, setVoiceVolume) {
doc::test("Make sure setVoiceVolume only succeed if volume is in [0,1]");
- testUnitaryGain(
- [this](float volume) { return device->setVoiceVolume(volume); });
+ testUnitaryGain([](float volume) { return device->setVoiceVolume(volume); });
}
TEST_F(AudioPrimaryHidlTest, setMode) {
diff --git a/audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd b/audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd
new file mode 100644
index 0000000..64647de
--- /dev/null
+++ b/audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd
@@ -0,0 +1,238 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://schemas.android.com/audio/audio_effects_conf/v2_0"
+ xmlns:aec="http://schemas.android.com/audio/audio_effects_conf/v2_0"
+ elementFormDefault="qualified">
+
+ <!-- Simple types -->
+ <xs:simpleType name="versionType">
+ <xs:restriction base="xs:decimal">
+ <xs:enumeration value="2.0"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="uuidType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="streamInputType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="mic"/>
+ <xs:enumeration value="voice_uplink"/>
+ <xs:enumeration value="voice_downlink"/>
+ <xs:enumeration value="voice_call"/>
+ <xs:enumeration value="camcorder"/>
+ <xs:enumeration value="voice_recognition"/>
+ <xs:enumeration value="voice_communication"/>
+ <xs:enumeration value="unprocessed"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="streamOutputType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="default"/>
+ <xs:enumeration value="voice_call"/>
+ <xs:enumeration value="system"/>
+ <xs:enumeration value="ring"/>
+ <xs:enumeration value="music"/>
+ <xs:enumeration value="alarm"/>
+ <xs:enumeration value="notification"/>
+ <xs:enumeration value="bluetooth_sco"/>
+ <xs:enumeration value="enforced_audible"/>
+ <xs:enumeration value="dtmf"/>
+ <xs:enumeration value="tts"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <!-- Complex types -->
+ <xs:complexType name="libraryType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ List of effect libraries to load. Each library element must have "name" and
+ "path" attributes. The latter is giving the full path of the library .so file.
+
+ Example:
+
+ <library name="name" path="/vendor/lib/soundfx/lib.so"/>
+
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="library" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="path" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="effectImplType">
+ <xs:attribute name="library" type="xs:string" use="required"/>
+ <xs:attribute name="uuid" type="aec:uuidType" use="required"/>
+ </xs:complexType>
+ <xs:complexType name="effectProxyType">
+ <xs:complexContent>
+ <xs:extension base="aec:effectImplType">
+ <xs:sequence>
+ <xs:element name="libsw" type="aec:effectImplType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="libhw" type="aec:effectImplType" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="effectType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ List of effects to load. Each effect element must contain "name",
+ "library", and "uuid" attrs. The value of the "library" attr must
+ correspond to the name of a "library" element. The name of the effect
+ element is indicative, only the value of the "uuid" element designates
+ the effect for the audio framework. The uuid is the implementation
+ specific UUID as specified by the effect vendor. This is not the generic
+ effect type UUID.
+
+ For effect proxy implementations, SW and HW implemetations of the effect
+ can be specified.
+
+ Example:
+
+ <effect name="name" library="lib" uuid="uuuu"/>
+ <effect name="proxied" library="proxy" uuid="xxxx">
+ <libsw library="sw_bundle" uuid="yyyy"/>
+ <libhw library="offload_bundle" uuid="zzzz"/>
+ </effect>
+
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="effect" type="aec:effectProxyType" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="streamProcessingType">
+ <xs:sequence>
+ <xs:element name="apply" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="effect" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="streamPreprocessType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ Audio preprocessing configuration. The processing configuration consists
+ of a list of elements each describing processing settings for a given
+ input stream. Valid input stream types are listed in "streamInputType".
+
+ Each stream element contains a list of "apply" elements. The value of the
+ "effect" attr must correspond to the name of an "effect" element.
+
+ Example:
+
+ <stream type="voice_communication">
+ <apply effect="effect1"/>
+ <apply effect="effect2"/>
+ </stream>
+
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
+ <xs:extension base="aec:streamProcessingType">
+ <xs:attribute name="type" type="aec:streamInputType" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType name="streamPostprocessType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ Audio postprocessing configuration. The processing configuration consists
+ of a list of elements each describing processing settings for a given
+ output stream. Valid output stream types are listed in "streamOutputType".
+
+ Each stream element contains a list of "apply" elements. The value of the
+ "effect" attr must correspond to the name of an "effect" element.
+
+ Example:
+
+ <stream type="music">
+ <apply effect="effect1"/>
+ </stream>
+
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
+ <xs:extension base="aec:streamProcessingType">
+ <xs:attribute name="type" type="aec:streamOutputType" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!-- Root element -->
+ <xs:element name="audio_effects_conf">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="libraries" type="aec:libraryType"/>
+ <xs:element name="effects" type="aec:effectType"/>
+ <xs:element name="postprocess" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="stream" type="aec:streamPostprocessType" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="preprocess" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="stream" type="aec:streamPreprocessType" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="version" type="aec:versionType" use="required"/>
+ </xs:complexType>
+
+ <!-- Keys and references -->
+ <xs:key name="libraryName">
+ <xs:selector xpath="aec:libraries/aec:library"/>
+ <xs:field xpath="@name"/>
+ </xs:key>
+ <xs:keyref name="libraryNameRef1" refer="aec:libraryName">
+ <xs:selector xpath="aec:effects/aec:effect"/>
+ <xs:field xpath="@library"/>
+ </xs:keyref>
+ <xs:keyref name="libraryNameRef2" refer="aec:libraryName">
+ <xs:selector xpath="aec:effects/aec:effect/aec:libsw"/>
+ <xs:field xpath="@library"/>
+ </xs:keyref>
+ <xs:keyref name="libraryNameRef3" refer="aec:libraryName">
+ <xs:selector xpath="aec:effects/aec:effect/aec:libhw"/>
+ <xs:field xpath="@library"/>
+ </xs:keyref>
+ <xs:key name="effectName">
+ <xs:selector xpath="aec:effects/aec:effect"/>
+ <xs:field xpath="@name"/>
+ </xs:key>
+ <xs:keyref name="effectNamePreRef" refer="aec:effectName">
+ <xs:selector xpath="aec:preprocess/aec:stream/aec:apply"/>
+ <xs:field xpath="@effect"/>
+ </xs:keyref>
+ <xs:keyref name="effectNamePostRef" refer="aec:effectName">
+ <xs:selector xpath="aec:postprocess/aec:stream/aec:apply"/>
+ <xs:field xpath="@effect"/>
+ </xs:keyref>
+ </xs:element>
+</xs:schema>
diff --git a/automotive/Android.bp b/automotive/Android.bp
index aec8865..be58829 100644
--- a/automotive/Android.bp
+++ b/automotive/Android.bp
@@ -1,7 +1,6 @@
// This is an autogenerated file, do not edit.
subdirs = [
"evs/1.0",
- "evs/1.0/default",
"evs/1.0/vts/functional",
"vehicle/2.0",
"vehicle/2.1",
diff --git a/automotive/evs/1.0/default/Android.bp b/automotive/evs/1.0/default/Android.bp
deleted file mode 100644
index 2574e86..0000000
--- a/automotive/evs/1.0/default/Android.bp
+++ /dev/null
@@ -1,31 +0,0 @@
-cc_binary {
- name: "android.hardware.automotive.evs@1.0-service",
- defaults: ["hidl_defaults"],
- proprietary: true,
- relative_install_path: "hw",
- srcs: [
- "service.cpp",
- "EvsCamera.cpp",
- "EvsEnumerator.cpp",
- "EvsDisplay.cpp"
- ],
- init_rc: ["android.hardware.automotive.evs@1.0-service.rc"],
-
- shared_libs: [
- "android.hardware.automotive.evs@1.0",
- "libui",
- "libbase",
- "libbinder",
- "libcutils",
- "libhardware",
- "libhidlbase",
- "libhidltransport",
- "liblog",
- "libutils",
- ],
-
- cflags: [
- "-O0",
- "-g",
- ],
-}
diff --git a/automotive/evs/1.0/default/Android.mk b/automotive/evs/1.0/default/Android.mk
new file mode 100644
index 0000000..0ee7071
--- /dev/null
+++ b/automotive/evs/1.0/default/Android.mk
@@ -0,0 +1,29 @@
+LOCAL_PATH:=$(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.automotive.evs@1.0-service
+LOCAL_INIT_RC := android.hardware.automotive.evs@1.0-service.rc
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_VENDOR_MODULE := true
+
+LOCAL_SRC_FILES := \
+ service.cpp \
+ EvsCamera.cpp \
+ EvsEnumerator.cpp \
+ EvsDisplay.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.automotive.evs@1.0 \
+ libui \
+ libbase \
+ libbinder \
+ libcutils \
+ libhardware \
+ libhidlbase \
+ libhidltransport \
+ liblog \
+ libutils \
+
+LOCAL_CFLAGS := -O0 -g
+
+include $(BUILD_EXECUTABLE)
diff --git a/automotive/evs/1.0/vts/functional/FormatConvert.cpp b/automotive/evs/1.0/vts/functional/FormatConvert.cpp
index e5cc8ee..1e8929d 100644
--- a/automotive/evs/1.0/vts/functional/FormatConvert.cpp
+++ b/automotive/evs/1.0/vts/functional/FormatConvert.cpp
@@ -18,8 +18,6 @@
#include "FormatConvert.h"
-#include <algorithm> // std::min
-
// Round up to the nearest multiple of the given alignment value
template<unsigned alignment>
diff --git a/automotive/vehicle/2.0/default/Android.mk b/automotive/vehicle/2.0/default/Android.mk
index d5f5678..c63899d 100644
--- a/automotive/vehicle/2.0/default/Android.mk
+++ b/automotive/vehicle/2.0/default/Android.mk
@@ -98,6 +98,7 @@
$(vhal_v2_0) \
LOCAL_STATIC_LIBRARIES := \
+ libqemu_pipe \
$(vhal_v2_0)-libproto-native \
LOCAL_CFLAGS += -Wall -Wextra -Werror
@@ -165,6 +166,7 @@
$(vhal_v2_0)-manager-lib \
$(vhal_v2_0)-default-impl-lib \
$(vhal_v2_0)-libproto-native \
+ libqemu_pipe \
LOCAL_CFLAGS += -Wall -Wextra -Werror
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h
index be25adc..0ed8742 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h
@@ -26,6 +26,7 @@
#include <set>
#include <thread>
#include <unordered_map>
+#include <vector>
/**
* This class allows to specify multiple time intervals to receive
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp b/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp
index 311cdef..9146fa1 100644
--- a/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp
@@ -102,10 +102,10 @@
}
void shallowCopyHidlStr(hidl_string* dest, const hidl_string& src) {
- if (!src.empty()) {
+ if (src.empty()) {
+ dest->clear();
+ } else {
dest->setToExternal(src.c_str(), src.size());
- } else if (dest->size() > 0) {
- dest->setToExternal(0, 0);
}
}
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h
index 009485d..c25e083 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h
@@ -25,14 +25,11 @@
#include <utils/SystemClock.h>
-#include "VehicleHalProto.pb.h"
-
#include <vhal_v2_0/RecurrentTimer.h>
#include <vhal_v2_0/VehicleHal.h>
#include "vhal_v2_0/VehiclePropertyStore.h"
#include "DefaultConfig.h"
-#include "VehicleHalProto.pb.h"
#include "VehicleEmulator.h"
#include "FakeValueGenerator.h"
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp
index 2b15aa3..5a9b254 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/PipeComm.cpp
@@ -17,9 +17,8 @@
#define LOG_TAG "PipeComm"
#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
-#include <android/log.h>
#include <log/log.h>
-#include <system/qemu_pipe.h>
+#include <qemu_pipe.h>
#include "PipeComm.h"
diff --git a/automotive/vehicle/2.1/Android.mk b/automotive/vehicle/2.1/Android.mk
index 693fe2d..8e1c0dd 100644
--- a/automotive/vehicle/2.1/Android.mk
+++ b/automotive/vehicle/2.1/Android.mk
@@ -208,9 +208,9 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
-# Build types.hal (VmsMessageIntegerValuesIndex)
+# Build types.hal (VmsBaseMessageIntegerValuesIndex)
#
-GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsMessageIntegerValuesIndex.java
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsBaseMessageIntegerValuesIndex.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -220,7 +220,7 @@
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
- android.hardware.automotive.vehicle@2.1::types.VmsMessageIntegerValuesIndex
+ android.hardware.automotive.vehicle@2.1::types.VmsBaseMessageIntegerValuesIndex
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
@@ -246,6 +246,63 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (VmsOfferingMessageIntegerValuesIndex)
+#
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsOfferingMessageIntegerValuesIndex.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.automotive.vehicle@2.1::types.VmsOfferingMessageIntegerValuesIndex
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (VmsSimpleMessageIntegerValuesIndex)
+#
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsSimpleMessageIntegerValuesIndex.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.automotive.vehicle@2.1::types.VmsSimpleMessageIntegerValuesIndex
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (VmsSubscriptionResponseFormat)
+#
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsSubscriptionResponseFormat.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.automotive.vehicle@2.1::types.VmsSubscriptionResponseFormat
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build IVehicle.hal
#
GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/IVehicle.java
@@ -472,9 +529,9 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
-# Build types.hal (VmsMessageIntegerValuesIndex)
+# Build types.hal (VmsBaseMessageIntegerValuesIndex)
#
-GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsMessageIntegerValuesIndex.java
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsBaseMessageIntegerValuesIndex.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -484,7 +541,7 @@
-Ljava \
-randroid.hardware:hardware/interfaces \
-randroid.hidl:system/libhidl/transport \
- android.hardware.automotive.vehicle@2.1::types.VmsMessageIntegerValuesIndex
+ android.hardware.automotive.vehicle@2.1::types.VmsBaseMessageIntegerValuesIndex
$(GEN): $(LOCAL_PATH)/types.hal
$(transform-generated-source)
@@ -510,6 +567,63 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (VmsOfferingMessageIntegerValuesIndex)
+#
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsOfferingMessageIntegerValuesIndex.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.automotive.vehicle@2.1::types.VmsOfferingMessageIntegerValuesIndex
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (VmsSimpleMessageIntegerValuesIndex)
+#
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsSimpleMessageIntegerValuesIndex.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.automotive.vehicle@2.1::types.VmsSimpleMessageIntegerValuesIndex
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (VmsSubscriptionResponseFormat)
+#
+GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/VmsSubscriptionResponseFormat.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.automotive.vehicle@2.1::types.VmsSubscriptionResponseFormat
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build IVehicle.hal
#
GEN := $(intermediates)/android/hardware/automotive/vehicle/V2_1/IVehicle.java
diff --git a/automotive/vehicle/2.1/default/Android.mk b/automotive/vehicle/2.1/default/Android.mk
index 32ec456..f19263c 100644
--- a/automotive/vehicle/2.1/default/Android.mk
+++ b/automotive/vehicle/2.1/default/Android.mk
@@ -65,6 +65,7 @@
LOCAL_STATIC_LIBRARIES := \
$(vhal_v2_0)-default-impl-lib \
$(vhal_v2_0)-manager-lib \
+ libqemu_pipe \
$(vhal_v2_1)-manager-lib \
$(vhal_v2_0)-libproto-native
@@ -101,6 +102,7 @@
$(vhal_v2_0)-manager-lib \
$(vhal_v2_0)-default-impl-lib \
$(vhal_v2_1)-default-impl-lib \
+ libqemu_pipe \
$(vhal_v2_1)-manager-lib \
LOCAL_SHARED_LIBRARIES := \
diff --git a/automotive/vehicle/2.1/default/impl/vhal_v2_1/EmulatedVehicleHal.cpp b/automotive/vehicle/2.1/default/impl/vhal_v2_1/EmulatedVehicleHal.cpp
index 4dceae0..46e062b 100644
--- a/automotive/vehicle/2.1/default/impl/vhal_v2_1/EmulatedVehicleHal.cpp
+++ b/automotive/vehicle/2.1/default/impl/vhal_v2_1/EmulatedVehicleHal.cpp
@@ -23,7 +23,6 @@
#include <algorithm>
#include "EmulatedVehicleHal.h"
-#include "VehicleHalProto.pb.h"
#define DEBUG_SOCKET (33452)
@@ -139,6 +138,8 @@
for (auto&& dtc : sampleDtcs) {
auto freezeFrame = createVehiclePropValue(V2_0::VehiclePropertyType::COMPLEX, 0);
sensorStore->fillPropValue(dtc, freezeFrame.get());
+ freezeFrame->prop = OBD2_FREEZE_FRAME;
+
mPropStore->writeValue(*freezeFrame);
}
}
diff --git a/automotive/vehicle/2.1/types.hal b/automotive/vehicle/2.1/types.hal
index 08dc144..7be611c 100644
--- a/automotive/vehicle/2.1/types.hal
+++ b/automotive/vehicle/2.1/types.hal
@@ -584,22 +584,70 @@
/** A client publishes a data packet. */
DATA = 3,
+
+ /* A client declaring layers offering. */
+ OFFERING = 4,
+
+ /* Requesting the list of available layers. */
+ AVAILABILITY_REQUEST = 5,
+
+ /* Returning the list of available layers. */
+ AVAILABILITY_RESPONSE = 6,
+
+ /** Requesting layers that have subscribers. */
+ SUBSCRIPTION_REQUEST = 7,
+
+ /** Returning layers that have subscribers. */
+ SUBSCRIPTION_RESPONSE = 8,
};
/**
* This enum provides the canonical mapping for VMS properties that have an
* integer value.
*/
-enum VmsMessageIntegerValuesIndex : int32_t {
- /** The message type as enumerated by VmsMessageType enum. */
+enum VmsBaseMessageIntegerValuesIndex : int32_t {
+ /* The message type as enumerated by VmsMessageType enum. */
VMS_MESSAGE_TYPE = 0,
+};
- /** The layer ID as defined in the vms protocol. */
+/*
+ * This enum provides the canonical mapping for VMS SUBMIT, UNSUBMIT and DATA
+ * messages integer value properties.
+ */
+enum VmsSimpleMessageIntegerValuesIndex : VmsBaseMessageIntegerValuesIndex {
+ /* The layer ID as defined in the vms protocol. */
VMS_LAYER_ID = 1,
- /** The version of the VMS layer. */
+ /* The version of the VMS layer. */
VMS_LAYER_VERSION = 2,
+};
- /** The number of bytes in the payload */
- VMS_PAYLOAD_SIZE_BYTES = 3,
+/*
+ * This enum provides the canonical mapping for VMS offering messages integer
+ * value properties
+ */
+enum VmsOfferingMessageIntegerValuesIndex : VmsBaseMessageIntegerValuesIndex {
+ /* The number of VMS layer dependencies. */
+ VMS_NUMBER_OF_LAYERS_DEPENDENCIES = 1,
+
+ /* The first index that contain dependencies */
+ FIRST_DEPENDENCIES_INDEX = 2,
+};
+
+/**
+ * A VMS subscription request only contains its message type. The format of a VMS subscription
+ * response is described below.
+ */
+enum VmsSubscriptionResponseFormat : VmsBaseMessageIntegerValuesIndex {
+ /**
+ * Recipients should ignore any packet with a sequence number that is less than the highest
+ * sequence number they have seen thus far.
+ */
+ SEQUENCE_NUMBER = 1,
+
+ /** The number of VMS layers. Each layer has two integers: type and version. */
+ NUMBER_OF_LAYERS = 2,
+
+ /** The first index that contains a layer. */
+ FIRST_LAYER = 3,
};
diff --git a/broadcastradio/1.0/Android.mk b/broadcastradio/1.0/Android.mk
deleted file mode 100644
index f9e3276..0000000
--- a/broadcastradio/1.0/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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/broadcastradio/1.0/default/Android.bp b/broadcastradio/1.0/default/Android.bp
new file mode 100644
index 0000000..f961dfd
--- /dev/null
+++ b/broadcastradio/1.0/default/Android.bp
@@ -0,0 +1,41 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library_shared {
+ name: "android.hardware.broadcastradio@1.0-impl",
+ vendor: true,
+ relative_install_path: "hw",
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ srcs: [
+ "BroadcastRadio.cpp",
+ "BroadcastRadioFactory.cpp",
+ "Tuner.cpp",
+ "Utils.cpp",
+ ],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "liblog",
+ "libhardware",
+ "android.hardware.broadcastradio@1.0",
+ "libradio_metadata",
+ ],
+}
diff --git a/broadcastradio/1.0/default/Android.mk b/broadcastradio/1.0/default/Android.mk
deleted file mode 100644
index bb32595..0000000
--- a/broadcastradio/1.0/default/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.broadcastradio@1.0-impl
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
- BroadcastRadio.cpp \
- BroadcastRadioFactory.cpp \
- Tuner.cpp \
- Utils.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libhidlbase \
- libhidltransport \
- 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/vts/Android.mk b/broadcastradio/1.0/vts/Android.mk
deleted file mode 100644
index f9e3276..0000000
--- a/broadcastradio/1.0/vts/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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/broadcastradio/1.1/Android.mk b/broadcastradio/1.1/Android.mk
deleted file mode 100644
index 0c4c55d..0000000
--- a/broadcastradio/1.1/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-subdir-makefiles)
diff --git a/broadcastradio/1.1/ITuner.hal b/broadcastradio/1.1/ITuner.hal
index 82d45c6..7511629 100644
--- a/broadcastradio/1.1/ITuner.hal
+++ b/broadcastradio/1.1/ITuner.hal
@@ -47,8 +47,8 @@
*
* @return result OK if the scan was properly scheduled (this does not mean
* it successfully finished).
- * TEMPORARILY_UNAVAILABLE if the background scan is
- * temporarily unavailable, ie. due to ongoing foreground
+ * UNAVAILABLE if the background scan is unavailable,
+ * ie. temporarily due to ongoing foreground
* playback in single-tuner device.
* NOT_INITIALIZED other error, ie. HW failure.
*/
@@ -65,6 +65,7 @@
* Client application MUST verify vendor/product name
* before setting this parameter to anything else.
* @return result OK if the list was successfully retrieved.
+ * INVALID_ARGUMENTS if invalid arguments are passed
* NOT_READY if the scan is in progress.
* NOT_STARTED if the scan has not been started, client may
* call startBackgroundScan to fix this.
@@ -74,4 +75,33 @@
getProgramList(string filter)
generates (ProgramListResult result, vec<ProgramInfo> programList);
+ /**
+ * Checks, if the analog playback is forced, see setAnalogForced.
+ *
+ * The isForced value is only valid if result was OK.
+ *
+ * @return result OK if the call succeeded and isForced is valid.
+ * INVALID_STATE if the switch is not supported at current
+ * configuration.
+ * NOT_INITIALIZED if any other error occurs.
+ * @return isForced true if analog is forced, false otherwise.
+ */
+ isAnalogForced() generates (Result result, bool isForced);
+
+ /**
+ * Forces the analog playback for the supporting radio technology.
+ *
+ * User may disable digital playback for FM HD Radio or hybrid FM/DAB with
+ * this option. This is purely user choice, ie. does not reflect digital-
+ * analog handover managed from the HAL implementation side.
+ *
+ * Some radio technologies may not support this, ie. DAB.
+ *
+ * @param isForced true to force analog, false for a default behaviour.
+ * @return result OK if the setting was successfully done.
+ * INVALID_STATE if the switch is not supported at current
+ * configuration.
+ * NOT_INITIALIZED if any other error occurs.
+ */
+ setAnalogForced(bool isForced) generates (Result result);
};
diff --git a/broadcastradio/1.1/ITunerCallback.hal b/broadcastradio/1.1/ITunerCallback.hal
index 07ce984..158e217 100644
--- a/broadcastradio/1.1/ITunerCallback.hal
+++ b/broadcastradio/1.1/ITunerCallback.hal
@@ -40,11 +40,19 @@
oneway afSwitch_1_1(ProgramInfo info);
/**
+ * Called by the HAL when background scan feature becomes available or not.
+ *
+ * @param isAvailable true, if the tuner turned temporarily background-
+ * capable, false in the other case.
+ */
+ oneway backgroundScanAvailable(bool isAvailable);
+
+ /**
* Called by the HAL when background scan initiated by startBackgroundScan
* finishes. If the list was changed, programListChanged must be called too.
* @param result OK if the scan succeeded, client may retrieve the actual
* list with ITuner::getProgramList.
- * TEMPORARILY_UNAVAILABLE if the scan was interrupted due to
+ * UNAVAILABLE if the scan was interrupted due to
* hardware becoming temporarily unavailable.
* NOT_INITIALIZED other error, ie. HW failure.
*/
diff --git a/broadcastradio/1.1/default/Android.bp b/broadcastradio/1.1/default/Android.bp
new file mode 100644
index 0000000..759eb09
--- /dev/null
+++ b/broadcastradio/1.1/default/Android.bp
@@ -0,0 +1,42 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library_shared {
+ name: "android.hardware.broadcastradio@1.1-impl",
+ vendor: true,
+ relative_install_path: "hw",
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ srcs: [
+ "BroadcastRadio.cpp",
+ "BroadcastRadioFactory.cpp",
+ "Tuner.cpp",
+ "Utils.cpp",
+ ],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "liblog",
+ "libhardware",
+ "android.hardware.broadcastradio@1.0",
+ "android.hardware.broadcastradio@1.1",
+ "libradio_metadata",
+ ],
+}
diff --git a/broadcastradio/1.1/default/Android.mk b/broadcastradio/1.1/default/Android.mk
deleted file mode 100644
index bb32d50..0000000
--- a/broadcastradio/1.1/default/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.broadcastradio@1.1-impl
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_CFLAGS += -Werror -Wall -Wextra
-LOCAL_SRC_FILES := \
- BroadcastRadio.cpp \
- BroadcastRadioFactory.cpp \
- Tuner.cpp \
- Utils.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libhidlbase \
- libhidltransport \
- libutils \
- liblog \
- libhardware \
- android.hardware.broadcastradio@1.0 \
- android.hardware.broadcastradio@1.1 \
- libradio_metadata
-
-ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
-LOCAL_MULTILIB := 32
-else
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-endif
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp
index f280754..ae5848c 100644
--- a/broadcastradio/1.1/default/Tuner.cpp
+++ b/broadcastradio/1.1/default/Tuner.cpp
@@ -201,16 +201,27 @@
}
Return<ProgramListResult> Tuner::startBackgroundScan() {
- return ProgramListResult::NOT_INITIALIZED;
+ return ProgramListResult::UNAVAILABLE;
}
Return<void> Tuner::getProgramList(const hidl_string& filter __unused, getProgramList_cb _hidl_cb) {
hidl_vec<ProgramInfo> pList;
// TODO(b/34054813): do the actual implementation.
- _hidl_cb(ProgramListResult::NOT_INITIALIZED, pList);
+ _hidl_cb(ProgramListResult::NOT_STARTED, pList);
return Void();
}
+Return<void> Tuner::isAnalogForced(isAnalogForced_cb _hidl_cb) {
+ // TODO(b/34348946): do the actual implementation.
+ _hidl_cb(Result::INVALID_STATE, false);
+ return Void();
+}
+
+Return<Result> Tuner::setAnalogForced(bool isForced __unused) {
+ // TODO(b/34348946): do the actual implementation.
+ return Result::INVALID_STATE;
+}
+
} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio
diff --git a/broadcastradio/1.1/default/Tuner.h b/broadcastradio/1.1/default/Tuner.h
index d7b4545..57eafd3 100644
--- a/broadcastradio/1.1/default/Tuner.h
+++ b/broadcastradio/1.1/default/Tuner.h
@@ -44,6 +44,8 @@
Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
Return<ProgramListResult> startBackgroundScan() override;
Return<void> getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override;
+ Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
+ Return<Result> setAnalogForced(bool isForced) override;
static void callback(radio_hal_event_t *halEvent, void *cookie);
void onCallback(radio_hal_event_t *halEvent);
diff --git a/broadcastradio/1.1/types.hal b/broadcastradio/1.1/types.hal
index 3021f2e..5577ea0 100644
--- a/broadcastradio/1.1/types.hal
+++ b/broadcastradio/1.1/types.hal
@@ -23,7 +23,7 @@
enum ProgramListResult : Result {
NOT_READY,
NOT_STARTED,
- TEMPORARILY_UNAVAILABLE,
+ UNAVAILABLE,
};
/**
@@ -53,6 +53,18 @@
* it may not be available though, see startBackgroundScan.
*/
bool supportsBackgroundScanning;
+
+ /**
+ * Opaque vendor-specific string, to be passed to front-end without changes.
+ * Format of this string can vary across vendors.
+ *
+ * It may be used for extra features, that's not supported by a platform,
+ * for example: "preset-slots=6;ultra-hd-capable=false".
+ *
+ * Front-end application MUST verify vendor/product name from the
+ * @1.0::Properties struct before doing any interpretation of this value.
+ */
+ string vendorExension;
};
/**
@@ -64,10 +76,14 @@
bitfield<ProgramInfoFlags> flags;
/**
- * Vendors are allowed to define their own set of flags and store it in this
- * field. They MUST verify vendor/product name from Properties struct
- * (IBroadcastRadio::getProperties) before doing any interpretation
- * of such values.
+ * Opaque vendor-specific string, to be passed to front-end without changes.
+ * Format of this string can vary across vendors.
+ *
+ * It may be used for extra features, that's not supported by a platform,
+ * for example: "paid-service=true;bitrate=320kbps".
+ *
+ * Front-end application MUST verify vendor/product name from the
+ * @1.0::Properties struct before doing any interpretation of this value.
*/
- uint32_t vendorFlags;
+ string vendorExension;
};
diff --git a/broadcastradio/1.1/vts/Android.mk b/broadcastradio/1.1/vts/Android.mk
deleted file mode 100644
index 0c4c55d..0000000
--- a/broadcastradio/1.1/vts/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-subdir-makefiles)
diff --git a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
index d3c05c4..aa5ab54 100644
--- a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
+++ b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
@@ -129,6 +129,10 @@
return Void();
}
+ virtual Return<void> backgroundScanAvailable(bool isAvailable __unused) {
+ return Void();
+ }
+
virtual Return<void> backgroundScanComplete(ProgramListResult result __unused) {
return Void();
}
diff --git a/broadcastradio/Android.bp b/broadcastradio/Android.bp
index 5cacbf3..7a315fa 100644
--- a/broadcastradio/Android.bp
+++ b/broadcastradio/Android.bp
@@ -1,7 +1,9 @@
// This is an autogenerated file, do not edit.
subdirs = [
"1.0",
+ "1.0/default",
"1.0/vts/functional",
"1.1",
+ "1.1/default",
"1.1/vts/functional",
]
diff --git a/camera/common/1.0/default/include/HandleImporter.h b/camera/common/1.0/default/include/HandleImporter.h
index c68cfc0..e47397c 100644
--- a/camera/common/1.0/default/include/HandleImporter.h
+++ b/camera/common/1.0/default/include/HandleImporter.h
@@ -17,9 +17,9 @@
#ifndef CAMERA_COMMON_1_0_HANDLEIMPORTED_H
#define CAMERA_COMMON_1_0_HANDLEIMPORTED_H
-#include <system/window.h>
#include <utils/Mutex.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <cutils/native_handle.h>
using android::hardware::graphics::mapper::V2_0::IMapper;
diff --git a/camera/provider/2.4/default/Android.bp b/camera/provider/2.4/default/Android.bp
index d897fc7..f2a2d2e 100644
--- a/camera/provider/2.4/default/Android.bp
+++ b/camera/provider/2.4/default/Android.bp
@@ -38,7 +38,7 @@
shared_libs: [
"libhidlbase",
"libhidltransport",
- "libbinder",
+ "libbinder",
"liblog",
"libutils",
"android.hardware.camera.device@1.0",
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index c8e44d3..7a29d42 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -2217,11 +2217,11 @@
inputStream, zslStream, outputStream};
StreamConfiguration config = {streams,
StreamConfigurationMode::NORMAL_MODE};
- ret = session->configureStreams(config, [streamId] (Status s,
- HalStreamConfiguration halConfig) {
- ASSERT_EQ(Status::OK, s);
- ASSERT_EQ(3u, halConfig.streams.size());
- });
+ ret = session->configureStreams(config,
+ [](Status s, HalStreamConfiguration halConfig) {
+ ASSERT_EQ(Status::OK, s);
+ ASSERT_EQ(3u, halConfig.streams.size());
+ });
ASSERT_TRUE(ret.isOk());
}
}
@@ -2280,11 +2280,11 @@
previewStream, blobStream};
StreamConfiguration config = {streams,
StreamConfigurationMode::NORMAL_MODE};
- ret = session->configureStreams(config, [streamId] (Status s,
- HalStreamConfiguration halConfig) {
- ASSERT_EQ(Status::OK, s);
- ASSERT_EQ(2u, halConfig.streams.size());
- });
+ ret = session->configureStreams(config,
+ [](Status s, HalStreamConfiguration halConfig) {
+ ASSERT_EQ(Status::OK, s);
+ ASSERT_EQ(2u, halConfig.streams.size());
+ });
ASSERT_TRUE(ret.isOk());
}
}
@@ -2348,8 +2348,7 @@
streams[0] = stream;
config = {streams,
StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE};
- ret = session->configureStreams(config, [streamId] (Status s,
- HalStreamConfiguration) {
+ ret = session->configureStreams(config, [](Status s, HalStreamConfiguration) {
ASSERT_TRUE((Status::ILLEGAL_ARGUMENT == s) ||
(Status::INTERNAL_ERROR == s));
});
@@ -2363,8 +2362,7 @@
streams[0] = stream;
config = {streams,
StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE};
- ret = session->configureStreams(config, [streamId] (Status s,
- HalStreamConfiguration) {
+ ret = session->configureStreams(config, [](Status s, HalStreamConfiguration) {
ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
});
ASSERT_TRUE(ret.isOk());
@@ -2377,8 +2375,7 @@
streams[0] = stream;
config = {streams,
StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE};
- ret = session->configureStreams(config, [streamId] (Status s,
- HalStreamConfiguration) {
+ ret = session->configureStreams(config, [](Status s, HalStreamConfiguration) {
ASSERT_EQ(Status::ILLEGAL_ARGUMENT, s);
});
ASSERT_TRUE(ret.isOk());
@@ -2438,11 +2435,11 @@
videoStream, blobStream};
StreamConfiguration config = {streams,
StreamConfigurationMode::NORMAL_MODE};
- ret = session->configureStreams(config, [streamId] (Status s,
- HalStreamConfiguration halConfig) {
- ASSERT_EQ(Status::OK, s);
- ASSERT_EQ(2u, halConfig.streams.size());
- });
+ ret = session->configureStreams(config,
+ [](Status s, HalStreamConfiguration halConfig) {
+ ASSERT_EQ(Status::OK, s);
+ ASSERT_EQ(2u, halConfig.streams.size());
+ });
ASSERT_TRUE(ret.isOk());
}
}
diff --git a/compatibility_matrix.xml b/compatibility_matrix.xml
index 9aa5418..9603bd6 100644
--- a/compatibility_matrix.xml
+++ b/compatibility_matrix.xml
@@ -204,6 +204,10 @@
</interface>
</hal>
<hal format="hidl" optional="true">
+ <name>android.hardware.oemlock</name>
+ <version>1.0</version>
+ </hal>
+ <hal format="hidl" optional="true">
<name>android.hardware.power</name>
<version>1.0</version>
<interface>
@@ -304,6 +308,10 @@
</interface>
</hal>
<hal format="hidl" optional="true">
+ <name>android.hardware.weaver</name>
+ <version>1.0</version>
+ </hal>
+ <hal format="hidl" optional="true">
<name>android.hardware.wifi</name>
<version>1.0</version>
<interface>
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.h b/configstore/1.0/default/SurfaceFlingerConfigs.h
deleted file mode 100644
index 17a424e..0000000
--- a/configstore/1.0/default/SurfaceFlingerConfigs.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef ANDROID_HARDWARE_CONFIGSTORE_V1_0_SURFACEFLINGERCONFIGS_H
-#define ANDROID_HARDWARE_CONFIGSTORE_V1_0_SURFACEFLINGERCONFIGS_H
-
-#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace configstore {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs;
-using ::android::hardware::configstore::V1_0::OptionalBool;
-using ::android::hidl::base::V1_0::IBase;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-struct SurfaceFlingerConfigs : public ISurfaceFlingerConfigs {
- // Methods from ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs follow.
- Return<void> vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) override;
- Return<void> vsyncSfEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) override;
- Return<void> useContextPriority(useContextPriority_cb _hidl_cb) override;
- Return<void> hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) override;
- Return<void> hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) override;
- Return<void> presentTimeOffsetFromVSyncNs(presentTimeOffsetFromVSyncNs_cb _hidl_cb) override;
- Return<void> useHwcForRGBtoYUV(useHwcForRGBtoYUV_cb _hidl_cb) override;
- Return<void> maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) override;
- Return<void> hasSyncFramework(hasSyncFramework_cb _hidl_cb) override;
- Return<void> useVrFlinger(useVrFlinger_cb _hidl_cb) override;
- Return<void> maxFrameBufferAcquiredBuffers(maxFrameBufferAcquiredBuffers_cb _hidl_cb) override;
- Return<void> startGraphicsAllocatorService(
- startGraphicsAllocatorService_cb _hidl_cb) override;
-
- // Methods from ::android::hidl::base::V1_0::IBase follow.
-
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace configstore
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_CONFIGSTORE_V1_0_SURFACEFLINGERCONFIGS_H
diff --git a/configstore/1.0/default/android.hardware.configstore@1.0-service.rc b/configstore/1.0/default/android.hardware.configstore@1.0-service.rc
deleted file mode 100644
index 563d854..0000000
--- a/configstore/1.0/default/android.hardware.configstore@1.0-service.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service configstore-hal-1-0 /vendor/bin/hw/android.hardware.configstore@1.0-service
- class hal animation
- user system
- group system
diff --git a/configstore/1.1/Android.bp b/configstore/1.1/Android.bp
new file mode 100644
index 0000000..91c5dd3
--- /dev/null
+++ b/configstore/1.1/Android.bp
@@ -0,0 +1,60 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.configstore@1.1_hal",
+ srcs: [
+ "ISurfaceFlingerConfigs.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.configstore@1.1_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.configstore@1.1",
+ srcs: [
+ ":android.hardware.configstore@1.1_hal",
+ ],
+ out: [
+ "android/hardware/configstore/1.1/SurfaceFlingerConfigsAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.configstore@1.1_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.configstore@1.1",
+ srcs: [
+ ":android.hardware.configstore@1.1_hal",
+ ],
+ out: [
+ "android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h",
+ "android/hardware/configstore/1.1/IHwSurfaceFlingerConfigs.h",
+ "android/hardware/configstore/1.1/BnHwSurfaceFlingerConfigs.h",
+ "android/hardware/configstore/1.1/BpHwSurfaceFlingerConfigs.h",
+ "android/hardware/configstore/1.1/BsSurfaceFlingerConfigs.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.configstore@1.1",
+ generated_sources: ["android.hardware.configstore@1.1_genc++"],
+ generated_headers: ["android.hardware.configstore@1.1_genc++_headers"],
+ export_generated_headers: ["android.hardware.configstore@1.1_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.configstore@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.configstore@1.0",
+ ],
+}
diff --git a/configstore/1.1/Android.mk b/configstore/1.1/Android.mk
new file mode 100644
index 0000000..a5fa6c4
--- /dev/null
+++ b/configstore/1.1/Android.mk
@@ -0,0 +1,78 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.configstore-V1.1-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hardware.configstore-V1.0-java \
+ android.hidl.base-V1.0-java \
+
+
+#
+# Build ISurfaceFlingerConfigs.hal
+#
+GEN := $(intermediates)/android/hardware/configstore/V1_1/ISurfaceFlingerConfigs.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/ISurfaceFlingerConfigs.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.configstore@1.1::ISurfaceFlingerConfigs
+
+$(GEN): $(LOCAL_PATH)/ISurfaceFlingerConfigs.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.configstore-V1.1-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hardware.configstore-V1.0-java-static \
+ android.hidl.base-V1.0-java-static \
+
+
+#
+# Build ISurfaceFlingerConfigs.hal
+#
+GEN := $(intermediates)/android/hardware/configstore/V1_1/ISurfaceFlingerConfigs.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/ISurfaceFlingerConfigs.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.configstore@1.1::ISurfaceFlingerConfigs
+
+$(GEN): $(LOCAL_PATH)/ISurfaceFlingerConfigs.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/configstore/1.1/ISurfaceFlingerConfigs.hal b/configstore/1.1/ISurfaceFlingerConfigs.hal
new file mode 100644
index 0000000..5eacbe0
--- /dev/null
+++ b/configstore/1.1/ISurfaceFlingerConfigs.hal
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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.configstore@1.1;
+
+import @1.0::ISurfaceFlingerConfigs;
+
+/**
+ * New revision of ISurfaceFlingerConfigs
+ */
+
+interface ISurfaceFlingerConfigs extends @1.0::ISurfaceFlingerConfigs {
+};
diff --git a/configstore/1.0/default/Android.mk b/configstore/1.1/default/Android.mk
similarity index 75%
rename from configstore/1.0/default/Android.mk
rename to configstore/1.1/default/Android.mk
index e017cfd..ac3d8b0 100644
--- a/configstore/1.0/default/Android.mk
+++ b/configstore/1.1/default/Android.mk
@@ -2,17 +2,18 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.configstore@1.0-service
+LOCAL_MODULE := android.hardware.configstore@1.1-service
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_INIT_RC := android.hardware.configstore@1.0-service.rc
+LOCAL_INIT_RC := android.hardware.configstore@1.1-service.rc
LOCAL_SRC_FILES:= service.cpp
include $(LOCAL_PATH)/surfaceflinger.mk
LOCAL_SHARED_LIBRARIES := \
android.hardware.configstore@1.0 \
+ android.hardware.configstore@1.1 \
libhidlbase \
libhidltransport \
libbase \
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.cpp b/configstore/1.1/default/SurfaceFlingerConfigs.cpp
similarity index 70%
rename from configstore/1.0/default/SurfaceFlingerConfigs.cpp
rename to configstore/1.1/default/SurfaceFlingerConfigs.cpp
index 9c134ef..5a040f2 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.cpp
+++ b/configstore/1.1/default/SurfaceFlingerConfigs.cpp
@@ -1,14 +1,29 @@
-#include "SurfaceFlingerConfigs.h"
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.1 (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.1
+ *
+ * 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 <android-base/logging.h>
+#include "SurfaceFlingerConfigs.h"
namespace android {
namespace hardware {
namespace configstore {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
-// Methods from ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs follow.
+// Methods from ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs
+// follow.
Return<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
#ifdef VSYNC_EVENT_PHASE_OFFSET_NS
_hidl_cb({true, VSYNC_EVENT_PHASE_OFFSET_NS});
@@ -36,7 +51,8 @@
return Void();
}
-Return<void> SurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers(maxFrameBufferAcquiredBuffers_cb _hidl_cb) {
+Return<void> SurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers(
+ maxFrameBufferAcquiredBuffers_cb _hidl_cb) {
#ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS
_hidl_cb({true, NUM_FRAMEBUFFER_SURFACE_BUFFERS});
#else
@@ -72,13 +88,14 @@
return Void();
}
-Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs(presentTimeOffsetFromVSyncNs_cb _hidl_cb) {
+Return<void> SurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs(
+ presentTimeOffsetFromVSyncNs_cb _hidl_cb) {
#ifdef PRESENT_TIME_OFFSET_FROM_VSYNC_NS
- _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS});
+ _hidl_cb({true, PRESENT_TIME_OFFSET_FROM_VSYNC_NS});
#else
- _hidl_cb({false, 0});
+ _hidl_cb({false, 0});
#endif
- return Void();
+ return Void();
}
Return<void> SurfaceFlingerConfigs::useHwcForRGBtoYUV(useHwcForRGBtoYUV_cb _hidl_cb) {
@@ -91,14 +108,14 @@
}
Return<void> SurfaceFlingerConfigs::maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) {
- uint64_t maxSize = 0;
+ uint64_t maxSize = 0;
#ifdef MAX_VIRTUAL_DISPLAY_DIMENSION
- maxSize = MAX_VIRTUAL_DISPLAY_DIMENSION;
- _hidl_cb({true, maxSize});
+ maxSize = MAX_VIRTUAL_DISPLAY_DIMENSION;
+ _hidl_cb({true, maxSize});
#else
- _hidl_cb({false, maxSize});
+ _hidl_cb({false, maxSize});
#endif
- return Void();
+ return Void();
}
Return<void> SurfaceFlingerConfigs::useVrFlinger(useVrFlinger_cb _hidl_cb) {
@@ -122,8 +139,13 @@
return Void();
}
+// Methods from ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs
+// follow.
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
} // namespace implementation
-} // namespace V1_0
+} // namespace V1_1
} // namespace configstore
} // namespace hardware
} // namespace android
diff --git a/configstore/1.1/default/SurfaceFlingerConfigs.h b/configstore/1.1/default/SurfaceFlingerConfigs.h
new file mode 100644
index 0000000..53e8ae8
--- /dev/null
+++ b/configstore/1.1/default/SurfaceFlingerConfigs.h
@@ -0,0 +1,47 @@
+#ifndef ANDROID_HARDWARE_CONFIGSTORE_V1_1_SURFACEFLINGERCONFIGS_H
+#define ANDROID_HARDWARE_CONFIGSTORE_V1_1_SURFACEFLINGERCONFIGS_H
+
+#include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace configstore {
+namespace V1_1 {
+namespace implementation {
+
+using ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct SurfaceFlingerConfigs : public ISurfaceFlingerConfigs {
+ // Methods from
+ // ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs follow.
+ Return<void> vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) override;
+ Return<void> vsyncSfEventPhaseOffsetNs(vsyncSfEventPhaseOffsetNs_cb _hidl_cb) override;
+ Return<void> useContextPriority(useContextPriority_cb _hidl_cb) override;
+ Return<void> hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) override;
+ Return<void> hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) override;
+ Return<void> presentTimeOffsetFromVSyncNs(presentTimeOffsetFromVSyncNs_cb _hidl_cb) override;
+ Return<void> useHwcForRGBtoYUV(useHwcForRGBtoYUV_cb _hidl_cb) override;
+ Return<void> maxVirtualDisplaySize(maxVirtualDisplaySize_cb _hidl_cb) override;
+ Return<void> hasSyncFramework(hasSyncFramework_cb _hidl_cb) override;
+ Return<void> useVrFlinger(useVrFlinger_cb _hidl_cb) override;
+ Return<void> maxFrameBufferAcquiredBuffers(maxFrameBufferAcquiredBuffers_cb _hidl_cb) override;
+ Return<void> startGraphicsAllocatorService(startGraphicsAllocatorService_cb _hidl_cb) override;
+
+ // Methods from
+ // ::android::hardware::configstore::V1_1::ISurfaceFlingerConfigs follow.
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+};
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace configstore
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_CONFIGSTORE_V1_1_SURFACEFLINGERCONFIGS_H
diff --git a/configstore/1.1/default/android.hardware.configstore@1.1-service.rc b/configstore/1.1/default/android.hardware.configstore@1.1-service.rc
new file mode 100644
index 0000000..018ef10
--- /dev/null
+++ b/configstore/1.1/default/android.hardware.configstore@1.1-service.rc
@@ -0,0 +1,4 @@
+service configstore-hal /vendor/bin/hw/android.hardware.configstore@1.1-service
+ class hal animation
+ user system
+ group system
diff --git a/configstore/1.0/default/service.cpp b/configstore/1.1/default/service.cpp
similarity index 76%
rename from configstore/1.0/default/service.cpp
rename to configstore/1.1/default/service.cpp
index 60b69ab..3a4cd3f 100644
--- a/configstore/1.0/default/service.cpp
+++ b/configstore/1.1/default/service.cpp
@@ -1,11 +1,11 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.1 (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
+ * http://www.apache.org/licenses/LICENSE-2.1
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,17 +14,17 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.configstore@1.0-service"
+#define LOG_TAG "android.hardware.configstore@1.1-service"
-#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
+#include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h>
#include <hidl/HidlTransportSupport.h>
#include "SurfaceFlingerConfigs.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
-using android::hardware::configstore::V1_0::ISurfaceFlingerConfigs;
-using android::hardware::configstore::V1_0::implementation::SurfaceFlingerConfigs;
+using android::hardware::configstore::V1_1::ISurfaceFlingerConfigs;
+using android::hardware::configstore::V1_1::implementation::SurfaceFlingerConfigs;
using android::sp;
using android::status_t;
using android::OK;
diff --git a/configstore/1.0/default/surfaceflinger.mk b/configstore/1.1/default/surfaceflinger.mk
similarity index 100%
rename from configstore/1.0/default/surfaceflinger.mk
rename to configstore/1.1/default/surfaceflinger.mk
diff --git a/configstore/Android.bp b/configstore/Android.bp
index ba3e62e..21dc2b4 100644
--- a/configstore/Android.bp
+++ b/configstore/Android.bp
@@ -2,5 +2,6 @@
subdirs = [
"1.0",
"1.0/vts/functional",
+ "1.1",
"utils",
]
diff --git a/contexthub/1.0/default/Android.bp b/contexthub/1.0/default/Android.bp
index 78d27cc..9f5131d 100644
--- a/contexthub/1.0/default/Android.bp
+++ b/contexthub/1.0/default/Android.bp
@@ -32,3 +32,23 @@
"android.hardware.contexthub@1.0",
],
}
+
+cc_binary {
+ name: "android.hardware.contexthub@1.0-service",
+ relative_install_path: "hw",
+ proprietary: true,
+ init_rc: ["android.hardware.contexthub@1.0-service.rc"],
+ srcs: ["service.cpp"],
+
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libdl",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libutils",
+ "android.hardware.contexthub@1.0",
+ ],
+}
diff --git a/contexthub/1.0/default/Android.mk b/contexthub/1.0/default/Android.mk
deleted file mode 100644
index 917bfe0..0000000
--- a/contexthub/1.0/default/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.contexthub@1.0-service
-LOCAL_INIT_RC := android.hardware.contexthub@1.0-service.rc
-LOCAL_SRC_FILES := \
- service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libcutils \
- libdl \
- libhardware \
- libhidlbase \
- libhidltransport \
- liblog \
- libutils \
- android.hardware.contexthub@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
index 04f2658..26641e8 100644
--- a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
@@ -16,7 +16,6 @@
#define LOG_TAG "drm_hal_clearkey_test@1.0"
-#include <android-base/logging.h>
#include <android/hardware/drm/1.0/ICryptoFactory.h>
#include <android/hardware/drm/1.0/ICryptoPlugin.h>
#include <android/hardware/drm/1.0/IDrmFactory.h>
@@ -27,8 +26,8 @@
#include <hidl/HidlSupport.h>
#include <hidlmemory/mapping.h>
#include <log/log.h>
-#include <openssl/aes.h>
#include <memory>
+#include <openssl/aes.h>
#include <random>
#include "VtsHalHidlTargetTestBase.h"
diff --git a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
index 33fb6fb..e2c9cca 100644
--- a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
@@ -16,7 +16,6 @@
#define LOG_TAG "drm_hal_vendor_test@1.0"
-#include <android-base/logging.h>
#include <android/hardware/drm/1.0/ICryptoFactory.h>
#include <android/hardware/drm/1.0/ICryptoPlugin.h>
#include <android/hardware/drm/1.0/IDrmFactory.h>
@@ -27,8 +26,8 @@
#include <gtest/gtest.h>
#include <hidlmemory/mapping.h>
#include <log/log.h>
-#include <openssl/aes.h>
#include <memory>
+#include <openssl/aes.h>
#include <random>
#include "drm_hal_vendor_module_api.h"
diff --git a/dumpstate/1.0/default/DumpstateDevice.cpp b/dumpstate/1.0/default/DumpstateDevice.cpp
index 213fc62..818a531 100644
--- a/dumpstate/1.0/default/DumpstateDevice.cpp
+++ b/dumpstate/1.0/default/DumpstateDevice.cpp
@@ -37,7 +37,7 @@
// this interface - since HIDL_FETCH_IDumpstateDevice() is not defined, this function will never
// be called by dumpstate.
- if (handle->numFds < 1) {
+ if (handle == nullptr || handle->numFds < 1) {
ALOGE("no FDs\n");
return Void();
}
diff --git a/gnss/1.0/default/android.hardware.gnss@1.0-service.rc b/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
index 96638a3..1f6d13e 100644
--- a/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
+++ b/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
@@ -1,4 +1,4 @@
service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service
- class main
- user system
+ class hal
+ user gps
group system gps
diff --git a/graphics/allocator/2.0/default/service.cpp b/graphics/allocator/2.0/default/service.cpp
index a43740c..99f462c 100644
--- a/graphics/allocator/2.0/default/service.cpp
+++ b/graphics/allocator/2.0/default/service.cpp
@@ -24,5 +24,5 @@
using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- return defaultPassthroughServiceImplementation<IAllocator>();
+ return defaultPassthroughServiceImplementation<IAllocator>(4);
}
diff --git a/graphics/mapper/2.0/default/GrallocMapper.h b/graphics/mapper/2.0/default/GrallocMapper.h
index aa1aeaa..e876fe4 100644
--- a/graphics/mapper/2.0/default/GrallocMapper.h
+++ b/graphics/mapper/2.0/default/GrallocMapper.h
@@ -18,7 +18,7 @@
#define ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC_MAPPER_H
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
-#include <system/window.h>
+#include <cutils/native_handle.h>
#include <mutex>
#include <unordered_set>
diff --git a/keymaster/3.0/default/Android.mk b/keymaster/3.0/default/Android.mk
index 9df5bf8..87ad245 100644
--- a/keymaster/3.0/default/Android.mk
+++ b/keymaster/3.0/default/Android.mk
@@ -11,7 +11,8 @@
liblog \
libsoftkeymasterdevice \
libcrypto \
- libkeymaster1 \
+ libkeymaster_portable \
+ libkeymaster_staging \
libhidlbase \
libhidltransport \
libutils \
diff --git a/keymaster/3.0/default/KeymasterDevice.cpp b/keymaster/3.0/default/KeymasterDevice.cpp
index fcdd329..d83963f 100644
--- a/keymaster/3.0/default/KeymasterDevice.cpp
+++ b/keymaster/3.0/default/KeymasterDevice.cpp
@@ -64,7 +64,7 @@
assert(mod->module_api_version < KEYMASTER_MODULE_API_VERSION_1_0);
ALOGI("Found keymaster0 module %s, version %x", mod->name, mod->module_api_version);
- UniquePtr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
+ std::unique_ptr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
keymaster0_device_t* km0_device = NULL;
keymaster_error_t error = KM_ERROR_OK;
@@ -107,7 +107,7 @@
assert(mod->module_api_version >= KEYMASTER_MODULE_API_VERSION_1_0);
ALOGI("Found keymaster1 module %s, version %x", mod->name, mod->module_api_version);
- UniquePtr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
+ std::unique_ptr<SoftKeymasterDevice> soft_keymaster(new SoftKeymasterDevice);
keymaster1_device_t* km1_device = nullptr;
keymaster_error_t error = KM_ERROR_OK;
diff --git a/media/Android.bp b/media/Android.bp
index f25a609..53e82bd 100644
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -3,6 +3,7 @@
"1.0",
"omx/1.0",
"omx/1.0/vts/functional/audio",
+ "omx/1.0/vts/functional/common",
"omx/1.0/vts/functional/component",
"omx/1.0/vts/functional/master",
"omx/1.0/vts/functional/video",
diff --git a/media/omx/1.0/vts/functional/audio/Android.bp b/media/omx/1.0/vts/functional/audio/Android.bp
index d6c73ce..66fd20b 100644
--- a/media/omx/1.0/vts/functional/audio/Android.bp
+++ b/media/omx/1.0/vts/functional/audio/Android.bp
@@ -34,7 +34,8 @@
"android.hidl.memory@1.0",
"android.hardware.media.omx@1.0",
],
- static_libs: ["VtsHalHidlTargetTestBase"],
+ static_libs: ["VtsHalHidlTargetTestBase",
+ "VtsHalMediaOmxV1_0CommonUtil"],
cflags: [
"-O0",
"-g",
@@ -65,7 +66,8 @@
"android.hidl.memory@1.0",
"android.hardware.media.omx@1.0",
],
- static_libs: ["VtsHalHidlTargetTestBase"],
+ static_libs: ["VtsHalHidlTargetTestBase",
+ "VtsHalMediaOmxV1_0CommonUtil"],
cflags: [
"-O0",
"-g",
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
index 1cc1817..5ba195e 100644
--- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
+++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
@@ -30,6 +30,7 @@
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -136,7 +137,9 @@
gEnv->getInstance());
ASSERT_NE(omx, nullptr);
observer =
- new CodecObserver([this](Message msg) { handleMessage(msg); });
+ new CodecObserver([this](Message msg, const BufferInfo* buffer) {
+ handleMessage(msg, buffer);
+ });
ASSERT_NE(observer, nullptr);
if (strncmp(gEnv->getComponent().c_str(), "OMX.", 4) != 0)
disableTest = true;
@@ -218,7 +221,8 @@
// callback function to process messages received by onMessages() from IL
// client.
- void handleMessage(Message msg) {
+ void handleMessage(Message msg, const BufferInfo* buffer) {
+ (void)buffer;
if (msg.type == Message::Type::FILL_BUFFER_DONE) {
if (msg.data.extendedBufferData.flags & OMX_BUFFERFLAG_EOS) {
eosFlag = true;
@@ -254,13 +258,26 @@
}
}
}
+#define WRITE_OUTPUT 0
+#if WRITE_OUTPUT
+ static int count = 0;
+ FILE* ofp = nullptr;
+ if (count)
+ ofp = fopen("out.bin", "ab");
+ else
+ ofp = fopen("out.bin", "wb");
+ if (ofp != nullptr) {
+ fwrite(static_cast<void*>(buffer->mMemory->getPointer()),
+ sizeof(char),
+ msg.data.extendedBufferData.rangeLength, ofp);
+ fclose(ofp);
+ count++;
+ }
+#endif
}
}
}
- void testEOS(android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, bool signalEOS = false);
-
enum standardComp {
mp3,
amrnb,
@@ -294,44 +311,6 @@
}
};
-// end of stream test for audio decoder components
-void AudioDecHidlTest::testEOS(android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- bool signalEOS) {
- android::hardware::media::omx::V1_0::Status status;
- size_t i = 0;
- if (signalEOS) {
- if ((i = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
- // signal an empty buffer with flag set to EOS
- dispatchInputBuffer(omxNode, iBuffer, i, 0, OMX_BUFFERFLAG_EOS, 0);
- } else {
- ASSERT_TRUE(false);
- }
- }
- // Dispatch all client owned output buffers to recover remaining frames
- while (1) {
- if ((i = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
- dispatchOutputBuffer(omxNode, oBuffer, i);
- } else {
- break;
- }
- }
- while (1) {
- Message msg;
- status =
- observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- EXPECT_EQ(status,
- android::hardware::media::omx::V1_0::Status::TIMED_OUT);
- for (; i < iBuffer->size(); i++) {
- if ((*iBuffer)[i].owner != client) break;
- }
- if (i == iBuffer->size()) break;
- }
- // test for flag
- EXPECT_EQ(eosFlag, true);
- eosFlag = false;
-}
-
// Set Default port param.
void setDefaultPortParam(
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding,
@@ -580,8 +559,9 @@
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput) {
android::hardware::media::omx::V1_0::Status status;
Message msg;
+ int timeOut = TIMEOUT_COUNTER;
- while (1) {
+ while (timeOut--) {
size_t i = 0;
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
@@ -603,6 +583,7 @@
if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
dispatchOutputBuffer(omxNode, oBuffer, index);
}
+ timeOut--;
}
}
@@ -642,6 +623,8 @@
frameID++;
}
+ int timeOut = TIMEOUT_COUNTER;
+ bool stall = false;
while (1) {
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
@@ -672,9 +655,21 @@
(*Info)[frameID].bytesCount, flags,
(*Info)[frameID].timestamp);
frameID++;
- }
+ stall = false;
+ } else
+ stall = true;
if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
dispatchOutputBuffer(omxNode, oBuffer, index);
+ stall = false;
+ } else
+ stall = true;
+ if (stall)
+ timeOut--;
+ else
+ timeOut = TIMEOUT_COUNTER;
+ if (timeOut == 0) {
+ EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite";
+ break;
}
}
}
@@ -778,7 +773,7 @@
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
EXPECT_EQ(timestampUslist.empty(), true);
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
@@ -825,7 +820,7 @@
changeStateIdletoExecute(omxNode, observer);
// request EOS at the start
- testEOS(&iBuffer, &oBuffer, true);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 0U);
@@ -908,7 +903,7 @@
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@@ -924,7 +919,7 @@
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer, true);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@@ -1004,7 +999,7 @@
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
framesReceived = 0;
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
index bd4e84f..ecd9ef9 100644
--- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
+++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
@@ -30,6 +30,7 @@
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -135,7 +136,10 @@
omx = ::testing::VtsHalHidlTargetTestBase::getService<IOmx>(
gEnv->getInstance());
ASSERT_NE(omx, nullptr);
- observer = new CodecObserver([this](Message msg) { (void)msg; });
+ observer =
+ new CodecObserver([this](Message msg, const BufferInfo* buffer) {
+ handleMessage(msg, buffer);
+ });
ASSERT_NE(observer, nullptr);
if (strncmp(gEnv->getComponent().c_str(), "OMX.", 4) != 0)
disableTest = true;
@@ -191,6 +195,7 @@
}
}
if (i == kNumCompToCoding) disableTest = true;
+ eosFlag = false;
if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n";
}
@@ -201,6 +206,36 @@
}
}
+ // callback function to process messages received by onMessages() from IL
+ // client.
+ void handleMessage(Message msg, const BufferInfo* buffer) {
+ (void)buffer;
+
+ if (msg.type == Message::Type::FILL_BUFFER_DONE) {
+ if (msg.data.extendedBufferData.flags & OMX_BUFFERFLAG_EOS) {
+ eosFlag = true;
+ }
+ if (msg.data.extendedBufferData.rangeLength != 0) {
+#define WRITE_OUTPUT 0
+#if WRITE_OUTPUT
+ static int count = 0;
+ FILE* ofp = nullptr;
+ if (count)
+ ofp = fopen("out.bin", "ab");
+ else
+ ofp = fopen("out.bin", "wb");
+ if (ofp != nullptr) {
+ fwrite(static_cast<void*>(buffer->mMemory->getPointer()),
+ sizeof(char),
+ msg.data.extendedBufferData.rangeLength, ofp);
+ fclose(ofp);
+ count++;
+ }
+#endif
+ }
+ }
+ }
+
enum standardComp {
amrnb,
amrwb,
@@ -215,6 +250,7 @@
standardComp compName;
OMX_AUDIO_CODINGTYPE eEncoding;
bool disableTest;
+ bool eosFlag;
protected:
static void description(const std::string& description) {
@@ -289,12 +325,44 @@
}
}
+// blocking call to ensures application to Wait till all the inputs are consumed
+void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+ int timeOut = TIMEOUT_COUNTER;
+
+ while (timeOut--) {
+ size_t i = 0;
+ status =
+ observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ EXPECT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+ // status == TIMED_OUT, it could be due to process time being large
+ // than DEFAULT_TIMEOUT or component needs output buffers to start
+ // processing.
+ for (; i < iBuffer->size(); i++) {
+ if ((*iBuffer)[i].owner != client) break;
+ }
+ if (i == iBuffer->size()) break;
+
+ // Dispatch an output buffer assuming outQueue.empty() is true
+ size_t index;
+ if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
+ dispatchOutputBuffer(omxNode, oBuffer, index);
+ }
+ timeOut--;
+ }
+}
+
// Encode N Frames
void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer, uint32_t nFrames,
int32_t samplesPerFrame, int32_t nChannels,
- int32_t nSampleRate, std::ifstream& eleStream) {
+ int32_t nSampleRate, std::ifstream& eleStream,
+ bool signalEOS = true) {
android::hardware::media::omx::V1_0::Status status;
Message msg;
@@ -307,6 +375,7 @@
int32_t timestampIncr =
(int)(((float)samplesPerFrame / nSampleRate) * 1000000);
uint64_t timestamp = 0;
+ uint32_t flags = 0;
for (size_t i = 0; i < iBuffer->size() && nFrames != 0; i++) {
char* ipBuffer = static_cast<char*>(
static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
@@ -314,11 +383,14 @@
static_cast<int>((*iBuffer)[i].mMemory->getSize()));
eleStream.read(ipBuffer, bytesCount);
if (eleStream.gcount() != bytesCount) break;
- dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, 0, timestamp);
+ if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS;
+ dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, flags, timestamp);
timestamp += timestampIncr;
nFrames--;
}
+ int timeOut = TIMEOUT_COUNTER;
+ bool stall = false;
while (1) {
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
@@ -337,14 +409,27 @@
static_cast<int>((*iBuffer)[index].mMemory->getSize()));
eleStream.read(ipBuffer, bytesCount);
if (eleStream.gcount() != bytesCount) break;
- dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, 0,
+ if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS;
+ dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, flags,
timestamp);
timestamp += timestampIncr;
nFrames--;
- }
+ stall = false;
+ } else
+ stall = true;
// Dispatch output buffer
if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
dispatchOutputBuffer(omxNode, oBuffer, index);
+ stall = false;
+ } else
+ stall = true;
+ if (stall)
+ timeOut--;
+ else
+ timeOut = TIMEOUT_COUNTER;
+ if (timeOut == 0) {
+ EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite";
+ break;
}
}
}
@@ -380,8 +465,8 @@
}
// test raw stream encode
-TEST_F(AudioEncHidlTest, EncodeTest) {
- description("Tests Encode");
+TEST_F(AudioEncHidlTest, SimpleEncodeTest) {
+ description("Tests Basic encoding and EOS");
if (disableTest) return;
android::hardware::media::omx::V1_0::Status status;
uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
@@ -399,8 +484,6 @@
GetURLForComponent(compName, mURL);
std::ifstream eleStream;
- eleStream.open(mURL, std::ifstream::binary);
- ASSERT_EQ(eleStream.is_open(), true);
// Configure input port
int32_t nChannels = 2;
@@ -449,16 +532,19 @@
// set state to executing
changeStateIdletoExecute(omxNode, observer);
- encodeNFrames(omxNode, observer, &iBuffer, &oBuffer, 1024, samplesPerFrame,
+ eleStream.open(mURL, std::ifstream::binary);
+ ASSERT_EQ(eleStream.is_open(), true);
+ encodeNFrames(omxNode, observer, &iBuffer, &oBuffer, 128, samplesPerFrame,
nChannels, nSampleRate, eleStream);
+ eleStream.close();
+ waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
// set state to executing
changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput);
-
- eleStream.close();
}
int main(int argc, char** argv) {
diff --git a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
index f09d21d..abd044d 100644
--- a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
+++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
@@ -30,6 +30,7 @@
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -45,277 +46,6 @@
#include <media_hidl_test_common.h>
#include <memory>
-// allocate buffers needed on a component port
-void allocatePortBuffers(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- OMX_U32 portIndex) {
- android::hardware::media::omx::V1_0::Status status;
- OMX_PARAM_PORTDEFINITIONTYPE portDef;
-
- buffArray->clear();
-
- sp<IAllocator> allocator = IAllocator::getService("ashmem");
- EXPECT_NE(allocator.get(), nullptr);
-
- status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
- &portDef);
- ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
-
- for (size_t i = 0; i < portDef.nBufferCountActual; i++) {
- BufferInfo buffer;
- buffer.owner = client;
- buffer.omxBuffer.type = CodecBuffer::Type::SHARED_MEM;
- buffer.omxBuffer.attr.preset.rangeOffset = 0;
- buffer.omxBuffer.attr.preset.rangeLength = 0;
- bool success = false;
- allocator->allocate(
- portDef.nBufferSize,
- [&success, &buffer](bool _s,
- ::android::hardware::hidl_memory const& mem) {
- success = _s;
- buffer.omxBuffer.sharedMemory = mem;
- });
- ASSERT_EQ(success, true);
- ASSERT_EQ(buffer.omxBuffer.sharedMemory.size(), portDef.nBufferSize);
- buffer.mMemory = mapMemory(buffer.omxBuffer.sharedMemory);
- ASSERT_NE(buffer.mMemory, nullptr);
- omxNode->useBuffer(
- portIndex, buffer.omxBuffer,
- [&status, &buffer](android::hardware::media::omx::V1_0::Status _s,
- uint32_t id) {
- status = _s;
- buffer.id = id;
- });
- buffArray->push(buffer);
- ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
- }
-}
-
-// State Transition : Loaded -> Idle
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to idle
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateIdle);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
-
- // Dont switch states until the ports are populated
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- // allocate buffers on input port
- allocatePortBuffers(omxNode, iBuffer, kPortIndexInput);
-
- // Dont switch states until the ports are populated
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- // allocate buffers on output port
- allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput);
-
- // As the ports are populated, check if the state transition is complete
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
-
- return;
-}
-
-// State Transition : Idle -> Loaded
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to Loaded
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateLoaded);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
-
- // dont change state until all buffers are freed
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- status = omxNode->freeBuffer(kPortIndexInput, (*iBuffer)[i].id);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- }
-
- // dont change state until all buffers are freed
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- status = omxNode->freeBuffer(kPortIndexOutput, (*oBuffer)[i].id);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- }
-
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded);
-
- return;
-}
-
-// State Transition : Idle -> Execute
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateIdletoExecute(sp<IOmxNode> omxNode,
- sp<CodecObserver> observer) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to execute
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateExecuting);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateExecuting);
-
- return;
-}
-
-// State Transition : Execute -> Idle
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to Idle
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateIdle);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
-
- // test if client got all its buffers back
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- EXPECT_EQ((*oBuffer)[i].owner, client);
- }
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- EXPECT_EQ((*iBuffer)[i].owner, client);
- }
-}
-
-// get empty buffer index
-size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray) {
- for (size_t i = 0; i < buffArray->size(); i++) {
- if ((*buffArray)[i].owner == client) return i;
- }
- return buffArray->size();
-}
-
-// dispatch buffer to output port
-void dispatchOutputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex) {
- android::hardware::media::omx::V1_0::Status status;
- CodecBuffer t;
- t.sharedMemory = android::hardware::hidl_memory();
- t.nativeHandle = android::hardware::hidl_handle();
- t.type = CodecBuffer::Type::PRESET;
- t.attr.preset.rangeOffset = 0;
- t.attr.preset.rangeLength = 0;
- native_handle_t* fenceNh = native_handle_create(0, 0);
- ASSERT_NE(fenceNh, nullptr);
- status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
- native_handle_close(fenceNh);
- native_handle_delete(fenceNh);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- buffArray->editItemAt(bufferIndex).owner = component;
-}
-
-// dispatch buffer to input port
-void dispatchInputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex, int bytesCount, uint32_t flags,
- uint64_t timestamp) {
- android::hardware::media::omx::V1_0::Status status;
- CodecBuffer t;
- t.sharedMemory = android::hardware::hidl_memory();
- t.nativeHandle = android::hardware::hidl_handle();
- t.type = CodecBuffer::Type::PRESET;
- t.attr.preset.rangeOffset = 0;
- t.attr.preset.rangeLength = bytesCount;
- native_handle_t* fenceNh = native_handle_create(0, 0);
- ASSERT_NE(fenceNh, nullptr);
- status = omxNode->emptyBuffer((*buffArray)[bufferIndex].id, t, flags,
- timestamp, fenceNh);
- native_handle_close(fenceNh);
- native_handle_delete(fenceNh);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- buffArray->editItemAt(bufferIndex).owner = component;
-}
-
-// Flush input and output ports
-void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput, int64_t timeoutUs) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // Flush input port
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
- kPortIndexInput);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, timeoutUs, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
- ASSERT_EQ(msg.data.eventData.data2, kPortIndexInput);
- // test if client got all its buffers back
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- EXPECT_EQ((*iBuffer)[i].owner, client);
- }
-
- // Flush output port
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
- kPortIndexOutput);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, timeoutUs, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
- ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
- // test if client got all its buffers back
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- EXPECT_EQ((*oBuffer)[i].owner, client);
- }
-}
-
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding) {
OMX_U32 index = 0;
diff --git a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
index d420ab5..a762436 100644
--- a/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016, The Android Open Source Project
+ * Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
#define MEDIA_AUDIO_HIDL_TEST_COMMON_H
#include <media_hidl_test_common.h>
+
/*
* Random Index used for monkey testing while get/set parameters
*/
@@ -26,42 +27,6 @@
/*
* Common audio utils
*/
-void allocatePortBuffers(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- OMX_U32 portIndex);
-
-void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput);
-
-void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput);
-
-void changeStateIdletoExecute(sp<IOmxNode> omxNode, sp<CodecObserver> observer);
-
-void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer);
-
-size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray);
-
-void dispatchOutputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex);
-
-void dispatchInputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex, int bytesCount, uint32_t flags,
- uint64_t timestamp);
-
-void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT);
-
Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding);
diff --git a/media/omx/1.0/vts/functional/common/Android.bp b/media/omx/1.0/vts/functional/common/Android.bp
new file mode 100755
index 0000000..93251fe
--- /dev/null
+++ b/media/omx/1.0/vts/functional/common/Android.bp
@@ -0,0 +1,33 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library_static {
+ name: "VtsHalMediaOmxV1_0CommonUtil",
+ defaults: ["hidl_defaults"],
+ srcs: ["media_hidl_test_common.cpp"],
+ shared_libs: [
+ "liblog",
+ "libhidlmemory",
+ "android.hidl.allocator@1.0",
+ "android.hidl.memory@1.0",
+ "android.hardware.media.omx@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [ "-O0", "-g", ],
+ include_dirs: [
+ "frameworks/native/include/media/openmax/",
+ ],
+}
diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp
new file mode 100755
index 0000000..30344a1
--- /dev/null
+++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp
@@ -0,0 +1,435 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "media_omx_hidl_video_test_common"
+
+#ifdef __LP64__
+#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+#endif
+
+#include <android-base/logging.h>
+
+#include <android/hardware/media/omx/1.0/IOmx.h>
+#include <android/hardware/media/omx/1.0/IOmxNode.h>
+#include <android/hardware/media/omx/1.0/IOmxObserver.h>
+#include <android/hardware/media/omx/1.0/types.h>
+#include <android/hidl/allocator/1.0/IAllocator.h>
+#include <android/hidl/memory/1.0/IMapper.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+
+using ::android::hardware::media::omx::V1_0::IOmx;
+using ::android::hardware::media::omx::V1_0::IOmxObserver;
+using ::android::hardware::media::omx::V1_0::IOmxNode;
+using ::android::hardware::media::omx::V1_0::Message;
+using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::hidl::memory::V1_0::IMapper;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <hidlmemory/mapping.h>
+#include <media/hardware/HardwareAPI.h>
+#include <media_hidl_test_common.h>
+#include <memory>
+
+// allocate buffers needed on a component port
+void allocatePortBuffers(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ OMX_U32 portIndex, PortMode portMode) {
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_PARAM_PORTDEFINITIONTYPE portDef;
+
+ buffArray->clear();
+
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
+ &portDef);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ if (portMode == PortMode::PRESET_SECURE_BUFFER) {
+ for (size_t i = 0; i < portDef.nBufferCountActual; i++) {
+ BufferInfo buffer;
+ buffer.owner = client;
+ buffer.omxBuffer.type = CodecBuffer::Type::NATIVE_HANDLE;
+ omxNode->allocateSecureBuffer(
+ portIndex, portDef.nBufferSize,
+ [&status, &buffer](
+ android::hardware::media::omx::V1_0::Status _s, uint32_t id,
+ ::android::hardware::hidl_handle const& nativeHandle) {
+ status = _s;
+ buffer.id = id;
+ buffer.omxBuffer.nativeHandle = nativeHandle;
+ });
+ buffArray->push(buffer);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ }
+ } else if (portMode == PortMode::PRESET_BYTE_BUFFER ||
+ portMode == PortMode::DYNAMIC_ANW_BUFFER) {
+ sp<IAllocator> allocator = IAllocator::getService("ashmem");
+ EXPECT_NE(allocator.get(), nullptr);
+
+ for (size_t i = 0; i < portDef.nBufferCountActual; i++) {
+ BufferInfo buffer;
+ buffer.owner = client;
+ buffer.omxBuffer.type = CodecBuffer::Type::SHARED_MEM;
+ buffer.omxBuffer.attr.preset.rangeOffset = 0;
+ buffer.omxBuffer.attr.preset.rangeLength = 0;
+ bool success = false;
+ if (portMode != PortMode::PRESET_BYTE_BUFFER) {
+ portDef.nBufferSize = sizeof(android::VideoNativeMetadata);
+ }
+ allocator->allocate(
+ portDef.nBufferSize,
+ [&success, &buffer](
+ bool _s, ::android::hardware::hidl_memory const& mem) {
+ success = _s;
+ buffer.omxBuffer.sharedMemory = mem;
+ });
+ ASSERT_EQ(success, true);
+ ASSERT_EQ(buffer.omxBuffer.sharedMemory.size(),
+ portDef.nBufferSize);
+ buffer.mMemory = mapMemory(buffer.omxBuffer.sharedMemory);
+ ASSERT_NE(buffer.mMemory, nullptr);
+ if (portMode == PortMode::DYNAMIC_ANW_BUFFER) {
+ android::VideoNativeMetadata* metaData =
+ static_cast<android::VideoNativeMetadata*>(
+ static_cast<void*>(buffer.mMemory->getPointer()));
+ metaData->nFenceFd = -1;
+ buffer.slot = -1;
+ }
+ omxNode->useBuffer(
+ portIndex, buffer.omxBuffer,
+ [&status, &buffer](
+ android::hardware::media::omx::V1_0::Status _s,
+ uint32_t id) {
+ status = _s;
+ buffer.id = id;
+ });
+ buffArray->push(buffer);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ }
+ }
+}
+
+// State Transition : Loaded -> Idle
+// Note: This function does not make any background checks for this transition.
+// The callee holds the reponsibility to ensure the legality of the transition.
+void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer,
+ OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
+ PortMode* portMode) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+ PortMode defaultPortMode[2], *pm;
+
+ defaultPortMode[0] = PortMode::PRESET_BYTE_BUFFER;
+ defaultPortMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ pm = portMode ? portMode : defaultPortMode;
+
+ // set state to idle
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateIdle);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // Dont switch states until the ports are populated
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ // allocate buffers on input port
+ allocatePortBuffers(omxNode, iBuffer, kPortIndexInput, pm[0]);
+
+ // Dont switch states until the ports are populated
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ // allocate buffers on output port
+ allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput, pm[1]);
+
+ // As the ports are populated, check if the state transition is complete
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
+ ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
+
+ return;
+}
+
+// State Transition : Idle -> Loaded
+// Note: This function does not make any background checks for this transition.
+// The callee holds the reponsibility to ensure the legality of the transition.
+void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer,
+ OMX_U32 kPortIndexInput,
+ OMX_U32 kPortIndexOutput) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+
+ // set state to Loaded
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateLoaded);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // dont change state until all buffers are freed
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ for (size_t i = 0; i < iBuffer->size(); ++i) {
+ status = omxNode->freeBuffer(kPortIndexInput, (*iBuffer)[i].id);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ }
+
+ // dont change state until all buffers are freed
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ for (size_t i = 0; i < oBuffer->size(); ++i) {
+ status = omxNode->freeBuffer(kPortIndexOutput, (*oBuffer)[i].id);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ }
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
+ ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded);
+
+ return;
+}
+
+// State Transition : Idle -> Execute
+// Note: This function does not make any background checks for this transition.
+// The callee holds the reponsibility to ensure the legality of the transition.
+void changeStateIdletoExecute(sp<IOmxNode> omxNode,
+ sp<CodecObserver> observer) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+
+ // set state to execute
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateExecuting);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
+ ASSERT_EQ(msg.data.eventData.data2, OMX_StateExecuting);
+
+ return;
+}
+
+// State Transition : Execute -> Idle
+// Note: This function does not make any background checks for this transition.
+// The callee holds the reponsibility to ensure the legality of the transition.
+void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+
+ // set state to Idle
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateIdle);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
+ ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
+
+ // test if client got all its buffers back
+ for (size_t i = 0; i < oBuffer->size(); ++i) {
+ EXPECT_EQ((*oBuffer)[i].owner, client);
+ }
+ for (size_t i = 0; i < iBuffer->size(); ++i) {
+ EXPECT_EQ((*iBuffer)[i].owner, client);
+ }
+}
+
+// get empty buffer index
+size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray) {
+ android::Vector<BufferInfo>::iterator it = buffArray->begin();
+ while (it != buffArray->end()) {
+ if (it->owner == client) {
+ // This block of code ensures that all buffers allocated at init
+ // time are utilized
+ BufferInfo backup = *it;
+ buffArray->erase(it);
+ buffArray->push_back(backup);
+ return buffArray->size() - 1;
+ }
+ it++;
+ }
+ return buffArray->size();
+}
+
+// dispatch buffer to output port
+void dispatchOutputBuffer(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ size_t bufferIndex, PortMode portMode) {
+ if (portMode == PortMode::DYNAMIC_ANW_BUFFER) {
+ android::hardware::media::omx::V1_0::Status status;
+ CodecBuffer t = (*buffArray)[bufferIndex].omxBuffer;
+ t.type = CodecBuffer::Type::ANW_BUFFER;
+ native_handle_t* fenceNh = native_handle_create(0, 0);
+ ASSERT_NE(fenceNh, nullptr);
+ status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
+ native_handle_close(fenceNh);
+ native_handle_delete(fenceNh);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ buffArray->editItemAt(bufferIndex).owner = component;
+ } else {
+ android::hardware::media::omx::V1_0::Status status;
+ CodecBuffer t;
+ t.sharedMemory = android::hardware::hidl_memory();
+ t.nativeHandle = android::hardware::hidl_handle();
+ t.type = CodecBuffer::Type::PRESET;
+ t.attr.preset.rangeOffset = 0;
+ t.attr.preset.rangeLength = 0;
+ native_handle_t* fenceNh = native_handle_create(0, 0);
+ ASSERT_NE(fenceNh, nullptr);
+ status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
+ native_handle_close(fenceNh);
+ native_handle_delete(fenceNh);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ buffArray->editItemAt(bufferIndex).owner = component;
+ }
+}
+
+// dispatch buffer to input port
+void dispatchInputBuffer(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ size_t bufferIndex, int bytesCount, uint32_t flags,
+ uint64_t timestamp) {
+ android::hardware::media::omx::V1_0::Status status;
+ CodecBuffer t;
+ t.sharedMemory = android::hardware::hidl_memory();
+ t.nativeHandle = android::hardware::hidl_handle();
+ t.type = CodecBuffer::Type::PRESET;
+ t.attr.preset.rangeOffset = 0;
+ t.attr.preset.rangeLength = bytesCount;
+ native_handle_t* fenceNh = native_handle_create(0, 0);
+ ASSERT_NE(fenceNh, nullptr);
+ status = omxNode->emptyBuffer((*buffArray)[bufferIndex].id, t, flags,
+ timestamp, fenceNh);
+ native_handle_close(fenceNh);
+ native_handle_delete(fenceNh);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ buffArray->editItemAt(bufferIndex).owner = component;
+}
+
+// Flush input and output ports
+void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
+ OMX_U32 kPortIndexOutput, int64_t timeoutUs) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+
+ // Flush input port
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
+ kPortIndexInput);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ status = observer->dequeueMessage(&msg, timeoutUs, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
+ ASSERT_EQ(msg.data.eventData.data2, kPortIndexInput);
+ // test if client got all its buffers back
+ for (size_t i = 0; i < iBuffer->size(); ++i) {
+ EXPECT_EQ((*iBuffer)[i].owner, client);
+ }
+
+ // Flush output port
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
+ kPortIndexOutput);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ status = observer->dequeueMessage(&msg, timeoutUs, iBuffer, oBuffer);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
+ ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
+ // test if client got all its buffers back
+ for (size_t i = 0; i < oBuffer->size(); ++i) {
+ EXPECT_EQ((*oBuffer)[i].owner, client);
+ }
+}
+
+// dispatch an empty input buffer with eos flag set if requested.
+// This call assumes that all input buffers are processed completely.
+// feed output buffers till we receive a buffer with eos flag set
+void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer, bool signalEOS,
+ bool& eosFlag, PortMode* portMode) {
+ android::hardware::media::omx::V1_0::Status status;
+ PortMode defaultPortMode[2], *pm;
+
+ defaultPortMode[0] = PortMode::PRESET_BYTE_BUFFER;
+ defaultPortMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ pm = portMode ? portMode : defaultPortMode;
+
+ size_t i = 0;
+ if (signalEOS) {
+ if ((i = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
+ // signal an empty buffer with flag set to EOS
+ dispatchInputBuffer(omxNode, iBuffer, i, 0, OMX_BUFFERFLAG_EOS, 0);
+ } else {
+ ASSERT_TRUE(false);
+ }
+ }
+
+ int timeOut = TIMEOUT_COUNTER;
+ while (timeOut--) {
+ // Dispatch all client owned output buffers to recover remaining frames
+ while (1) {
+ if ((i = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
+ dispatchOutputBuffer(omxNode, oBuffer, i, pm[1]);
+ // if dispatch is successful, perhaps there is a latency
+ // in the component. Dont be in a haste to leave. reset timeout
+ // counter
+ timeOut = TIMEOUT_COUNTER;
+ } else {
+ break;
+ }
+ }
+
+ Message msg;
+ status =
+ observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ EXPECT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+ if (eosFlag == true) break;
+ }
+ // test for flag
+ EXPECT_EQ(eosFlag, true);
+ eosFlag = false;
+}
diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
index 52d8ae2..a402532 100644
--- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
@@ -33,9 +33,19 @@
#include <media/openmax/OMX_AudioExt.h>
#include <media/openmax/OMX_VideoExt.h>
+#define DEFAULT_TIMEOUT 40000
+#define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT)
+
+enum bufferOwner {
+ client,
+ component,
+ unknown,
+};
+
/*
- * TODO: Borrowed from Conversion.h. This is not the ideal way to do it.
- * Loose these definitions once you include Conversion.h
+ * TODO: below definitions are borrowed from Conversion.h.
+ * This is not the ideal way to do it. Loose these definitions once you
+ * include Conversion.h
*/
inline uint32_t toRawIndexType(OMX_INDEXTYPE l) {
return static_cast<uint32_t>(l);
@@ -57,22 +67,14 @@
}
/*
- * Handle Callback functions EmptythisBuffer(), FillthisBuffer(),
- * EventHandler()
+ * struct definitions
*/
-#define DEFAULT_TIMEOUT 40000
-
-enum bufferOwner {
- client,
- component,
- unknown,
-};
-
struct BufferInfo {
uint32_t id;
bufferOwner owner;
android::hardware::media::omx::V1_0::CodecBuffer omxBuffer;
::android::sp<IMemory> mMemory;
+ int32_t slot;
};
struct FrameData {
@@ -81,9 +83,14 @@
uint32_t timestamp;
};
+/*
+ * Handle Callback functions EmptythisBuffer(), FillthisBuffer(),
+ * EventHandler()
+ */
struct CodecObserver : public IOmxObserver {
public:
- CodecObserver(std::function<void(Message)> fn) : callBack(fn) {}
+ CodecObserver(std::function<void(Message, const BufferInfo*)> fn)
+ : callBack(fn) {}
Return<void> onMessages(const hidl_vec<Message>& messages) override {
android::Mutex::Autolock autoLock(msgLock);
for (hidl_vec<Message>::const_iterator it = messages.begin();
@@ -114,7 +121,7 @@
for (i = 0; i < oBuffers->size(); ++i) {
if ((*oBuffers)[i].id ==
it->data.bufferData.buffer) {
- if (callBack) callBack(*it);
+ if (callBack) callBack(*it, &(*oBuffers)[i]);
oBuffers->editItemAt(i).owner = client;
msgQueue.erase(it);
break;
@@ -129,6 +136,7 @@
for (i = 0; i < iBuffers->size(); ++i) {
if ((*iBuffers)[i].id ==
it->data.bufferData.buffer) {
+ if (callBack) callBack(*it, &(*iBuffers)[i]);
iBuffers->editItemAt(i).owner = client;
msgQueue.erase(it);
break;
@@ -154,7 +162,7 @@
android::List<Message> msgQueue;
android::Mutex msgLock;
android::Condition msgCondition;
- std::function<void(Message)> callBack;
+ std::function<void(Message, const BufferInfo*)> callBack;
};
/*
@@ -245,4 +253,51 @@
inHidlBytes(params, sizeof(*params)));
}
+/*
+ * common functions declarations
+ */
+void allocatePortBuffers(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ OMX_U32 portIndex,
+ PortMode portMode = PortMode::PRESET_BYTE_BUFFER);
+
+void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer,
+ OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
+ PortMode* portMode = nullptr);
+
+void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer,
+ OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput);
+
+void changeStateIdletoExecute(sp<IOmxNode> omxNode, sp<CodecObserver> observer);
+
+void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer);
+
+size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray);
+
+void dispatchOutputBuffer(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ size_t bufferIndex,
+ PortMode portMode = PortMode::PRESET_BYTE_BUFFER);
+
+void dispatchInputBuffer(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ size_t bufferIndex, int bytesCount, uint32_t flags,
+ uint64_t timestamp);
+
+void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
+ OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT);
+
+void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer, bool signalEOS,
+ bool& eosFlag, PortMode* portMode = nullptr);
+
#endif // MEDIA_HIDL_TEST_COMMON_H
diff --git a/media/omx/1.0/vts/functional/component/Android.bp b/media/omx/1.0/vts/functional/component/Android.bp
index 02fe182..fd3210f 100644
--- a/media/omx/1.0/vts/functional/component/Android.bp
+++ b/media/omx/1.0/vts/functional/component/Android.bp
@@ -23,6 +23,7 @@
"liblog",
"libcutils",
"libhidlbase",
+ "libhidlmemory",
"libhidltransport",
"libhwbinder",
"libnativehelper",
@@ -32,7 +33,8 @@
"android.hidl.memory@1.0",
"android.hardware.media.omx@1.0",
],
- static_libs: ["VtsHalHidlTargetTestBase"],
+ static_libs: ["VtsHalHidlTargetTestBase",
+ "VtsHalMediaOmxV1_0CommonUtil"],
cflags: [
"-O0",
"-g",
diff --git a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
index 17c49ca..39e8864 100644
--- a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
+++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
@@ -30,6 +30,7 @@
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -196,268 +197,6 @@
// Random Index used for monkey testing while get/set parameters
#define RANDOM_INDEX 1729
-// allocate buffers needed on a component port
-void allocatePortBuffers(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- OMX_U32 portIndex) {
- android::hardware::media::omx::V1_0::Status status;
- OMX_PARAM_PORTDEFINITIONTYPE portDef;
-
- buffArray->clear();
-
- sp<IAllocator> allocator = IAllocator::getService("ashmem");
- EXPECT_NE(allocator.get(), nullptr);
-
- status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
- &portDef);
- ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
-
- for (size_t i = 0; i < portDef.nBufferCountActual; i++) {
- BufferInfo buffer;
- buffer.owner = client;
- buffer.omxBuffer.type = CodecBuffer::Type::SHARED_MEM;
- buffer.omxBuffer.attr.preset.rangeOffset = 0;
- buffer.omxBuffer.attr.preset.rangeLength = 0;
- bool success = false;
- allocator->allocate(
- portDef.nBufferSize,
- [&success, &buffer](bool _s,
- ::android::hardware::hidl_memory const& mem) {
- success = _s;
- buffer.omxBuffer.sharedMemory = mem;
- });
- ASSERT_EQ(success, true);
- ASSERT_EQ(buffer.omxBuffer.sharedMemory.size(), portDef.nBufferSize);
-
- omxNode->useBuffer(
- portIndex, buffer.omxBuffer,
- [&status, &buffer](android::hardware::media::omx::V1_0::Status _s,
- uint32_t id) {
- status = _s;
- buffer.id = id;
- });
- buffArray->push(buffer);
- ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
- }
-}
-
-// State Transition : Loaded -> Idle
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to idle
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateIdle);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
-
- // Dont switch states until the ports are populated
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- // allocate buffers on input port
- allocatePortBuffers(omxNode, iBuffer, kPortIndexInput);
-
- // Dont switch states until the ports are populated
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- // allocate buffers on output port
- allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput);
-
- // As the ports are populated, check if the state transition is complete
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
-
- return;
-}
-
-// State Transition : Idle -> Loaded
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to Loaded
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateLoaded);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
-
- // dont change state until all buffers are freed
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- status = omxNode->freeBuffer(kPortIndexInput, (*iBuffer)[i].id);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- }
-
- // dont change state until all buffers are freed
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- status = omxNode->freeBuffer(kPortIndexOutput, (*oBuffer)[i].id);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- }
-
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded);
-
- return;
-}
-
-// State Transition : Idle -> Execute
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateIdletoExecute(sp<IOmxNode> omxNode,
- sp<CodecObserver> observer) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to execute
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateExecuting);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateExecuting);
-
- return;
-}
-
-// State Transition : Execute -> Idle
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to Idle
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateIdle);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
-
- // test if client got all its buffers back
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- EXPECT_EQ((*oBuffer)[i].owner, client);
- }
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- EXPECT_EQ((*iBuffer)[i].owner, client);
- }
-}
-
-// dispatch buffer to output port
-void dispatchOutputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex) {
- android::hardware::media::omx::V1_0::Status status;
- CodecBuffer t;
- t.sharedMemory = android::hardware::hidl_memory();
- t.nativeHandle = android::hardware::hidl_handle();
- t.type = CodecBuffer::Type::PRESET;
- t.attr.preset.rangeOffset = 0;
- t.attr.preset.rangeLength = 0;
- native_handle_t* fenceNh = native_handle_create(0, 0);
- ASSERT_NE(fenceNh, nullptr);
- status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
- native_handle_close(fenceNh);
- native_handle_delete(fenceNh);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- buffArray->editItemAt(bufferIndex).owner = component;
-}
-
-// dispatch buffer to input port
-void dispatchInputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex, int bytesCount, uint32_t flags,
- uint64_t timestamp) {
- android::hardware::media::omx::V1_0::Status status;
- CodecBuffer t;
- t.sharedMemory = android::hardware::hidl_memory();
- t.nativeHandle = android::hardware::hidl_handle();
- t.type = CodecBuffer::Type::PRESET;
- t.attr.preset.rangeOffset = 0;
- t.attr.preset.rangeLength = bytesCount;
- native_handle_t* fenceNh = native_handle_create(0, 0);
- ASSERT_NE(fenceNh, nullptr);
- status = omxNode->emptyBuffer((*buffArray)[bufferIndex].id, t, flags,
- timestamp, fenceNh);
- native_handle_close(fenceNh);
- native_handle_delete(fenceNh);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- buffArray->editItemAt(bufferIndex).owner = component;
-}
-
-// Flush input and output ports
-void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // Flush input port
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
- kPortIndexInput);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
- ASSERT_EQ(msg.data.eventData.data2, kPortIndexInput);
- // test if client got all its buffers back
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- EXPECT_EQ((*iBuffer)[i].owner, client);
- }
-
- // Flush output port
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
- kPortIndexOutput);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
- ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
- // test if client got all its buffers back
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- EXPECT_EQ((*oBuffer)[i].owner, client);
- }
-}
-
// get/set video component port format
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex,
diff --git a/media/omx/1.0/vts/functional/video/Android.bp b/media/omx/1.0/vts/functional/video/Android.bp
index a8c8d99..4e94f3b 100644
--- a/media/omx/1.0/vts/functional/video/Android.bp
+++ b/media/omx/1.0/vts/functional/video/Android.bp
@@ -33,8 +33,12 @@
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",
"android.hardware.media.omx@1.0",
+ "android.hardware.graphics.allocator@2.0",
+ "android.hardware.graphics.mapper@2.0",
+ "android.hardware.graphics.common@1.0",
],
- static_libs: ["VtsHalHidlTargetTestBase"],
+ static_libs: ["VtsHalHidlTargetTestBase",
+ "VtsHalMediaOmxV1_0CommonUtil"],
cflags: [
"-O0",
"-g",
@@ -59,13 +63,17 @@
"libhidltransport",
"libhwbinder",
"libnativehelper",
+ "libnativewindow",
"libutils",
"libstagefright_foundation",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",
"android.hardware.media.omx@1.0",
+ "android.hardware.graphics.bufferqueue@1.0",
+ "android.hardware.graphics.mapper@2.0",
],
- static_libs: ["VtsHalHidlTargetTestBase"],
+ static_libs: ["VtsHalHidlTargetTestBase",
+ "VtsHalMediaOmxV1_0CommonUtil"],
cflags: [
"-O0",
"-g",
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
index 35c2b0c..8caf697 100644
--- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
+++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
@@ -17,6 +17,9 @@
#define LOG_TAG "media_omx_hidl_video_dec_test"
#include <android-base/logging.h>
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <android/hardware/graphics/mapper/2.0/types.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
#include <android/hardware/media/omx/1.0/IOmxNode.h>
#include <android/hardware/media/omx/1.0/IOmxObserver.h>
@@ -25,11 +28,14 @@
#include <android/hidl/memory/1.0/IMapper.h>
#include <android/hidl/memory/1.0/IMemory.h>
+using ::android::hardware::graphics::common::V1_0::BufferUsage;
+using ::android::hardware::graphics::common::V1_0::PixelFormat;
using ::android::hardware::media::omx::V1_0::IOmx;
using ::android::hardware::media::omx::V1_0::IOmxObserver;
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -136,7 +142,9 @@
gEnv->getInstance());
ASSERT_NE(omx, nullptr);
observer =
- new CodecObserver([this](Message msg) { handleMessage(msg); });
+ new CodecObserver([this](Message msg, const BufferInfo* buffer) {
+ handleMessage(msg, buffer);
+ });
ASSERT_NE(observer, nullptr);
if (strncmp(gEnv->getComponent().c_str(), "OMX.", 4) != 0)
disableTest = true;
@@ -193,10 +201,19 @@
}
}
if (i == kNumCompToCompression) disableTest = true;
+ portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
eosFlag = false;
framesReceived = 0;
timestampUs = 0;
timestampDevTest = false;
+ isSecure = false;
+ size_t suffixLen = strlen(".secure");
+ if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
+ }
+ isSecure = !strcmp(gEnv->getComponent().c_str() +
+ strlen(gEnv->getComponent().c_str()) - suffixLen,
+ ".secure");
+ if (isSecure) disableTest = true;
if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n";
}
@@ -209,7 +226,8 @@
// callback function to process messages received by onMessages() from IL
// client.
- void handleMessage(Message msg) {
+ void handleMessage(Message msg, const BufferInfo* buffer) {
+ (void)buffer;
if (msg.type == Message::Type::FILL_BUFFER_DONE) {
if (msg.data.extendedBufferData.flags & OMX_BUFFERFLAG_EOS) {
eosFlag = true;
@@ -245,13 +263,27 @@
}
}
}
+#define WRITE_OUTPUT 0
+#if WRITE_OUTPUT
+ static int count = 0;
+ FILE* ofp = nullptr;
+ if (count)
+ ofp = fopen("out.bin", "ab");
+ else
+ ofp = fopen("out.bin", "wb");
+ if (ofp != nullptr &&
+ portMode[1] == PortMode::PRESET_BYTE_BUFFER) {
+ fwrite(static_cast<void*>(buffer->mMemory->getPointer()),
+ sizeof(char),
+ msg.data.extendedBufferData.rangeLength, ofp);
+ fclose(ofp);
+ count++;
+ }
+#endif
}
}
}
- void testEOS(android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, bool signalEOS = false);
-
enum standardComp {
h263,
avc,
@@ -269,11 +301,13 @@
standardComp compName;
OMX_VIDEO_CODINGTYPE eCompressionFormat;
bool disableTest;
+ PortMode portMode[2];
bool eosFlag;
uint32_t framesReceived;
uint64_t timestampUs;
::android::List<uint64_t> timestampUslist;
bool timestampDevTest;
+ bool isSecure;
protected:
static void description(const std::string& description) {
@@ -281,44 +315,6 @@
}
};
-// end of stream test for video decoder components
-void VideoDecHidlTest::testEOS(android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- bool signalEOS) {
- android::hardware::media::omx::V1_0::Status status;
- size_t i = 0;
- if (signalEOS) {
- if ((i = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
- // signal an empty buffer with flag set to EOS
- dispatchInputBuffer(omxNode, iBuffer, i, 0, OMX_BUFFERFLAG_EOS, 0);
- } else {
- ASSERT_TRUE(false);
- }
- }
- // Dispatch all client owned output buffers to recover remaining frames
- while (1) {
- if ((i = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
- dispatchOutputBuffer(omxNode, oBuffer, i);
- } else {
- break;
- }
- }
- while (1) {
- Message msg;
- status =
- observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- EXPECT_EQ(status,
- android::hardware::media::omx::V1_0::Status::TIMED_OUT);
- for (; i < iBuffer->size(); i++) {
- if ((*iBuffer)[i].owner != client) break;
- }
- if (i == iBuffer->size()) break;
- }
- // test for flag
- EXPECT_EQ(eosFlag, true);
- eosFlag = false;
-}
-
// Set Default port param.
void setDefaultPortParam(sp<IOmxNode> omxNode, OMX_U32 portIndex,
OMX_VIDEO_CODINGTYPE eCompressionFormat,
@@ -399,12 +395,85 @@
}
}
+void allocateGraphicBuffers(sp<IOmxNode> omxNode, OMX_U32 portIndex,
+ android::Vector<BufferInfo>* buffArray,
+ uint32_t nFrameWidth, uint32_t nFrameHeight,
+ int32_t* nStride, uint32_t count) {
+ android::hardware::media::omx::V1_0::Status status;
+ sp<android::hardware::graphics::allocator::V2_0::IAllocator> allocator =
+ android::hardware::graphics::allocator::V2_0::IAllocator::getService();
+ ASSERT_NE(nullptr, allocator.get());
+
+ sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper =
+ android::hardware::graphics::mapper::V2_0::IMapper::getService();
+ ASSERT_NE(mapper.get(), nullptr);
+
+ android::hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo
+ descriptorInfo;
+ uint32_t usage;
+
+ descriptorInfo.width = nFrameWidth;
+ descriptorInfo.height = nFrameHeight;
+ descriptorInfo.layerCount = 1;
+ descriptorInfo.format = PixelFormat::RGBA_8888;
+ descriptorInfo.usage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN);
+ omxNode->getGraphicBufferUsage(
+ portIndex,
+ [&status, &usage](android::hardware::media::omx::V1_0::Status _s,
+ uint32_t _n1) {
+ status = _s;
+ usage = _n1;
+ });
+ if (status == android::hardware::media::omx::V1_0::Status::OK) {
+ descriptorInfo.usage |= usage;
+ }
+
+ ::android::hardware::hidl_vec<uint32_t> descriptor;
+ android::hardware::graphics::mapper::V2_0::Error error;
+ mapper->createDescriptor(
+ descriptorInfo, [&error, &descriptor](
+ android::hardware::graphics::mapper::V2_0::Error _s,
+ ::android::hardware::hidl_vec<uint32_t> _n1) {
+ error = _s;
+ descriptor = _n1;
+ });
+ EXPECT_EQ(error, android::hardware::graphics::mapper::V2_0::Error::NONE);
+
+ EXPECT_EQ(buffArray->size(), count);
+ allocator->allocate(
+ descriptor, count,
+ [&](android::hardware::graphics::mapper::V2_0::Error _s, uint32_t _n1,
+ const ::android::hardware::hidl_vec<
+ ::android::hardware::hidl_handle>& _n2) {
+ ASSERT_EQ(android::hardware::graphics::mapper::V2_0::Error::NONE,
+ _s);
+ *nStride = _n1;
+ ASSERT_EQ(count, _n2.size());
+ for (uint32_t i = 0; i < count; i++) {
+ buffArray->editItemAt(i).omxBuffer.nativeHandle = _n2[i];
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.width =
+ nFrameWidth;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.height =
+ nFrameHeight;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.stride = _n1;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.format =
+ descriptorInfo.format;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.usage =
+ descriptorInfo.usage;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.layerCount =
+ descriptorInfo.layerCount;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer.id =
+ (*buffArray)[i].id;
+ }
+ });
+}
+
// port settings reconfiguration during runtime. reconfigures frame dimensions
void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
- Message msg) {
+ Message msg, PortMode oPortMode) {
android::hardware::media::omx::V1_0::Status status;
if (msg.data.eventData.event == OMX_EventPortSettingsChanged) {
@@ -461,7 +530,8 @@
status,
android::hardware::media::omx::V1_0::Status::TIMED_OUT);
- allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput);
+ allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput,
+ oPortMode);
status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
iBuffer, oBuffer);
ASSERT_EQ(status,
@@ -472,7 +542,7 @@
// dispatch output buffers
for (size_t i = 0; i < oBuffer->size(); i++) {
- dispatchOutputBuffer(omxNode, oBuffer, i);
+ dispatchOutputBuffer(omxNode, oBuffer, i, oPortMode);
}
} else {
ASSERT_TRUE(false);
@@ -499,18 +569,21 @@
void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput) {
+ OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
+ PortMode oPortMode) {
android::hardware::media::omx::V1_0::Status status;
Message msg;
+ int timeOut = TIMEOUT_COUNTER;
- while (1) {
+ while (timeOut--) {
size_t i = 0;
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
if (status == android::hardware::media::omx::V1_0::Status::OK) {
EXPECT_EQ(msg.type, Message::Type::EVENT);
portReconfiguration(omxNode, observer, iBuffer, oBuffer,
- kPortIndexInput, kPortIndexOutput, msg);
+ kPortIndexInput, kPortIndexOutput, msg,
+ oPortMode);
}
// status == TIMED_OUT, it could be due to process time being large
// than DEFAULT_TIMEOUT or component needs output buffers to start
@@ -523,8 +596,9 @@
// Dispatch an output buffer assuming outQueue.empty() is true
size_t index;
if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
- dispatchOutputBuffer(omxNode, oBuffer, index);
+ dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode);
}
+ timeOut--;
}
}
@@ -534,13 +608,14 @@
android::Vector<BufferInfo>* oBuffer,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
std::ifstream& eleStream, android::Vector<FrameData>* Info,
- int offset, int range, bool signalEOS = true) {
+ int offset, int range, PortMode oPortMode,
+ bool signalEOS = true) {
android::hardware::media::omx::V1_0::Status status;
Message msg;
// dispatch output buffers
for (size_t i = 0; i < oBuffer->size(); i++) {
- dispatchOutputBuffer(omxNode, oBuffer, i);
+ dispatchOutputBuffer(omxNode, oBuffer, i, oPortMode);
}
// dispatch input buffers
uint32_t flags = 0;
@@ -563,6 +638,8 @@
frameID++;
}
+ int timeOut = TIMEOUT_COUNTER;
+ bool stall = false;
while (1) {
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
@@ -571,7 +648,8 @@
if (status == android::hardware::media::omx::V1_0::Status::OK &&
msg.type == Message::Type::EVENT) {
portReconfiguration(omxNode, observer, iBuffer, oBuffer,
- kPortIndexInput, kPortIndexOutput, msg);
+ kPortIndexInput, kPortIndexOutput, msg,
+ oPortMode);
}
if (frameID == (int)Info->size() || frameID == (offset + range)) break;
@@ -593,9 +671,21 @@
(*Info)[frameID].bytesCount, flags,
(*Info)[frameID].timestamp);
frameID++;
- }
+ stall = false;
+ } else
+ stall = true;
if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
- dispatchOutputBuffer(omxNode, oBuffer, index);
+ dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode);
+ stall = false;
+ } else
+ stall = true;
+ if (stall)
+ timeOut--;
+ else
+ timeOut = TIMEOUT_COUNTER;
+ if (timeOut == 0) {
+ EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite";
+ break;
}
}
}
@@ -675,6 +765,28 @@
}
eleInfo.close();
+ // set port mode
+ if (isSecure) {
+ portMode[0] = PortMode::PRESET_SECURE_BUFFER;
+ portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ } else {
+ portMode[0] = PortMode::PRESET_BYTE_BUFFER;
+ portMode[1] = PortMode::DYNAMIC_ANW_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ if (status != ::android::hardware::media::omx::V1_0::Status::OK) {
+ portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ }
+ }
+
// set Port Params
uint32_t nFrameWidth, nFrameHeight, xFramerate;
OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatYUV420Planar;
@@ -682,23 +794,38 @@
&xFramerate);
setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
+ omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);
android::Vector<BufferInfo> iBuffer, oBuffer;
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
+ kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
+
+ if (portMode[1] != PortMode::PRESET_BYTE_BUFFER) {
+ OMX_PARAM_PORTDEFINITIONTYPE portDef;
+
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexOutput, &portDef);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ allocateGraphicBuffers(
+ omxNode, kPortIndexOutput, &oBuffer,
+ portDef.format.video.nFrameWidth, portDef.format.video.nFrameHeight,
+ &portDef.format.video.nStride, portDef.nBufferCountActual);
+ }
+
// Port Reconfiguration
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
- kPortIndexOutput, eleStream, &Info, 0, (int)Info.size());
+ kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(),
+ portMode[1]);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer);
+ kPortIndexInput, kPortIndexOutput, portMode[1]);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode);
EXPECT_EQ(timestampUslist.empty(), true);
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
@@ -730,18 +857,25 @@
&xFramerate);
setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
- omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);
+
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
android::Vector<BufferInfo> iBuffer, oBuffer;
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
+ kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
// request EOS at the start
- testEOS(&iBuffer, &oBuffer, true);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 0U);
@@ -798,13 +932,20 @@
&xFramerate);
setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
- omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);
+
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
android::Vector<BufferInfo> iBuffer, oBuffer;
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
+ kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
@@ -814,11 +955,11 @@
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
- kPortIndexOutput, eleStream, &Info, 0, i + 1);
+ kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1]);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer);
+ kPortIndexInput, kPortIndexOutput, portMode[1]);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@@ -828,11 +969,12 @@
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
- kPortIndexOutput, eleStream, &Info, 0, i + 1, false);
+ kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1],
+ false);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer, true);
+ kPortIndexInput, kPortIndexOutput, portMode[1]);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@@ -889,13 +1031,20 @@
&xFramerate);
setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
- omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);
+
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
android::Vector<BufferInfo> iBuffer, oBuffer;
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
+ kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
@@ -903,11 +1052,12 @@
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
- kPortIndexOutput, eleStream, &Info, 0, (int)Info.size());
+ kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(),
+ portMode[1]);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
- testEOS(&iBuffer, &oBuffer);
+ kPortIndexInput, kPortIndexOutput, portMode[1]);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
framesReceived = 0;
@@ -964,11 +1114,19 @@
setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
android::Vector<BufferInfo> iBuffer, oBuffer;
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
+ kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
@@ -979,7 +1137,8 @@
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
- kPortIndexOutput, eleStream, &Info, 0, nFrames, false);
+ kPortIndexOutput, eleStream, &Info, 0, nFrames, portMode[1],
+ false);
// Note: Assumes 200 ms is enough to end any decode call that started
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput, 200000);
@@ -1001,7 +1160,7 @@
if (keyFrame) {
decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput, eleStream, &Info, index,
- Info.size() - index, false);
+ Info.size() - index, portMode[1], false);
}
// Note: Assumes 200 ms is enough to end any decode call that started
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
index 87aac0c..6bc95ca 100644
--- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
+++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
@@ -21,6 +21,11 @@
#include <android-base/logging.h>
+#include <android/hardware/graphics/bufferqueue/1.0/IGraphicBufferProducer.h>
+#include <android/hardware/graphics/bufferqueue/1.0/IProducerListener.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <android/hardware/graphics/mapper/2.0/types.h>
+#include <android/hardware/media/omx/1.0/IGraphicBufferSource.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
#include <android/hardware/media/omx/1.0/IOmxNode.h>
#include <android/hardware/media/omx/1.0/IOmxObserver.h>
@@ -29,11 +34,17 @@
#include <android/hidl/memory/1.0/IMapper.h>
#include <android/hidl/memory/1.0/IMemory.h>
+using ::android::hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer;
+using ::android::hardware::graphics::bufferqueue::V1_0::IProducerListener;
+using ::android::hardware::graphics::common::V1_0::BufferUsage;
+using ::android::hardware::graphics::common::V1_0::PixelFormat;
+using ::android::hardware::media::omx::V1_0::IGraphicBufferSource;
using ::android::hardware::media::omx::V1_0::IOmx;
using ::android::hardware::media::omx::V1_0::IOmxObserver;
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -48,6 +59,7 @@
#include <media/hardware/HardwareAPI.h>
#include <media_hidl_test_common.h>
#include <media_video_hidl_test_common.h>
+#include <system/window.h>
#include <fstream>
// A class for test environment setup
@@ -140,7 +152,10 @@
omx = ::testing::VtsHalHidlTargetTestBase::getService<IOmx>(
gEnv->getInstance());
ASSERT_NE(omx, nullptr);
- observer = new CodecObserver([this](Message msg) { (void)msg; });
+ observer =
+ new CodecObserver([this](Message msg, const BufferInfo* buffer) {
+ handleMessage(msg, buffer);
+ });
ASSERT_NE(observer, nullptr);
if (strncmp(gEnv->getComponent().c_str(), "OMX.", 4) != 0)
disableTest = true;
@@ -196,6 +211,19 @@
}
}
if (i == kNumCompToCompression) disableTest = true;
+ eosFlag = false;
+ prependSPSPPS = false;
+ timestampDevTest = false;
+ producer = nullptr;
+ source = nullptr;
+ isSecure = false;
+ size_t suffixLen = strlen(".secure");
+ if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
+ }
+ isSecure = !strcmp(gEnv->getComponent().c_str() +
+ strlen(gEnv->getComponent().c_str()) - suffixLen,
+ ".secure");
+ if (isSecure) disableTest = true;
if (disableTest) std::cerr << "[ ] Warning ! Test Disabled\n";
}
@@ -206,6 +234,63 @@
}
}
+ // callback function to process messages received by onMessages() from IL
+ // client.
+ void handleMessage(Message msg, const BufferInfo* buffer) {
+ (void)buffer;
+
+ if (msg.type == Message::Type::FILL_BUFFER_DONE) {
+ if (msg.data.extendedBufferData.flags & OMX_BUFFERFLAG_EOS) {
+ eosFlag = true;
+ }
+ if (msg.data.extendedBufferData.rangeLength != 0) {
+ // Test if current timestamp is among the list of queued
+ // timestamps
+ if (timestampDevTest && (prependSPSPPS ||
+ (msg.data.extendedBufferData.flags &
+ OMX_BUFFERFLAG_CODECCONFIG) == 0)) {
+ bool tsHit = false;
+ android::List<uint64_t>::iterator it =
+ timestampUslist.begin();
+ while (it != timestampUslist.end()) {
+ if (*it == msg.data.extendedBufferData.timestampUs) {
+ timestampUslist.erase(it);
+ tsHit = true;
+ break;
+ }
+ it++;
+ }
+ if (tsHit == false) {
+ if (timestampUslist.empty() == false) {
+ EXPECT_EQ(tsHit, true)
+ << "TimeStamp not recognized";
+ } else {
+ std::cerr
+ << "[ ] Warning ! Received non-zero "
+ "output / TimeStamp not recognized \n";
+ }
+ }
+ }
+#define WRITE_OUTPUT 0
+#if WRITE_OUTPUT
+ static int count = 0;
+ FILE* ofp = nullptr;
+ if (count)
+ ofp = fopen("out.bin", "ab");
+ else
+ ofp = fopen("out.bin", "wb");
+ if (ofp != nullptr) {
+ fwrite(static_cast<void*>(buffer->mMemory->getPointer()),
+ sizeof(char),
+ msg.data.extendedBufferData.rangeLength, ofp);
+ fclose(ofp);
+ count++;
+ }
+#endif
+ }
+ }
+ }
+
enum standardComp {
h263,
avc,
@@ -222,6 +307,13 @@
standardComp compName;
OMX_VIDEO_CODINGTYPE eCompressionFormat;
bool disableTest;
+ bool eosFlag;
+ bool prependSPSPPS;
+ ::android::List<uint64_t> timestampUslist;
+ bool timestampDevTest;
+ bool isSecure;
+ sp<IGraphicBufferProducer> producer;
+ sp<IGraphicBufferSource> source;
protected:
static void description(const std::string& description) {
@@ -229,6 +321,30 @@
}
};
+// CodecProducerListener class
+struct CodecProducerListener : public IProducerListener {
+ public:
+ CodecProducerListener(int a, int b)
+ : freeBuffers(a), minUnDequeuedCount(b) {}
+ virtual ::android::hardware::Return<void> onBufferReleased() override {
+ android::Mutex::Autolock autoLock(bufferLock);
+ freeBuffers += 1;
+ return Void();
+ }
+ virtual ::android::hardware::Return<bool> needsReleaseNotify() override {
+ return true;
+ }
+ void reduceCount() {
+ android::Mutex::Autolock autoLock(bufferLock);
+ freeBuffers -= 1;
+ EXPECT_GE(freeBuffers, minUnDequeuedCount);
+ }
+
+ size_t freeBuffers;
+ size_t minUnDequeuedCount;
+ android::Mutex bufferLock;
+};
+
// request VOP refresh
void requestIDR(sp<IOmxNode> omxNode, OMX_U32 portIndex) {
android::hardware::media::omx::V1_0::Status status;
@@ -375,13 +491,313 @@
strcat(URL, "bbb_352x288_420p_30fps_32frames.yuv");
}
+// blocking call to ensures application to Wait till all the inputs are consumed
+void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer,
+ bool inputDataIsMeta = false,
+ sp<CodecProducerListener> listener = nullptr) {
+ android::hardware::media::omx::V1_0::Status status;
+ Message msg;
+ int timeOut = TIMEOUT_COUNTER;
+
+ while (timeOut--) {
+ size_t i = 0;
+ status =
+ observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ EXPECT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+ // status == TIMED_OUT, it could be due to process time being large
+ // than DEFAULT_TIMEOUT or component needs output buffers to start
+ // processing.
+ if (inputDataIsMeta) {
+ if (listener->freeBuffers == iBuffer->size()) break;
+ } else {
+ for (; i < iBuffer->size(); i++) {
+ if ((*iBuffer)[i].owner != client) break;
+ }
+ if (i == iBuffer->size()) break;
+ }
+
+ // Dispatch an output buffer assuming outQueue.empty() is true
+ size_t index;
+ if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
+ dispatchOutputBuffer(omxNode, oBuffer, index);
+ }
+ }
+}
+
+int colorFormatConversion(BufferInfo* buffer, void* buff, PixelFormat format,
+ std::ifstream& eleStream) {
+ sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper =
+ android::hardware::graphics::mapper::V2_0::IMapper::getService();
+ EXPECT_NE(mapper.get(), nullptr);
+ if (mapper.get() == nullptr) return 1;
+
+ android::hardware::hidl_handle fence;
+ android::hardware::graphics::mapper::V2_0::IMapper::Rect rect;
+ android::hardware::graphics::mapper::V2_0::YCbCrLayout ycbcrLayout;
+ android::hardware::graphics::mapper::V2_0::Error error;
+ rect.left = 0;
+ rect.top = 0;
+ rect.width = buffer->omxBuffer.attr.anwBuffer.width;
+ rect.height = buffer->omxBuffer.attr.anwBuffer.height;
+
+ if (format == PixelFormat::YV12) {
+ mapper->lockYCbCr(
+ buff, buffer->omxBuffer.attr.anwBuffer.usage, rect, fence,
+ [&](android::hardware::graphics::mapper::V2_0::Error _e,
+ android::hardware::graphics::mapper::V2_0::YCbCrLayout _n1) {
+ error = _e;
+ ycbcrLayout = _n1;
+ });
+ EXPECT_EQ(error,
+ android::hardware::graphics::mapper::V2_0::Error::NONE);
+ if (error != android::hardware::graphics::mapper::V2_0::Error::NONE)
+ return 1;
+
+ EXPECT_EQ(ycbcrLayout.chromaStep, 1U);
+ char* ipBuffer = static_cast<char*>(ycbcrLayout.y);
+ for (size_t y = rect.height; y > 0; --y) {
+ eleStream.read(ipBuffer, rect.width);
+ if (eleStream.gcount() != rect.width) return 1;
+ ipBuffer += ycbcrLayout.yStride;
+ }
+ ipBuffer = static_cast<char*>(ycbcrLayout.cb);
+ for (size_t y = rect.height >> 1; y > 0; --y) {
+ eleStream.read(ipBuffer, rect.width >> 1);
+ if (eleStream.gcount() != rect.width >> 1) return 1;
+ ipBuffer += ycbcrLayout.cStride;
+ }
+ ipBuffer = static_cast<char*>(ycbcrLayout.cr);
+ for (size_t y = rect.height >> 1; y > 0; --y) {
+ eleStream.read(ipBuffer, rect.width >> 1);
+ if (eleStream.gcount() != rect.width >> 1) return 1;
+ ipBuffer += ycbcrLayout.cStride;
+ }
+
+ mapper->unlock(buff,
+ [&](android::hardware::graphics::mapper::V2_0::Error _e,
+ android::hardware::hidl_handle _n1) {
+ error = _e;
+ fence = _n1;
+ });
+ EXPECT_EQ(error,
+ android::hardware::graphics::mapper::V2_0::Error::NONE);
+ if (error != android::hardware::graphics::mapper::V2_0::Error::NONE)
+ return 1;
+ } else if (format == PixelFormat::YCBCR_420_888) {
+ void* data;
+ mapper->lock(buff, buffer->omxBuffer.attr.anwBuffer.usage, rect, fence,
+ [&](android::hardware::graphics::mapper::V2_0::Error _e,
+ void* _n1) {
+ error = _e;
+ data = _n1;
+ });
+ EXPECT_EQ(error,
+ android::hardware::graphics::mapper::V2_0::Error::NONE);
+ if (error != android::hardware::graphics::mapper::V2_0::Error::NONE)
+ return 1;
+
+ ycbcrLayout.chromaStep = 1;
+ ycbcrLayout.yStride = buffer->omxBuffer.attr.anwBuffer.stride;
+ ycbcrLayout.cStride = ycbcrLayout.yStride >> 1;
+ ycbcrLayout.y = data;
+ ycbcrLayout.cb = static_cast<char*>(ycbcrLayout.y) +
+ (ycbcrLayout.yStride * rect.height);
+ ycbcrLayout.cr = static_cast<char*>(ycbcrLayout.cb) +
+ ((ycbcrLayout.yStride * rect.height) >> 2);
+
+ char* ipBuffer = static_cast<char*>(ycbcrLayout.y);
+ for (size_t y = rect.height; y > 0; --y) {
+ eleStream.read(ipBuffer, rect.width);
+ if (eleStream.gcount() != rect.width) return 1;
+ ipBuffer += ycbcrLayout.yStride;
+ }
+ ipBuffer = static_cast<char*>(ycbcrLayout.cb);
+ for (size_t y = rect.height >> 1; y > 0; --y) {
+ eleStream.read(ipBuffer, rect.width >> 1);
+ if (eleStream.gcount() != rect.width >> 1) return 1;
+ ipBuffer += ycbcrLayout.cStride;
+ }
+ ipBuffer = static_cast<char*>(ycbcrLayout.cr);
+ for (size_t y = rect.height >> 1; y > 0; --y) {
+ eleStream.read(ipBuffer, rect.width >> 1);
+ if (eleStream.gcount() != rect.width >> 1) return 1;
+ ipBuffer += ycbcrLayout.cStride;
+ }
+
+ mapper->unlock(buff,
+ [&](android::hardware::graphics::mapper::V2_0::Error _e,
+ android::hardware::hidl_handle _n1) {
+ error = _e;
+ fence = _n1;
+ });
+ EXPECT_EQ(error,
+ android::hardware::graphics::mapper::V2_0::Error::NONE);
+ if (error != android::hardware::graphics::mapper::V2_0::Error::NONE)
+ return 1;
+ } else {
+ EXPECT_TRUE(false) << "un expected pixel format";
+ return 1;
+ }
+
+ return 0;
+}
+
+int fillGraphicBuffer(BufferInfo* buffer, PixelFormat format,
+ std::ifstream& eleStream) {
+ sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper =
+ android::hardware::graphics::mapper::V2_0::IMapper::getService();
+ EXPECT_NE(mapper.get(), nullptr);
+ if (mapper.get() == nullptr) return 1;
+
+ void* buff = nullptr;
+ android::hardware::graphics::mapper::V2_0::Error error;
+ mapper->importBuffer(
+ buffer->omxBuffer.nativeHandle,
+ [&](android::hardware::graphics::mapper::V2_0::Error _e, void* _n1) {
+ error = _e;
+ buff = _n1;
+ });
+ EXPECT_EQ(error, android::hardware::graphics::mapper::V2_0::Error::NONE);
+ if (error != android::hardware::graphics::mapper::V2_0::Error::NONE)
+ return 1;
+
+ if (colorFormatConversion(buffer, buff, format, eleStream)) return 1;
+
+ error = mapper->freeBuffer(buff);
+ EXPECT_EQ(error, android::hardware::graphics::mapper::V2_0::Error::NONE);
+ if (error != android::hardware::graphics::mapper::V2_0::Error::NONE)
+ return 1;
+
+ return 0;
+}
+
+int dispatchGraphicBuffer(sp<IOmxNode> omxNode,
+ sp<IGraphicBufferProducer> producer,
+ sp<CodecProducerListener> listener,
+ android::Vector<BufferInfo>* buffArray,
+ OMX_U32 portIndex, std::ifstream& eleStream,
+ uint64_t timestamp) {
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_PARAM_PORTDEFINITIONTYPE portDef;
+
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
+ &portDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ if (status != ::android::hardware::media::omx::V1_0::Status::OK) return 1;
+
+ enum {
+ // A flag returned by dequeueBuffer when the client needs to call
+ // requestBuffer immediately thereafter.
+ BUFFER_NEEDS_REALLOCATION = 0x1,
+ // A flag returned by dequeueBuffer when all mirrored slots should be
+ // released by the client. This flag should always be processed first.
+ RELEASE_ALL_BUFFERS = 0x2,
+ };
+
+ int32_t slot;
+ int32_t result;
+ ::android::hardware::hidl_handle fence;
+ IGraphicBufferProducer::FrameEventHistoryDelta outTimestamps;
+ ::android::hardware::media::V1_0::AnwBuffer AnwBuffer;
+ PixelFormat format = PixelFormat::YV12;
+ producer->dequeueBuffer(
+ portDef.format.video.nFrameWidth, portDef.format.video.nFrameHeight,
+ format, BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
+ true, [&](int32_t _s, int32_t const& _n1,
+ ::android::hardware::hidl_handle const& _n2,
+ IGraphicBufferProducer::FrameEventHistoryDelta const& _n3) {
+ result = _s;
+ slot = _n1;
+ fence = _n2;
+ outTimestamps = _n3;
+ });
+ if (result & BUFFER_NEEDS_REALLOCATION) {
+ producer->requestBuffer(
+ slot, [&](int32_t _s,
+ ::android::hardware::media::V1_0::AnwBuffer const& _n1) {
+ result = _s;
+ AnwBuffer = _n1;
+ });
+ EXPECT_EQ(result, 0);
+ if (result != 0) return 1;
+ size_t i;
+ for (i = 0; i < buffArray->size(); i++) {
+ if ((*buffArray)[i].slot == -1) {
+ buffArray->editItemAt(i).slot = slot;
+ buffArray->editItemAt(i).omxBuffer.nativeHandle =
+ AnwBuffer.nativeHandle;
+ buffArray->editItemAt(i).omxBuffer.attr.anwBuffer =
+ AnwBuffer.attr;
+ break;
+ }
+ }
+ EXPECT_NE(i, buffArray->size());
+ if (i == buffArray->size()) return 1;
+ }
+ EXPECT_EQ(result, 0);
+ if (result != 0) return 1;
+
+ // fill Buffer
+ BufferInfo buffer;
+ size_t i;
+ for (i = 0; i < buffArray->size(); i++) {
+ if ((*buffArray)[i].slot == slot) {
+ buffer = (*buffArray)[i];
+ break;
+ }
+ }
+ EXPECT_NE(i, buffArray->size());
+ if (i == buffArray->size()) return 1;
+ if (fillGraphicBuffer(&buffer, format, eleStream)) return 1;
+
+ // queue Buffer
+ IGraphicBufferProducer::QueueBufferOutput output;
+ IGraphicBufferProducer::QueueBufferInput input;
+ android::hardware::media::V1_0::Rect rect;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = buffer.omxBuffer.attr.anwBuffer.width;
+ rect.bottom = buffer.omxBuffer.attr.anwBuffer.height;
+ input.timestamp = timestamp;
+ input.isAutoTimestamp = false;
+ input.dataSpace =
+ android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN;
+ input.crop = rect;
+ input.scalingMode = 0;
+ input.transform = 0;
+ input.stickyTransform = 0;
+ input.fence = android::hardware::hidl_handle();
+ input.surfaceDamage =
+ android::hardware::hidl_vec<android::hardware::media::V1_0::Rect>{rect};
+ input.getFrameTimestamps = false;
+ producer->queueBuffer(
+ buffer.slot, input,
+ [&](int32_t _s, const IGraphicBufferProducer::QueueBufferOutput& _n1) {
+ result = _s;
+ output = _n1;
+ });
+ EXPECT_EQ(result, 0);
+ if (result != 0) return 1;
+
+ listener->reduceCount();
+
+ return 0;
+}
+
// Encode N Frames
void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- OMX_U32 portIndexOutput,
+ OMX_U32 portIndexInput, OMX_U32 portIndexOutput,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer, uint32_t nFrames,
uint32_t xFramerate, int bytesCount,
- std::ifstream& eleStream) {
+ std::ifstream& eleStream,
+ ::android::List<uint64_t>* timestampUslist = nullptr,
+ bool signalEOS = true, bool inputDataIsMeta = false,
+ sp<IGraphicBufferProducer> producer = nullptr,
+ sp<CodecProducerListener> listener = nullptr) {
android::hardware::media::omx::V1_0::Status status;
Message msg;
uint32_t ipCount = 0;
@@ -398,20 +814,39 @@
}
// dispatch input buffers
int32_t timestampIncr = (int)((float)1000000 / (xFramerate >> 16));
+ // timestamp scale = Nano sec
+ if (inputDataIsMeta) timestampIncr *= 1000;
uint64_t timestamp = 0;
+ uint32_t flags = 0;
for (size_t i = 0; i < iBuffer->size() && nFrames != 0; i++) {
- char* ipBuffer = static_cast<char*>(
- static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
- ASSERT_LE(bytesCount,
- static_cast<int>((*iBuffer)[i].mMemory->getSize()));
- eleStream.read(ipBuffer, bytesCount);
- if (eleStream.gcount() != bytesCount) break;
- dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, 0, timestamp);
- timestamp += timestampIncr;
- nFrames--;
- ipCount++;
+ if (inputDataIsMeta) {
+ if (listener->freeBuffers > listener->minUnDequeuedCount) {
+ if (dispatchGraphicBuffer(omxNode, producer, listener, iBuffer,
+ portIndexInput, eleStream, timestamp))
+ break;
+ timestamp += timestampIncr;
+ nFrames--;
+ ipCount++;
+ }
+ } else {
+ char* ipBuffer = static_cast<char*>(
+ static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
+ ASSERT_LE(bytesCount,
+ static_cast<int>((*iBuffer)[i].mMemory->getSize()));
+ eleStream.read(ipBuffer, bytesCount);
+ if (eleStream.gcount() != bytesCount) break;
+ if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS;
+ dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, flags,
+ timestamp);
+ if (timestampUslist) timestampUslist->push_back(timestamp);
+ timestamp += timestampIncr;
+ nFrames--;
+ ipCount++;
+ }
}
+ int timeOut = TIMEOUT_COUNTER;
+ bool stall = false;
while (1) {
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
@@ -422,6 +857,9 @@
ASSERT_EQ(msg.data.eventData.data1, portIndexOutput);
ASSERT_EQ(msg.data.eventData.data2,
OMX_IndexConfigAndroidIntraRefresh);
+ } else if (msg.data.eventData.event == OMX_EventError) {
+ EXPECT_TRUE(false) << "Received OMX_EventError, not sure why";
+ break;
} else {
ASSERT_TRUE(false);
}
@@ -431,21 +869,51 @@
// Dispatch input buffer
size_t index = 0;
- if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
- char* ipBuffer = static_cast<char*>(
- static_cast<void*>((*iBuffer)[index].mMemory->getPointer()));
- ASSERT_LE(bytesCount,
- static_cast<int>((*iBuffer)[index].mMemory->getSize()));
- eleStream.read(ipBuffer, bytesCount);
- if (eleStream.gcount() != bytesCount) break;
- dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, 0,
- timestamp);
- timestamp += timestampIncr;
- nFrames--;
- ipCount++;
+ if (inputDataIsMeta) {
+ if (listener->freeBuffers > listener->minUnDequeuedCount) {
+ if (dispatchGraphicBuffer(omxNode, producer, listener, iBuffer,
+ portIndexInput, eleStream, timestamp))
+ break;
+ timestamp += timestampIncr;
+ nFrames--;
+ ipCount++;
+ stall = false;
+ } else {
+ stall = true;
+ }
+ } else {
+ if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
+ char* ipBuffer = static_cast<char*>(static_cast<void*>(
+ (*iBuffer)[index].mMemory->getPointer()));
+ ASSERT_LE(
+ bytesCount,
+ static_cast<int>((*iBuffer)[index].mMemory->getSize()));
+ eleStream.read(ipBuffer, bytesCount);
+ if (eleStream.gcount() != bytesCount) break;
+ if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS;
+ dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, flags,
+ timestamp);
+ if (timestampUslist) timestampUslist->push_back(timestamp);
+ timestamp += timestampIncr;
+ nFrames--;
+ ipCount++;
+ stall = false;
+ } else {
+ stall = true;
+ }
}
if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
dispatchOutputBuffer(omxNode, oBuffer, index);
+ stall = false;
+ } else
+ stall = true;
+ if (stall)
+ timeOut--;
+ else
+ timeOut = TIMEOUT_COUNTER;
+ if (timeOut == 0) {
+ EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite";
+ break;
}
if (ipCount == 15) {
changeBitrate(omxNode, portIndexOutput, 768000);
@@ -491,7 +959,7 @@
EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
}
-// test raw stream encode
+// test raw stream encode (input is byte buffers)
TEST_F(VideoEncHidlTest, EncodeTest) {
description("Test Encode");
if (disableTest) return;
@@ -511,8 +979,8 @@
GetURLForComponent(mURL);
std::ifstream eleStream;
- eleStream.open(mURL, std::ifstream::binary);
- ASSERT_EQ(eleStream.is_open(), true);
+
+ timestampDevTest = true;
// Configure input port
uint32_t nFrameWidth = 352;
@@ -526,6 +994,7 @@
setDefaultPortParam(omxNode, kPortIndexOutput, eCompressionFormat, nBitRate,
xFramerate);
setRefreshPeriod(omxNode, kPortIndexOutput, 0);
+
unsigned int index;
omxNode->getExtensionIndex(
"OMX.google.android.index.prependSPSPPSToIDRFrames",
@@ -542,24 +1011,299 @@
if (status != ::android::hardware::media::omx::V1_0::Status::OK)
std::cerr
<< "[ ] Warning ! unable to prependSPSPPSToIDRFrames\n";
+ else
+ prependSPSPPS = true;
+
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ if (isSecure && prependSPSPPS) portMode[1] = PortMode::PRESET_SECURE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
android::Vector<BufferInfo> iBuffer, oBuffer;
// set state to idle
changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
- kPortIndexInput, kPortIndexOutput);
+ kPortIndexInput, kPortIndexOutput, portMode);
// set state to executing
changeStateIdletoExecute(omxNode, observer);
- encodeNFrames(omxNode, observer, kPortIndexOutput, &iBuffer, &oBuffer, 1024,
- xFramerate, (nFrameWidth * nFrameHeight * 3) >> 1, eleStream);
+ eleStream.open(mURL, std::ifstream::binary);
+ ASSERT_EQ(eleStream.is_open(), true);
+ encodeNFrames(omxNode, observer, kPortIndexInput, kPortIndexOutput,
+ &iBuffer, &oBuffer, 32, xFramerate,
+ (nFrameWidth * nFrameHeight * 3) >> 1, eleStream,
+ ×tampUslist);
+ eleStream.close();
+ waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
+ EXPECT_EQ(timestampUslist.empty(), true);
+
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
// set state to executing
changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput);
+}
+// test raw stream encode (input is ANW buffers)
+TEST_F(VideoEncHidlTest, EncodeTestBufferMetaModes) {
+ description("Test Encode Input buffer metamodes");
+ if (disableTest) return;
+ android::hardware::media::omx::V1_0::Status status;
+ uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ kPortIndexInput = params.nStartPortNumber;
+ kPortIndexOutput = kPortIndexInput + 1;
+ }
+
+ // Configure input port
+ uint32_t nFrameWidth = 352;
+ uint32_t nFrameHeight = 288;
+ uint32_t xFramerate = (30U << 16);
+ OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatAndroidOpaque;
+ setupRAWPort(omxNode, kPortIndexInput, nFrameWidth, nFrameHeight, 0,
+ xFramerate, eColorFormat);
+
+ // CreateInputSurface
+ EXPECT_TRUE(omx->createInputSurface(
+ [&](android::hardware::media::omx::V1_0::Status _s,
+ sp<IGraphicBufferProducer> const& _nl,
+ sp<IGraphicBufferSource> const& _n2) {
+ status = _s;
+ producer = _nl;
+ source = _n2;
+ })
+ .isOk());
+ ASSERT_NE(producer, nullptr);
+ ASSERT_NE(source, nullptr);
+
+ // Do setInputSurface()
+ // enable MetaMode on input port
+ status = source->configure(
+ omxNode, android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ // setMaxDequeuedBufferCount
+ int32_t returnval;
+ int32_t value;
+ producer->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ [&returnval, &value](int32_t _s, int32_t _n1) {
+ returnval = _s;
+ value = _n1;
+ });
+ ASSERT_EQ(returnval, 0);
+ OMX_PARAM_PORTDEFINITIONTYPE portDef;
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &portDef);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(::android::OK,
+ producer->setMaxDequeuedBufferCount(portDef.nBufferCountActual));
+
+ // Connect :: Mock Producer Listener
+ IGraphicBufferProducer::QueueBufferOutput qbo;
+ sp<CodecProducerListener> listener =
+ new CodecProducerListener(portDef.nBufferCountActual + value, value);
+ producer->connect(
+ listener, NATIVE_WINDOW_API_CPU, false,
+ [&](int32_t _s, IGraphicBufferProducer::QueueBufferOutput const& _n1) {
+ returnval = _s;
+ qbo = _n1;
+ });
+ ASSERT_EQ(returnval, 0);
+
+ portDef.nBufferCountActual = portDef.nBufferCountActual + value;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &portDef);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = PortMode::DYNAMIC_ANW_BUFFER;
+ portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ char mURL[512];
+ strcpy(mURL, gEnv->getRes().c_str());
+ GetURLForComponent(mURL);
+
+ std::ifstream eleStream;
+
+ status = source->setSuspend(false, 0);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = source->setRepeatPreviousFrameDelayUs(100000);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = source->setMaxFps(24.0f);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = source->setTimeLapseConfig(24.0, 24.0);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = source->setTimeOffsetUs(-100);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = source->setStartTimeUs(10);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = source->setStopTimeUs(1000000);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ ::android::hardware::media::omx::V1_0::ColorAspects aspects;
+ aspects.range =
+ ::android::hardware::media::omx::V1_0::ColorAspects::Range::UNSPECIFIED;
+ aspects.primaries = ::android::hardware::media::omx::V1_0::ColorAspects::
+ Primaries::UNSPECIFIED;
+ aspects.transfer = ::android::hardware::media::omx::V1_0::ColorAspects::
+ Transfer::UNSPECIFIED;
+ aspects.matrixCoeffs = ::android::hardware::media::omx::V1_0::ColorAspects::
+ MatrixCoeffs::UNSPECIFIED;
+ status = source->setColorAspects(aspects);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ int64_t stopTimeOffsetUs;
+ source->getStopTimeOffsetUs(
+ [&](android::hardware::media::omx::V1_0::Status _s, int64_t _n1) {
+ status = _s;
+ stopTimeOffsetUs = _n1;
+ });
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ android::Vector<BufferInfo> iBuffer, oBuffer;
+ // set state to idle
+ changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
+ kPortIndexInput, kPortIndexOutput, portMode);
+ // set state to executing
+ changeStateIdletoExecute(omxNode, observer);
+
+ eleStream.open(mURL, std::ifstream::binary);
+ ASSERT_EQ(eleStream.is_open(), true);
+ encodeNFrames(omxNode, observer, kPortIndexInput, kPortIndexOutput,
+ &iBuffer, &oBuffer, 1024, xFramerate,
+ (nFrameWidth * nFrameHeight * 3) >> 1, eleStream, nullptr,
+ false, true, producer, listener);
eleStream.close();
+ waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, true,
+ listener);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
+
+ // set state to idle
+ changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
+ EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers);
+ // set state to executing
+ changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
+ kPortIndexInput, kPortIndexOutput);
+
+ returnval = producer->disconnect(
+ NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API);
+ ASSERT_EQ(returnval, 0);
+}
+
+// Test end of stream
+TEST_F(VideoEncHidlTest, EncodeTestEOS) {
+ description("Test EOS");
+ if (disableTest) return;
+ android::hardware::media::omx::V1_0::Status status;
+ uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ kPortIndexInput = params.nStartPortNumber;
+ kPortIndexOutput = kPortIndexInput + 1;
+ }
+
+ // CreateInputSurface
+ EXPECT_TRUE(omx->createInputSurface(
+ [&](android::hardware::media::omx::V1_0::Status _s,
+ sp<IGraphicBufferProducer> const& _nl,
+ sp<IGraphicBufferSource> const& _n2) {
+ status = _s;
+ producer = _nl;
+ source = _n2;
+ })
+ .isOk());
+ ASSERT_NE(producer, nullptr);
+ ASSERT_NE(source, nullptr);
+
+ // Do setInputSurface()
+ // enable MetaMode on input port
+ status = source->configure(
+ omxNode, android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ // setMaxDequeuedBufferCount
+ int32_t returnval;
+ int32_t value;
+ producer->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ [&returnval, &value](int32_t _s, int32_t _n1) {
+ returnval = _s;
+ value = _n1;
+ });
+ ASSERT_EQ(returnval, 0);
+ OMX_PARAM_PORTDEFINITIONTYPE portDef;
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &portDef);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(::android::OK,
+ producer->setMaxDequeuedBufferCount(portDef.nBufferCountActual));
+
+ // Connect :: Mock Producer Listener
+ IGraphicBufferProducer::QueueBufferOutput qbo;
+ sp<CodecProducerListener> listener =
+ new CodecProducerListener(portDef.nBufferCountActual + value, value);
+ producer->connect(
+ listener, NATIVE_WINDOW_API_CPU, false,
+ [&](int32_t _s, IGraphicBufferProducer::QueueBufferOutput const& _n1) {
+ returnval = _s;
+ qbo = _n1;
+ });
+ ASSERT_EQ(returnval, 0);
+
+ portDef.nBufferCountActual = portDef.nBufferCountActual + value;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &portDef);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ // set port mode
+ PortMode portMode[2];
+ portMode[0] = PortMode::DYNAMIC_ANW_BUFFER;
+ portMode[1] = PortMode::PRESET_BYTE_BUFFER;
+ status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ android::Vector<BufferInfo> iBuffer, oBuffer;
+ // set state to idle
+ changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
+ kPortIndexInput, kPortIndexOutput, portMode);
+ // set state to executing
+ changeStateIdletoExecute(omxNode, observer);
+
+ // send EOS
+ status = source->signalEndOfInputStream();
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, true,
+ listener);
+ testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
+
+ // set state to idle
+ changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
+ EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers);
+ // set state to executing
+ changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
+ kPortIndexInput, kPortIndexOutput);
+
+ returnval = producer->disconnect(
+ NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API);
+ ASSERT_EQ(returnval, 0);
}
int main(int argc, char** argv) {
diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp
index 7035048..271b4d4 100644
--- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp
+++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp
@@ -15,6 +15,11 @@
*/
#define LOG_TAG "media_omx_hidl_video_test_common"
+
+#ifdef __LP64__
+#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+#endif
+
#include <android-base/logging.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
@@ -30,6 +35,7 @@
using ::android::hardware::media::omx::V1_0::IOmxNode;
using ::android::hardware::media::omx::V1_0::Message;
using ::android::hardware::media::omx::V1_0::CodecBuffer;
+using ::android::hardware::media::omx::V1_0::PortMode;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::hidl::memory::V1_0::IMapper;
@@ -41,281 +47,11 @@
#include <VtsHalHidlTargetTestBase.h>
#include <hidlmemory/mapping.h>
+#include <media/hardware/HardwareAPI.h>
#include <media_hidl_test_common.h>
#include <media_video_hidl_test_common.h>
#include <memory>
-// allocate buffers needed on a component port
-void allocatePortBuffers(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- OMX_U32 portIndex) {
- android::hardware::media::omx::V1_0::Status status;
- OMX_PARAM_PORTDEFINITIONTYPE portDef;
-
- buffArray->clear();
-
- sp<IAllocator> allocator = IAllocator::getService("ashmem");
- EXPECT_NE(allocator.get(), nullptr);
-
- status = getPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
- &portDef);
- ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
-
- for (size_t i = 0; i < portDef.nBufferCountActual; i++) {
- BufferInfo buffer;
- buffer.owner = client;
- buffer.omxBuffer.type = CodecBuffer::Type::SHARED_MEM;
- buffer.omxBuffer.attr.preset.rangeOffset = 0;
- buffer.omxBuffer.attr.preset.rangeLength = 0;
- bool success = false;
- allocator->allocate(
- portDef.nBufferSize,
- [&success, &buffer](bool _s,
- ::android::hardware::hidl_memory const& mem) {
- success = _s;
- buffer.omxBuffer.sharedMemory = mem;
- });
- ASSERT_EQ(success, true);
- ASSERT_EQ(buffer.omxBuffer.sharedMemory.size(), portDef.nBufferSize);
- buffer.mMemory = mapMemory(buffer.omxBuffer.sharedMemory);
- ASSERT_NE(buffer.mMemory, nullptr);
- omxNode->useBuffer(
- portIndex, buffer.omxBuffer,
- [&status, &buffer](android::hardware::media::omx::V1_0::Status _s,
- uint32_t id) {
- status = _s;
- buffer.id = id;
- });
- buffArray->push(buffer);
- ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
- }
-}
-
-// State Transition : Loaded -> Idle
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to idle
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateIdle);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
-
- // Dont switch states until the ports are populated
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- // allocate buffers on input port
- allocatePortBuffers(omxNode, iBuffer, kPortIndexInput);
-
- // Dont switch states until the ports are populated
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- // allocate buffers on output port
- allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput);
-
- // As the ports are populated, check if the state transition is complete
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
-
- return;
-}
-
-// State Transition : Idle -> Loaded
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to Loaded
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateLoaded);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
-
- // dont change state until all buffers are freed
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- status = omxNode->freeBuffer(kPortIndexInput, (*iBuffer)[i].id);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- }
-
- // dont change state until all buffers are freed
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
-
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- status = omxNode->freeBuffer(kPortIndexOutput, (*oBuffer)[i].id);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- }
-
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded);
-
- return;
-}
-
-// State Transition : Idle -> Execute
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateIdletoExecute(sp<IOmxNode> omxNode,
- sp<CodecObserver> observer) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to execute
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateExecuting);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateExecuting);
-
- return;
-}
-
-// State Transition : Execute -> Idle
-// Note: This function does not make any background checks for this transition.
-// The callee holds the reponsibility to ensure the legality of the transition.
-void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // set state to Idle
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
- OMX_StateIdle);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
- ASSERT_EQ(msg.data.eventData.data2, OMX_StateIdle);
-
- // test if client got all its buffers back
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- EXPECT_EQ((*oBuffer)[i].owner, client);
- }
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- EXPECT_EQ((*iBuffer)[i].owner, client);
- }
-}
-
-// get empty buffer index
-size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray) {
- for (size_t i = 0; i < buffArray->size(); i++) {
- if ((*buffArray)[i].owner == client) return i;
- }
- return buffArray->size();
-}
-
-// dispatch buffer to output port
-void dispatchOutputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex) {
- android::hardware::media::omx::V1_0::Status status;
- CodecBuffer t;
- t.sharedMemory = android::hardware::hidl_memory();
- t.nativeHandle = android::hardware::hidl_handle();
- t.type = CodecBuffer::Type::PRESET;
- t.attr.preset.rangeOffset = 0;
- t.attr.preset.rangeLength = 0;
- native_handle_t* fenceNh = native_handle_create(0, 0);
- ASSERT_NE(fenceNh, nullptr);
- status = omxNode->fillBuffer((*buffArray)[bufferIndex].id, t, fenceNh);
- native_handle_close(fenceNh);
- native_handle_delete(fenceNh);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- buffArray->editItemAt(bufferIndex).owner = component;
-}
-
-// dispatch buffer to input port
-void dispatchInputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex, int bytesCount, uint32_t flags,
- uint64_t timestamp) {
- android::hardware::media::omx::V1_0::Status status;
- CodecBuffer t;
- t.sharedMemory = android::hardware::hidl_memory();
- t.nativeHandle = android::hardware::hidl_handle();
- t.type = CodecBuffer::Type::PRESET;
- t.attr.preset.rangeOffset = 0;
- t.attr.preset.rangeLength = bytesCount;
- native_handle_t* fenceNh = native_handle_create(0, 0);
- ASSERT_NE(fenceNh, nullptr);
- status = omxNode->emptyBuffer((*buffArray)[bufferIndex].id, t, flags,
- timestamp, fenceNh);
- native_handle_close(fenceNh);
- native_handle_delete(fenceNh);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- buffArray->editItemAt(bufferIndex).owner = component;
-}
-
-// Flush input and output ports
-void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput, int64_t timeoutUs) {
- android::hardware::media::omx::V1_0::Status status;
- Message msg;
-
- // Flush input port
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
- kPortIndexInput);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, timeoutUs, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
- ASSERT_EQ(msg.data.eventData.data2, kPortIndexInput);
- // test if client got all its buffers back
- for (size_t i = 0; i < iBuffer->size(); ++i) {
- EXPECT_EQ((*iBuffer)[i].owner, client);
- }
-
- // Flush output port
- status = omxNode->sendCommand(toRawCommandType(OMX_CommandFlush),
- kPortIndexOutput);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- status = observer->dequeueMessage(&msg, timeoutUs, iBuffer, oBuffer);
- ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
- ASSERT_EQ(msg.type, Message::Type::EVENT);
- ASSERT_EQ(msg.data.eventData.event, OMX_EventCmdComplete);
- ASSERT_EQ(msg.data.eventData.data1, OMX_CommandFlush);
- ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
- // test if client got all its buffers back
- for (size_t i = 0; i < oBuffer->size(); ++i) {
- EXPECT_EQ((*oBuffer)[i].owner, client);
- }
-}
-
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex,
OMX_VIDEO_CODINGTYPE eCompressionFormat, OMX_COLOR_FORMATTYPE eColorFormat,
diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
index 00f9afe..ce4272c 100644
--- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h
@@ -25,41 +25,6 @@
/*
* Common video utils
*/
-void allocatePortBuffers(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- OMX_U32 portIndex);
-
-void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput);
-
-void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer,
- OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput);
-
-void changeStateIdletoExecute(sp<IOmxNode> omxNode, sp<CodecObserver> observer);
-
-void changeStateExecutetoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer);
-
-size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray);
-
-void dispatchOutputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex);
-
-void dispatchInputBuffer(sp<IOmxNode> omxNode,
- android::Vector<BufferInfo>* buffArray,
- size_t bufferIndex, int bytesCount, uint32_t flags,
- uint64_t timestamp);
-
-void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
- android::Vector<BufferInfo>* iBuffer,
- android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
- OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT);
Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
sp<IOmxNode> omxNode, OMX_U32 portIndex,
diff --git a/oemlock/1.0/Android.bp b/oemlock/1.0/Android.bp
new file mode 100644
index 0000000..dc6581e
--- /dev/null
+++ b/oemlock/1.0/Android.bp
@@ -0,0 +1,62 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.oemlock@1.0_hal",
+ srcs: [
+ "types.hal",
+ "IOemLock.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.oemlock@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.oemlock@1.0",
+ srcs: [
+ ":android.hardware.oemlock@1.0_hal",
+ ],
+ out: [
+ "android/hardware/oemlock/1.0/types.cpp",
+ "android/hardware/oemlock/1.0/OemLockAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.oemlock@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.oemlock@1.0",
+ srcs: [
+ ":android.hardware.oemlock@1.0_hal",
+ ],
+ out: [
+ "android/hardware/oemlock/1.0/types.h",
+ "android/hardware/oemlock/1.0/hwtypes.h",
+ "android/hardware/oemlock/1.0/IOemLock.h",
+ "android/hardware/oemlock/1.0/IHwOemLock.h",
+ "android/hardware/oemlock/1.0/BnHwOemLock.h",
+ "android/hardware/oemlock/1.0/BpHwOemLock.h",
+ "android/hardware/oemlock/1.0/BsOemLock.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.oemlock@1.0",
+ generated_sources: ["android.hardware.oemlock@1.0_genc++"],
+ generated_headers: ["android.hardware.oemlock@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.oemlock@1.0_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/oemlock/1.0/Android.mk b/oemlock/1.0/Android.mk
new file mode 100644
index 0000000..d986441
--- /dev/null
+++ b/oemlock/1.0/Android.mk
@@ -0,0 +1,156 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.oemlock-V1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java \
+
+
+#
+# Build types.hal (OemLockSecureStatus)
+#
+GEN := $(intermediates)/android/hardware/oemlock/V1_0/OemLockSecureStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.oemlock@1.0::types.OemLockSecureStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (OemLockStatus)
+#
+GEN := $(intermediates)/android/hardware/oemlock/V1_0/OemLockStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.oemlock@1.0::types.OemLockStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IOemLock.hal
+#
+GEN := $(intermediates)/android/hardware/oemlock/V1_0/IOemLock.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IOemLock.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.oemlock@1.0::IOemLock
+
+$(GEN): $(LOCAL_PATH)/IOemLock.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.oemlock-V1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java-static \
+
+
+#
+# Build types.hal (OemLockSecureStatus)
+#
+GEN := $(intermediates)/android/hardware/oemlock/V1_0/OemLockSecureStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.oemlock@1.0::types.OemLockSecureStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (OemLockStatus)
+#
+GEN := $(intermediates)/android/hardware/oemlock/V1_0/OemLockStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.oemlock@1.0::types.OemLockStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IOemLock.hal
+#
+GEN := $(intermediates)/android/hardware/oemlock/V1_0/IOemLock.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IOemLock.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.oemlock@1.0::IOemLock
+
+$(GEN): $(LOCAL_PATH)/IOemLock.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/oemlock/1.0/IOemLock.hal b/oemlock/1.0/IOemLock.hal
new file mode 100644
index 0000000..d570123
--- /dev/null
+++ b/oemlock/1.0/IOemLock.hal
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.oemlock@1.0;
+
+/*
+ * The OEM lock prevents the bootloader from allowing the device to be flashed.
+ *
+ * Both the carrier and the device itself have a say as to whether OEM unlock is
+ * allowed and both must agree that is allowed in order for unlock to be
+ * possible.
+ */
+interface IOemLock {
+ /**
+ * Returns a vendor specific identifier of the HAL.
+ *
+ * The name returned must not be interpreted by the framework but must be
+ * passed to vendor code which may use it to identify the security protocol
+ * used by setOemUnlockAllowedByCarrier. This allows the vendor to identify
+ * the protocol without having to maintain a device-to-protocol mapping.
+ *
+ * @return name of the implementation.
+ */
+ getName() generates (OemLockStatus status, string name);
+
+ /**
+ * Updates whether OEM unlock is allowed by the carrier.
+ *
+ * The implementation may require a vendor defined signature to prove the
+ * validity of this request in order to harden its security.
+ *
+ * @param allowed is the new value of the flag.
+ * @param signature to prove validity of this request or empty if not
+ * required.
+ * @return status is OK if the flag was successfully updated,
+ * INVALID_SIGNATURE if a signature is required but the wrong one
+ * was provided or FAILED if the update was otherwise unsuccessful.
+ */
+ setOemUnlockAllowedByCarrier(bool allowed, vec<uint8_t> signature)
+ generates (OemLockSecureStatus status);
+
+ /**
+ * Returns whether OEM unlock is allowed by the carrier.
+ *
+ * @return status is OK if the flag was successfully read.
+ * @return allowed is the current state of the flag.
+ */
+ isOemUnlockAllowedByCarrier() generates (OemLockStatus status, bool allowed);
+
+ /**
+ * Updates whether OEM unlock is allowed by the device.
+ *
+ * @param allowed is the new value of the flag.
+ * @return status is OK if the flag was successfully updated.
+ */
+ setOemUnlockAllowedByDevice(bool allowed) generates (OemLockStatus status);
+
+ /**
+ * Returns whether OEM unlock ia allowed by the device.
+ *
+ * @return status is OK if the flag was successfully read.
+ * @return allowed is the current state of the flag.
+ */
+ isOemUnlockAllowedByDevice() generates (OemLockStatus status, bool allowed);
+};
diff --git a/oemlock/1.0/types.hal b/oemlock/1.0/types.hal
new file mode 100644
index 0000000..0b4a8d1
--- /dev/null
+++ b/oemlock/1.0/types.hal
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.oemlock@1.0;
+
+enum OemLockStatus : uint32_t {
+ /** The operation completed successfully. */
+ OK,
+ /** The operation encountered a problem. */
+ FAILED,
+};
+
+enum OemLockSecureStatus : OemLockStatus {
+ /** An invalid signature was provided so the operation was not performed. */
+ INVALID_SIGNATURE,
+};
diff --git a/oemlock/Android.bp b/oemlock/Android.bp
new file mode 100644
index 0000000..bbb3e4b
--- /dev/null
+++ b/oemlock/Android.bp
@@ -0,0 +1,4 @@
+// This is an autogenerated file, do not edit.
+subdirs = [
+ "1.0",
+]
diff --git a/power/1.1/Android.bp b/power/1.1/Android.bp
new file mode 100644
index 0000000..ee50a18
--- /dev/null
+++ b/power/1.1/Android.bp
@@ -0,0 +1,64 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.power@1.1_hal",
+ srcs: [
+ "types.hal",
+ "IPower.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.power@1.1_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.power@1.1",
+ srcs: [
+ ":android.hardware.power@1.1_hal",
+ ],
+ out: [
+ "android/hardware/power/1.1/types.cpp",
+ "android/hardware/power/1.1/PowerAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.power@1.1_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.power@1.1",
+ srcs: [
+ ":android.hardware.power@1.1_hal",
+ ],
+ out: [
+ "android/hardware/power/1.1/types.h",
+ "android/hardware/power/1.1/hwtypes.h",
+ "android/hardware/power/1.1/IPower.h",
+ "android/hardware/power/1.1/IHwPower.h",
+ "android/hardware/power/1.1/BnHwPower.h",
+ "android/hardware/power/1.1/BpHwPower.h",
+ "android/hardware/power/1.1/BsPower.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.power@1.1",
+ generated_sources: ["android.hardware.power@1.1_genc++"],
+ generated_headers: ["android.hardware.power@1.1_genc++_headers"],
+ export_generated_headers: ["android.hardware.power@1.1_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.power@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.power@1.0",
+ ],
+}
diff --git a/power/1.1/Android.mk b/power/1.1/Android.mk
new file mode 100644
index 0000000..16cfcbd
--- /dev/null
+++ b/power/1.1/Android.mk
@@ -0,0 +1,158 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.power-V1.1-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hardware.power-V1.0-java \
+ android.hidl.base-V1.0-java \
+
+
+#
+# Build types.hal (PowerStateSubsystem)
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/PowerStateSubsystem.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::types.PowerStateSubsystem
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStateSubsystemSleepState)
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/PowerStateSubsystemSleepState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::types.PowerStateSubsystemSleepState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IPower.hal
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/IPower.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IPower.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::IPower
+
+$(GEN): $(LOCAL_PATH)/IPower.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.power-V1.1-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hardware.power-V1.0-java-static \
+ android.hidl.base-V1.0-java-static \
+
+
+#
+# Build types.hal (PowerStateSubsystem)
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/PowerStateSubsystem.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::types.PowerStateSubsystem
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStateSubsystemSleepState)
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/PowerStateSubsystemSleepState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::types.PowerStateSubsystemSleepState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IPower.hal
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/IPower.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IPower.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::IPower
+
+$(GEN): $(LOCAL_PATH)/IPower.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/power/1.1/IPower.hal b/power/1.1/IPower.hal
new file mode 100644
index 0000000..0c0f211
--- /dev/null
+++ b/power/1.1/IPower.hal
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.power@1.1;
+
+import android.hardware.power@1.0;
+
+/**
+ * Interface to collect subsystem level sleep information
+ */
+interface IPower extends android.hardware.power@1.0::IPower {
+
+ /**
+ * Subsystem-level sleep state stats:
+ * Report cumulative info on the statistics on subsystem-level sleep states
+ * since boot.
+ *
+ * @return subsystems supported on this device and their sleep states
+ * @return retval SUCCESS on success or FILESYSTEM_ERROR on filesystem
+ * nodes access error.
+ */
+ getSubsystemLowPowerStats()
+ generates (vec<PowerStateSubsystem> subsystems, Status retval);
+};
diff --git a/power/1.1/default/Android.bp b/power/1.1/default/Android.bp
new file mode 100644
index 0000000..0b3598b
--- /dev/null
+++ b/power/1.1/default/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.
+
+cc_binary {
+ proprietary: true,
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ name: "android.hardware.power@1.1-service",
+ init_rc: ["android.hardware.power@1.1-service.rc"],
+ srcs: ["service.cpp" , "Power.cpp"],
+
+ shared_libs: [
+ "liblog",
+ "libdl",
+ "libutils",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "android.hardware.power@1.0",
+ "android.hardware.power@1.1",
+ ],
+}
diff --git a/power/1.1/default/Power.cpp b/power/1.1/default/Power.cpp
new file mode 100644
index 0000000..bf7c1fc
--- /dev/null
+++ b/power/1.1/default/Power.cpp
@@ -0,0 +1,172 @@
+/*
+ * 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 "android.hardware.power@1.1-impl"
+
+#include <log/log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+
+#include "Power.h"
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace V1_1 {
+namespace implementation {
+
+using ::android::hardware::power::V1_0::Feature;
+using ::android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::power::V1_0::PowerStatePlatformSleepState;
+using ::android::hardware::power::V1_0::Status;
+using ::android::hardware::power::V1_1::PowerStateSubsystem;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+Power::Power(power_module_t *module) : mModule(module) {
+ if (mModule)
+ mModule->init(mModule);
+}
+
+Power::~Power() {
+ delete(mModule);
+}
+
+// Methods from ::android::hardware::power::V1_0::IPower follow.
+Return<void> Power::setInteractive(bool interactive) {
+ if (mModule->setInteractive)
+ mModule->setInteractive(mModule, interactive ? 1 : 0);
+ return Void();
+}
+
+Return<void> Power::powerHint(PowerHint hint, int32_t data) {
+ int32_t param = data;
+ if (mModule->powerHint) {
+ if (data)
+ mModule->powerHint(mModule, static_cast<power_hint_t>(hint), ¶m);
+ else
+ mModule->powerHint(mModule, static_cast<power_hint_t>(hint), NULL);
+ }
+ return Void();
+}
+
+Return<void> Power::setFeature(Feature feature, bool activate) {
+ if (mModule->setFeature)
+ mModule->setFeature(mModule, static_cast<feature_t>(feature),
+ activate ? 1 : 0);
+ return Void();
+}
+
+Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
+ hidl_vec<PowerStatePlatformSleepState> states;
+ ssize_t number_platform_modes;
+ size_t *voters = nullptr;
+ power_state_platform_sleep_state_t *legacy_states = nullptr;
+ int ret;
+
+ if (mModule->get_number_of_platform_modes == nullptr ||
+ mModule->get_voter_list == nullptr ||
+ mModule->get_platform_low_power_stats == nullptr)
+ {
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+ }
+
+ number_platform_modes = mModule->get_number_of_platform_modes(mModule);
+ if (number_platform_modes)
+ {
+ if ((ssize_t) (SIZE_MAX / sizeof(size_t)) <= number_platform_modes) // overflow
+ goto done;
+ voters = new (std::nothrow) size_t [number_platform_modes];
+ if (voters == nullptr)
+ goto done;
+
+ ret = mModule->get_voter_list(mModule, voters);
+ if (ret != 0)
+ goto done;
+
+ if ((ssize_t) (SIZE_MAX / sizeof(power_state_platform_sleep_state_t))
+ <= number_platform_modes) // overflow
+ goto done;
+ legacy_states = new (std::nothrow)
+ power_state_platform_sleep_state_t [number_platform_modes];
+ if (legacy_states == nullptr)
+ goto done;
+
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ legacy_states[i].voters = nullptr;
+ legacy_states[i].voters = new power_state_voter_t [voters[i]];
+ if (legacy_states[i].voters == nullptr)
+ goto done;
+ }
+
+ ret = mModule->get_platform_low_power_stats(mModule, legacy_states);
+ if (ret != 0)
+ goto done;
+
+ states.resize(number_platform_modes);
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ power_state_platform_sleep_state_t& legacy_state = legacy_states[i];
+ PowerStatePlatformSleepState& state = states[i];
+ state.name = legacy_state.name;
+ state.residencyInMsecSinceBoot = legacy_state.residency_in_msec_since_boot;
+ state.totalTransitions = legacy_state.total_transitions;
+ state.supportedOnlyInSuspend = legacy_state.supported_only_in_suspend;
+ state.voters.resize(voters[i]);
+ for(size_t j = 0; j < voters[i]; j++)
+ {
+ state.voters[j].name = legacy_state.voters[j].name;
+ state.voters[j].totalTimeInMsecVotedForSinceBoot = legacy_state.voters[j].total_time_in_msec_voted_for_since_boot;
+ state.voters[j].totalNumberOfTimesVotedSinceBoot = legacy_state.voters[j].total_number_of_times_voted_since_boot;
+ }
+ }
+ }
+done:
+ if (legacy_states)
+ {
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ if(legacy_states[i].voters)
+ delete(legacy_states[i].voters);
+ }
+ }
+ delete[] legacy_states;
+ delete[] voters;
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+}
+
+// Methods from ::android::hardware::power::V1_1::IPower follow.
+Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
+ hidl_vec<PowerStateSubsystem> subsystems;
+ ssize_t number_subsystems = 0;
+
+ //This API will report zero subsystems to support older devices
+ //For devices that support this API, they will have their own implementation
+ subsystems.resize(number_subsystems);
+ _hidl_cb(subsystems, Status::SUCCESS);
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace power
+} // namespace hardware
+} // namespace android
diff --git a/power/1.1/default/Power.h b/power/1.1/default/Power.h
new file mode 100644
index 0000000..ea9e8c3
--- /dev/null
+++ b/power/1.1/default/Power.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_POWER_V1_1_POWER_H
+#define ANDROID_HARDWARE_POWER_V1_1_POWER_H
+
+#include <android/hardware/power/1.1/IPower.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <hardware/power.h>
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace V1_1 {
+namespace implementation {
+
+using ::android::hardware::power::V1_0::Feature;
+using ::android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::power::V1_1::IPower;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct Power : public IPower {
+ Power(power_module_t* module);
+ ~Power();
+
+ // Methods from ::android::hardware::power::V1_0::IPower follow
+ Return<void> setInteractive(bool interactive) override;
+ Return<void> powerHint(PowerHint hint, int32_t data) override;
+ Return<void> setFeature(Feature feature, bool activate) override;
+ Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override;
+
+ // Methods from ::android::hardware::power::V1_1::IPower follow.
+ Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+
+ private:
+ power_module_t* mModule;
+};
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace power
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_POWER_V1_1_POWER_H
diff --git a/power/1.1/default/android.hardware.power@1.1-service.rc b/power/1.1/default/android.hardware.power@1.1-service.rc
new file mode 100644
index 0000000..f2512f1
--- /dev/null
+++ b/power/1.1/default/android.hardware.power@1.1-service.rc
@@ -0,0 +1,4 @@
+service power-hal-1-1 /vendor/bin/hw/android.hardware.power@1.1-service
+ class hal
+ user system
+ group system
diff --git a/power/1.1/default/service.cpp b/power/1.1/default/service.cpp
new file mode 100644
index 0000000..571db2f
--- /dev/null
+++ b/power/1.1/default/service.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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 "android.hardware.power@1.1-service"
+
+#include <android/log.h>
+#include <hidl/HidlTransportSupport.h>
+#include <android/hardware/power/1.1/IPower.h>
+#include <hardware/power.h>
+#include "Power.h"
+
+using android::sp;
+using android::status_t;
+using android::OK;
+
+// libhwbinder:
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+// Generated HIDL files
+using android::hardware::power::V1_1::IPower;
+using android::hardware::power::V1_1::implementation::Power;
+
+int main() {
+
+ status_t status;
+ android::sp<IPower> service = nullptr;
+ const hw_module_t* hw_module = nullptr;
+ power_module_t* power_module = nullptr;
+ int err;
+
+ ALOGI("Power HAL Service 1.1 (Default) is starting.");
+
+ err = hw_get_module(POWER_HARDWARE_MODULE_ID, &hw_module);
+ if (err) {
+ ALOGE("hw_get_module %s failed: %d", POWER_HARDWARE_MODULE_ID, err);
+ goto shutdown;
+ }
+
+ if (!hw_module->methods || !hw_module->methods->open) {
+ power_module = reinterpret_cast<power_module_t*>(
+ const_cast<hw_module_t*>(hw_module));
+ } else {
+ err = hw_module->methods->open(hw_module, POWER_HARDWARE_MODULE_ID,
+ reinterpret_cast<hw_device_t**>(&power_module));
+ if (err) {
+ ALOGE("Passthrough failed to load legacy HAL.");
+ goto shutdown;
+ }
+ }
+
+ service = new Power(power_module);
+ if (service == nullptr) {
+ ALOGE("Can not create an instance of Power HAL Iface, exiting.");
+
+ goto shutdown;
+ }
+
+ configureRpcThreadpool(1, true /*callerWillJoin*/);
+
+ status = service->registerAsService();
+ if (status != OK) {
+ ALOGE("Could not register service for Power HAL Iface (%d).", status);
+ goto shutdown;
+ }
+
+ ALOGI("Power Service is ready");
+ joinRpcThreadpool();
+ //Should not pass this line
+
+shutdown:
+ // In normal operation, we don't expect the thread pool to exit
+
+ ALOGE("Power Service is shutting down");
+ return 1;
+}
diff --git a/power/1.1/types.hal b/power/1.1/types.hal
new file mode 100644
index 0000000..5298d4e
--- /dev/null
+++ b/power/1.1/types.hal
@@ -0,0 +1,75 @@
+/*
+ * 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.power@1.1;
+
+/**
+ * Subsytem-level sleep state stats:
+ * PowerStateSubsystemSleepState represents the sleep states
+ * a subsystem (e.g. wifi, bt) is capable of getting into.
+ *
+ * SoCs like wifi, bt usually have more than one subsystem level sleep state.
+ */
+struct PowerStateSubsystemSleepState {
+ /**
+ * Subsystem-level Sleep state name.
+ */
+ string name;
+
+ /**
+ * Time spent in msec at this subsystem-level sleep state since boot.
+ */
+ uint64_t residencyInMsecSinceBoot;
+
+ /**
+ * Total number of times sub-system entered this state.
+ */
+ uint64_t totalTransitions;
+
+ /**
+ * Timestamp of last entry of this state measured in MSec
+ */
+ uint64_t lastEntryTimestampMs;
+
+ /**
+ * This subsystem-level sleep state can only be reached during system suspend
+ */
+ bool supportedOnlyInSuspend;
+};
+
+/**
+ * Subsytem-level sleep state stats:
+ * PowerStateSubsystem represents a subsystem (e.g. wifi, bt)
+ * and all the sleep states this susbsystem is capable of getting into.
+ *
+ * SoCs like wifi, bt usually have more than one subsystem level sleep state.
+ */
+struct PowerStateSubsystem {
+ /**
+ * Subsystem name (e.g. wifi, bt etc.)
+ */
+ string name;
+
+ /**
+ * states represents the list of sleep states supported by this susbsystem.
+ * Higher the index in the returned <states> vector deeper the state is
+ * i.e. lesser steady-state power is consumed by the subsystem to
+ * to be resident in that state.
+ *
+ * Vector of size zero implies either the info is not available
+ * or the subsystem does not have any sleep states.
+ */
+ vec<PowerStateSubsystemSleepState> states;
+};
diff --git a/power/1.1/vts/functional/Android.bp b/power/1.1/vts/functional/Android.bp
new file mode 100644
index 0000000..f886bd2
--- /dev/null
+++ b/power/1.1/vts/functional/Android.bp
@@ -0,0 +1,34 @@
+//
+// 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: "VtsHalPowerV1_1TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalPowerV1_1TargetTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "android.hardware.power@1.1",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ]
+}
diff --git a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
new file mode 100644
index 0000000..1d0d50f
--- /dev/null
+++ b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "power_hidl_hal_test"
+#include <android-base/logging.h>
+#include <android/hardware/power/1.1/IPower.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+using ::android::hardware::power::V1_1::IPower;
+using ::android::hardware::power::V1_1::PowerStateSubsystem;
+using ::android::hardware::power::V1_0::Status;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::sp;
+
+class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
+ ASSERT_NE(power, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ sp<IPower> power;
+};
+
+// Sanity check Power::getSubsystemLowPowerStats().
+TEST_F(PowerHidlTest, GetSubsystemLowPowerStats) {
+ hidl_vec<PowerStateSubsystem> vec;
+ Status s;
+ auto cb = [&vec, &s](hidl_vec<PowerStateSubsystem> subsystems,
+ Status status) {
+ vec = subsystems;
+ s = status;
+ };
+
+ Return<void> ret = power->getSubsystemLowPowerStats(cb);
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_TRUE(s == Status::SUCCESS || s == Status::FILESYSTEM_ERROR);
+}
+
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/power/Android.bp b/power/Android.bp
index ed19a37..7a315fa 100644
--- a/power/Android.bp
+++ b/power/Android.bp
@@ -3,4 +3,7 @@
"1.0",
"1.0/default",
"1.0/vts/functional",
+ "1.1",
+ "1.1/default",
+ "1.1/vts/functional",
]
diff --git a/renderscript/1.0/vts/functional/Android.bp b/renderscript/1.0/vts/functional/Android.bp
index 635e2e6..5256c1f 100644
--- a/renderscript/1.0/vts/functional/Android.bp
+++ b/renderscript/1.0/vts/functional/Android.bp
@@ -32,6 +32,7 @@
"libhidltransport",
"libnativehelper",
"libutils",
+ "libnativewindow",
"android.hardware.renderscript@1.0",
],
static_libs: ["VtsHalHidlTargetTestBase"],
diff --git a/sensors/1.0/default/convert.cpp b/sensors/1.0/default/convert.cpp
index 3d859ec..2908737 100644
--- a/sensors/1.0/default/convert.cpp
+++ b/sensors/1.0/default/convert.cpp
@@ -374,6 +374,10 @@
return false;
}
+ if (memIn.memoryHandle == nullptr) {
+ return false;
+ }
+
memOut->size = memIn.size;
memOut->handle = memIn.memoryHandle;
return true;
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
index 06a9d7e..c92603b 100644
--- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
+++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
@@ -1319,9 +1319,7 @@
// stop sensor and unregister channel
configDirectReport(sensor.sensorHandle, channelHandle, RateLevel::STOP,
- [&eventToken] (auto result, auto) {
- EXPECT_EQ(result, Result::OK);
- });
+ [](auto result, auto) { EXPECT_EQ(result, Result::OK); });
EXPECT_EQ(unregisterDirectChannel(channelHandle), Result::OK);
}
diff --git a/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp b/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
index 3989c94..dfa11a1 100644
--- a/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
+++ b/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
@@ -68,10 +68,12 @@
if (i < baseSize_) {
EXPECT_EQ(names_[i], temperatures[i].name.c_str());
} else {
- // Names must be unique.
- EXPECT_EQ(names_.end(), std::find(names_.begin(), names_.end(),
- temperatures[i].name.c_str()));
- names_.push_back(temperatures[i].name);
+ // Names must be unique only for known temperature types.
+ if (temperatures[i].type != TemperatureType::UNKNOWN) {
+ EXPECT_EQ(names_.end(), std::find(names_.begin(), names_.end(),
+ temperatures[i].name.c_str()));
+ }
+ names_.push_back(temperatures[i].name);
}
}
baseSize_ = size;
@@ -88,10 +90,9 @@
if (i < baseSize_) {
EXPECT_EQ(names_[i], cpuUsages[i].name.c_str());
} else {
- // Names must be unique.
- EXPECT_EQ(names_.end(), std::find(names_.begin(), names_.end(),
- cpuUsages[i].name.c_str()));
- names_.push_back(cpuUsages[i].name);
+ // Names are not guaranteed to be unique because of the current
+ // default Thermal HAL implementation.
+ names_.push_back(cpuUsages[i].name);
}
}
baseSize_ = size;
diff --git a/usb/1.1/Android.bp b/usb/1.1/Android.bp
new file mode 100644
index 0000000..d5cdf04
--- /dev/null
+++ b/usb/1.1/Android.bp
@@ -0,0 +1,71 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.usb@1.1_hal",
+ srcs: [
+ "types.hal",
+ "IUsb.hal",
+ "IUsbCallback.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.usb@1.1_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.usb@1.1",
+ srcs: [
+ ":android.hardware.usb@1.1_hal",
+ ],
+ out: [
+ "android/hardware/usb/1.1/types.cpp",
+ "android/hardware/usb/1.1/UsbAll.cpp",
+ "android/hardware/usb/1.1/UsbCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.usb@1.1_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.usb@1.1",
+ srcs: [
+ ":android.hardware.usb@1.1_hal",
+ ],
+ out: [
+ "android/hardware/usb/1.1/types.h",
+ "android/hardware/usb/1.1/hwtypes.h",
+ "android/hardware/usb/1.1/IUsb.h",
+ "android/hardware/usb/1.1/IHwUsb.h",
+ "android/hardware/usb/1.1/BnHwUsb.h",
+ "android/hardware/usb/1.1/BpHwUsb.h",
+ "android/hardware/usb/1.1/BsUsb.h",
+ "android/hardware/usb/1.1/IUsbCallback.h",
+ "android/hardware/usb/1.1/IHwUsbCallback.h",
+ "android/hardware/usb/1.1/BnHwUsbCallback.h",
+ "android/hardware/usb/1.1/BpHwUsbCallback.h",
+ "android/hardware/usb/1.1/BsUsbCallback.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.usb@1.1",
+ generated_sources: ["android.hardware.usb@1.1_genc++"],
+ generated_headers: ["android.hardware.usb@1.1_genc++_headers"],
+ export_generated_headers: ["android.hardware.usb@1.1_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.usb@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.usb@1.0",
+ ],
+}
diff --git a/usb/1.1/Android.mk b/usb/1.1/Android.mk
new file mode 100644
index 0000000..12d306b
--- /dev/null
+++ b/usb/1.1/Android.mk
@@ -0,0 +1,231 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.usb-V1.1-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hardware.usb-V1.0-java \
+ android.hidl.base-V1.0-java \
+
+
+#
+# Build types.hal (PortMode_1_1)
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/PortMode_1_1.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::types.PortMode_1_1
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PortStatus_1_1)
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/PortStatus_1_1.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::types.PortStatus_1_1
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IUsb.hal
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/IUsb.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IUsb.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::IUsb
+
+$(GEN): $(LOCAL_PATH)/IUsb.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IUsbCallback.hal
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/IUsbCallback.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IUsbCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::IUsbCallback
+
+$(GEN): $(LOCAL_PATH)/IUsbCallback.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.usb-V1.1-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hardware.usb-V1.0-java-static \
+ android.hidl.base-V1.0-java-static \
+
+
+#
+# Build types.hal (PortMode_1_1)
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/PortMode_1_1.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::types.PortMode_1_1
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PortStatus_1_1)
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/PortStatus_1_1.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::types.PortStatus_1_1
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IUsb.hal
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/IUsb.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IUsb.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::IUsb
+
+$(GEN): $(LOCAL_PATH)/IUsb.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IUsbCallback.hal
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/IUsbCallback.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IUsbCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1::IUsbCallback
+
+$(GEN): $(LOCAL_PATH)/IUsbCallback.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.usb-V1.1-java-constants
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+#
+GEN := $(intermediates)/android/hardware/usb/V1_1/Constants.java
+$(GEN): $(HIDL)
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/IUsb.hal
+$(GEN): $(LOCAL_PATH)/IUsbCallback.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 \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.usb@1.1
+
+$(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/usb/1.1/IUsb.hal b/usb/1.1/IUsb.hal
new file mode 100644
index 0000000..9cedea0
--- /dev/null
+++ b/usb/1.1/IUsb.hal
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.usb@1.1;
+
+import android.hardware.usb@1.0;
+
+interface IUsb extends android.hardware.usb@1.0::IUsb {
+ /**
+ * The setCallback function in V1_0 is used to register the V1_1
+ * IUsbCallback object as well. The implementation can use the
+ * castFrom method to cast the IUsbCallback object.
+ */
+};
+
diff --git a/usb/1.1/IUsbCallback.hal b/usb/1.1/IUsbCallback.hal
new file mode 100644
index 0000000..369ffc8
--- /dev/null
+++ b/usb/1.1/IUsbCallback.hal
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.usb@1.1;
+
+import android.hardware.usb@1.0;
+
+/**
+ * Callback object used for all the IUsb async methods which expects a result.
+ * Caller is expected to register the callback object using setCallback method
+ * to receive updates on the PortStatus.
+ */
+interface IUsbCallback extends @1.0::IUsbCallback {
+ /**
+ * Used to convey the current port status to the caller.
+ * Must be called either when PortState changes due to the port partner or
+ * when caller requested for the PortStatus update through queryPortStatus.
+ *
+ * @param currentPortStatus vector object of current status(PortStatus_1_1
+ * of all the typeC ports in the device.
+ * @param retval SUCCESS when the required information was enquired form
+ * kernel and the PortStatus_1_1 object was built.
+ * ERROR otherwise.
+ */
+ oneway notifyPortStatusChange_1_1(vec<PortStatus_1_1> currentPortStatus,
+ Status retval);
+};
diff --git a/usb/1.1/types.hal b/usb/1.1/types.hal
new file mode 100644
index 0000000..2261e09
--- /dev/null
+++ b/usb/1.1/types.hal
@@ -0,0 +1,57 @@
+/*
+ * 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.usb@1.1;
+
+import android.hardware.usb@1.0;
+
+@export
+enum PortMode_1_1 : PortMode {
+ /*
+ * Indicates that the port supports Audio Accessory mode.
+ */
+ AUDIO_ACCESSORY = 1 << 2,
+
+ /*
+ * Indicates that the port supports Debug Accessory mode.
+ */
+ DEBUG_ACCESSORY = 1 << 3,
+
+ NUM_MODES_1_1 = 1 << 4,
+};
+
+/*
+ * Used as the container to report data back to the caller.
+ * Represents the current connection status of a single USB port.
+ */
+struct PortStatus_1_1 {
+ /*
+ * The supportedModes and the currentMode fields of the status
+ * object should be set to NONE.
+ */
+ PortStatus status;
+
+ /*
+ * Identifies the modes supported by the port.
+ * Refer to PortMode_1_1 for the significance of the individual bits.
+ */
+ bitfield<PortMode_1_1> supportedModes;
+
+ /*
+ * Indicates the current mode in which the port is operating.
+ */
+ PortMode_1_1 currentMode;
+};
diff --git a/usb/Android.bp b/usb/Android.bp
index 33f70eb..3aa1151 100644
--- a/usb/Android.bp
+++ b/usb/Android.bp
@@ -2,4 +2,5 @@
subdirs = [
"1.0",
"1.0/vts/functional",
+ "1.1",
]
diff --git a/weaver/1.0/Android.bp b/weaver/1.0/Android.bp
new file mode 100644
index 0000000..8d6c1d1
--- /dev/null
+++ b/weaver/1.0/Android.bp
@@ -0,0 +1,62 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.weaver@1.0_hal",
+ srcs: [
+ "types.hal",
+ "IWeaver.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.weaver@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.weaver@1.0",
+ srcs: [
+ ":android.hardware.weaver@1.0_hal",
+ ],
+ out: [
+ "android/hardware/weaver/1.0/types.cpp",
+ "android/hardware/weaver/1.0/WeaverAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.weaver@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.weaver@1.0",
+ srcs: [
+ ":android.hardware.weaver@1.0_hal",
+ ],
+ out: [
+ "android/hardware/weaver/1.0/types.h",
+ "android/hardware/weaver/1.0/hwtypes.h",
+ "android/hardware/weaver/1.0/IWeaver.h",
+ "android/hardware/weaver/1.0/IHwWeaver.h",
+ "android/hardware/weaver/1.0/BnHwWeaver.h",
+ "android/hardware/weaver/1.0/BpHwWeaver.h",
+ "android/hardware/weaver/1.0/BsWeaver.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.weaver@1.0",
+ generated_sources: ["android.hardware.weaver@1.0_genc++"],
+ generated_headers: ["android.hardware.weaver@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.weaver@1.0_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/weaver/1.0/Android.mk b/weaver/1.0/Android.mk
new file mode 100644
index 0000000..7f35b4e
--- /dev/null
+++ b/weaver/1.0/Android.mk
@@ -0,0 +1,232 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.weaver-V1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java \
+
+
+#
+# Build types.hal (WeaverConfig)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverConfig.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverConfig
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (WeaverReadResponse)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverReadResponse.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverReadResponse
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (WeaverReadStatus)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverReadStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverReadStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (WeaverStatus)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWeaver.hal
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/IWeaver.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWeaver.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::IWeaver
+
+$(GEN): $(LOCAL_PATH)/IWeaver.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.weaver-V1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android.hidl.base-V1.0-java-static \
+
+
+#
+# Build types.hal (WeaverConfig)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverConfig.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverConfig
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (WeaverReadResponse)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverReadResponse.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverReadResponse
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (WeaverReadStatus)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverReadStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverReadStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (WeaverStatus)
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/WeaverStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::types.WeaverStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWeaver.hal
+#
+GEN := $(intermediates)/android/hardware/weaver/V1_0/IWeaver.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWeaver.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.weaver@1.0::IWeaver
+
+$(GEN): $(LOCAL_PATH)/IWeaver.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/weaver/1.0/IWeaver.hal b/weaver/1.0/IWeaver.hal
new file mode 100644
index 0000000..e572123
--- /dev/null
+++ b/weaver/1.0/IWeaver.hal
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.weaver@1.0;
+
+/**
+ * Weaver provides secure storage of secret values that may only be read if the
+ * corresponding key has been presented.
+ *
+ * The storage must be secure as the device's user authentication and encryption
+ * relies on the security of these values. The cardinality of the domains of the
+ * key and value must be suitably large such that they cannot be easily guessed.
+ *
+ * Weaver is structured as an array of slots, each containing a key-value pair.
+ * Slots are uniquely identified by an ID in the range [0, `getConfig().slots`).
+ */
+interface IWeaver {
+ /**
+ * Retrieves the config information for this implementation of Weaver.
+ *
+ * The config is static i.e. every invocation returns the same information.
+ *
+ * @return status is OK if the config was successfuly obtained.
+ * @return config data for this implementation of Weaver if status is OK,
+ * otherwise undefined.
+ */
+ getConfig() generates (WeaverStatus status, WeaverConfig config);
+
+ /**
+ * Overwrites the identified slot with the provided key and value.
+ *
+ * The new values are written regardless of the current state of the slot in
+ * order to remain idempotent.
+ *
+ * @param slotId of the slot to write to.
+ * @param key to write to the slot.
+ * @param value to write to slot.
+ * @return status is OK if the write was successfully completed.
+ */
+ write(uint32_t slotId, vec<uint8_t> key, vec<uint8_t> value)
+ generates (WeaverStatus status);
+
+ /**
+ * Attempts to retrieve the value stored in the identified slot.
+ *
+ * The value is only returned if the provided key matches the key stored in
+ * the slot. The value is never returned if the wrong key is provided.
+ *
+ * Throttling must be used to limit the frequency of failed read attempts.
+ * The value is only returned when throttling is not active, even if the
+ * correct key is provided. If called when throttling is active, the time
+ * until the next attempt can be made is returned.
+ *
+ * @param slotId of the slot to read from.
+ * @param key that is stored in the slot.
+ * @return status is OK if the value was successfully read, INCORRECT_KEY if
+ * the key does not match the key in the slot, THROTTLE if
+ * throttling is active or FAILED if the read was unsuccessful for
+ * another reason.
+ * @return readResponse contains the value read and the timeout to wait
+ * before making the next request. If the status is OK, value is set
+ * to the value in the slot and timeout is 0. Otherwise, value is
+ * empty and timeout is set accordingly.
+ */
+ read(uint32_t slotId, vec<uint8_t> key)
+ generates (WeaverReadStatus status,
+ WeaverReadResponse readResponse);
+};
diff --git a/weaver/1.0/types.hal b/weaver/1.0/types.hal
new file mode 100644
index 0000000..49e5c04
--- /dev/null
+++ b/weaver/1.0/types.hal
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.weaver@1.0;
+
+enum WeaverStatus : uint32_t {
+ OK,
+ FAILED,
+};
+
+struct WeaverConfig {
+ /** The number of slots available. */
+ uint32_t slots;
+ /** The number of bytes used for a key. */
+ uint32_t keySize;
+ /** The number of bytes used for a value. */
+ uint32_t valueSize;
+};
+
+enum WeaverReadStatus : WeaverStatus {
+ INCORRECT_KEY,
+ THROTTLE,
+};
+
+struct WeaverReadResponse {
+ /** The time to wait, in milliseconds, before making the next request. */
+ uint32_t timeout;
+ /** The value read from the slot or empty if the value was not read. */
+ vec<uint8_t> value;
+};
diff --git a/weaver/Android.bp b/weaver/Android.bp
new file mode 100644
index 0000000..bbb3e4b
--- /dev/null
+++ b/weaver/Android.bp
@@ -0,0 +1,4 @@
+// This is an autogenerated file, do not edit.
+subdirs = [
+ "1.0",
+]
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
index 2564937..fe33e08 100644
--- a/wifi/1.0/default/Android.mk
+++ b/wifi/1.0/default/Android.mk
@@ -46,6 +46,6 @@
libnl \
libutils \
libwifi-hal \
- libwifi-system
+ libwifi-system-iface
LOCAL_INIT_RC := android.hardware.wifi@1.0-service.rc
include $(BUILD_EXECUTABLE)
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index 077dbb8..c9617f5 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -26,6 +26,16 @@
namespace implementation {
namespace hidl_struct_util {
+hidl_string safeConvertChar(const char* str, size_t max_len) {
+ const char* c = str;
+ size_t size = 0;
+ while (*c && (unsigned char)*c < 128 && size < max_len) {
+ ++size;
+ ++c;
+ }
+ return hidl_string(str, size);
+}
+
IWifiChip::ChipCapabilityMask convertLegacyLoggerFeatureToHidlChipCapability(
uint32_t feature) {
using HidlChipCaps = IWifiChip::ChipCapabilityMask;
@@ -134,7 +144,8 @@
return false;
}
*hidl_status = {};
- hidl_status->ringName = reinterpret_cast<const char*>(legacy_status.name);
+ hidl_status->ringName = safeConvertChar(reinterpret_cast<const char*>(legacy_status.name),
+ sizeof(legacy_status.name));
hidl_status->flags = 0;
for (const auto flag : {WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES,
WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES}) {
@@ -449,7 +460,8 @@
hidl_scan_result->timeStampInUs = legacy_scan_result.ts;
hidl_scan_result->ssid = std::vector<uint8_t>(
legacy_scan_result.ssid,
- legacy_scan_result.ssid + strlen(legacy_scan_result.ssid));
+ legacy_scan_result.ssid + strnlen(legacy_scan_result.ssid,
+ sizeof(legacy_scan_result.ssid) - 1));
memcpy(hidl_scan_result->bssid.data(),
legacy_scan_result.bssid,
hidl_scan_result->bssid.size());
@@ -882,6 +894,12 @@
CHECK(false);
}
+void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
+ WifiNanStatus* wifiNanStatus) {
+ wifiNanStatus->status = convertLegacyNanStatusTypeToHidl(type);
+ wifiNanStatus->description = safeConvertChar(str, max_len);
+}
+
bool convertHidlNanEnableRequestToLegacy(
const NanEnableRequest& hidl_request,
legacy_hal::NanEnableRequest* legacy_request) {
@@ -914,7 +932,14 @@
legacy_request->sid_beacon_val =
(hidl_request.configParams.includePublishServiceIdsInBeacon ? 0x1 : 0x0)
| (hidl_request.configParams.numberOfPublishServiceIdsInBeacon << 1);
- // TODO: b/35195516 connect SubscribeServiceIds to legacy HAL once implemented
+ legacy_request->config_subscribe_sid_beacon = 1;
+ if (hidl_request.configParams.numberOfSubscribeServiceIdsInBeacon > 127) {
+ LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: numberOfSubscribeServiceIdsInBeacon > 127";
+ return false;
+ }
+ legacy_request->subscribe_sid_beacon_val =
+ (hidl_request.configParams.includeSubscribeServiceIdsInBeacon ? 0x1 : 0x0)
+ | (hidl_request.configParams.numberOfSubscribeServiceIdsInBeacon << 1);
legacy_request->config_rssi_window_size = 1;
legacy_request->rssi_window_size_val = hidl_request.configParams.rssiWindowSize;
legacy_request->config_disc_mac_addr_randomization = 1;
@@ -1100,7 +1125,7 @@
return false;
}
if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: passphrase_len too large";
return false;
}
@@ -1216,7 +1241,7 @@
return false;
}
if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: passphrase_len too large";
return false;
}
@@ -1321,7 +1346,14 @@
}
legacy_request->sid_beacon = (hidl_request.includePublishServiceIdsInBeacon ? 0x1 : 0x0)
| (hidl_request.numberOfPublishServiceIdsInBeacon << 1);
- // TODO: b/35195516 connect SubscribeServiceIds to legacy HAL once implemented
+ legacy_request->config_subscribe_sid_beacon = 1;
+ if (hidl_request.numberOfSubscribeServiceIdsInBeacon > 127) {
+ LOG(ERROR) << "convertHidlNanConfigRequestToLegacy: numberOfSubscribeServiceIdsInBeacon > 127";
+ return false;
+ }
+ legacy_request->subscribe_sid_beacon_val =
+ (hidl_request.includeSubscribeServiceIdsInBeacon ? 0x1 : 0x0)
+ | (hidl_request.numberOfSubscribeServiceIdsInBeacon << 1);
legacy_request->config_rssi_window_size = 1;
legacy_request->rssi_window_size_val = hidl_request.rssiWindowSize;
legacy_request->config_disc_mac_addr_randomization = 1;
@@ -1433,7 +1465,7 @@
return false;
}
if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: passphrase_len too large";
return false;
}
@@ -1497,7 +1529,7 @@
return false;
}
if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: passphrase_len too large";
return false;
}
@@ -1525,8 +1557,8 @@
}
*wifiNanStatus = {};
- wifiNanStatus->status = convertLegacyNanStatusTypeToHidl(legacy_response.status);
- wifiNanStatus->description = legacy_response.nan_error;
+ convertToWifiNanStatus(legacy_response.status, legacy_response.nan_error,
+ sizeof(legacy_response.nan_error), wifiNanStatus);
return true;
}
diff --git a/wifi/1.0/default/hidl_struct_util.h b/wifi/1.0/default/hidl_struct_util.h
index 41e97b3..c04d92f 100644
--- a/wifi/1.0/default/hidl_struct_util.h
+++ b/wifi/1.0/default/hidl_struct_util.h
@@ -94,7 +94,8 @@
std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
// NAN iface conversion methods.
-NanStatusType convertLegacyNanStatusTypeToHidl(legacy_hal::NanStatusType type);
+void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
+ WifiNanStatus* wifiNanStatus);
bool convertHidlNanEnableRequestToLegacy(
const NanEnableRequest& hidl_request,
legacy_hal::NanEnableRequest* legacy_request);
diff --git a/wifi/1.0/default/wifi_nan_iface.cpp b/wifi/1.0/default/wifi_nan_iface.cpp
index 6977fc0..1072015 100644
--- a/wifi/1.0/default/wifi_nan_iface.cpp
+++ b/wifi/1.0/default/wifi_nan_iface.cpp
@@ -217,8 +217,8 @@
return;
}
WifiNanStatus status;
- status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
- status.description = msg.nan_reason;
+ hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
+ &status);
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
if (!callback->eventDisabled(status).isOk()) {
@@ -235,8 +235,8 @@
return;
}
WifiNanStatus status;
- status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
- status.description = msg.nan_reason;
+ hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
+ &status);
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) {
@@ -253,8 +253,8 @@
return;
}
WifiNanStatus status;
- status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
- status.description = msg.nan_reason;
+ hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
+ &status);
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) {
@@ -328,8 +328,8 @@
return;
}
WifiNanStatus status;
- status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
- status.description = msg.nan_reason;
+ hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
+ &status);
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
diff --git a/wifi/Android.bp b/wifi/Android.bp
index d4e0fda..523014f 100644
--- a/wifi/Android.bp
+++ b/wifi/Android.bp
@@ -2,5 +2,7 @@
subdirs = [
"1.0",
"1.0/vts/functional",
+ "offload/1.0",
+ "offload/1.0/vts/functional",
"supplicant/1.0",
]
diff --git a/wifi/offload/1.0/Android.bp b/wifi/offload/1.0/Android.bp
new file mode 100644
index 0000000..63f85a6
--- /dev/null
+++ b/wifi/offload/1.0/Android.bp
@@ -0,0 +1,69 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.wifi.offload@1.0_hal",
+ srcs: [
+ "types.hal",
+ "IOffload.hal",
+ "IOffloadCallback.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.wifi.offload@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi.offload@1.0",
+ srcs: [
+ ":android.hardware.wifi.offload@1.0_hal",
+ ],
+ out: [
+ "android/hardware/wifi/offload/1.0/types.cpp",
+ "android/hardware/wifi/offload/1.0/OffloadAll.cpp",
+ "android/hardware/wifi/offload/1.0/OffloadCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.wifi.offload@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.wifi.offload@1.0",
+ srcs: [
+ ":android.hardware.wifi.offload@1.0_hal",
+ ],
+ out: [
+ "android/hardware/wifi/offload/1.0/types.h",
+ "android/hardware/wifi/offload/1.0/hwtypes.h",
+ "android/hardware/wifi/offload/1.0/IOffload.h",
+ "android/hardware/wifi/offload/1.0/IHwOffload.h",
+ "android/hardware/wifi/offload/1.0/BnHwOffload.h",
+ "android/hardware/wifi/offload/1.0/BpHwOffload.h",
+ "android/hardware/wifi/offload/1.0/BsOffload.h",
+ "android/hardware/wifi/offload/1.0/IOffloadCallback.h",
+ "android/hardware/wifi/offload/1.0/IHwOffloadCallback.h",
+ "android/hardware/wifi/offload/1.0/BnHwOffloadCallback.h",
+ "android/hardware/wifi/offload/1.0/BpHwOffloadCallback.h",
+ "android/hardware/wifi/offload/1.0/BsOffloadCallback.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.wifi.offload@1.0",
+ generated_sources: ["android.hardware.wifi.offload@1.0_genc++"],
+ generated_headers: ["android.hardware.wifi.offload@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.wifi.offload@1.0_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/wifi/offload/1.0/IOffload.hal b/wifi/offload/1.0/IOffload.hal
new file mode 100644
index 0000000..7ad902c
--- /dev/null
+++ b/wifi/offload/1.0/IOffload.hal
@@ -0,0 +1,76 @@
+/*
+ * Copyright 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.wifi.offload@1.0;
+
+import IOffloadCallback;
+
+interface IOffload {
+ /**
+ * Configure the offload module to perform scans and filter results
+ * Scans must not be triggered due to configuration of the module.
+ *
+ * @param ScanParam paramters for scanning
+ * @param ScanFilter settings to filter scan result
+ * @return boolean status indicating success (true) when configuration
+ * is applied or failure (false) for invalid configuration
+ */
+ @entry
+ @callflow(next={"setEventCallback", "subscribeScanResults"})
+ configureScans(ScanParam param, ScanFilter filter);
+
+ /**
+ * Get scan statistics
+ *
+ * @return ScanStats statistics of scans performed
+ */
+ @exit
+ @callflow(next={"subscribeScanResults", "unsubscribeScanResults", "getScanStats"})
+ getScanStats() generates (ScanStats scanStats);
+
+ /**
+ * Subscribe to asynchronous scan events sent by offload module. This enables
+ * offload scans to be performed as per scan parameters, filtering the scan
+ * results based on configured scan filter and delivering the results after
+ * at least delayMs milliseconds from this call. If the client is already
+ * subscribed to the scan results, a call to this API must be a no-op.
+ *
+ * @param delayMs an integer expressing the minimum delay in mS after
+ * subscribing when scan results must be delivered to the client
+ */
+ @callflow(next={"unsubscribeScanResults", "getScanStats"})
+ subscribeScanResults(uint32_t delayMs);
+
+ /**
+ * Unsubscribe to scan events sent by the offload module, hence disabling scans.
+ * If the client is already unsubscribed, a call to this API will be a no-op.
+ */
+ @exit
+ @callflow(next={"*"})
+ unsubscribeScanResults();
+
+ /**
+ * Setup the HIDL interface for reporting asynchronous scan events. A maximum
+ * of one callback interface is supported. Only one callback must be registered
+ * at any given time. If two consecutive calls are made with different callback
+ * interface objects, the latest one must be used to deliver events to client.
+ *
+ * @param cb An instance of the |IOffloadCallback| HIDL interface object
+ */
+ @entry
+ @callflow(next={"subscribeScanStats", "configureScans"})
+ setEventCallback(IOffloadCallback cb);
+};
diff --git a/wifi/offload/1.0/IOffloadCallback.hal b/wifi/offload/1.0/IOffloadCallback.hal
new file mode 100644
index 0000000..4888125
--- /dev/null
+++ b/wifi/offload/1.0/IOffloadCallback.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright 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.wifi.offload@1.0;
+
+interface IOffloadCallback {
+ /**
+ * Interface for the Offload HAL to return scan events to the client
+ *
+ * @param scanResult a vector of scan result objects
+ */
+ oneway onScanResult(vec<ScanResult> scanResult);
+ /**
+ * Interface for the Offload HAL to inform the client of error conditions
+ * see OffloadStatus for the error conditions to be reported
+ *
+ * @param status OffloadStatus
+ */
+ oneway onError(OffloadStatus status);
+};
diff --git a/wifi/offload/1.0/types.hal b/wifi/offload/1.0/types.hal
new file mode 100644
index 0000000..38d5eda
--- /dev/null
+++ b/wifi/offload/1.0/types.hal
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.wifi.offload@1.0;
+
+/**
+ * Defines a bitmap of security modes
+ */
+enum SecurityMode : uint8_t {
+ OPEN = 0x1 << 1,
+ WEP = 0x1 << 2,
+ PSK = 0x1 << 3,
+ EAP = 0x1 << 4,
+};
+
+/**
+ * SSID of the Access Point, maximum 32 characters
+ */
+typedef vec<uint8_t> Ssid;
+
+/**
+ * Preferred network information
+ * SSID and associated security mode(s)
+ */
+struct NetworkInfo {
+ Ssid ssid;
+ /* SecurityMode flags that are associated with this SSID
+ * More than one security mode can be supported, see SecurityMode */
+ bitfield<SecurityMode> flags;
+};
+
+/**
+ * This is a bit mask describing the capabilities of a BSS.
+ * See IEEE Std 802.11: 8.4.1.4
+ */
+enum Capability : uint16_t {
+ ESS = 1 << 0,
+ IBSS = 1 << 1,
+ CF_POLLABLE = 1 << 2,
+ CF_PLL_REQ = 1 << 3,
+ PRIVACY = 1 << 4,
+ SHORT_PREAMBLE = 1 << 5,
+ PBCC = 1 << 6,
+ CHANNEL_AGILITY = 1 << 7,
+ SPECTURM_MGMT = 1 << 8,
+ QOS = 1 << 9,
+ SHORT_SLOT_TIME = 1 << 10,
+ APSD = 1 << 11,
+ RADIO_MEASUREMENT = 1 << 12,
+ DSSS_OFDM = 1 << 13,
+ DELAYED_BLOCK_ACK = 1 << 14,
+ IMMEDIATE_BLOCK_ACK = 1 << 15,
+};
+
+/**
+ * Scan Results returned by the offload Hal
+ */
+struct ScanResult {
+ /* Information about this BSS
+ * SSID and security modes supported */
+ NetworkInfo networkInfo;
+ /* BSSID of the BSS */
+ uint8_t[6] bssid;
+ /* Can have multiple bits set, see Capability */
+ bitfield<Capability> capability;
+ /* Frequency scanned, in mHz */
+ uint32_t frequency;
+ /* Signal strength in dBm */
+ int8_t rssi;
+ /* TSF found in beacon/probe response */
+ uint64_t tsf;
+};
+
+
+/**
+ * Parameters for performing offload scans
+ */
+struct ScanParam {
+ /* Specify a list of SSIDs to scan, an empty list implies no preferred
+ * networks to scan */
+ vec<Ssid> ssidList;
+ /* Frequencies to scan, in mHz, an empty frequency list implies a full scan */
+ vec<uint32_t> frequencyList;
+ /* Periodicity of the scans to be performed by the offload module
+ * A value of zero indicates disable periodic scans. For this revision,
+ * where offload module is performing scans in disconnected mode, this value
+ * should not be zero. In future versions, periodic scans can be eliminated */
+ uint32_t disconnectedModeScanIntervalMs;
+};
+
+/**
+ * Instruction on how to filter the scan result before performing network
+ * selection and waking up the AP to connect
+ */
+struct ScanFilter {
+ /* Preferred network List of SSIDs and their security mode of interest
+ * The filter will drop the remaining scan results in the scan event.
+ * An empty list implies no filtering of scan result based on SSID and
+ * security mode. */
+ vec<NetworkInfo> preferredNetworkInfoList;
+ /* Minimum qualifying RSSI to be considered for network selection (dBm) */
+ int8_t rssiThreshold;
+};
+
+struct ScanRecord {
+ /* Amount of time spent scanning */
+ uint64_t durationMs;
+ /* Number of channels scanned */
+ uint32_t numChannelsScanned;
+ /* Number of entries aggregated into this record */
+ uint32_t numEntriesAggregated;
+};
+
+/**
+ * Enumerates the type of log that is recorded
+ */
+enum RecordName : uint32_t {
+ CMD_BASE = 0x00001000,
+ /* Record name corresponding to initialization */
+ CMD_INT = CMD_BASE + 0,
+ /* Record name corresponding to configureScans() API */
+ CMD_CONFIG_SCANS = CMD_BASE + 1,
+ /* Record name corresponding to subscribeScanResults() API */
+ CMD_SUBSCRIBE_SCAN_RESULTS = CMD_BASE + 2,
+ /* Record name corresponding to unsubscribeScanResults() API */
+ CMD_UNSUBSCRIBE_SCAN_RESULTS = CMD_BASE + 3,
+ /* Record name corresponding to getScanStats() API */
+ CMD_GET_SCAN_STATS = CMD_BASE + 4,
+ /* Record name corresponding to a reset*/
+ CMD_RESET = CMD_BASE + 5,
+ /* Add new commands here */
+ EVENT_RECVD_BASE = 0x00002000,
+ /* Record name corresponding to scan monitor event*/
+ EVENT_RECVD_SCAN_RESULT_ASYNC = EVENT_RECVD_BASE + 0,
+ /* Record name corresponding to scan response event */
+ EVENT_RECVD_SCAN_RESULT = EVENT_RECVD_BASE + 1,
+ /* Add new events received here */
+ EVENT_SENT_BASE = 0x00003000,
+ /* Record name corresponding to scan event sent */
+ EVENT_SENT_SCAN_RESULT = EVENT_SENT_BASE + 0,
+ /* Record name corresponding to abort event sent */
+ EVENT_SENT_ABORT = EVENT_SENT_BASE + 1,
+ /* Record name corresponding to error event sent */
+ EVENT_SENT_ERROR = EVENT_SENT_BASE + 2,
+ /* Add new events sent here */
+ REQ_BASE = 0x00004000,
+ /* Record name corresponding to scan request sent*/
+ REQ_SCAN = REQ_BASE + 0,
+ /* Add new requests here */
+};
+
+/**
+ * Defines the structure of each log record
+ */
+struct LogRecord {
+ /* Indicates the log recorded */
+ RecordName recordName;
+ /* Platform reference time in milliseconds when the log is recorded */
+ uint64_t logTimeMs;
+};
+
+/**
+ * Defines the scan statistics to be returned to the framework
+ */
+struct ScanStats {
+ /* Incremented everytime a new scan is requested */
+ uint32_t numScansRequestedByWifi;
+ /* Incremented everytime the scan is serviced by performing a scan*/
+ uint32_t numScansServicedByWifi;
+ /* Incremented everytime the scan is serviced by the scan cache */
+ uint32_t numScansServicedbyCache;
+ /* The last (CHRE reference) time this data structure is updated */
+ uint64_t lastUpdated;
+ /* The last (CHRE reference) time this data structure is read */
+ uint64_t lastRead;
+ /* The total time when the Offload module could be performing scans (T2 - T1)
+ * T1 - time when the framework subscribes for scan result (includes delayMs)
+ * T2 - min (time when the framework unsubscribes for scan result,
+ * currentTime) */
+ uint64_t subscriptionDurationMs;
+ /* Histograms of the channels scanned, 802.11 and with an 8 bit
+ * representation, only 256 channels are available */
+ uint8_t[256] histogramChannelsScanned;
+ /* Scan Record for this subscribe duration */
+ vec<ScanRecord> scanRecord;
+ /* Vector of the logRecord entries */
+ vec<LogRecord> logRecord;
+};
+
+/**
+ * Defines a list of return codes to indicate status of Offload HAL
+ */
+enum OffloadStatus : uint32_t {
+ /* No error */
+ OFFLOAD_STATUS_OK,
+ /* No Connection to underlying implementation */
+ OFFLOAD_STATUS_NO_CONNECTION,
+ /* Operation timeout */
+ OFFLOAD_STATUS_TIMEOUT,
+ /* Other errors */
+ OFFLOAD_STATUS_ERROR
+};
+
+
+
+
+
diff --git a/wifi/offload/1.0/vts/functional/Android.bp b/wifi/offload/1.0/vts/functional/Android.bp
new file mode 100644
index 0000000..f907a89
--- /dev/null
+++ b/wifi/offload/1.0/vts/functional/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+ name: "VtsHalWifiOffloadV1_0TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalWifiOffloadV1_0TargetTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.wifi.offload@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
diff --git a/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp b/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp
new file mode 100644
index 0000000..3020542
--- /dev/null
+++ b/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp
@@ -0,0 +1,198 @@
+/*
+ * 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 "wifi_offload_hidl_hal_test"
+
+#include <android-base/logging.h>
+#include <android/hardware/wifi/offload/1.0/IOffload.h>
+#include <android/hardware/wifi/offload/1.0/IOffloadCallback.h>
+#include <android/hardware/wifi/offload/1.0/types.h>
+
+#include <VtsHalHidlTargetCallbackBase.h>
+#include <VtsHalHidlTargetTestBase.h>
+
+#include <vector>
+
+using ::android::hardware::wifi::offload::V1_0::IOffload;
+using ::android::hardware::wifi::offload::V1_0::IOffloadCallback;
+using ::android::hardware::wifi::offload::V1_0::ScanResult;
+using ::android::hardware::wifi::offload::V1_0::ScanParam;
+using ::android::hardware::wifi::offload::V1_0::ScanFilter;
+using ::android::hardware::wifi::offload::V1_0::ScanStats;
+using ::android::hardware::wifi::offload::V1_0::OffloadStatus;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::sp;
+
+constexpr char kOffloadCallbackSendScanResult[] = "onScanResult";
+constexpr char kOffloadCallbackSendError[] = "onError";
+
+namespace {
+const uint8_t kSsid[] = {'G', 'o', 'o', 'g', 'l', 'e'};
+const uint8_t kBssid[6] = {0x12, 0xef, 0xa1, 0x2c, 0x97, 0x8b};
+const int16_t kRssi = -60;
+const uint32_t kFrequency = 2412;
+const uint8_t kBssidSize = 6;
+const uint64_t kTsf = 0;
+const uint16_t kCapability = 0;
+const uint8_t kNetworkFlags = 0;
+}
+
+class OffloadCallbackArgs {
+ public:
+ hidl_vec<ScanResult> scan_results_;
+ OffloadStatus error_code_;
+};
+
+// The main test class for WifiOffload HIDL HAL.
+class WifiOffloadHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ wifi_offload_ =
+ ::testing::VtsHalHidlTargetTestBase::getService<IOffload>();
+ ASSERT_NE(wifi_offload_, nullptr);
+
+ wifi_offload_cb_ = new OffloadCallback();
+ ASSERT_NE(wifi_offload_cb_, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ /* Callback class for Offload HAL. */
+ class OffloadCallback
+ : public ::testing::VtsHalHidlTargetCallbackBase<OffloadCallbackArgs>,
+ public IOffloadCallback {
+ public:
+ OffloadCallback(){};
+
+ virtual ~OffloadCallback() = default;
+
+ Return<void> onScanResult(
+ const hidl_vec<ScanResult>& scan_result) override {
+ OffloadCallbackArgs args;
+ args.scan_results_ = scan_result;
+ NotifyFromCallback(kOffloadCallbackSendScanResult, args);
+ return Void();
+ };
+
+ Return<void> onError(OffloadStatus status) {
+ OffloadCallbackArgs args;
+ args.error_code_ = status;
+ NotifyFromCallback(kOffloadCallbackSendError, args);
+ return Void();
+ }
+ };
+
+ sp<IOffload> wifi_offload_;
+ sp<OffloadCallback> wifi_offload_cb_;
+};
+
+/*
+ * Verify that setEventCallback method returns without errors
+ */
+TEST_F(WifiOffloadHidlTest, setEventCallback) {
+ auto returnObject = wifi_offload_->setEventCallback(wifi_offload_cb_);
+ ASSERT_EQ(returnObject.isOk(), true);
+}
+
+/*
+ * Verify that subscribeScanResults method returns without errors
+ */
+TEST_F(WifiOffloadHidlTest, subscribeScanResults) {
+ auto returnObject = wifi_offload_->subscribeScanResults(0);
+ ASSERT_EQ(returnObject.isOk(), true);
+}
+
+/*
+ * Verify that unsubscribeScanResults method returns without errors
+ */
+TEST_F(WifiOffloadHidlTest, unsubscribeScanResults) {
+ auto returnObject = wifi_offload_->unsubscribeScanResults();
+ ASSERT_EQ(returnObject.isOk(), true);
+}
+
+/*
+ * Verify that configureScans method returns without errors
+ */
+TEST_F(WifiOffloadHidlTest, configureScans) {
+ ScanParam* pScanParam = new ScanParam();
+ ScanFilter* pScanFilter = new ScanFilter();
+ auto returnObject =
+ wifi_offload_->configureScans(*pScanParam, *pScanFilter);
+ ASSERT_EQ(returnObject.isOk(), true);
+}
+
+/*
+ * Verify that getScanStats returns without any errors
+ */
+TEST_F(WifiOffloadHidlTest, getScanStats) {
+ ScanStats* pScanStats = new ScanStats();
+ const auto& returnObject =
+ wifi_offload_->getScanStats([pScanStats](ScanStats scanStats) -> void {
+ *pScanStats = std::move(scanStats);
+ });
+ ASSERT_EQ(returnObject.isOk(), true);
+}
+
+/*
+ * Verify that onScanResult callback is invoked
+ */
+TEST_F(WifiOffloadHidlTest, getScanResults) {
+ wifi_offload_->setEventCallback(wifi_offload_cb_);
+ std::vector<ScanResult> scan_results;
+ std::vector<uint8_t> ssid(kSsid, kSsid + sizeof(kSsid));
+ ScanResult scan_result;
+ scan_result.tsf = kTsf;
+ scan_result.rssi = kRssi;
+ scan_result.frequency = kFrequency;
+ scan_result.capability = kCapability;
+ memcpy(&scan_result.bssid[0], &kBssid[0], kBssidSize);
+ scan_result.networkInfo.ssid = ssid;
+ scan_result.networkInfo.flags = kNetworkFlags;
+ scan_results.push_back(scan_result);
+ wifi_offload_cb_->onScanResult(scan_results);
+ auto res =
+ wifi_offload_cb_->WaitForCallback(kOffloadCallbackSendScanResult);
+ ASSERT_EQ(res.no_timeout, true);
+}
+
+/*
+ * Verify that onError callback is invoked
+ */
+TEST_F(WifiOffloadHidlTest, getError) {
+ wifi_offload_->setEventCallback(wifi_offload_cb_);
+ wifi_offload_cb_->onError(OffloadStatus::OFFLOAD_STATUS_ERROR);
+ auto res = wifi_offload_cb_->WaitForCallback(kOffloadCallbackSendError);
+ ASSERT_EQ(res.no_timeout, true);
+}
+
+// A class for test environment setup
+class WifiOffloadHalHidlEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+};
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(new WifiOffloadHalHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
+
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+
+ return status;
+}
diff --git a/wifi/supplicant/1.0/vts/functional/Android.mk b/wifi/supplicant/1.0/vts/functional/Android.mk
index cfcd4f8..d87d7ef 100644
--- a/wifi/supplicant/1.0/vts/functional/Android.mk
+++ b/wifi/supplicant/1.0/vts/functional/Android.mk
@@ -34,7 +34,8 @@
liblog \
libutils \
libwifi-hal \
- libwifi-system
+ libwifi-system \
+ libwifi-system-iface
LOCAL_STATIC_LIBRARIES := \
libgmock \
VtsHalHidlTargetTestBase