Merge "Adding a custom property to the default VHAL impl" into oc-dev
diff --git a/audio/2.0/Android.bp b/audio/2.0/Android.bp
index f7975ec..9aa9e2c 100644
--- a/audio/2.0/Android.bp
+++ b/audio/2.0/Android.bp
@@ -86,6 +86,7 @@
generated_sources: ["android.hardware.audio@2.0_genc++"],
generated_headers: ["android.hardware.audio@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.audio@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/audio/2.0/Android.mk b/audio/2.0/Android.mk
index e989364..d5e840f 100644
--- a/audio/2.0/Android.mk
+++ b/audio/2.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.audio@2.0-java-constants
+LOCAL_MODULE := android.hardware.audio-V2.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/audio/2.0/default/service.cpp b/audio/2.0/default/service.cpp
index f3a858a..7f28d7d 100644
--- a/audio/2.0/default/service.cpp
+++ b/audio/2.0/default/service.cpp
@@ -50,7 +50,7 @@
status = registerPassthroughServiceImplementation<IEffectsFactory>();
LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status);
// Soundtrigger and FM radio might be not present.
- status = registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
+ status = registerPassthroughServiceImplementation<ISoundTriggerHw>();
ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status);
if (useBroadcastRadioFutureFeatures) {
status = registerPassthroughServiceImplementation<
diff --git a/audio/Android.bp b/audio/Android.bp
index 8a1e892..c3c2be1 100644
--- a/audio/Android.bp
+++ b/audio/Android.bp
@@ -3,6 +3,7 @@
"2.0",
"2.0/vts/functional",
"common/2.0",
+ "common/2.0/default",
"effect/2.0",
"effect/2.0/vts/functional",
]
diff --git a/audio/common/2.0/Android.bp b/audio/common/2.0/Android.bp
index ad599ed..fa80d20 100644
--- a/audio/common/2.0/Android.bp
+++ b/audio/common/2.0/Android.bp
@@ -37,6 +37,7 @@
generated_sources: ["android.hardware.audio.common@2.0_genc++"],
generated_headers: ["android.hardware.audio.common@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.audio.common@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/audio/common/2.0/Android.mk b/audio/common/2.0/Android.mk
index 7d62779..a78a395 100644
--- a/audio/common/2.0/Android.mk
+++ b/audio/common/2.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.audio.common@2.0-java-constants
+LOCAL_MODULE := android.hardware.audio.common-V2.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp
new file mode 100644
index 0000000..e39a908
--- /dev/null
+++ b/audio/common/2.0/default/Android.bp
@@ -0,0 +1,32 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_library_shared {
+ name: "android.hardware.audio.common@2.0-util",
+ vendor_available: true,
+ srcs: [
+ "EffectMap.cpp",
+ "HidlUtils.cpp",
+ ],
+
+ export_include_dirs: ["."],
+
+ shared_libs: [
+ "libutils",
+ "libhidlbase",
+ "android.hardware.audio.common@2.0",
+ ],
+
+}
diff --git a/audio/common/2.0/default/Android.mk b/audio/common/2.0/default/Android.mk
deleted file mode 100644
index 8e2fed4..0000000
--- a/audio/common/2.0/default/Android.mk
+++ /dev/null
@@ -1,32 +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 $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.audio.common@2.0-util
-LOCAL_SRC_FILES := \
- EffectMap.cpp \
- HidlUtils.cpp \
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libhidlbase \
- android.hardware.audio.common@2.0 \
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/effect/2.0/Android.bp b/audio/effect/2.0/Android.bp
index 937a4e6..fea2a33 100644
--- a/audio/effect/2.0/Android.bp
+++ b/audio/effect/2.0/Android.bp
@@ -135,6 +135,7 @@
generated_sources: ["android.hardware.audio.effect@2.0_genc++"],
generated_headers: ["android.hardware.audio.effect@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.audio.effect@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/audio/effect/2.0/Android.mk b/audio/effect/2.0/Android.mk
index d71255e..a426763 100644
--- a/audio/effect/2.0/Android.mk
+++ b/audio/effect/2.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.audio.effect@2.0-java-constants
+LOCAL_MODULE := android.hardware.audio.effect-V2.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/automotive/evs/1.0/Android.bp b/automotive/evs/1.0/Android.bp
index ec56c8f..a9f094f 100644
--- a/automotive/evs/1.0/Android.bp
+++ b/automotive/evs/1.0/Android.bp
@@ -65,6 +65,7 @@
generated_sources: ["android.hardware.automotive.evs@1.0_genc++"],
generated_headers: ["android.hardware.automotive.evs@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.automotive.evs@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/automotive/evs/1.0/vts/functional/FrameHandler.cpp b/automotive/evs/1.0/vts/functional/FrameHandler.cpp
index 01d9a0e..58c2f26 100644
--- a/automotive/evs/1.0/vts/functional/FrameHandler.cpp
+++ b/automotive/evs/1.0/vts/functional/FrameHandler.cpp
@@ -23,7 +23,6 @@
#include <android/log.h>
#include <cutils/native_handle.h>
-#include <ui/GraphicBufferMapper.h>
#include <ui/GraphicBuffer.h>
#include <algorithm> // std::min
@@ -135,11 +134,7 @@
// Local flag we use to keep track of when the stream is stopping
bool timeToStop = false;
- // TODO: Why do we get a gralloc crash if we don't clone the buffer here?
- BufferDesc buffer(bufferArg);
- ALOGD("Clone the received frame as %p", buffer.memHandle.getNativeHandle());
-
- if (buffer.memHandle.getNativeHandle() == nullptr) {
+ if (bufferArg.memHandle.getNativeHandle() == nullptr) {
// Signal that the last frame has been received and the stream is stopped
timeToStop = true;
} else {
@@ -157,13 +152,8 @@
printf("Didn't get target buffer - frame lost\n");
ALOGE("Didn't get requested output buffer -- skipping this frame.");
} else {
- // In order for the handles passed through HIDL and stored in the BufferDesc to
- // be lockable, we must register them with GraphicBufferMapper
- registerBufferHelper(tgtBuffer);
- registerBufferHelper(buffer);
-
// Copy the contents of the of buffer.memHandle into tgtBuffer
- copyBufferContents(tgtBuffer, buffer);
+ copyBufferContents(tgtBuffer, bufferArg);
// Send the target buffer back for display
Return <EvsResult> result = mDisplay->returnTargetBufferForDisplay(tgtBuffer);
@@ -183,10 +173,6 @@
mFramesDisplayed++;
mLock.unlock();
}
-
- // Now tell GraphicBufferMapper we won't be using these handles anymore
- unregisterBufferHelper(tgtBuffer);
- unregisterBufferHelper(buffer);
}
}
@@ -233,24 +219,22 @@
const unsigned height = std::min(tgtBuffer.height,
srcBuffer.height);
- android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get();
-
+ sp<android::GraphicBuffer> tgt = new android::GraphicBuffer(
+ tgtBuffer.memHandle, android::GraphicBuffer::CLONE_HANDLE,
+ tgtBuffer.width, tgtBuffer.height, tgtBuffer.format, 1, tgtBuffer.usage,
+ tgtBuffer.stride);
+ sp<android::GraphicBuffer> src = new android::GraphicBuffer(
+ srcBuffer.memHandle, android::GraphicBuffer::CLONE_HANDLE,
+ srcBuffer.width, srcBuffer.height, srcBuffer.format, 1, srcBuffer.usage,
+ srcBuffer.stride);
// Lock our source buffer for reading
unsigned char* srcPixels = nullptr;
- mapper.registerBuffer(srcBuffer.memHandle);
- mapper.lock(srcBuffer.memHandle,
- GRALLOC_USAGE_SW_READ_OFTEN,
- android::Rect(width, height),
- (void **) &srcPixels);
+ src->lock(GRALLOC_USAGE_SW_READ_OFTEN, (void**)&srcPixels);
// Lock our target buffer for writing
unsigned char* tgtPixels = nullptr;
- mapper.registerBuffer(tgtBuffer.memHandle);
- mapper.lock(tgtBuffer.memHandle,
- GRALLOC_USAGE_SW_WRITE_OFTEN,
- android::Rect(width, height),
- (void **) &tgtPixels);
+ tgt->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)&tgtPixels);
if (srcPixels && tgtPixels) {
for (unsigned row = 0; row < height; row++) {
@@ -267,45 +251,11 @@
}
if (srcPixels) {
- mapper.unlock(srcBuffer.memHandle);
+ src->unlock();
}
if (tgtPixels) {
- mapper.unlock(tgtBuffer.memHandle);
+ tgt->unlock();
}
- mapper.unregisterBuffer(srcBuffer.memHandle);
- mapper.unregisterBuffer(tgtBuffer.memHandle);
return success;
}
-
-
-void FrameHandler::registerBufferHelper(const BufferDesc& buffer)
-{
- // In order for the handles passed through HIDL and stored in the BufferDesc to
- // be lockable, we must register them with GraphicBufferMapper.
- // If the device upon which we're running supports gralloc1, we could just call
- // registerBuffer directly with the handle. But that call is broken for gralloc0 devices
- // (which we care about, at least for now). As a result, we have to synthesize a GraphicBuffer
- // object around the buffer handle in order to make a call to the overloaded alternate
- // version of the registerBuffer call that does happen to work on gralloc0 devices.
-#if REGISTER_BUFFER_ALWAYS_WORKS
- android::GraphicBufferMapper::get().registerBuffer(buffer.memHandle);
-#else
- android::sp<android::GraphicBuffer> pGfxBuff = new android::GraphicBuffer(
- buffer.width, buffer.height, buffer.format,
- 1, /* we always use exactly one layer */
- buffer.usage, buffer.stride,
- const_cast<native_handle_t*>(buffer.memHandle.getNativeHandle()),
- false /* GraphicBuffer should not try to free the handle */
- );
-
- android::GraphicBufferMapper::get().registerBuffer(pGfxBuff.get());
-#endif
-}
-
-
-void FrameHandler::unregisterBufferHelper(const BufferDesc& buffer)
-{
- // Now tell GraphicBufferMapper we won't be using these handles anymore
- android::GraphicBufferMapper::get().unregisterBuffer(buffer.memHandle);
-}
diff --git a/automotive/evs/1.0/vts/functional/FrameHandler.h b/automotive/evs/1.0/vts/functional/FrameHandler.h
index d5c3f6b..17a3980 100644
--- a/automotive/evs/1.0/vts/functional/FrameHandler.h
+++ b/automotive/evs/1.0/vts/functional/FrameHandler.h
@@ -68,8 +68,6 @@
// Local implementation details
bool copyBufferContents(const BufferDesc& tgtBuffer, const BufferDesc& srcBuffer);
- void registerBufferHelper(const BufferDesc& buffer);
- void unregisterBufferHelper(const BufferDesc& buffer);
// Values initialized as startup
android::sp <IEvsCamera> mCamera;
diff --git a/automotive/vehicle/2.0/Android.bp b/automotive/vehicle/2.0/Android.bp
index 6957bf8..b6fde6e 100644
--- a/automotive/vehicle/2.0/Android.bp
+++ b/automotive/vehicle/2.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.automotive.vehicle@2.0_genc++"],
generated_headers: ["android.hardware.automotive.vehicle@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.automotive.vehicle@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/automotive/vehicle/2.0/Android.mk b/automotive/vehicle/2.0/Android.mk
index d093017..eb05f35 100644
--- a/automotive/vehicle/2.0/Android.mk
+++ b/automotive/vehicle/2.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.automotive.vehicle@2.0-java
+LOCAL_MODULE := android.hardware.automotive.vehicle-V2.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -977,7 +977,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.automotive.vehicle@2.0-java-static
+LOCAL_MODULE := android.hardware.automotive.vehicle-V2.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -985,7 +985,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/automotive/vehicle/2.1/Android.bp b/automotive/vehicle/2.1/Android.bp
index 825ec1f..536950a 100644
--- a/automotive/vehicle/2.1/Android.bp
+++ b/automotive/vehicle/2.1/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.automotive.vehicle@2.1_genc++"],
generated_headers: ["android.hardware.automotive.vehicle@2.1_genc++_headers"],
export_generated_headers: ["android.hardware.automotive.vehicle@2.1_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/automotive/vehicle/2.1/Android.mk b/automotive/vehicle/2.1/Android.mk
index f030af08..693fe2d 100644
--- a/automotive/vehicle/2.1/Android.mk
+++ b/automotive/vehicle/2.1/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.automotive.vehicle@2.1-java
+LOCAL_MODULE := android.hardware.automotive.vehicle-V2.1-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,8 +13,8 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hardware.automotive.vehicle@2.0-java \
- android.hidl.base@1.0-java \
+ android.hardware.automotive.vehicle-V2.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -269,7 +269,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.automotive.vehicle@2.1-java-static
+LOCAL_MODULE := android.hardware.automotive.vehicle-V2.1-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -277,8 +277,8 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hardware.automotive.vehicle@2.0-java-static \
- android.hidl.base@1.0-java-static \
+ android.hardware.automotive.vehicle-V2.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/biometrics/fingerprint/2.1/Android.bp b/biometrics/fingerprint/2.1/Android.bp
index e928f9b..9a6e9d8 100644
--- a/biometrics/fingerprint/2.1/Android.bp
+++ b/biometrics/fingerprint/2.1/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.biometrics.fingerprint@2.1_genc++"],
generated_headers: ["android.hardware.biometrics.fingerprint@2.1_genc++_headers"],
export_generated_headers: ["android.hardware.biometrics.fingerprint@2.1_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/biometrics/fingerprint/2.1/Android.mk b/biometrics/fingerprint/2.1/Android.mk
index 567b38a..2f32371 100644
--- a/biometrics/fingerprint/2.1/Android.mk
+++ b/biometrics/fingerprint/2.1/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-java
+LOCAL_MODULE := android.hardware.biometrics.fingerprint-V2.1-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -236,7 +236,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-java-static
+LOCAL_MODULE := android.hardware.biometrics.fingerprint-V2.1-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -244,7 +244,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/biometrics/fingerprint/2.1/default/Android.mk b/biometrics/fingerprint/2.1/default/Android.mk
index 3d06397..f02db94 100644
--- a/biometrics/fingerprint/2.1/default/Android.mk
+++ b/biometrics/fingerprint/2.1/default/Android.mk
@@ -10,12 +10,11 @@
service.cpp \
LOCAL_SHARED_LIBRARIES := \
- libbinder \
+ libcutils \
liblog \
libhidlbase \
libhidltransport \
libhardware \
- libkeystore_binder \
libutils \
android.hardware.biometrics.fingerprint@2.1 \
diff --git a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp
index 4f5aaf9..16197d7 100644
--- a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp
+++ b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp
@@ -16,8 +16,6 @@
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service"
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service"
-// For communication with Keystore binder interface
-#include <keystore/keystore.h> // for error codes
#include <hardware/hw_auth_token.h>
#include <hardware/hardware.h>
@@ -25,6 +23,7 @@
#include "BiometricsFingerprint.h"
#include <inttypes.h>
+#include <unistd.h>
namespace android {
namespace hardware {
@@ -189,7 +188,12 @@
const hidl_string& storePath) {
if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
ALOGE("Bad path length: %zd", storePath.size());
+ return RequestStatus::SYS_EINVAL;
}
+ if (access(storePath.c_str(), W_OK)) {
+ return RequestStatus::SYS_EINVAL;
+ }
+
return ErrorFilter(mDevice->set_active_group(mDevice, gid,
storePath.c_str()));
}
diff --git a/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp b/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
index d3f6612..29776b4 100644
--- a/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
+++ b/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
@@ -43,7 +43,7 @@
static const uint32_t kTimeout = 3;
static const std::chrono::seconds kTimeoutInSeconds = std::chrono::seconds(kTimeout);
static const uint32_t kGroupId = 99;
-static const std::string kTmpDir = "/data/local/tmp/";
+static const std::string kTmpDir = "/data/system/";
static const uint32_t kIterations = 1000;
// Wait for a callback to occur (signaled by the given future) up to the
@@ -186,6 +186,8 @@
ASSERT_FALSE(mService == nullptr);
// Create an active group
+ // FP service can only write to /data/system due to
+ // SELinux Policy and Linux Dir Permissions
Return<RequestStatus> res = mService->setActiveGroup(kGroupId, kTmpDir);
ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
}
diff --git a/bluetooth/1.0/Android.bp b/bluetooth/1.0/Android.bp
index 75cdcfc..e831069 100644
--- a/bluetooth/1.0/Android.bp
+++ b/bluetooth/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.bluetooth@1.0_genc++"],
generated_headers: ["android.hardware.bluetooth@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.bluetooth@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/bluetooth/1.0/Android.mk b/bluetooth/1.0/Android.mk
index d824d5d..f8cd96e 100644
--- a/bluetooth/1.0/Android.mk
+++ b/bluetooth/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.bluetooth@1.0-java
+LOCAL_MODULE := android.hardware.bluetooth-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -84,7 +84,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.bluetooth@1.0-java-static
+LOCAL_MODULE := android.hardware.bluetooth-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -92,7 +92,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index 292f97c..fec2264 100644
--- a/bluetooth/1.0/default/Android.bp
+++ b/bluetooth/1.0/default/Android.bp
@@ -16,7 +16,7 @@
cc_library_shared {
name: "android.hardware.bluetooth@1.0-impl",
defaults: ["hidl_defaults"],
- proprietary: true,
+ vendor: true,
relative_install_path: "hw",
srcs: [
"bluetooth_hci.cc",
@@ -41,21 +41,20 @@
cc_library_static {
name: "android.hardware.bluetooth-async",
+ vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"async_fd_watcher.cc",
],
export_include_dirs: ["."],
shared_libs: [
- "libbase",
- "libcutils",
"liblog",
- "libutils",
],
}
cc_library_static {
name: "android.hardware.bluetooth-hci",
+ vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"hci_packetizer.cc",
@@ -66,7 +65,6 @@
export_include_dirs: ["."],
shared_libs: [
"libbase",
- "libcutils",
"libhidlbase",
"liblog",
"libutils",
@@ -75,6 +73,7 @@
cc_test {
name: "bluetooth-vendor-interface-unit-tests",
+ vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"test/async_fd_watcher_unittest.cc",
diff --git a/bluetooth/1.0/default/Android.mk b/bluetooth/1.0/default/Android.mk
index 7530925..38294c7 100644
--- a/bluetooth/1.0/default/Android.mk
+++ b/bluetooth/1.0/default/Android.mk
@@ -29,7 +29,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
libhardware \
LOCAL_SHARED_LIBRARIES += \
diff --git a/bluetooth/1.0/default/bluetooth_hci.cc b/bluetooth/1.0/default/bluetooth_hci.cc
index 8eccfc7..e14e3d7 100644
--- a/bluetooth/1.0/default/bluetooth_hci.cc
+++ b/bluetooth/1.0/default/bluetooth_hci.cc
@@ -17,7 +17,7 @@
#define LOG_TAG "android.hardware.bluetooth@1.0-impl"
#include "bluetooth_hci.h"
-#include <utils/Log.h>
+#include <log/log.h>
#include "vendor_interface.h"
diff --git a/bluetooth/1.0/default/hci_protocol.cc b/bluetooth/1.0/default/hci_protocol.cc
index bb1e36b..a208da1 100644
--- a/bluetooth/1.0/default/hci_protocol.cc
+++ b/bluetooth/1.0/default/hci_protocol.cc
@@ -17,10 +17,9 @@
#include "hci_protocol.h"
#define LOG_TAG "android.hardware.bluetooth-hci-hci_protocol"
-#include <android-base/logging.h>
#include <assert.h>
#include <fcntl.h>
-#include <utils/Log.h>
+#include <log/log.h>
namespace android {
namespace hardware {
diff --git a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
index b0c533c..dfc50a3 100644
--- a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
+++ b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
@@ -22,12 +22,12 @@
#include <cstring>
#include <vector>
+#include <log/log.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
-#include <utils/Log.h>
namespace android {
namespace hardware {
diff --git a/bluetooth/1.0/default/test/h4_protocol_unittest.cc b/bluetooth/1.0/default/test/h4_protocol_unittest.cc
index d53aaa9..ad08086 100644
--- a/bluetooth/1.0/default/test/h4_protocol_unittest.cc
+++ b/bluetooth/1.0/default/test/h4_protocol_unittest.cc
@@ -25,10 +25,10 @@
#include <mutex>
#include <vector>
+#include <log/log.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
-#include <utils/Log.h>
namespace android {
namespace hardware {
diff --git a/bluetooth/1.0/default/test/mct_protocol_unittest.cc b/bluetooth/1.0/default/test/mct_protocol_unittest.cc
index 0a6e9eb..d45058e 100644
--- a/bluetooth/1.0/default/test/mct_protocol_unittest.cc
+++ b/bluetooth/1.0/default/test/mct_protocol_unittest.cc
@@ -25,10 +25,10 @@
#include <mutex>
#include <vector>
+#include <log/log.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
-#include <utils/Log.h>
namespace android {
namespace hardware {
diff --git a/bluetooth/1.0/default/test/properties.cc b/bluetooth/1.0/default/test/properties.cc
index ad5c194..6ac4fb4 100644
--- a/bluetooth/1.0/default/test/properties.cc
+++ b/bluetooth/1.0/default/test/properties.cc
@@ -23,7 +23,7 @@
#include <unistd.h>
#include <cutils/properties.h>
-#include <utils/Log.h>
+#include <log/log.h>
static const int MAX_PROPERTIES = 5;
diff --git a/boot/1.0/Android.bp b/boot/1.0/Android.bp
index 498c940..c56499a 100644
--- a/boot/1.0/Android.bp
+++ b/boot/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.boot@1.0_genc++"],
generated_headers: ["android.hardware.boot@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.boot@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/boot/1.0/Android.mk b/boot/1.0/Android.mk
index b188acb..efd5759 100644
--- a/boot/1.0/Android.mk
+++ b/boot/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.boot@1.0-java
+LOCAL_MODULE := android.hardware.boot-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -80,7 +80,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.boot@1.0-java-static
+LOCAL_MODULE := android.hardware.boot-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -88,7 +88,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
index 5f50748..cbed9f7 100644
--- a/broadcastradio/1.0/Android.bp
+++ b/broadcastradio/1.0/Android.bp
@@ -65,6 +65,7 @@
generated_sources: ["android.hardware.broadcastradio@1.0_genc++"],
generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/broadcastradio/1.1/Android.bp b/broadcastradio/1.1/Android.bp
index cc0747a..2c51ca5 100644
--- a/broadcastradio/1.1/Android.bp
+++ b/broadcastradio/1.1/Android.bp
@@ -65,6 +65,7 @@
generated_sources: ["android.hardware.broadcastradio@1.1_genc++"],
generated_headers: ["android.hardware.broadcastradio@1.1_genc++_headers"],
export_generated_headers: ["android.hardware.broadcastradio@1.1_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/camera/common/1.0/Android.bp b/camera/common/1.0/Android.bp
index 80b5e54..76f1cf3 100644
--- a/camera/common/1.0/Android.bp
+++ b/camera/common/1.0/Android.bp
@@ -37,6 +37,7 @@
generated_sources: ["android.hardware.camera.common@1.0_genc++"],
generated_headers: ["android.hardware.camera.common@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.camera.common@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/camera/common/1.0/Android.mk b/camera/common/1.0/Android.mk
index 9e05172..47bfb31 100644
--- a/camera/common/1.0/Android.mk
+++ b/camera/common/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.camera.common@1.0-java
+LOCAL_MODULE := android.hardware.camera.common-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -188,7 +188,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.camera.common@1.0-java-static
+LOCAL_MODULE := android.hardware.camera.common-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/camera/common/1.0/default/Android.bp b/camera/common/1.0/default/Android.bp
index 6437480..10f9fdb 100644
--- a/camera/common/1.0/default/Android.bp
+++ b/camera/common/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_static {
name: "android.hardware.camera.common@1.0-helper",
+ vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"CameraModule.cpp",
diff --git a/camera/device/1.0/Android.bp b/camera/device/1.0/Android.bp
index 44a108c..0b65892 100644
--- a/camera/device/1.0/Android.bp
+++ b/camera/device/1.0/Android.bp
@@ -58,6 +58,7 @@
generated_sources: ["android.hardware.camera.device@1.0_genc++"],
generated_headers: ["android.hardware.camera.device@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.camera.device@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
@@ -66,7 +67,6 @@
"libutils",
"libcutils",
"android.hardware.camera.common@1.0",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
@@ -76,7 +76,6 @@
"libhwbinder",
"libutils",
"android.hardware.camera.common@1.0",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
diff --git a/camera/device/1.0/ICameraDevicePreviewCallback.hal b/camera/device/1.0/ICameraDevicePreviewCallback.hal
index 4c9b517..5421981 100644
--- a/camera/device/1.0/ICameraDevicePreviewCallback.hal
+++ b/camera/device/1.0/ICameraDevicePreviewCallback.hal
@@ -17,7 +17,6 @@
package android.hardware.camera.device@1.0;
import android.hardware.camera.common@1.0::types;
-import android.hardware.graphics.allocator@2.0::types;
import android.hardware.graphics.common@1.0::types;
/**
@@ -89,7 +88,7 @@
*
* @return Status The status code for this operation.
*/
- setUsage(ProducerUsage usage) generates (Status status);
+ setUsage(BufferUsage usage) generates (Status status);
/**
* Set the expected buffering mode for the preview output.
diff --git a/camera/device/1.0/default/CameraDevice.cpp b/camera/device/1.0/default/CameraDevice.cpp
index 6495f30..cb20fec 100644
--- a/camera/device/1.0/default/CameraDevice.cpp
+++ b/camera/device/1.0/default/CameraDevice.cpp
@@ -30,7 +30,7 @@
namespace V1_0 {
namespace implementation {
-using ::android::hardware::graphics::allocator::V2_0::ProducerUsage;
+using ::android::hardware::graphics::common::V1_0::BufferUsage;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
HandleImporter& CameraDevice::sHandleImporter = HandleImporter::getInstance();
@@ -259,7 +259,7 @@
}
object->cleanUpCirculatingBuffers();
- return getStatusT(object->mPreviewCallback->setUsage((ProducerUsage) usage));
+ return getStatusT(object->mPreviewCallback->setUsage((BufferUsage)usage));
}
int CameraDevice::sSetSwapInterval(struct preview_stream_ops *w, int interval) {
diff --git a/camera/device/3.2/Android.bp b/camera/device/3.2/Android.bp
index fd7276f..cbfdcff 100644
--- a/camera/device/3.2/Android.bp
+++ b/camera/device/3.2/Android.bp
@@ -58,6 +58,7 @@
generated_sources: ["android.hardware.camera.device@3.2_genc++"],
generated_headers: ["android.hardware.camera.device@3.2_genc++_headers"],
export_generated_headers: ["android.hardware.camera.device@3.2_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
@@ -66,7 +67,6 @@
"libutils",
"libcutils",
"android.hardware.camera.common@1.0",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
@@ -76,7 +76,6 @@
"libhwbinder",
"libutils",
"android.hardware.camera.common@1.0",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
diff --git a/camera/device/3.2/ICameraDevice.hal b/camera/device/3.2/ICameraDevice.hal
index 6e66bf3..1f523e4 100644
--- a/camera/device/3.2/ICameraDevice.hal
+++ b/camera/device/3.2/ICameraDevice.hal
@@ -167,7 +167,7 @@
* longer available. This interface is now stale, and a new instance
* must be acquired if the device is reconnected. All subsequent
* calls on this interface must return CAMERA_DISCONNECTED.
- * @return cameraDevice The interface to the newly-opened camera session,
+ * @return session The interface to the newly-opened camera session,
* or null if status is not OK.
*/
open(ICameraDeviceCallback callback) generates
diff --git a/camera/device/3.2/ICameraDeviceCallback.hal b/camera/device/3.2/ICameraDeviceCallback.hal
index bf51da2..69715de 100644
--- a/camera/device/3.2/ICameraDeviceCallback.hal
+++ b/camera/device/3.2/ICameraDeviceCallback.hal
@@ -42,7 +42,9 @@
* metadata and low-resolution buffers to be returned in one call, and
* post-processed JPEG buffers in a later call, once it is available. Each
* call must include the frame number of the request it is returning
- * metadata or buffers for.
+ * metadata or buffers for. Only one call to processCaptureResult
+ * may be made at a time by the HAL although the calls may come from
+ * different threads in the HAL.
*
* A component (buffer or metadata) of the complete result may only be
* included in one process_capture_result call. A buffer for each stream,
diff --git a/camera/device/3.2/ICameraDeviceSession.hal b/camera/device/3.2/ICameraDeviceSession.hal
index 731fc76..477a3cc 100644
--- a/camera/device/3.2/ICameraDeviceSession.hal
+++ b/camera/device/3.2/ICameraDeviceSession.hal
@@ -248,6 +248,39 @@
generates (Status status, uint32_t numRequestProcessed);
/**
+ * getCaptureRequestMetadataQueue:
+ *
+ * Retrieves the queue used along with processCaptureRequest. If
+ * client decides to use fast message queue to pass request metadata,
+ * it must:
+ * - Call getCaptureRequestMetadataQueue to retrieve the fast message queue;
+ * - In each of the requests sent in processCaptureRequest, set
+ * fmqSettingsSize field of CaptureRequest to be the size to read from the
+ * fast message queue; leave settings field of CaptureRequest empty.
+ *
+ * @return queue the queue that client writes request metadata to.
+ */
+ getCaptureRequestMetadataQueue() generates (fmq_sync<uint8_t> queue);
+
+ /**
+ * getCaptureResultMetadataQueue:
+ *
+ * Retrieves the queue used along with
+ * ICameraDeviceCallback.processCaptureResult.
+ *
+ * Clients to ICameraDeviceSession must:
+ * - Call getCaptureRequestMetadataQueue to retrieve the fast message queue;
+ * - In implementation of ICameraDeviceCallback, test whether
+ * .fmqResultSize field is zero.
+ * - If .fmqResultSize != 0, read result metadata from the fast message
+ * queue;
+ * - otherwise, read result metadata in CaptureResult.result.
+ *
+ * @return queue the queue that implementation writes result metadata to.
+ */
+ getCaptureResultMetadataQueue() generates (fmq_sync<uint8_t> queue);
+
+ /**
* flush:
*
* Flush all currently in-process captures and all buffers in the pipeline
diff --git a/camera/device/3.2/default/Android.bp b/camera/device/3.2/default/Android.bp
index e0dc5ff..d95f8f4 100644
--- a/camera/device/3.2/default/Android.bp
+++ b/camera/device/3.2/default/Android.bp
@@ -14,10 +14,14 @@
"android.hardware.camera.provider@2.4",
"liblog",
"libhardware",
- "libcamera_metadata"
+ "libcamera_metadata",
+ "libfmq"
],
static_libs: [
"android.hardware.camera.common@1.0-helper"
],
- export_include_dirs: ["."]
+ export_include_dirs: ["."],
+ export_shared_lib_headers: [
+ "libfmq",
+ ]
}
diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp
index 5b3024b..2499b1a 100644
--- a/camera/device/3.2/default/CameraDeviceSession.cpp
+++ b/camera/device/3.2/default/CameraDeviceSession.cpp
@@ -30,6 +30,11 @@
namespace V3_2 {
namespace implementation {
+// Size of request metadata fast message queue. Change to 0 to always use hwbinder buffer.
+static constexpr size_t CAMERA_REQUEST_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */;
+// Size of result metadata fast message queue. Change to 0 to always use hwbinder buffer.
+static constexpr size_t CAMERA_RESULT_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */;
+
HandleImporter& CameraDeviceSession::sHandleImporter = HandleImporter::getInstance();
const int CameraDeviceSession::ResultBatcher::NOT_BATCHED;
@@ -66,6 +71,21 @@
mClosed = true;
return true;
}
+
+ mRequestMetadataQueue = std::make_unique<RequestMetadataQueue>(
+ CAMERA_REQUEST_METADATA_QUEUE_SIZE, false /* non blocking */);
+ if (!mRequestMetadataQueue->isValid()) {
+ ALOGE("%s: invalid request fmq", __FUNCTION__);
+ return true;
+ }
+ mResultMetadataQueue = std::make_shared<RequestMetadataQueue>(
+ CAMERA_RESULT_METADATA_QUEUE_SIZE, false /* non blocking */);
+ if (!mResultMetadataQueue->isValid()) {
+ ALOGE("%s: invalid result fmq", __FUNCTION__);
+ return true;
+ }
+ mResultBatcher.setResultMetadataQueue(mResultMetadataQueue);
+
return false;
}
@@ -220,6 +240,11 @@
mStreamsToBatch = streamsToBatch;
}
+void CameraDeviceSession::ResultBatcher::setResultMetadataQueue(std::shared_ptr<ResultMetadataQueue> q) {
+ Mutex::Autolock _l(mLock);
+ mResultMetadataQueue = q;
+}
+
void CameraDeviceSession::ResultBatcher::registerBatch(
const hidl_vec<CaptureRequest>& requests) {
auto batch = std::make_shared<InflightBatch>();
@@ -339,6 +364,7 @@
results.resize(batchSize);
for (size_t i = 0; i < batchSize; i++) {
results[i].frameNumber = batch->mFirstFrame + i;
+ results[i].fmqResultSize = 0;
results[i].partialResult = 0; // 0 for buffer only results
results[i].inputBuffer.streamId = -1;
results[i].inputBuffer.bufferId = 0;
@@ -355,7 +381,7 @@
}
results[i].outputBuffers = outBufs;
}
- mCallback->processCaptureResult(results);
+ invokeProcessCaptureResultCallback(results, /* tryWriteFmq */false);
freeReleaseFences(results);
for (int streamId : streams) {
InflightBatch::BufferBatch& bb = batch->mBatchBufs[streamId];
@@ -385,6 +411,7 @@
CaptureResult result;
result.frameNumber = p.first;
result.result = std::move(p.second);
+ result.fmqResultSize = 0;
result.inputBuffer.streamId = -1;
result.inputBuffer.bufferId = 0;
result.inputBuffer.buffer = nullptr;
@@ -393,7 +420,9 @@
}
mb.mMds.clear();
}
- mCallback->processCaptureResult(results);
+ hidl_vec<CaptureResult> hResults;
+ hResults.setToExternal(results.data(), results.size());
+ invokeProcessCaptureResultCallback(hResults, /* tryWriteFmq */true);
batch->mPartialResultProgress = lastPartialResultIdx;
for (uint32_t partialIdx : toBeRemovedIdxes) {
batch->mResultMds.erase(partialIdx);
@@ -466,9 +495,37 @@
}
}
+void CameraDeviceSession::ResultBatcher::invokeProcessCaptureResultCallback(
+ hidl_vec<CaptureResult> &results, bool tryWriteFmq) {
+ if (mProcessCaptureResultLock.tryLock() != OK) {
+ ALOGW("%s: previous call is not finished! waiting 1s...",
+ __FUNCTION__);
+ if (mProcessCaptureResultLock.timedLock(1000000000 /* 1s */) != OK) {
+ ALOGE("%s: cannot acquire lock in 1s, cannot proceed",
+ __FUNCTION__);
+ return;
+ }
+ }
+ if (tryWriteFmq && mResultMetadataQueue->availableToWrite() > 0) {
+ for (CaptureResult &result : results) {
+ if (result.result.size() > 0) {
+ if (mResultMetadataQueue->write(result.result.data(), result.result.size())) {
+ result.fmqResultSize = result.result.size();
+ result.result.resize(0);
+ } else {
+ ALOGW("%s: couldn't utilize fmq, fall back to hwbinder", __FUNCTION__);
+ result.fmqResultSize = 0;
+ }
+ }
+ }
+ }
+ mCallback->processCaptureResult(results);
+ mProcessCaptureResultLock.unlock();
+}
+
void CameraDeviceSession::ResultBatcher::processOneCaptureResult(CaptureResult& result) {
hidl_vec<CaptureResult> results = {result};
- mCallback->processCaptureResult(results);
+ invokeProcessCaptureResultCallback(results, /* tryWriteFmq */true);
freeReleaseFences(results);
return;
}
@@ -515,6 +572,7 @@
if (nonBatchedBuffers.size() > 0 || result.inputBuffer.streamId != -1) {
CaptureResult nonBatchedResult;
nonBatchedResult.frameNumber = result.frameNumber;
+ nonBatchedResult.fmqResultSize = 0;
nonBatchedResult.outputBuffers = nonBatchedBuffers;
nonBatchedResult.inputBuffer = result.inputBuffer;
nonBatchedResult.partialResult = 0; // 0 for buffer only results
@@ -650,7 +708,8 @@
mVideoStreamIds.clear();
for (const auto& stream : requestedConfiguration.streams) {
if (stream.streamType == StreamType::OUTPUT &&
- stream.usage & graphics::allocator::V2_0::ConsumerUsage::VIDEO_ENCODER) {
+ stream.usage &
+ graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) {
mVideoStreamIds.push_back(stream.id);
}
}
@@ -698,6 +757,18 @@
}
}
+Return<void> CameraDeviceSession::getCaptureRequestMetadataQueue(
+ getCaptureRequestMetadataQueue_cb _hidl_cb) {
+ _hidl_cb(*mRequestMetadataQueue->getDesc());
+ return Void();
+}
+
+Return<void> CameraDeviceSession::getCaptureResultMetadataQueue(
+ getCaptureResultMetadataQueue_cb _hidl_cb) {
+ _hidl_cb(*mResultMetadataQueue->getDesc());
+ return Void();
+}
+
Return<void> CameraDeviceSession::processCaptureRequest(
const hidl_vec<CaptureRequest>& requests,
const hidl_vec<BufferCache>& cachesToRemove,
@@ -730,7 +801,24 @@
camera3_capture_request_t halRequest;
halRequest.frame_number = request.frameNumber;
- bool converted = convertFromHidl(request.settings, &halRequest.settings);
+
+ bool converted = true;
+ CameraMetadata settingsFmq; // settings from FMQ
+ if (request.fmqSettingsSize > 0) {
+ // non-blocking read; client must write metadata before calling
+ // processOneCaptureRequest
+ settingsFmq.resize(request.fmqSettingsSize);
+ bool read = mRequestMetadataQueue->read(settingsFmq.data(), request.fmqSettingsSize);
+ if (read) {
+ converted = convertFromHidl(settingsFmq, &halRequest.settings);
+ } else {
+ ALOGE("%s: capture request settings metadata couldn't be read from fmq!", __FUNCTION__);
+ converted = false;
+ }
+ } else {
+ converted = convertFromHidl(request.settings, &halRequest.settings);
+ }
+
if (!converted) {
ALOGE("%s: capture request settings metadata is corrupt!", __FUNCTION__);
return Status::INTERNAL_ERROR;
@@ -880,6 +968,7 @@
// within the scope of this function
CaptureResult result;
result.frameNumber = frameNumber;
+ result.fmqResultSize = 0;
result.partialResult = hal_result->partial_result;
convertToHidl(hal_result->result, &result.result);
if (hasInputBuf) {
diff --git a/camera/device/3.2/default/CameraDeviceSession.h b/camera/device/3.2/default/CameraDeviceSession.h
index 781056e..7682165 100644
--- a/camera/device/3.2/default/CameraDeviceSession.h
+++ b/camera/device/3.2/default/CameraDeviceSession.h
@@ -17,19 +17,20 @@
#ifndef ANDROID_HARDWARE_CAMERA_DEVICE_V3_2_CAMERADEVICE3SESSION_H
#define ANDROID_HARDWARE_CAMERA_DEVICE_V3_2_CAMERADEVICE3SESSION_H
+#include <android/hardware/camera/device/3.2/ICameraDevice.h>
+#include <android/hardware/camera/device/3.2/ICameraDeviceSession.h>
+#include <fmq/MessageQueue.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <include/convert.h>
#include <deque>
#include <map>
#include <unordered_map>
-#include "hardware/camera_common.h"
-#include "hardware/camera3.h"
-#include "utils/Mutex.h"
-#include <android/hardware/camera/device/3.2/ICameraDevice.h>
-#include <android/hardware/camera/device/3.2/ICameraDeviceSession.h>
-#include <hidl/Status.h>
-#include <hidl/MQDescriptor.h>
-#include <include/convert.h>
-#include "HandleImporter.h"
#include "CameraMetadata.h"
+#include "HandleImporter.h"
+#include "hardware/camera3.h"
+#include "hardware/camera_common.h"
+#include "utils/Mutex.h"
namespace android {
namespace hardware {
@@ -44,6 +45,9 @@
using ::android::hardware::camera::device::V3_2::ICameraDeviceSession;
using ::android::hardware::camera::common::V1_0::Status;
using ::android::hardware::camera::common::V1_0::helper::HandleImporter;
+using ::android::hardware::kSynchronizedReadWrite;
+using ::android::hardware::MessageQueue;
+using ::android::hardware::MQDescriptorSync;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
@@ -84,6 +88,10 @@
RequestTemplate type, constructDefaultRequestSettings_cb _hidl_cb) override;
Return<void> configureStreams(
const StreamConfiguration& requestedConfiguration, configureStreams_cb _hidl_cb) override;
+ Return<void> getCaptureRequestMetadataQueue(
+ getCaptureRequestMetadataQueue_cb _hidl_cb) override;
+ Return<void> getCaptureResultMetadataQueue(
+ getCaptureResultMetadataQueue_cb _hidl_cb) override;
Return<void> processCaptureRequest(
const hidl_vec<CaptureRequest>& requests,
const hidl_vec<BufferCache>& cachesToRemove,
@@ -126,11 +134,17 @@
common::V1_0::helper::CameraMetadata mDeviceInfo;
+ using RequestMetadataQueue = MessageQueue<uint8_t, kSynchronizedReadWrite>;
+ std::unique_ptr<RequestMetadataQueue> mRequestMetadataQueue;
+ using ResultMetadataQueue = MessageQueue<uint8_t, kSynchronizedReadWrite>;
+ std::shared_ptr<ResultMetadataQueue> mResultMetadataQueue;
+
class ResultBatcher {
public:
ResultBatcher(const sp<ICameraDeviceCallback>& callback);
void setNumPartialResults(uint32_t n);
void setBatchedStreams(const std::vector<int>& streamsToBatch);
+ void setResultMetadataQueue(std::shared_ptr<ResultMetadataQueue> q);
void registerBatch(const hidl_vec<CaptureRequest>& requests);
void notify(NotifyMsg& msg);
@@ -208,6 +222,7 @@
void freeReleaseFences(hidl_vec<CaptureResult>&);
void notifySingleMsg(NotifyMsg& msg);
void processOneCaptureResult(CaptureResult& result);
+ void invokeProcessCaptureResultCallback(hidl_vec<CaptureResult> &results, bool tryWriteFmq);
// Protect access to mInflightBatches, mNumPartialResults and mStreamsToBatch
// processCaptureRequest, processCaptureResult, notify will compete for this lock
@@ -217,6 +232,11 @@
uint32_t mNumPartialResults;
std::vector<int> mStreamsToBatch;
const sp<ICameraDeviceCallback> mCallback;
+ std::shared_ptr<ResultMetadataQueue> mResultMetadataQueue;
+
+ // Protect against invokeProcessCaptureResultCallback()
+ Mutex mProcessCaptureResultLock;
+
} mResultBatcher;
std::vector<int> mVideoStreamIds;
diff --git a/camera/device/3.2/default/convert.cpp b/camera/device/3.2/default/convert.cpp
index c7cc75a..d878deb 100644
--- a/camera/device/3.2/default/convert.cpp
+++ b/camera/device/3.2/default/convert.cpp
@@ -28,8 +28,7 @@
using ::android::hardware::graphics::common::V1_0::Dataspace;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
-using ::android::hardware::camera::device::V3_2::ConsumerUsageFlags;
-using ::android::hardware::camera::device::V3_2::ProducerUsageFlags;
+using ::android::hardware::camera::device::V3_2::BufferUsageFlags;
bool convertFromHidl(const CameraMetadata &src, const camera_metadata_t** dst) {
if (src.size() == 0) {
@@ -78,11 +77,11 @@
dst->overrideFormat = (PixelFormat) src->format;
dst->maxBuffers = src->max_buffers;
if (src->stream_type == CAMERA3_STREAM_OUTPUT) {
- dst->consumerUsage = (ConsumerUsageFlags) 0;
- dst->producerUsage = (ProducerUsageFlags) src->usage;
+ dst->consumerUsage = (BufferUsageFlags)0;
+ dst->producerUsage = (BufferUsageFlags)src->usage;
} else if (src->stream_type == CAMERA3_STREAM_INPUT) {
- dst->producerUsage = (ProducerUsageFlags) 0;
- dst->consumerUsage = (ConsumerUsageFlags) src->usage;
+ dst->producerUsage = (BufferUsageFlags)0;
+ dst->consumerUsage = (BufferUsageFlags)src->usage;
} else {
//Should not reach here per current HIDL spec, but we might end up adding
// bi-directional stream to HIDL.
diff --git a/camera/device/3.2/types.hal b/camera/device/3.2/types.hal
index 5ae7a18..276e92a 100644
--- a/camera/device/3.2/types.hal
+++ b/camera/device/3.2/types.hal
@@ -16,12 +16,10 @@
package android.hardware.camera.device@3.2;
-import android.hardware.graphics.allocator@2.0::types;
import android.hardware.graphics.common@1.0::types;
typedef vec<uint8_t> CameraMetadata;
-typedef bitfield<ProducerUsage> ProducerUsageFlags;
-typedef bitfield<ConsumerUsage> ConsumerUsageFlags;
+typedef bitfield<BufferUsage> BufferUsageFlags;
typedef bitfield<Dataspace> DataspaceFlags;
/**
@@ -255,7 +253,7 @@
* with ILLEGAL_ARGUMENT if the combined flags cannot be supported due to
* imcompatible buffer format, dataSpace, or other hardware limitations.
*/
- ConsumerUsageFlags usage;
+ BufferUsageFlags usage;
/**
* A field that describes the contents of the buffer. The format and buffer
@@ -373,8 +371,8 @@
* consumerUsage must be set. For other types, producerUsage must be set,
* and consumerUsage must be 0.
*/
- ProducerUsageFlags producerUsage;
- ConsumerUsageFlags consumerUsage;
+ BufferUsageFlags producerUsage;
+ BufferUsageFlags consumerUsage;
/**
* The maximum number of buffers the HAL device may need to have dequeued at
@@ -755,11 +753,22 @@
uint32_t frameNumber;
/**
- * The settings buffer contains the capture and processing parameters for
+ * If non-zero, read settings from request queue instead
+ * (see ICameraDeviceSession.getCaptureRequestMetadataQueue).
+ * If zero, read settings from .settings field.
+ */
+ uint64_t fmqSettingsSize;
+
+ /**
+ * If fmqSettingsSize is zero,
+ * the settings buffer contains the capture and processing parameters for
* the request. As a special case, an empty settings buffer indicates that
* the settings are identical to the most-recently submitted capture
* request. A empty buffer cannot be used as the first submitted request
* after a configureStreams() call.
+ *
+ * This field must be used if fmqSettingsSize is zero. It must not be used
+ * if fmqSettingsSize is non-zero.
*/
CameraMetadata settings;
@@ -844,6 +853,13 @@
uint32_t frameNumber;
/**
+ * If non-zero, read result from result queue instead
+ * (see ICameraDeviceSession.getCaptureResultMetadataQueue).
+ * If zero, read result from .result field.
+ */
+ uint64_t fmqResultSize;
+
+ /**
* The result metadata for this capture. This contains information about the
* final capture parameters, the state of the capture and post-processing
* hardware, the state of the 3A algorithms, if enabled, and the output of
diff --git a/camera/metadata/3.2/Android.bp b/camera/metadata/3.2/Android.bp
index d6bb9a3..0534b9c 100644
--- a/camera/metadata/3.2/Android.bp
+++ b/camera/metadata/3.2/Android.bp
@@ -37,6 +37,7 @@
generated_sources: ["android.hardware.camera.metadata@3.2_genc++"],
generated_headers: ["android.hardware.camera.metadata@3.2_genc++_headers"],
export_generated_headers: ["android.hardware.camera.metadata@3.2_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/camera/metadata/3.2/Android.mk b/camera/metadata/3.2/Android.mk
index 86cee91..935c37c 100644
--- a/camera/metadata/3.2/Android.mk
+++ b/camera/metadata/3.2/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.camera.metadata@3.2-java
+LOCAL_MODULE := android.hardware.camera.metadata-V3.2-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -1233,7 +1233,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.camera.metadata@3.2-java-static
+LOCAL_MODULE := android.hardware.camera.metadata-V3.2-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/camera/provider/2.4/Android.bp b/camera/provider/2.4/Android.bp
index 1656325..02e02eb 100644
--- a/camera/provider/2.4/Android.bp
+++ b/camera/provider/2.4/Android.bp
@@ -47,6 +47,7 @@
generated_sources: ["android.hardware.camera.provider@2.4_genc++"],
generated_headers: ["android.hardware.camera.provider@2.4_genc++_headers"],
export_generated_headers: ["android.hardware.camera.provider@2.4_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
@@ -57,7 +58,6 @@
"android.hardware.camera.common@1.0",
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.2",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
@@ -69,7 +69,6 @@
"android.hardware.camera.common@1.0",
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.2",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
diff --git a/camera/provider/2.4/default/Android.bp b/camera/provider/2.4/default/Android.bp
index 9506827..8e8df62 100644
--- a/camera/provider/2.4/default/Android.bp
+++ b/camera/provider/2.4/default/Android.bp
@@ -37,6 +37,7 @@
shared_libs: [
"libhidlbase",
"libhidltransport",
+ "libbinder",
"liblog",
"libutils",
"android.hardware.camera.device@1.0",
diff --git a/camera/provider/2.4/default/service.cpp b/camera/provider/2.4/default/service.cpp
index df2602e..7eeb637 100644
--- a/camera/provider/2.4/default/service.cpp
+++ b/camera/provider/2.4/default/service.cpp
@@ -19,11 +19,16 @@
#include <android/hardware/camera/provider/2.4/ICameraProvider.h>
#include <hidl/LegacySupport.h>
+#include <binder/ProcessState.h>
+
using android::hardware::camera::provider::V2_4::ICameraProvider;
using android::hardware::defaultPassthroughServiceImplementation;
int main()
{
ALOGI("Camera provider Service is starting.");
+ // The camera HAL may communicate to other vendor components via
+ // /dev/vndbinder
+ android::ProcessState::initWithDriver("/dev/vndbinder");
return defaultPassthroughServiceImplementation<ICameraProvider>("legacy/0", /*maxThreads*/ 6);
}
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 74e6efe..b7ce858 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -52,8 +52,8 @@
using ::android::BufferItemConsumer;
using ::android::Surface;
using ::android::CameraParameters;
+using ::android::hardware::graphics::common::V1_0::BufferUsage;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
-using ::android::hardware::graphics::allocator::V2_0::ProducerUsage;
using ::android::hardware::camera::common::V1_0::Status;
using ::android::hardware::camera::common::V1_0::CameraDeviceStatus;
using ::android::hardware::camera::common::V1_0::TorchMode;
@@ -233,7 +233,7 @@
Return<Status> setCrop(int32_t left, int32_t top,
int32_t right, int32_t bottom) override;
- Return<Status> setUsage(ProducerUsage usage) override;
+ Return<Status> setUsage(BufferUsage usage) override;
Return<Status> setSwapInterval(int32_t interval) override;
@@ -408,7 +408,7 @@
return mapToStatus(rc);
}
-Return<Status> PreviewWindowCb::setUsage(ProducerUsage usage) {
+Return<Status> PreviewWindowCb::setUsage(BufferUsage usage) {
auto rc = native_window_set_usage(mAnw.get(), static_cast<int>(usage));
if (rc == ::android::OK) {
mPreviewUsage = static_cast<int>(usage);
@@ -2493,7 +2493,7 @@
outputBuffer};
StreamBuffer emptyInputBuffer = {-1, 0, nullptr,
BufferStatus::ERROR, nullptr, nullptr};
- CaptureRequest request = {frameNumber, settings,
+ CaptureRequest request = {frameNumber, 0 /* fmqSettingsSize */, settings,
emptyInputBuffer, outputBuffers};
{
@@ -2599,7 +2599,7 @@
outputBuffer};
StreamBuffer emptyInputBuffer = {-1, 0, nullptr,
BufferStatus::ERROR, nullptr, nullptr};
- CaptureRequest request = {frameNumber, settings,
+ CaptureRequest request = {frameNumber, 0 /* fmqSettingsSize */, settings,
emptyInputBuffer, outputBuffers};
//Settings were not correctly initialized, we should fail here
@@ -2654,7 +2654,7 @@
::android::hardware::hidl_vec<StreamBuffer> emptyOutputBuffers;
StreamBuffer emptyInputBuffer = {-1, 0, nullptr,
BufferStatus::ERROR, nullptr, nullptr};
- CaptureRequest request = {frameNumber, settings,
+ CaptureRequest request = {frameNumber, 0/* fmqSettingsSize */, settings,
emptyInputBuffer, emptyOutputBuffers};
//Output buffers are missing, we should fail here
@@ -2719,7 +2719,7 @@
outputBuffer};
const StreamBuffer emptyInputBuffer = {-1, 0, nullptr,
BufferStatus::ERROR, nullptr, nullptr};
- CaptureRequest request = {frameNumber, settings,
+ CaptureRequest request = {frameNumber, 0 /* fmqSettingsSize */, settings,
emptyInputBuffer, outputBuffers};
{
diff --git a/configstore/1.0/Android.bp b/configstore/1.0/Android.bp
index 712e9a7..bd203cc 100644
--- a/configstore/1.0/Android.bp
+++ b/configstore/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.configstore@1.0_genc++"],
generated_headers: ["android.hardware.configstore@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.configstore@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/configstore/1.0/Android.mk b/configstore/1.0/Android.mk
index 010d509..6be99db 100644
--- a/configstore/1.0/Android.mk
+++ b/configstore/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.configstore@1.0-java
+LOCAL_MODULE := android.hardware.configstore-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -156,7 +156,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.configstore@1.0-java-static
+LOCAL_MODULE := android.hardware.configstore-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -164,7 +164,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/configstore/1.0/ISurfaceFlingerConfigs.hal b/configstore/1.0/ISurfaceFlingerConfigs.hal
index dcc9bbb..5f975bd 100644
--- a/configstore/1.0/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.0/ISurfaceFlingerConfigs.hal
@@ -108,4 +108,10 @@
* FramebufferSurface.
*/
maxFrameBufferAcquiredBuffers() generates(OptionalInt64 value);
+
+ /**
+ * Returns true if surface flinger should start
+ * hardware.graphics.allocator@2.0::IAllocator service.
+ */
+ startGraphicsAllocatorService() generates(OptionalBool value);
};
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.cpp b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
index 70bd803..9c134ef 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.cpp
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
@@ -112,6 +112,16 @@
return Void();
}
+Return<void> SurfaceFlingerConfigs::startGraphicsAllocatorService(
+ startGraphicsAllocatorService_cb _hidl_cb) {
+ bool value = false;
+#ifdef START_GRAPHICS_ALLOCATOR_SERVICE
+ value = true;
+#endif
+ _hidl_cb({true, value});
+ return Void();
+}
+
} // namespace implementation
} // namespace V1_0
} // namespace configstore
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.h b/configstore/1.0/default/SurfaceFlingerConfigs.h
index 9300511..17a424e 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.h
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.h
@@ -35,6 +35,8 @@
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.
diff --git a/configstore/1.0/default/surfaceflinger.mk b/configstore/1.0/default/surfaceflinger.mk
index 9e3d4d4..3ce768a 100644
--- a/configstore/1.0/default/surfaceflinger.mk
+++ b/configstore/1.0/default/surfaceflinger.mk
@@ -50,3 +50,7 @@
ifneq ($(NUM_FRAMEBUFFER_SURFACE_BUFFERS),)
LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
endif
+
+ifneq ($(SF_START_GRAPHICS_ALLOCATOR_SERVICE),)
+ LOCAL_CFLAGS += -DSTART_GRAPHICS_ALLOCATOR_SERVICE
+endif
diff --git a/contexthub/1.0/Android.bp b/contexthub/1.0/Android.bp
index 2bf951a..a4c7175 100644
--- a/contexthub/1.0/Android.bp
+++ b/contexthub/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.contexthub@1.0_genc++"],
generated_headers: ["android.hardware.contexthub@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.contexthub@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/contexthub/1.0/Android.mk b/contexthub/1.0/Android.mk
index a053986..d161e3b 100644
--- a/contexthub/1.0/Android.mk
+++ b/contexthub/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.contexthub@1.0-java
+LOCAL_MODULE := android.hardware.contexthub-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -331,7 +331,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.contexthub@1.0-java-static
+LOCAL_MODULE := android.hardware.contexthub-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -339,7 +339,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/drm/1.0/Android.bp b/drm/1.0/Android.bp
index 9fddaa8..0ca4766 100644
--- a/drm/1.0/Android.bp
+++ b/drm/1.0/Android.bp
@@ -72,6 +72,7 @@
generated_sources: ["android.hardware.drm@1.0_genc++"],
generated_headers: ["android.hardware.drm@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.drm@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/drm/1.0/default/Android.mk b/drm/1.0/default/Android.mk
index 23a4506..7602399 100644
--- a/drm/1.0/default/Android.mk
+++ b/drm/1.0/default/Android.mk
@@ -34,6 +34,7 @@
libhardware \
liblog \
libutils \
+ libbinder \
LOCAL_C_INCLUDES := \
hardware/interfaces/drm
diff --git a/drm/1.0/default/service.cpp b/drm/1.0/default/service.cpp
index a112aaf..1a44ce2 100644
--- a/drm/1.0/default/service.cpp
+++ b/drm/1.0/default/service.cpp
@@ -21,6 +21,8 @@
#include <hidl/HidlTransportSupport.h>
#include <hidl/LegacySupport.h>
+#include <binder/ProcessState.h>
+
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::registerPassthroughServiceImplementation;
@@ -30,13 +32,18 @@
int main() {
ALOGD("android.hardware.drm@1.0-service starting...");
+
+ // The DRM HAL may communicate to other vendor components via
+ // /dev/vndbinder
+ android::ProcessState::initWithDriver("/dev/vndbinder");
+
configureRpcThreadpool(8, true /* callerWillJoin */);
android::status_t status =
- registerPassthroughServiceImplementation<IDrmFactory>("drm");
+ registerPassthroughServiceImplementation<IDrmFactory>();
LOG_ALWAYS_FATAL_IF(
status != android::OK,
"Error while registering drm service: %d", status);
- status = registerPassthroughServiceImplementation<ICryptoFactory>("crypto");
+ status = registerPassthroughServiceImplementation<ICryptoFactory>();
LOG_ALWAYS_FATAL_IF(
status != android::OK,
"Error while registering crypto service: %d", status);
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 e97ac10..71b893a 100644
--- a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
@@ -94,12 +94,10 @@
test_info->name());
drmFactory =
- ::testing::VtsHalHidlTargetTestBase::getService<IDrmFactory>(
- "drm");
+ ::testing::VtsHalHidlTargetTestBase::getService<IDrmFactory>();
ASSERT_NE(drmFactory, nullptr);
cryptoFactory =
- ::testing::VtsHalHidlTargetTestBase::getService<ICryptoFactory>(
- "crypto");
+ ::testing::VtsHalHidlTargetTestBase::getService<ICryptoFactory>();
ASSERT_NE(cryptoFactory, nullptr);
}
@@ -247,6 +245,7 @@
SessionId openSession();
void closeSession(const SessionId& sessionId);
+ hidl_vec<uint8_t> loadKeys(const SessionId& sessionId, const KeyType& type);
sp<IMemory> getDecryptMemory(size_t size, size_t index);
protected:
@@ -315,6 +314,70 @@
}
/**
+ * Helper method to load keys for subsequent decrypt tests.
+ * These tests use predetermined key request/response to
+ * avoid requiring a round trip to a license server.
+ */
+hidl_vec<uint8_t> DrmHalClearkeyPluginTest::loadKeys(
+ const SessionId& sessionId, const KeyType& type = KeyType::STREAMING) {
+ hidl_vec<uint8_t> initData = {
+ // BMFF box header (4 bytes size + 'pssh')
+ 0x00, 0x00, 0x00, 0x34, 0x70, 0x73, 0x73, 0x68,
+ // full box header (version = 1 flags = 0)
+ 0x01, 0x00, 0x00, 0x00,
+ // system id
+ 0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e,
+ 0x52, 0xe2, 0xfb, 0x4b,
+ // number of key ids
+ 0x00, 0x00, 0x00, 0x01,
+ // key id
+ 0x60, 0x06, 0x1e, 0x01, 0x7e, 0x47, 0x7e, 0x87, 0x7e, 0x57, 0xd0, 0x0d,
+ 0x1e, 0xd0, 0x0d, 0x1e,
+ // size of data, must be zero
+ 0x00, 0x00, 0x00, 0x00};
+
+ hidl_vec<uint8_t> expectedKeyRequest = {
+ 0x7b, 0x22, 0x6b, 0x69, 0x64, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x59,
+ 0x41, 0x59, 0x65, 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2b,
+ 0x56, 0x39, 0x41, 0x4e, 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22,
+ 0x5d, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x74,
+ 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x79, 0x22, 0x7d};
+
+ hidl_vec<uint8_t> knownKeyResponse = {
+ 0x7b, 0x22, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22,
+ 0x6b, 0x74, 0x79, 0x22, 0x3a, 0x22, 0x6f, 0x63, 0x74, 0x22, 0x2c,
+ 0x22, 0x6b, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x59, 0x41, 0x59, 0x65,
+ 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2b, 0x56, 0x39, 0x41,
+ 0x4e, 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22, 0x2c, 0x22, 0x6b,
+ 0x22, 0x3a, 0x22, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x54, 0x65,
+ 0x73, 0x74, 0x4b, 0x65, 0x79, 0x42, 0x61, 0x73, 0x65, 0x36, 0x34,
+ 0x67, 0x67, 0x67, 0x22, 0x7d, 0x5d, 0x7d, 0x0a};
+
+ hidl_string mimeType = "video/mp4";
+ KeyedVector optionalParameters;
+ auto res = drmPlugin->getKeyRequest(
+ sessionId, initData, mimeType, type, optionalParameters,
+ [&](Status status, const hidl_vec<uint8_t>& request,
+ KeyRequestType requestType, const hidl_string&) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_EQ(KeyRequestType::INITIAL, requestType);
+ EXPECT_EQ(request, expectedKeyRequest);
+ });
+ EXPECT_OK(res);
+
+ hidl_vec<uint8_t> keySetId;
+ res = drmPlugin->provideKeyResponse(
+ sessionId, knownKeyResponse,
+ [&](Status status, const hidl_vec<uint8_t>& myKeySetId) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_EQ(0u, myKeySetId.size());
+ keySetId = myKeySetId;
+ });
+ EXPECT_OK(res);
+ return keySetId;
+}
+
+/**
* Test that a session can be opened and closed
*/
TEST_F(DrmHalClearkeyPluginTest, OpenCloseSession) {
@@ -473,6 +536,30 @@
}
/**
+ * Test that ClearKey cannot handle key restoring.
+ * Expected message is Status::ERROR_DRM_CANNOT_HANDLE.
+ */
+TEST_F(DrmHalClearkeyPluginTest, RestoreKeysCannotHandle) {
+ hidl_vec<uint8_t> keySetId = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ SessionId sessionId = openSession();
+ Status status = drmPlugin->restoreKeys(sessionId, keySetId);
+ EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status);
+ closeSession(sessionId);
+}
+
+/**
+ * Test that restoreKeys fails with a null key set ID.
+ * Error message is expected to be Status::BAD_VALUE.
+ */
+TEST_F(DrmHalClearkeyPluginTest, RestoreKeysNull) {
+ SessionId sessionId = openSession();
+ hidl_vec<uint8_t> nullKeySetId;
+ Status status = drmPlugin->restoreKeys(sessionId, nullKeySetId);
+ EXPECT_EQ(Status::BAD_VALUE, status);
+ closeSession(sessionId);
+}
+
+/**
* Test that the clearkey plugin doesn't support getting
* secure stops.
*/
@@ -833,7 +920,6 @@
class DrmHalClearkeyDecryptTest : public DrmHalClearkeyPluginTest {
public:
- void loadKeys(const SessionId& sessionId);
void fillRandom(const sp<IMemory>& memory);
hidl_array<uint8_t, 16> toHidlArray(const vector<uint8_t>& vec) {
EXPECT_EQ(16u, vec.size());
@@ -847,67 +933,6 @@
const hidl_vec<SubSample>& subSamples, const vector<uint8_t>& key);
};
-/**
- * Helper method to load keys for subsequent decrypt tests.
- * These tests use predetermined key request/response to
- * avoid requiring a round trip to a license server.
- */
-void DrmHalClearkeyDecryptTest::loadKeys(const SessionId& sessionId) {
- hidl_vec<uint8_t> initData = {
- // BMFF box header (4 bytes size + 'pssh')
- 0x00, 0x00, 0x00, 0x34, 0x70, 0x73, 0x73, 0x68,
- // full box header (version = 1 flags = 0)
- 0x01, 0x00, 0x00, 0x00,
- // system id
- 0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c,
- 0x1e, 0x52, 0xe2, 0xfb, 0x4b,
- // number of key ids
- 0x00, 0x00, 0x00, 0x01,
- // key id
- 0x60, 0x06, 0x1e, 0x01, 0x7e, 0x47, 0x7e, 0x87, 0x7e, 0x57, 0xd0,
- 0x0d, 0x1e, 0xd0, 0x0d, 0x1e,
- // size of data, must be zero
- 0x00, 0x00, 0x00, 0x00};
-
- hidl_vec<uint8_t> expectedKeyRequest = {
- 0x7b, 0x22, 0x6b, 0x69, 0x64, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x59,
- 0x41, 0x59, 0x65, 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2b,
- 0x56, 0x39, 0x41, 0x4e, 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22,
- 0x5d, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x74,
- 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x79, 0x22, 0x7d};
-
- hidl_vec<uint8_t> knownKeyResponse = {
- 0x7b, 0x22, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22,
- 0x6b, 0x74, 0x79, 0x22, 0x3a, 0x22, 0x6f, 0x63, 0x74, 0x22, 0x2c,
- 0x22, 0x6b, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x59, 0x41, 0x59, 0x65,
- 0x41, 0x58, 0x35, 0x48, 0x66, 0x6f, 0x64, 0x2b, 0x56, 0x39, 0x41,
- 0x4e, 0x48, 0x74, 0x41, 0x4e, 0x48, 0x67, 0x22, 0x2c, 0x22, 0x6b,
- 0x22, 0x3a, 0x22, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x54, 0x65,
- 0x73, 0x74, 0x4b, 0x65, 0x79, 0x42, 0x61, 0x73, 0x65, 0x36, 0x34,
- 0x67, 0x67, 0x67, 0x22, 0x7d, 0x5d, 0x7d, 0x0a};
-
- hidl_string mimeType = "video/mp4";
- KeyedVector optionalParameters;
- auto res = drmPlugin->getKeyRequest(
- sessionId, initData, mimeType, KeyType::STREAMING,
- optionalParameters,
- [&](Status status, const hidl_vec<uint8_t>& request,
- KeyRequestType requestType, const hidl_string&) {
- EXPECT_EQ(Status::OK, status);
- EXPECT_EQ(KeyRequestType::INITIAL, requestType);
- EXPECT_EQ(request, expectedKeyRequest);
- });
- EXPECT_OK(res);
-
- res = drmPlugin->provideKeyResponse(
- sessionId, knownKeyResponse,
- [&](Status status, const hidl_vec<uint8_t>& keySetId) {
- EXPECT_EQ(Status::OK, status);
- EXPECT_EQ(0u, keySetId.size());
- });
- EXPECT_OK(res);
-}
-
void DrmHalClearkeyDecryptTest::fillRandom(const sp<IMemory>& memory) {
random_device rd;
mt19937 rand(rd());
diff --git a/drm/1.0/vts/functional/drm_hal_vendor_module_api.h b/drm/1.0/vts/functional/drm_hal_vendor_module_api.h
index 73e0cfe..b8b2052 100644
--- a/drm/1.0/vts/functional/drm_hal_vendor_module_api.h
+++ b/drm/1.0/vts/functional/drm_hal_vendor_module_api.h
@@ -65,7 +65,7 @@
class DrmHalVTSVendorModule {
public:
- DrmHalVTSVendorModule() {}
+ DrmHalVTSVendorModule() : installed(true) {}
virtual ~DrmHalVTSVendorModule() {}
/**
@@ -89,7 +89,15 @@
*/
virtual std::string getServiceName() const = 0;
+ /**
+ * Set a flag in the vendor module to indicate whether or not the drm
+ * scheme corresponding to this module is installed on the device.
+ */
+ void setInstalled(bool flag) {installed = flag;}
+ bool isInstalled() const {return installed;}
+
private:
+ bool installed;
DrmHalVTSVendorModule(const DrmHalVTSVendorModule&) = delete;
void operator=(const DrmHalVTSVendorModule&) = delete;
};
@@ -158,17 +166,30 @@
const std::map<std::string, std::string> optionalParameters;
/**
+ * Define license policy attributes for the content configuration.
+ * These attributes can affect which tests are able to be applied.
+ */
+ struct Policy {
+ /**
+ * Indicate if the license policy allows offline playback.
+ * Content configurated with this policy supports KeyType::OFFLINE
+ * key requests/responses. A vendor module should provide at least
+ * one content configuration where allowOffline is true if the drm
+ * scheme supports offline content.
+ */
+ bool allowOffline;
+ } policy;
+
+ /**
* The keys that will be available once the keys are loaded
*/
struct Key {
/**
* Indicate if the key content is configured to require secure
- * buffers,
- * where the output buffers are protected and cannot be accessed.
- * A vendor module should provide some content configurations where
- * isSecure is false, to allow decrypt result verification tests to
- * be
- * run.
+ * buffers, where the output buffers are protected and cannot be
+ * accessed by the non-secure cpu. A vendor module should provide
+ * at least one content configurations where isSecure is false, to
+ * allow decrypt result verification tests to be run.
*/
bool isSecure;
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 44675dc..ec73a7d 100644
--- a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
@@ -33,7 +33,8 @@
#include "drm_hal_vendor_module_api.h"
#include "vendor_modules.h"
-#include "VtsHalHidlTargetTestBase.h"
+#include <VtsHalHidlTargetCallbackBase.h>
+#include <VtsHalHidlTargetTestBase.h>
using ::android::hardware::drm::V1_0::BufferType;
using ::android::hardware::drm::V1_0::DestinationBuffer;
@@ -77,10 +78,19 @@
using ContentConfiguration = ::DrmHalVTSVendorModule_V1::ContentConfiguration;
using Key = ::DrmHalVTSVendorModule_V1::ContentConfiguration::Key;
+using VtsTestBase = ::testing::VtsHalHidlTargetTestBase;
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
+#define RETURN_IF_SKIPPED \
+ if (!vendorModule->isInstalled()) { \
+ std::cout << "[ SKIPPED ] This drm scheme not supported." << \
+ " library:" << GetParam() << " service-name:" << \
+ vendorModule->getServiceName() << std::endl; \
+ return; \
+ }
+
static const uint8_t kInvalidUUID[16] = {
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
@@ -105,15 +115,29 @@
GetParam().c_str());
ASSERT_NE(vendorModule, nullptr);
+
+ // First try the binderized service name provided by the vendor module.
+ // If that fails, which it can on non-binderized devices, try the default
+ // service.
string name = vendorModule->getServiceName();
- drmFactory =
- ::testing::VtsHalHidlTargetTestBase::getService<IDrmFactory>(
- name != "default" ? name : "drm");
+ drmFactory = VtsTestBase::getService<IDrmFactory>(name);
+ if (drmFactory == nullptr) {
+ drmFactory = VtsTestBase::getService<IDrmFactory>();
+ }
ASSERT_NE(drmFactory, nullptr);
- cryptoFactory =
- ::testing::VtsHalHidlTargetTestBase::getService<ICryptoFactory>(
- name != "default" ? name : "crypto");
+
+ // Do the same for the crypto factory
+ cryptoFactory = VtsTestBase::getService<ICryptoFactory>(name);
+ if (cryptoFactory == nullptr) {
+ VtsTestBase::getService<ICryptoFactory>();
+ }
ASSERT_NE(cryptoFactory, nullptr);
+
+ // If drm scheme not installed skip subsequent tests
+ if (!drmFactory->isCryptoSchemeSupported(getVendorUUID())) {
+ vendorModule->setInstalled(false);
+ return;
+ }
}
virtual void TearDown() override {}
@@ -132,6 +156,7 @@
TEST_P(DrmHalVendorFactoryTest, ValidateConfigurations) {
const char* kVendorStr = "Vendor module ";
+ size_t count = 0;
for (auto config : contentConfigurations) {
ASSERT_TRUE(config.name.size() > 0) << kVendorStr << "has no name";
ASSERT_TRUE(config.serverUrl.size() > 0) << kVendorStr
@@ -147,7 +172,9 @@
ASSERT_TRUE(key.keyId.size() > 0) << kVendorStr
<< " has zero length key value";
}
+ count++;
}
+ EXPECT_NE(0u, count);
}
/**
@@ -168,9 +195,10 @@
}
/**
- * Ensure the factory supports the scheme uuid in the config
+ * Check if the factory supports the scheme uuid in the config.
*/
-TEST_P(DrmHalVendorFactoryTest, EmptyPluginConfigUUIDSupported) {
+TEST_P(DrmHalVendorFactoryTest, PluginConfigUUIDSupported) {
+ RETURN_IF_SKIPPED;
EXPECT_TRUE(drmFactory->isCryptoSchemeSupported(getVendorUUID()));
EXPECT_TRUE(cryptoFactory->isCryptoSchemeSupported(getVendorUUID()));
}
@@ -195,6 +223,7 @@
* Ensure valid content types in the configs are supported
*/
TEST_P(DrmHalVendorFactoryTest, ValidContentTypeSupported) {
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
EXPECT_TRUE(drmFactory->isContentTypeSupported(config.mimeType));
}
@@ -204,6 +233,7 @@
* Ensure vendor drm plugin can be created
*/
TEST_P(DrmHalVendorFactoryTest, CreateVendorDrmPlugin) {
+ RETURN_IF_SKIPPED;
hidl_string packageName("android.hardware.drm.test");
auto res = drmFactory->createPlugin(
getVendorUUID(), packageName,
@@ -218,6 +248,7 @@
* Ensure vendor crypto plugin can be created
*/
TEST_P(DrmHalVendorFactoryTest, CreateVendorCryptoPlugin) {
+ RETURN_IF_SKIPPED;
hidl_vec<uint8_t> initVec;
auto res = cryptoFactory->createPlugin(
getVendorUUID(), initVec,
@@ -232,6 +263,7 @@
* Ensure invalid drm plugin can't be created
*/
TEST_P(DrmHalVendorFactoryTest, CreateInvalidDrmPlugin) {
+ RETURN_IF_SKIPPED;
hidl_string packageName("android.hardware.drm.test");
auto res = drmFactory->createPlugin(
kInvalidUUID, packageName,
@@ -246,6 +278,7 @@
* Ensure invalid crypto plugin can't be created
*/
TEST_P(DrmHalVendorFactoryTest, CreateInvalidCryptoPlugin) {
+ RETURN_IF_SKIPPED;
hidl_vec<uint8_t> initVec;
auto res = cryptoFactory->createPlugin(
kInvalidUUID, initVec,
@@ -262,6 +295,7 @@
virtual void SetUp() override {
// Create factories
DrmHalVendorFactoryTest::SetUp();
+ RETURN_IF_SKIPPED;
hidl_string packageName("android.hardware.drm.test");
auto res = drmFactory->createPlugin(
@@ -289,6 +323,10 @@
SessionId openSession();
void closeSession(const SessionId& sessionId);
sp<IMemory> getDecryptMemory(size_t size, size_t index);
+ KeyedVector toHidlKeyedVector(const map<string, string>& params);
+ hidl_vec<uint8_t> loadKeys(const SessionId& sessionId,
+ const ContentConfiguration& configuration,
+ const KeyType& type);
protected:
sp<IDrmPlugin> drmPlugin;
@@ -309,6 +347,7 @@
*/
TEST_P(DrmHalVendorPluginTest, DoProvisioning) {
+ RETURN_IF_SKIPPED;
hidl_string certificateType;
hidl_string certificateAuthority;
hidl_vec<uint8_t> provisionRequest;
@@ -346,6 +385,7 @@
* response is provided.
*/
TEST_P(DrmHalVendorPluginTest, ProvideEmptyProvisionResponse) {
+ RETURN_IF_SKIPPED;
hidl_vec<uint8_t> response;
auto res = drmPlugin->provideProvisionResponse(
response, [&](Status status, const hidl_vec<uint8_t>&,
@@ -379,10 +419,69 @@
EXPECT_EQ(Status::OK, status);
}
+KeyedVector DrmHalVendorPluginTest::toHidlKeyedVector(
+ const map<string, string>& params) {
+ std::vector<KeyValue> stdKeyedVector;
+ for (auto it = params.begin(); it != params.end(); ++it) {
+ KeyValue keyValue;
+ keyValue.key = it->first;
+ keyValue.value = it->second;
+ stdKeyedVector.push_back(keyValue);
+ }
+ return KeyedVector(stdKeyedVector);
+}
+
+/**
+ * Helper method to load keys for subsequent decrypt tests.
+ * These tests use predetermined key request/response to
+ * avoid requiring a round trip to a license server.
+ */
+hidl_vec<uint8_t> DrmHalVendorPluginTest::loadKeys(
+ const SessionId& sessionId, const ContentConfiguration& configuration,
+ const KeyType& type = KeyType::STREAMING) {
+ hidl_vec<uint8_t> keyRequest;
+ auto res = drmPlugin->getKeyRequest(
+ sessionId, configuration.initData, configuration.mimeType, type,
+ toHidlKeyedVector(configuration.optionalParameters),
+ [&](Status status, const hidl_vec<uint8_t>& request,
+ KeyRequestType type, const hidl_string&) {
+ EXPECT_EQ(Status::OK, status) << "Failed to get "
+ "key request for configuration "
+ << configuration.name;
+ EXPECT_EQ(type, KeyRequestType::INITIAL);
+ EXPECT_NE(request.size(), 0u) << "Expected key request size"
+ " to have length > 0 bytes";
+ keyRequest = request;
+ });
+ EXPECT_OK(res);
+
+ /**
+ * Get key response from vendor module
+ */
+ hidl_vec<uint8_t> keyResponse =
+ vendorModule->handleKeyRequest(keyRequest, configuration.serverUrl);
+
+ EXPECT_NE(keyResponse.size(), 0u) << "Expected key response size "
+ "to have length > 0 bytes";
+
+ hidl_vec<uint8_t> keySetId;
+ res = drmPlugin->provideKeyResponse(
+ sessionId, keyResponse,
+ [&](Status status, const hidl_vec<uint8_t>& myKeySetId) {
+ EXPECT_EQ(Status::OK, status) << "Failure providing "
+ "key response for configuration "
+ << configuration.name;
+ keySetId = myKeySetId;
+ });
+ EXPECT_OK(res);
+ return keySetId;
+}
+
/**
* Test that a session can be opened and closed
*/
TEST_P(DrmHalVendorPluginTest, OpenCloseSession) {
+ RETURN_IF_SKIPPED;
auto sessionId = openSession();
closeSession(sessionId);
}
@@ -392,6 +491,7 @@
* is prohibited with the documented error code.
*/
TEST_P(DrmHalVendorPluginTest, CloseInvalidSession) {
+ RETURN_IF_SKIPPED;
SessionId invalidSessionId;
Status status = drmPlugin->closeSession(invalidSessionId);
EXPECT_EQ(Status::BAD_VALUE, status);
@@ -402,6 +502,7 @@
* is prohibited with the documented error code.
*/
TEST_P(DrmHalVendorPluginTest, CloseClosedSession) {
+ RETURN_IF_SKIPPED;
auto sessionId = openSession();
closeSession(sessionId);
Status status = drmPlugin->closeSession(sessionId);
@@ -412,6 +513,7 @@
* A get key request should fail if no sessionId is provided
*/
TEST_P(DrmHalVendorPluginTest, GetKeyRequestNoSession) {
+ RETURN_IF_SKIPPED;
SessionId invalidSessionId;
hidl_vec<uint8_t> initData;
hidl_string mimeType = "video/mp4";
@@ -428,6 +530,7 @@
* Test that an empty sessionID returns BAD_VALUE
*/
TEST_P(DrmHalVendorPluginTest, ProvideKeyResponseEmptySessionId) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_vec<uint8_t> keyResponse = {0x7b, 0x22, 0x6b, 0x65,
@@ -445,6 +548,7 @@
* Test that an empty key response returns BAD_VALUE
*/
TEST_P(DrmHalVendorPluginTest, ProvideKeyResponseEmptyResponse) {
+ RETURN_IF_SKIPPED;
SessionId session = openSession();
hidl_vec<uint8_t> emptyResponse;
auto res = drmPlugin->provideKeyResponse(
@@ -461,6 +565,7 @@
* Test that a removeKeys on an empty sessionID returns BAD_VALUE
*/
TEST_P(DrmHalVendorPluginTest, RemoveKeysEmptySessionId) {
+ RETURN_IF_SKIPPED;
SessionId sessionId;
Status status = drmPlugin->removeKeys(sessionId);
EXPECT_TRUE(status == Status::BAD_VALUE);
@@ -471,6 +576,7 @@
* that has no keys.
*/
TEST_P(DrmHalVendorPluginTest, RemoveKeysNewSession) {
+ RETURN_IF_SKIPPED;
SessionId sessionId = openSession();
Status status = drmPlugin->removeKeys(sessionId);
EXPECT_TRUE(status == Status::OK);
@@ -478,11 +584,68 @@
}
/**
+ * Test that keys are successfully restored to a new session
+ * for all content having a policy that allows offline use.
+ */
+TEST_P(DrmHalVendorPluginTest, RestoreKeys) {
+ RETURN_IF_SKIPPED;
+ for (auto config : contentConfigurations) {
+ if (config.policy.allowOffline) {
+ auto sessionId = openSession();
+ hidl_vec<uint8_t> keySetId =
+ loadKeys(sessionId, config, KeyType::OFFLINE);
+ closeSession(sessionId);
+ sessionId = openSession();
+ EXPECT_NE(0u, keySetId.size());
+ Status status = drmPlugin->restoreKeys(sessionId, keySetId);
+ EXPECT_EQ(Status::OK, status);
+ closeSession(sessionId);
+ }
+ }
+}
+
+/**
+ * Test that restoreKeys fails with a null key set ID.
+ * Error message is expected to be Status::BAD_VALUE.
+ */
+TEST_P(DrmHalVendorPluginTest, RestoreKeysNull) {
+ RETURN_IF_SKIPPED;
+ SessionId sessionId = openSession();
+ hidl_vec<uint8_t> nullKeySetId;
+ Status status = drmPlugin->restoreKeys(sessionId, nullKeySetId);
+ EXPECT_EQ(Status::BAD_VALUE, status);
+ closeSession(sessionId);
+}
+
+/**
+ * Test that restoreKeys fails to restore keys to a closed
+ * session. Error message is expected to be
+ * Status::ERROR_DRM_SESSION_NOT_OPENED.
+ */
+TEST_P(DrmHalVendorPluginTest, RestoreKeysClosedSession) {
+ RETURN_IF_SKIPPED;
+ for (auto config : contentConfigurations) {
+ if (config.policy.allowOffline) {
+ auto sessionId = openSession();
+ hidl_vec<uint8_t> keySetId =
+ loadKeys(sessionId, config, KeyType::OFFLINE);
+ EXPECT_NE(0u, keySetId.size());
+ closeSession(sessionId);
+ sessionId = openSession();
+ closeSession(sessionId);
+ Status status = drmPlugin->restoreKeys(sessionId, keySetId);
+ EXPECT_EQ(Status::ERROR_DRM_SESSION_NOT_OPENED, status);
+ }
+ }
+}
+
+/**
* Test that the plugin either doesn't support getting
* secure stops, or has no secure stops available after
* clearing them.
*/
TEST_P(DrmHalVendorPluginTest, GetSecureStops) {
+ RETURN_IF_SKIPPED;
// There may be secure stops, depending on if there were keys
// loaded and unloaded previously. Clear them to get to a known
// state, then make sure there are none.
@@ -510,6 +673,7 @@
* an empty ssid is provided.
*/
TEST_P(DrmHalVendorPluginTest, GetSecureStopEmptySSID) {
+ RETURN_IF_SKIPPED;
SecureStopId ssid;
auto res = drmPlugin->getSecureStop(
ssid, [&](Status status, const SecureStop&) {
@@ -523,6 +687,7 @@
* or is completed successfully
*/
TEST_P(DrmHalVendorPluginTest, ReleaseAllSecureStops) {
+ RETURN_IF_SKIPPED;
Status status = drmPlugin->releaseAllSecureStops();
EXPECT_TRUE(status == Status::OK ||
status == Status::ERROR_DRM_CANNOT_HANDLE);
@@ -534,6 +699,7 @@
* This is an optional API so it can also return CANNOT_HANDLE.
*/
TEST_P(DrmHalVendorPluginTest, ReleaseSecureStopSequenceError) {
+ RETURN_IF_SKIPPED;
SecureStopId ssid = {1, 2, 3, 4};
Status status = drmPlugin->releaseSecureStop(ssid);
EXPECT_TRUE(status == Status::ERROR_DRM_INVALID_STATE ||
@@ -546,6 +712,7 @@
* CANNOT_HANDLE.
*/
TEST_P(DrmHalVendorPluginTest, ReleaseSecureStopEmptySSID) {
+ RETURN_IF_SKIPPED;
SecureStopId ssid;
Status status = drmPlugin->releaseSecureStop(ssid);
EXPECT_TRUE(status == Status::BAD_VALUE ||
@@ -558,6 +725,7 @@
* the plugin.
*/
TEST_P(DrmHalVendorPluginTest, GetVendorProperty) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyString(
"vendor", [&](Status status, const hidl_string& value) {
EXPECT_EQ(Status::OK, status);
@@ -567,6 +735,7 @@
}
TEST_P(DrmHalVendorPluginTest, GetVersionProperty) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyString(
"version", [&](Status status, const hidl_string& value) {
EXPECT_EQ(Status::OK, status);
@@ -576,6 +745,7 @@
}
TEST_P(DrmHalVendorPluginTest, GetDescriptionProperty) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyString(
"description", [&](Status status, const hidl_string& value) {
EXPECT_EQ(Status::OK, status);
@@ -585,6 +755,7 @@
}
TEST_P(DrmHalVendorPluginTest, GetAlgorithmsProperty) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyString(
"algorithms", [&](Status status, const hidl_string& value) {
if (status == Status::OK) {
@@ -597,6 +768,7 @@
}
TEST_P(DrmHalVendorPluginTest, GetPropertyUniqueDeviceID) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyByteArray(
"deviceUniqueId",
[&](Status status, const hidl_vec<uint8_t>& value) {
@@ -614,6 +786,7 @@
* properties returns the documented error code.
*/
TEST_P(DrmHalVendorPluginTest, GetInvalidStringProperty) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyString(
"invalid", [&](Status status, const hidl_string&) {
EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status);
@@ -622,6 +795,7 @@
}
TEST_P(DrmHalVendorPluginTest, GetInvalidByteArrayProperty) {
+ RETURN_IF_SKIPPED;
auto res = drmPlugin->getPropertyByteArray(
"invalid", [&](Status status, const hidl_vec<uint8_t>&) {
EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status);
@@ -634,11 +808,13 @@
* the expected status value.
*/
TEST_P(DrmHalVendorPluginTest, SetStringPropertyNotSupported) {
+ RETURN_IF_SKIPPED;
EXPECT_EQ(drmPlugin->setPropertyString("awefijaeflijwef", "value"),
Status::ERROR_DRM_CANNOT_HANDLE);
}
TEST_P(DrmHalVendorPluginTest, SetByteArrayPropertyNotSupported) {
+ RETURN_IF_SKIPPED;
hidl_vec<uint8_t> value;
EXPECT_EQ(drmPlugin->setPropertyByteArray("awefijaeflijwef", value),
Status::ERROR_DRM_CANNOT_HANDLE);
@@ -649,6 +825,7 @@
* the expected status value.
*/
TEST_P(DrmHalVendorPluginTest, SetCipherInvalidAlgorithm) {
+ RETURN_IF_SKIPPED;
SessionId session = openSession();
hidl_string algorithm;
Status status = drmPlugin->setCipherAlgorithm(session, algorithm);
@@ -661,6 +838,7 @@
* the expected status value.
*/
TEST_P(DrmHalVendorPluginTest, SetCipherAlgorithmNoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_string algorithm = "AES/CBC/NoPadding";
Status status = drmPlugin->setCipherAlgorithm(session, algorithm);
@@ -674,6 +852,7 @@
* either accept it or return ERROR_DRM_CANNOT_HANDLE
*/
TEST_P(DrmHalVendorPluginTest, SetCipherAlgorithm) {
+ RETURN_IF_SKIPPED;
SessionId session = openSession();
;
hidl_string algorithm = "AES/CBC/NoPadding";
@@ -688,6 +867,7 @@
* the expected status value.
*/
TEST_P(DrmHalVendorPluginTest, SetMacInvalidAlgorithm) {
+ RETURN_IF_SKIPPED;
SessionId session = openSession();
hidl_string algorithm;
Status status = drmPlugin->setMacAlgorithm(session, algorithm);
@@ -700,6 +880,7 @@
* the expected status value.
*/
TEST_P(DrmHalVendorPluginTest, SetMacNullAlgorithmNoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_string algorithm = "HmacSHA256";
Status status = drmPlugin->setMacAlgorithm(session, algorithm);
@@ -713,6 +894,7 @@
* either accept it or return ERROR_DRM_CANNOT_HANDLE
*/
TEST_P(DrmHalVendorPluginTest, SetMacAlgorithm) {
+ RETURN_IF_SKIPPED;
SessionId session = openSession();
hidl_string algorithm = "HmacSHA256";
Status status = drmPlugin->setMacAlgorithm(session, algorithm);
@@ -733,6 +915,7 @@
* inputs, e.g. empty sessionId
*/
TEST_P(DrmHalVendorPluginTest, GenericEncryptNoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_vec<uint8_t> keyId, input, iv;
auto res = drmPlugin->encrypt(
@@ -744,6 +927,7 @@
}
TEST_P(DrmHalVendorPluginTest, GenericDecryptNoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_vec<uint8_t> keyId, input, iv;
auto res = drmPlugin->decrypt(
@@ -755,6 +939,7 @@
}
TEST_P(DrmHalVendorPluginTest, GenericSignNoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_vec<uint8_t> keyId, message;
auto res = drmPlugin->sign(
@@ -766,6 +951,7 @@
}
TEST_P(DrmHalVendorPluginTest, GenericVerifyNoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_vec<uint8_t> keyId, message, signature;
auto res = drmPlugin->verify(
@@ -776,6 +962,7 @@
}
TEST_P(DrmHalVendorPluginTest, GenericSignRSANoSession) {
+ RETURN_IF_SKIPPED;
SessionId session;
hidl_string algorithm;
hidl_vec<uint8_t> message, wrappedKey;
@@ -796,6 +983,7 @@
* Verify that requiresSecureDecoderComponent handles empty mimetype.
*/
TEST_P(DrmHalVendorPluginTest, RequiresSecureDecoderEmptyMimeType) {
+ RETURN_IF_SKIPPED;
EXPECT_FALSE(cryptoPlugin->requiresSecureDecoderComponent(""));
}
@@ -803,6 +991,7 @@
* Verify that requiresSecureDecoderComponent handles invalid mimetype.
*/
TEST_P(DrmHalVendorPluginTest, RequiresSecureDecoderInvalidMimeType) {
+ RETURN_IF_SKIPPED;
EXPECT_FALSE(cryptoPlugin->requiresSecureDecoderComponent("bad"));
}
@@ -811,7 +1000,7 @@
* configurations
*/
TEST_P(DrmHalVendorPluginTest, RequiresSecureDecoderConfig) {
- const char* kVendorStr = "Vendor module ";
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
for (auto key : config.keys) {
if (key.isSecure) {
@@ -825,92 +1014,82 @@
/**
* Event Handling tests
*/
+struct ListenerEventArgs {
+ EventType eventType;
+ SessionId sessionId;
+ hidl_vec<uint8_t> data;
+ int64_t expiryTimeInMS;
+ hidl_vec<KeyStatus> keyStatusList;
+ bool hasNewUsableKey;
+};
-class TestDrmPluginListener : public IDrmPluginListener {
+const char *kCallbackEvent = "SendEvent";
+const char *kCallbackExpirationUpdate = "SendExpirationUpdate";
+const char *kCallbackKeysChange = "SendKeysChange";
+
+class TestDrmPluginListener
+ : public ::testing::VtsHalHidlTargetCallbackBase<ListenerEventArgs>,
+ public IDrmPluginListener {
public:
- TestDrmPluginListener() {reset();}
+ TestDrmPluginListener() {
+ SetWaitTimeoutDefault(std::chrono::milliseconds(500));
+ }
virtual ~TestDrmPluginListener() {}
virtual Return<void> sendEvent(EventType eventType, const hidl_vec<uint8_t>& sessionId,
const hidl_vec<uint8_t>& data) override {
- eventType_ = eventType;
- sessionId_ = sessionId;
- data_ = data;
- gotEvent_ = true;
+ ListenerEventArgs args;
+ args.eventType = eventType;
+ args.sessionId = sessionId;
+ args.data = data;
+ NotifyFromCallback(kCallbackEvent, args);
return Void();
}
virtual Return<void> sendExpirationUpdate(const hidl_vec<uint8_t>& sessionId,
int64_t expiryTimeInMS) override {
- sessionId_ = sessionId;
- expiryTimeInMS_ = expiryTimeInMS;
- gotExpirationUpdate_ = true;
+ ListenerEventArgs args;
+ args.sessionId = sessionId;
+ args.expiryTimeInMS = expiryTimeInMS;
+ NotifyFromCallback(kCallbackExpirationUpdate, args);
return Void();
}
virtual Return<void> sendKeysChange(const hidl_vec<uint8_t>& sessionId,
const hidl_vec<KeyStatus>& keyStatusList, bool hasNewUsableKey) override {
- sessionId_ = sessionId;
- keyStatusList_ = keyStatusList;
- hasNewUsableKey_ = hasNewUsableKey;
- gotKeysChange_ = true;
+ ListenerEventArgs args;
+ args.sessionId = sessionId;
+ args.keyStatusList = keyStatusList;
+ args.hasNewUsableKey = hasNewUsableKey;
+ NotifyFromCallback(kCallbackKeysChange, args);
return Void();
}
-
- EventType getEventType() const {return eventType_;}
- SessionId getSessionId() const {return sessionId_;}
- vector<uint8_t> getData() const {return data_;}
- int64_t getExpiryTimeInMS() const {return expiryTimeInMS_;}
- hidl_vec<KeyStatus> getKeyStatusList() const {return keyStatusList_;}
- bool hasNewUsableKey() {return hasNewUsableKey_;}
- bool gotEvent() {return gotEvent_;}
- bool gotExpirationUpdate() {return gotExpirationUpdate_;}
- bool gotKeysChange() {return gotKeysChange_;}
-
- void reset() {
- gotEvent_ = gotExpirationUpdate_ = gotKeysChange_ = false;
- eventType_ = EventType::PROVISION_REQUIRED;
- sessionId_ = SessionId();
- data_ = hidl_vec<uint8_t>();
- expiryTimeInMS_ = 0;
- keyStatusList_ = hidl_vec<KeyStatus>();
- hasNewUsableKey_ = false;
- }
-
-private:
- bool gotEvent_;
- bool gotExpirationUpdate_;
- bool gotKeysChange_;
-
- EventType eventType_;
- SessionId sessionId_;
- hidl_vec<uint8_t> data_;
- int64_t expiryTimeInMS_;
- hidl_vec<KeyStatus> keyStatusList_;
- bool hasNewUsableKey_;
};
+
/**
* Simulate the plugin sending events. Make sure the listener
* gets them.
*/
TEST_P(DrmHalVendorPluginTest, ListenerEvents) {
+ RETURN_IF_SKIPPED;
sp<TestDrmPluginListener> listener = new TestDrmPluginListener();
drmPlugin->setListener(listener);
auto sessionId = openSession();
- vector<uint8_t> data = {0, 1, 2};
+ hidl_vec<uint8_t> data = {0, 1, 2};
EventType eventTypes[] = {EventType::PROVISION_REQUIRED,
EventType::KEY_NEEDED,
EventType::KEY_EXPIRED,
EventType::VENDOR_DEFINED,
EventType::SESSION_RECLAIMED};
for (auto eventType : eventTypes) {
- listener->reset();
drmPlugin->sendEvent(eventType, sessionId, data);
- while (!listener->gotEvent()) {usleep(100);}
- EXPECT_EQ(eventType, listener->getEventType());
- EXPECT_EQ(sessionId, listener->getSessionId());
- EXPECT_EQ(data, listener->getData());
+ auto result = listener->WaitForCallback(kCallbackEvent);
+ EXPECT_TRUE(result.no_timeout);
+ EXPECT_TRUE(result.args);
+ EXPECT_EQ(eventType, result.args->eventType);
+ EXPECT_EQ(sessionId, result.args->sessionId);
+ EXPECT_EQ(data, result.args->data);
}
closeSession(sessionId);
}
@@ -920,13 +1099,16 @@
* the listener gets them.
*/
TEST_P(DrmHalVendorPluginTest, ListenerExpirationUpdate) {
+ RETURN_IF_SKIPPED;
sp<TestDrmPluginListener> listener = new TestDrmPluginListener();
drmPlugin->setListener(listener);
auto sessionId = openSession();
drmPlugin->sendExpirationUpdate(sessionId, 100);
- while (!listener->gotExpirationUpdate()) {usleep(100);}
- EXPECT_EQ(sessionId, listener->getSessionId());
- EXPECT_EQ(100, listener->getExpiryTimeInMS());
+ auto result = listener->WaitForCallback(kCallbackExpirationUpdate);
+ EXPECT_TRUE(result.no_timeout);
+ EXPECT_TRUE(result.args);
+ EXPECT_EQ(sessionId, result.args->sessionId);
+ EXPECT_EQ(100, result.args->expiryTimeInMS);
closeSession(sessionId);
}
@@ -935,6 +1117,7 @@
* the listener gets them.
*/
TEST_P(DrmHalVendorPluginTest, ListenerKeysChange) {
+ RETURN_IF_SKIPPED;
sp<TestDrmPluginListener> listener = new TestDrmPluginListener();
drmPlugin->setListener(listener);
auto sessionId = openSession();
@@ -947,10 +1130,12 @@
};
drmPlugin->sendKeysChange(sessionId, keyStatusList, true);
- while (!listener->gotKeysChange()) {usleep(100);}
- EXPECT_EQ(sessionId, listener->getSessionId());
- EXPECT_EQ(keyStatusList, listener->getKeyStatusList());
- EXPECT_EQ(true, listener->hasNewUsableKey());
+ auto result = listener->WaitForCallback(kCallbackKeysChange);
+ EXPECT_TRUE(result.no_timeout);
+ EXPECT_TRUE(result.args);
+ EXPECT_EQ(sessionId, result.args->sessionId);
+ EXPECT_EQ(keyStatusList, result.args->keyStatusList);
+ closeSession(sessionId);
}
/**
@@ -958,20 +1143,20 @@
* listener set.
*/
TEST_P(DrmHalVendorPluginTest, NotListening) {
+ RETURN_IF_SKIPPED;
sp<TestDrmPluginListener> listener = new TestDrmPluginListener();
drmPlugin->setListener(listener);
drmPlugin->setListener(nullptr);
SessionId sessionId;
- vector<uint8_t> data;
+ hidl_vec<uint8_t> data;
hidl_vec<KeyStatus> keyStatusList;
drmPlugin->sendEvent(EventType::PROVISION_REQUIRED, sessionId, data);
drmPlugin->sendExpirationUpdate(sessionId, 100);
drmPlugin->sendKeysChange(sessionId, keyStatusList, true);
- usleep(1000); // can't wait for the event to be recieved, just wait a long time
- EXPECT_EQ(false, listener->gotEvent());
- EXPECT_EQ(false, listener->gotExpirationUpdate());
- EXPECT_EQ(false, listener->gotKeysChange());
+ auto result = listener->WaitForCallbackAny(
+ {kCallbackEvent, kCallbackExpirationUpdate, kCallbackKeysChange});
+ EXPECT_FALSE(result.no_timeout);
}
@@ -984,6 +1169,7 @@
* just call the method for coverage.
*/
TEST_P(DrmHalVendorPluginTest, NotifyResolution) {
+ RETURN_IF_SKIPPED;
cryptoPlugin->notifyResolution(1920, 1080);
}
@@ -1023,6 +1209,7 @@
* is used to associate a drm session with a crypto session.
*/
TEST_P(DrmHalVendorPluginTest, SetMediaDrmSession) {
+ RETURN_IF_SKIPPED;
auto sessionId = openSession();
Status status = cryptoPlugin->setMediaDrmSession(sessionId);
EXPECT_EQ(Status::OK, status);
@@ -1033,6 +1220,7 @@
* setMediaDrmSession with a closed session id
*/
TEST_P(DrmHalVendorPluginTest, SetMediaDrmSessionClosedSession) {
+ RETURN_IF_SKIPPED;
auto sessionId = openSession();
closeSession(sessionId);
Status status = cryptoPlugin->setMediaDrmSession(sessionId);
@@ -1043,6 +1231,7 @@
* setMediaDrmSession with a empty session id: BAD_VALUE
*/
TEST_P(DrmHalVendorPluginTest, SetMediaDrmSessionEmptySession) {
+ RETURN_IF_SKIPPED;
SessionId sessionId;
Status status = cryptoPlugin->setMediaDrmSession(sessionId);
EXPECT_EQ(Status::BAD_VALUE, status);
@@ -1058,10 +1247,7 @@
virtual ~DrmHalVendorDecryptTest() {}
protected:
- void loadKeys(const SessionId& sessionId,
- const ContentConfiguration& configuration);
void fillRandom(const sp<IMemory>& memory);
- KeyedVector toHidlKeyedVector(const map<string, string>& params);
hidl_array<uint8_t, 16> toHidlArray(const vector<uint8_t>& vec) {
EXPECT_EQ(vec.size(), 16u);
return hidl_array<uint8_t, 16>(&vec[0]);
@@ -1078,63 +1264,6 @@
const hidl_vec<SubSample>& subSamples, const vector<uint8_t>& key);
};
-KeyedVector DrmHalVendorDecryptTest::toHidlKeyedVector(
- const map<string, string>& params) {
- std::vector<KeyValue> stdKeyedVector;
- for (auto it = params.begin(); it != params.end(); ++it) {
- KeyValue keyValue;
- keyValue.key = it->first;
- keyValue.value = it->second;
- stdKeyedVector.push_back(keyValue);
- }
- return KeyedVector(stdKeyedVector);
-}
-
-/**
- * Helper method to load keys for subsequent decrypt tests.
- * These tests use predetermined key request/response to
- * avoid requiring a round trip to a license server.
- */
-void DrmHalVendorDecryptTest::loadKeys(const SessionId& sessionId,
- const ContentConfiguration& configuration) {
- hidl_vec<uint8_t> keyRequest;
- auto res = drmPlugin->getKeyRequest(
- sessionId, configuration.initData, configuration.mimeType,
- KeyType::STREAMING,
- toHidlKeyedVector(configuration.optionalParameters),
- [&](Status status, const hidl_vec<uint8_t>& request,
- KeyRequestType type, const hidl_string&) {
- EXPECT_EQ(Status::OK, status)
- << "Failed to get "
- "key request for configuration "
- << configuration.name;
- EXPECT_EQ(type, KeyRequestType::INITIAL);
- EXPECT_NE(request.size(), 0u) << "Expected key request size"
- " to have length > 0 bytes";
- keyRequest = request;
- });
- EXPECT_OK(res);
-
- /**
- * Get key response from vendor module
- */
- hidl_vec<uint8_t> keyResponse =
- vendorModule->handleKeyRequest(keyRequest, configuration.serverUrl);
-
- EXPECT_NE(keyResponse.size(), 0u) << "Expected key response size "
- "to have length > 0 bytes";
-
- res = drmPlugin->provideKeyResponse(
- sessionId, keyResponse,
- [&](Status status, const hidl_vec<uint8_t>&) {
- EXPECT_EQ(Status::OK, status)
- << "Failure providing "
- "key response for configuration "
- << configuration.name;
- });
- EXPECT_OK(res);
-}
-
void DrmHalVendorDecryptTest::fillRandom(const sp<IMemory>& memory) {
random_device rd;
mt19937 rand(rd());
@@ -1296,6 +1425,7 @@
* Test key status with empty session id, should return BAD_VALUE
*/
TEST_P(DrmHalVendorDecryptTest, QueryKeyStatusInvalidSession) {
+ RETURN_IF_SKIPPED;
SessionId sessionId;
auto res = drmPlugin->queryKeyStatus(sessionId,
[&](Status status, KeyedVector /* info */) {
@@ -1309,6 +1439,7 @@
* Test key status. There should be no key status prior to loading keys
*/
TEST_P(DrmHalVendorDecryptTest, QueryKeyStatusWithNoKeys) {
+ RETURN_IF_SKIPPED;
auto sessionId = openSession();
auto keyStatus = queryKeyStatus(sessionId);
EXPECT_EQ(0u, keyStatus.size());
@@ -1320,6 +1451,7 @@
* Test key status. There should be key status after loading keys.
*/
TEST_P(DrmHalVendorDecryptTest, QueryKeyStatus) {
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
auto sessionId = openSession();
loadKeys(sessionId, config);
@@ -1333,6 +1465,7 @@
* Positive decrypt test. "Decrypt" a single clear segment and verify.
*/
TEST_P(DrmHalVendorDecryptTest, ClearSegmentTest) {
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
for (auto key : config.keys) {
const size_t kSegmentSize = 1024;
@@ -1360,6 +1493,7 @@
* Verify data matches.
*/
TEST_P(DrmHalVendorDecryptTest, EncryptedAesCtrSegmentTest) {
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
for (auto key : config.keys) {
const size_t kSegmentSize = 1024;
@@ -1386,6 +1520,7 @@
* Negative decrypt test. Decrypt without loading keys.
*/
TEST_P(DrmHalVendorDecryptTest, EncryptedAesCtrSegmentTestNoKeys) {
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
for (auto key : config.keys) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
@@ -1412,6 +1547,7 @@
* decryption can't be performed.
*/
TEST_P(DrmHalVendorDecryptTest, AttemptDecryptWithKeysRemoved) {
+ RETURN_IF_SKIPPED;
for (auto config : contentConfigurations) {
for (auto key : config.keys) {
vector<uint8_t> iv(AES_BLOCK_SIZE, 0);
@@ -1428,7 +1564,7 @@
uint32_t byteCount = decrypt(Mode::AES_CTR, key.isSecure,
toHidlArray(key.keyId), &iv[0], subSamples, noPattern,
- key.clearContentKey, Status::ERROR_DRM_DECRYPT);
+ key.clearContentKey, Status::ERROR_DRM_NO_LICENSE);
EXPECT_EQ(0u, byteCount);
closeSession(sessionId);
diff --git a/dumpstate/1.0/Android.bp b/dumpstate/1.0/Android.bp
index 1b473bc..df028b49 100644
--- a/dumpstate/1.0/Android.bp
+++ b/dumpstate/1.0/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.dumpstate@1.0_genc++"],
generated_headers: ["android.hardware.dumpstate@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.dumpstate@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/dumpstate/1.0/default/DumpstateDevice.cpp b/dumpstate/1.0/default/DumpstateDevice.cpp
index 8000d85..213fc62 100644
--- a/dumpstate/1.0/default/DumpstateDevice.cpp
+++ b/dumpstate/1.0/default/DumpstateDevice.cpp
@@ -52,7 +52,7 @@
dprintf(fd, "Dumpstate HIDL not provided by device; providing bogus data.\n");
// Shows some examples on how to use the libdumpstateutil API.
- RunCommandToFd(fd, "DATE", {"/system/bin/date"});
+ RunCommandToFd(fd, "DATE", {"/vendor/bin/date"});
DumpFileToFd(fd, "HOSTS", "/system/etc/hosts");
return Void();
diff --git a/gatekeeper/1.0/Android.bp b/gatekeeper/1.0/Android.bp
index 56e19db..eddf0e5 100644
--- a/gatekeeper/1.0/Android.bp
+++ b/gatekeeper/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.gatekeeper@1.0_genc++"],
generated_headers: ["android.hardware.gatekeeper@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.gatekeeper@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/gatekeeper/1.0/Android.mk b/gatekeeper/1.0/Android.mk
index 70206ff..576f729 100644
--- a/gatekeeper/1.0/Android.mk
+++ b/gatekeeper/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gatekeeper@1.0-java
+LOCAL_MODULE := android.hardware.gatekeeper-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -80,7 +80,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gatekeeper@1.0-java-static
+LOCAL_MODULE := android.hardware.gatekeeper-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -88,7 +88,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/gnss/1.0/Android.bp b/gnss/1.0/Android.bp
index ed6659d..42f35b8 100644
--- a/gnss/1.0/Android.bp
+++ b/gnss/1.0/Android.bp
@@ -177,6 +177,7 @@
generated_sources: ["android.hardware.gnss@1.0_genc++"],
generated_headers: ["android.hardware.gnss@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.gnss@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/gnss/1.0/Android.mk b/gnss/1.0/Android.mk
index 5985c87..bb1b765 100644
--- a/gnss/1.0/Android.mk
+++ b/gnss/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.0-java
+LOCAL_MODULE := android.hardware.gnss-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -527,7 +527,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.0-java-static
+LOCAL_MODULE := android.hardware.gnss-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -535,7 +535,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -1049,7 +1049,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.0-java-constants
+LOCAL_MODULE := android.hardware.gnss-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/gnss/1.0/default/Android.mk b/gnss/1.0/default/Android.mk
index 5ad5e50..dd0ebe9 100644
--- a/gnss/1.0/default/Android.mk
+++ b/gnss/1.0/default/Android.mk
@@ -47,6 +47,7 @@
libutils \
libhardware_legacy \
libhardware \
+ libbinder \
LOCAL_SHARED_LIBRARIES += \
libhidlbase \
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 f1116f4..96638a3 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,7 +1,4 @@
service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service
class main
user system
-#
-# TODO:(b/35757613) - STOPSHIP - HAL cannot have direct inet access
-#
- group system inet
+ group system gps
diff --git a/gnss/1.0/default/service.cpp b/gnss/1.0/default/service.cpp
index 5a8acc1..0704e7f 100644
--- a/gnss/1.0/default/service.cpp
+++ b/gnss/1.0/default/service.cpp
@@ -4,9 +4,14 @@
#include <hidl/LegacySupport.h>
+#include <binder/ProcessState.h>
+
using android::hardware::gnss::V1_0::IGnss;
using android::hardware::defaultPassthroughServiceImplementation;
int main() {
+ // The GNSS HAL may communicate to other vendor components via
+ // /dev/vndbinder
+ android::ProcessState::initWithDriver("/dev/vndbinder");
return defaultPassthroughServiceImplementation<IGnss>();
}
diff --git a/graphics/Android.bp b/graphics/Android.bp
index f4f7db4..9aea85f 100644
--- a/graphics/Android.bp
+++ b/graphics/Android.bp
@@ -2,7 +2,6 @@
subdirs = [
"allocator/2.0",
"allocator/2.0/default",
- "allocator/2.0/vts/functional",
"bufferqueue/1.0",
"common/1.0",
"composer/2.1",
diff --git a/graphics/allocator/2.0/Android.bp b/graphics/allocator/2.0/Android.bp
index 271f2ce..77a3f70 100644
--- a/graphics/allocator/2.0/Android.bp
+++ b/graphics/allocator/2.0/Android.bp
@@ -3,9 +3,7 @@
filegroup {
name: "android.hardware.graphics.allocator@2.0_hal",
srcs: [
- "types.hal",
"IAllocator.hal",
- "IAllocatorClient.hal",
],
}
@@ -17,9 +15,7 @@
":android.hardware.graphics.allocator@2.0_hal",
],
out: [
- "android/hardware/graphics/allocator/2.0/types.cpp",
"android/hardware/graphics/allocator/2.0/AllocatorAll.cpp",
- "android/hardware/graphics/allocator/2.0/AllocatorClientAll.cpp",
],
}
@@ -31,18 +27,11 @@
":android.hardware.graphics.allocator@2.0_hal",
],
out: [
- "android/hardware/graphics/allocator/2.0/types.h",
- "android/hardware/graphics/allocator/2.0/hwtypes.h",
"android/hardware/graphics/allocator/2.0/IAllocator.h",
"android/hardware/graphics/allocator/2.0/IHwAllocator.h",
"android/hardware/graphics/allocator/2.0/BnHwAllocator.h",
"android/hardware/graphics/allocator/2.0/BpHwAllocator.h",
"android/hardware/graphics/allocator/2.0/BsAllocator.h",
- "android/hardware/graphics/allocator/2.0/IAllocatorClient.h",
- "android/hardware/graphics/allocator/2.0/IHwAllocatorClient.h",
- "android/hardware/graphics/allocator/2.0/BnHwAllocatorClient.h",
- "android/hardware/graphics/allocator/2.0/BpHwAllocatorClient.h",
- "android/hardware/graphics/allocator/2.0/BsAllocatorClient.h",
],
}
@@ -51,6 +40,7 @@
generated_sources: ["android.hardware.graphics.allocator@2.0_genc++"],
generated_headers: ["android.hardware.graphics.allocator@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.graphics.allocator@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
@@ -59,6 +49,7 @@
"libutils",
"libcutils",
"android.hardware.graphics.common@1.0",
+ "android.hardware.graphics.mapper@2.0",
"android.hidl.base@1.0",
],
export_shared_lib_headers: [
@@ -67,6 +58,7 @@
"libhwbinder",
"libutils",
"android.hardware.graphics.common@1.0",
+ "android.hardware.graphics.mapper@2.0",
"android.hidl.base@1.0",
],
}
diff --git a/graphics/allocator/2.0/IAllocator.hal b/graphics/allocator/2.0/IAllocator.hal
index bf0e141..43a3916 100644
--- a/graphics/allocator/2.0/IAllocator.hal
+++ b/graphics/allocator/2.0/IAllocator.hal
@@ -16,38 +16,9 @@
package android.hardware.graphics.allocator@2.0;
-import IAllocatorClient;
+import android.hardware.graphics.mapper@2.0;
interface IAllocator {
- enum Capability : int32_t {
- /** reserved */
- INVALID = 0,
-
- /**
- * IAllocatorClient::testAllocate must always return UNDEFINED unless
- * this capability is supported.
- */
- TEST_ALLOCATE = 1,
-
- /**
- * IAllocatorClient::BufferDescriptorInfo::layerCount must be 1 unless
- * this capability is supported.
- */
- LAYERED_BUFFERS = 2,
- };
-
- /**
- * Provides a list of supported capabilities (as described in the
- * definition of Capability above). This list must not change after
- * initialization.
- *
- * @return capabilities is a list of supported capabilities.
- */
- @entry
- @exit
- @callflow(next="*")
- getCapabilities() generates (vec<Capability> capabilities);
-
/**
* Retrieves implementation-defined debug information, which will be
* displayed during, for example, `dumpsys SurfaceFlinger`.
@@ -60,15 +31,27 @@
dumpDebugInfo() generates (string debugInfo);
/**
- * Creates a client of the allocator. All resources created by the client
- * are owned by the client and are only visible to the client, unless they
- * are exported by exportHandle.
+ * Allocates buffers with the properties specified by the descriptor.
*
+ * @param descriptor specifies the properties of the buffers to allocate.
+ * @param count is the number of buffers to allocate.
* @return error is NONE upon success. Otherwise,
- * NO_RESOURCES when no more client can currently be created.
- * @return client is the newly created client.
+ * BAD_DESCRIPTOR when the descriptor is invalid.
+ * NO_RESOURCES when the allocation cannot be fulfilled at this
+ * time.
+ * UNSUPPORTED when any of the property encoded in the descriptor
+ * is not supported.
+ * @return stride is the number of pixels between two consecutive rows of
+ * the buffers, when the concept of consecutive rows is defined.
+ * Otherwise, it has no meaning.
+ * @return buffers is an array of raw handles to the newly allocated
+ * buffers.
*/
@entry
+ @exit
@callflow(next="*")
- createClient() generates (Error error, IAllocatorClient client);
+ allocate(BufferDescriptor descriptor, uint32_t count)
+ generates (Error error,
+ uint32_t stride,
+ vec<handle> buffers);
};
diff --git a/graphics/allocator/2.0/IAllocatorClient.hal b/graphics/allocator/2.0/IAllocatorClient.hal
deleted file mode 100644
index 8ca568f..0000000
--- a/graphics/allocator/2.0/IAllocatorClient.hal
+++ /dev/null
@@ -1,165 +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.
- */
-
-package android.hardware.graphics.allocator@2.0;
-
-import android.hardware.graphics.common@1.0::PixelFormat;
-
-interface IAllocatorClient {
- struct BufferDescriptorInfo {
- /**
- * The width specifies how many columns of pixels must be in the
- * allocated buffer, but does not necessarily represent the offset in
- * columns between the same column in adjacent rows. The rows may be
- * padded.
- */
- uint32_t width;
-
- /**
- * The height specifies how many rows of pixels must be in the
- * allocated buffer.
- */
- uint32_t height;
-
- /**
- * The number of image layers that must be in the allocated buffer.
- */
- uint32_t layerCount;
-
- /** Buffer pixel format. */
- PixelFormat format;
-
- /**
- * Buffer producer usage mask; valid flags can be found in the
- * definition of ProducerUsage.
- */
- uint64_t producerUsageMask;
-
- /**
- * Buffer consumer usage mask; valid flags can be found in the
- * definition of ConsumerUsage.
- */
- uint64_t consumerUsageMask;
- };
-
- /**
- * Creates a new, opaque buffer descriptor.
- *
- * @param descriptorInfo specifies the attributes of the buffer
- * descriptor.
- * @return error is NONE upon success. Otherwise,
- * BAD_VALUE when any attribute in descriptorInfo is invalid.
- * NO_RESOURCES when no more descriptors can currently be created.
- * @return descriptor is the newly created buffer descriptor.
- */
- @entry
- @callflow(next="*")
- createDescriptor(BufferDescriptorInfo descriptorInfo)
- generates (Error error,
- BufferDescriptor descriptor);
-
- /**
- * Destroys an existing buffer descriptor.
- *
- * @param descriptor is the descriptor to destroy.
- * @return error is either NONE or BAD_DESCRIPTOR.
- */
- @exit
- @callflow(next="*")
- destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
-
- /**
- * Tests whether a buffer allocation can succeed, ignoring potential
- * resource contention which might lead to a NO_RESOURCES error.
- *
- * @param descriptors is a list of buffer descriptors.
- * @return error is NONE or NOT_SHARED upon success;
- * NONE when buffers can be created and share a backing store.
- * NOT_SHARED when buffers can be created but require more than a
- * backing store.
- * Otherwise,
- * BAD_DESCRIPTOR when any of the descriptors is invalid.
- * UNSUPPORTED when any of the descriptors can never be satisfied.
- * UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
- */
- @callflow(next="allocate")
- testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
-
- /**
- * Attempts to allocate a list of buffers sharing a backing store.
- *
- * Each buffer must correspond to one of the descriptors passed into the
- * function and must hold a reference to its backing store. If the device
- * is unable to share the backing store between the buffers, it must
- * attempt to allocate the buffers with different backing stores and
- * return NOT_SHARED if it is successful.
- *
- * @param descriptors is the buffer descriptors to attempt to allocate.
- * @return error is NONE or NOT_SHARED upon success;
- * NONE when buffers can be created and share a backing store.
- * NOT_SHARED when buffers can be created but require more than a
- * backing store.
- * Otherwise,
- * BAD_DESCRIPTOR when any of the descriptors is invalid.
- * UNSUPPORTED when any of the descriptors can never be satisfied.
- * NO_RESOURCES when any of the buffers cannot be created at this
- * time.
- * @return buffers is the allocated buffers.
- */
- @callflow(next="exportHandle")
- allocate(vec<BufferDescriptor> descriptors)
- generates (Error error,
- vec<Buffer> buffers);
-
- /**
- * Frees a buffer.
- *
- * @param buffer is the buffer to be freed.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer is invalid.
- */
- @exit
- @callflow(next="*")
- free(Buffer buffer) generates (Error error);
-
- /**
- * Exports a buffer for use in other client libraries or for cross-process
- * sharing.
- *
- * The exported handle is a handle to the backing store of the buffer, not
- * to the buffer itself. It however may not hold any reference to the
- * backing store and may be considered invalid by client libraries. To use
- * it and, in most cases, to save it for later use, a client must make a
- * clone of the handle and have the cloned handle hold a reference to the
- * backing store. Such a cloned handle will stay valid even after the
- * original buffer is freed. Refer to native_handle_clone and IMapper for
- * how a handle is cloned and how a reference is added.
- *
- * @param descriptor is the descriptor used to allocate the buffer.
- * @param buffer is the buffer to be exported.
- * @return error is NONE upon success. Otherwise,
- * BAD_DESCRIPTOR when the descriptor is invalid.
- * BAD_BUFFER when the buffer is invalid.
- * BAD_VALUE when descriptor and buffer do not match.
- * NO_RESOURCES when the buffer cannot be exported at this time.
- * @return bufferHandle is the exported handle.
- */
- @callflow(next="free")
- exportHandle(BufferDescriptor descriptor,
- Buffer buffer)
- generates (Error error,
- handle bufferHandle);
-};
diff --git a/graphics/allocator/2.0/default/Android.bp b/graphics/allocator/2.0/default/Android.bp
index 0baef89..4a7cfe0 100644
--- a/graphics/allocator/2.0/default/Android.bp
+++ b/graphics/allocator/2.0/default/Android.bp
@@ -3,7 +3,7 @@
defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
- srcs: ["Gralloc.cpp"],
+ srcs: ["Gralloc.cpp", "Gralloc0Allocator.cpp", "Gralloc1Allocator.cpp"],
cppflags: ["-Wall", "-Wextra"],
shared_libs: [
"android.hardware.graphics.allocator@2.0",
@@ -15,6 +15,9 @@
"liblog",
"libutils",
],
+ header_libs: [
+ "libgrallocmapperincludes",
+ ],
}
cc_binary {
diff --git a/graphics/allocator/2.0/default/Gralloc.cpp b/graphics/allocator/2.0/default/Gralloc.cpp
index 0b9e863..273d3f5 100644
--- a/graphics/allocator/2.0/default/Gralloc.cpp
+++ b/graphics/allocator/2.0/default/Gralloc.cpp
@@ -16,17 +16,11 @@
#define LOG_TAG "GrallocPassthrough"
-#include <mutex>
-#include <type_traits>
-#include <unordered_set>
-#include <vector>
-
-#include <string.h>
-
-#include <hardware/gralloc1.h>
-#include <log/log.h>
-
#include "Gralloc.h"
+#include "Gralloc0Allocator.h"
+#include "Gralloc1Allocator.h"
+
+#include <log/log.h>
namespace android {
namespace hardware {
@@ -35,417 +29,6 @@
namespace V2_0 {
namespace implementation {
-class GrallocHal : public IAllocator {
-public:
- GrallocHal(const hw_module_t* module);
- virtual ~GrallocHal();
-
- // IAllocator interface
- Return<void> getCapabilities(getCapabilities_cb hidl_cb) override;
- Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
- Return<void> createClient(createClient_cb hidl_cb) override;
-
- Error createDescriptor(
- const IAllocatorClient::BufferDescriptorInfo& descriptorInfo,
- BufferDescriptor* outDescriptor);
- Error destroyDescriptor(BufferDescriptor descriptor);
-
- Error testAllocate(const hidl_vec<BufferDescriptor>& descriptors);
- Error allocate(const hidl_vec<BufferDescriptor>& descriptors,
- hidl_vec<Buffer>* outBuffers);
- Error free(Buffer buffer);
-
- Error exportHandle(Buffer buffer, const native_handle_t** outHandle);
-
-private:
- void initCapabilities();
-
- template<typename T>
- void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
- void initDispatch();
-
- bool hasCapability(Capability capability) const;
-
- gralloc1_device_t* mDevice;
-
- std::unordered_set<Capability> mCapabilities;
-
- struct {
- GRALLOC1_PFN_DUMP dump;
- GRALLOC1_PFN_CREATE_DESCRIPTOR createDescriptor;
- GRALLOC1_PFN_DESTROY_DESCRIPTOR destroyDescriptor;
- GRALLOC1_PFN_SET_DIMENSIONS setDimensions;
- GRALLOC1_PFN_SET_FORMAT setFormat;
- GRALLOC1_PFN_SET_LAYER_COUNT setLayerCount;
- GRALLOC1_PFN_SET_CONSUMER_USAGE setConsumerUsage;
- GRALLOC1_PFN_SET_PRODUCER_USAGE setProducerUsage;
- GRALLOC1_PFN_ALLOCATE allocate;
- GRALLOC1_PFN_RELEASE release;
- } mDispatch;
-};
-
-class GrallocClient : public IAllocatorClient {
-public:
- GrallocClient(GrallocHal& hal);
- virtual ~GrallocClient();
-
- // IAllocatorClient interface
- Return<void> createDescriptor(const BufferDescriptorInfo& descriptorInfo,
- createDescriptor_cb hidl_cb) override;
- Return<Error> destroyDescriptor(BufferDescriptor descriptor) override;
-
- Return<Error> testAllocate(
- const hidl_vec<BufferDescriptor>& descriptors) override;
- Return<void> allocate(const hidl_vec<BufferDescriptor>& descriptors,
- allocate_cb hidl_cb) override;
- Return<Error> free(Buffer buffer) override;
-
- Return<void> exportHandle(BufferDescriptor descriptor,
- Buffer buffer, exportHandle_cb hidl_cb) override;
-
-private:
- GrallocHal& mHal;
-
- std::mutex mMutex;
- std::unordered_set<BufferDescriptor> mDescriptors;
- std::unordered_set<Buffer> mBuffers;
-};
-
-GrallocHal::GrallocHal(const hw_module_t* module)
- : mDevice(nullptr), mDispatch()
-{
- int status = gralloc1_open(module, &mDevice);
- if (status) {
- LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s",
- strerror(-status));
- }
-
- initCapabilities();
- initDispatch();
-}
-
-GrallocHal::~GrallocHal()
-{
- gralloc1_close(mDevice);
-}
-
-void GrallocHal::initCapabilities()
-{
- uint32_t count = 0;
- mDevice->getCapabilities(mDevice, &count, nullptr);
-
- std::vector<Capability> caps(count);
- mDevice->getCapabilities(mDevice, &count, reinterpret_cast<
- std::underlying_type<Capability>::type*>(caps.data()));
- caps.resize(count);
-
- mCapabilities.insert(caps.cbegin(), caps.cend());
-}
-
-template<typename T>
-void GrallocHal::initDispatch(gralloc1_function_descriptor_t desc, T* outPfn)
-{
- auto pfn = mDevice->getFunction(mDevice, desc);
- if (!pfn) {
- LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc);
- }
-
- *outPfn = reinterpret_cast<T>(pfn);
-}
-
-void GrallocHal::initDispatch()
-{
- initDispatch(GRALLOC1_FUNCTION_DUMP, &mDispatch.dump);
- initDispatch(GRALLOC1_FUNCTION_CREATE_DESCRIPTOR,
- &mDispatch.createDescriptor);
- initDispatch(GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR,
- &mDispatch.destroyDescriptor);
- initDispatch(GRALLOC1_FUNCTION_SET_DIMENSIONS, &mDispatch.setDimensions);
- initDispatch(GRALLOC1_FUNCTION_SET_FORMAT, &mDispatch.setFormat);
- if (hasCapability(Capability::LAYERED_BUFFERS)) {
- initDispatch(GRALLOC1_FUNCTION_SET_LAYER_COUNT,
- &mDispatch.setLayerCount);
- }
- initDispatch(GRALLOC1_FUNCTION_SET_CONSUMER_USAGE,
- &mDispatch.setConsumerUsage);
- initDispatch(GRALLOC1_FUNCTION_SET_PRODUCER_USAGE,
- &mDispatch.setProducerUsage);
- initDispatch(GRALLOC1_FUNCTION_ALLOCATE, &mDispatch.allocate);
- initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release);
-}
-
-bool GrallocHal::hasCapability(Capability capability) const
-{
- return (mCapabilities.count(capability) > 0);
-}
-
-Return<void> GrallocHal::getCapabilities(getCapabilities_cb hidl_cb)
-{
- std::vector<Capability> caps(
- mCapabilities.cbegin(), mCapabilities.cend());
-
- hidl_vec<Capability> reply;
- reply.setToExternal(caps.data(), caps.size());
- hidl_cb(reply);
-
- return Void();
-}
-
-Return<void> GrallocHal::dumpDebugInfo(dumpDebugInfo_cb hidl_cb)
-{
- uint32_t len = 0;
- mDispatch.dump(mDevice, &len, nullptr);
-
- std::vector<char> buf(len + 1);
- mDispatch.dump(mDevice, &len, buf.data());
- buf.resize(len + 1);
- buf[len] = '\0';
-
- hidl_string reply;
- reply.setToExternal(buf.data(), len);
- hidl_cb(reply);
-
- return Void();
-}
-
-Return<void> GrallocHal::createClient(createClient_cb hidl_cb)
-{
- sp<IAllocatorClient> client = new GrallocClient(*this);
- hidl_cb(Error::NONE, client);
-
- return Void();
-}
-
-Error GrallocHal::createDescriptor(
- const IAllocatorClient::BufferDescriptorInfo& descriptorInfo,
- BufferDescriptor* outDescriptor)
-{
- gralloc1_buffer_descriptor_t descriptor;
- int32_t err = mDispatch.createDescriptor(mDevice, &descriptor);
- if (err != GRALLOC1_ERROR_NONE) {
- return static_cast<Error>(err);
- }
-
- err = mDispatch.setDimensions(mDevice, descriptor,
- descriptorInfo.width, descriptorInfo.height);
- if (err == GRALLOC1_ERROR_NONE) {
- err = mDispatch.setFormat(mDevice, descriptor,
- static_cast<int32_t>(descriptorInfo.format));
- }
- if (err == GRALLOC1_ERROR_NONE) {
- if (hasCapability(Capability::LAYERED_BUFFERS)) {
- err = mDispatch.setLayerCount(mDevice, descriptor,
- descriptorInfo.layerCount);
- } else if (descriptorInfo.layerCount != 1) {
- err = GRALLOC1_ERROR_BAD_VALUE;
- }
- }
- if (err == GRALLOC1_ERROR_NONE) {
- uint64_t producerUsageMask = descriptorInfo.producerUsageMask;
- if (producerUsageMask & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN) {
- producerUsageMask |= GRALLOC1_PRODUCER_USAGE_CPU_READ;
- }
- if (producerUsageMask & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN) {
- producerUsageMask |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE;
- }
- err = mDispatch.setProducerUsage(mDevice, descriptor,
- descriptorInfo.producerUsageMask);
- }
- if (err == GRALLOC1_ERROR_NONE) {
- uint64_t consumerUsageMask = descriptorInfo.consumerUsageMask;
- if (consumerUsageMask & GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN) {
- consumerUsageMask |= GRALLOC1_CONSUMER_USAGE_CPU_READ;
- }
- err = mDispatch.setConsumerUsage(mDevice, descriptor,
- consumerUsageMask);
- }
-
- if (err == GRALLOC1_ERROR_NONE) {
- *outDescriptor = descriptor;
- } else {
- mDispatch.destroyDescriptor(mDevice, descriptor);
- }
-
- return static_cast<Error>(err);
-}
-
-Error GrallocHal::destroyDescriptor(BufferDescriptor descriptor)
-{
- int32_t err = mDispatch.destroyDescriptor(mDevice, descriptor);
- return static_cast<Error>(err);
-}
-
-Error GrallocHal::testAllocate(const hidl_vec<BufferDescriptor>& descriptors)
-{
- if (!hasCapability(Capability::TEST_ALLOCATE)) {
- return Error::UNDEFINED;
- }
-
- int32_t err = mDispatch.allocate(mDevice, descriptors.size(),
- descriptors.data(), nullptr);
- return static_cast<Error>(err);
-}
-
-Error GrallocHal::allocate(const hidl_vec<BufferDescriptor>& descriptors,
- hidl_vec<Buffer>* outBuffers)
-{
- std::vector<buffer_handle_t> buffers(descriptors.size());
- int32_t err = mDispatch.allocate(mDevice, descriptors.size(),
- descriptors.data(), buffers.data());
- if (err == GRALLOC1_ERROR_NONE || err == GRALLOC1_ERROR_NOT_SHARED) {
- outBuffers->resize(buffers.size());
- for (size_t i = 0; i < outBuffers->size(); i++) {
- (*outBuffers)[i] = static_cast<Buffer>(
- reinterpret_cast<uintptr_t>(buffers[i]));
- }
- }
-
- return static_cast<Error>(err);
-}
-
-Error GrallocHal::free(Buffer buffer)
-{
- buffer_handle_t handle = reinterpret_cast<buffer_handle_t>(
- static_cast<uintptr_t>(buffer));
-
- int32_t err = mDispatch.release(mDevice, handle);
- return static_cast<Error>(err);
-}
-
-Error GrallocHal::exportHandle(Buffer buffer,
- const native_handle_t** outHandle)
-{
- // we rely on the caller to validate buffer here
- *outHandle = reinterpret_cast<buffer_handle_t>(
- static_cast<uintptr_t>(buffer));
- return Error::NONE;
-}
-
-GrallocClient::GrallocClient(GrallocHal& hal)
- : mHal(hal)
-{
-}
-
-GrallocClient::~GrallocClient()
-{
- if (!mBuffers.empty()) {
- ALOGW("client destroyed with valid buffers");
- for (auto buf : mBuffers) {
- mHal.free(buf);
- }
- }
-
- if (!mDescriptors.empty()) {
- ALOGW("client destroyed with valid buffer descriptors");
- for (auto desc : mDescriptors) {
- mHal.destroyDescriptor(desc);
- }
- }
-}
-
-Return<void> GrallocClient::createDescriptor(
- const BufferDescriptorInfo& descriptorInfo,
- createDescriptor_cb hidl_cb)
-{
- BufferDescriptor descriptor = 0;
- Error err = mHal.createDescriptor(descriptorInfo, &descriptor);
-
- if (err == Error::NONE) {
- std::lock_guard<std::mutex> lock(mMutex);
-
- auto result = mDescriptors.insert(descriptor);
- if (!result.second) {
- ALOGW("duplicated buffer descriptor id returned");
- mHal.destroyDescriptor(descriptor);
- err = Error::NO_RESOURCES;
- }
- }
-
- hidl_cb(err, descriptor);
- return Void();
-}
-
-Return<Error> GrallocClient::destroyDescriptor(BufferDescriptor descriptor)
-{
- {
- std::lock_guard<std::mutex> lock(mMutex);
- if (!mDescriptors.erase(descriptor)) {
- return Error::BAD_DESCRIPTOR;
- }
- }
-
- return mHal.destroyDescriptor(descriptor);
-}
-
-Return<Error> GrallocClient::testAllocate(
- const hidl_vec<BufferDescriptor>& descriptors)
-{
- return mHal.testAllocate(descriptors);
-}
-
-Return<void> GrallocClient::allocate(
- const hidl_vec<BufferDescriptor>& descriptors,
- allocate_cb hidl_cb) {
- hidl_vec<Buffer> buffers;
- Error err = mHal.allocate(descriptors, &buffers);
-
- if (err == Error::NONE || err == Error::NOT_SHARED) {
- std::lock_guard<std::mutex> lock(mMutex);
-
- for (size_t i = 0; i < buffers.size(); i++) {
- auto result = mBuffers.insert(buffers[i]);
- if (!result.second) {
- ALOGW("duplicated buffer id returned");
-
- for (size_t j = 0; j < buffers.size(); j++) {
- if (j < i) {
- mBuffers.erase(buffers[i]);
- }
- mHal.free(buffers[i]);
- }
-
- buffers = hidl_vec<Buffer>();
- err = Error::NO_RESOURCES;
- break;
- }
- }
- }
-
- hidl_cb(err, buffers);
- return Void();
-}
-
-Return<Error> GrallocClient::free(Buffer buffer)
-{
- {
- std::lock_guard<std::mutex> lock(mMutex);
- if (!mBuffers.erase(buffer)) {
- return Error::BAD_BUFFER;
- }
- }
-
- return mHal.free(buffer);
-}
-
-Return<void> GrallocClient::exportHandle(BufferDescriptor /*descriptor*/,
- Buffer buffer, exportHandle_cb hidl_cb)
-{
- const native_handle_t* handle = nullptr;
-
- {
- std::lock_guard<std::mutex> lock(mMutex);
- if (mBuffers.count(buffer) == 0) {
- hidl_cb(Error::BAD_BUFFER, handle);
- return Void();
- }
- }
-
- Error err = mHal.exportHandle(buffer, &handle);
-
- hidl_cb(err, handle);
- return Void();
-}
-
IAllocator* HIDL_FETCH_IAllocator(const char* /* name */) {
const hw_module_t* module = nullptr;
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
@@ -455,12 +38,15 @@
}
uint8_t major = (module->module_api_version >> 8) & 0xff;
- if (major != 1) {
- ALOGE("unknown gralloc module major version %d", major);
- return nullptr;
+ switch (major) {
+ case 1:
+ return new Gralloc1Allocator(module);
+ case 0:
+ return new Gralloc0Allocator(module);
+ default:
+ ALOGE("unknown gralloc module major version %d", major);
+ return nullptr;
}
-
- return new GrallocHal(module);
}
} // namespace implementation
diff --git a/graphics/allocator/2.0/default/Gralloc0Allocator.cpp b/graphics/allocator/2.0/default/Gralloc0Allocator.cpp
new file mode 100644
index 0000000..3b62bb3
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc0Allocator.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "Gralloc0Allocator"
+
+#include "Gralloc0Allocator.h"
+#include "GrallocBufferDescriptor.h"
+
+#include <vector>
+
+#include <string.h>
+
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::mapper::V2_0::implementation::
+ grallocDecodeBufferDescriptor;
+
+Gralloc0Allocator::Gralloc0Allocator(const hw_module_t* module) {
+ int result = gralloc_open(module, &mDevice);
+ if (result) {
+ LOG_ALWAYS_FATAL("failed to open gralloc0 device: %s",
+ strerror(-result));
+ }
+}
+
+Gralloc0Allocator::~Gralloc0Allocator() {
+ gralloc_close(mDevice);
+}
+
+Return<void> Gralloc0Allocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
+ char buf[4096] = {};
+ if (mDevice->dump) {
+ mDevice->dump(mDevice, buf, sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ }
+
+ hidl_cb(hidl_string(buf));
+
+ return Void();
+}
+
+Return<void> Gralloc0Allocator::allocate(const BufferDescriptor& descriptor,
+ uint32_t count, allocate_cb hidl_cb) {
+ IMapper::BufferDescriptorInfo descriptorInfo;
+ if (!grallocDecodeBufferDescriptor(descriptor, &descriptorInfo)) {
+ hidl_cb(Error::BAD_DESCRIPTOR, 0, hidl_vec<hidl_handle>());
+ return Void();
+ }
+
+ Error error = Error::NONE;
+ uint32_t stride = 0;
+ std::vector<hidl_handle> buffers;
+ buffers.reserve(count);
+
+ // allocate the buffers
+ for (uint32_t i = 0; i < count; i++) {
+ buffer_handle_t tmpBuffer;
+ uint32_t tmpStride;
+ error = allocateOne(descriptorInfo, &tmpBuffer, &tmpStride);
+ if (error != Error::NONE) {
+ break;
+ }
+
+ if (stride == 0) {
+ stride = tmpStride;
+ } else if (stride != tmpStride) {
+ // non-uniform strides
+ mDevice->free(mDevice, tmpBuffer);
+ stride = 0;
+ error = Error::UNSUPPORTED;
+ break;
+ }
+
+ buffers.emplace_back(hidl_handle(tmpBuffer));
+ }
+
+ // return the buffers
+ hidl_vec<hidl_handle> hidl_buffers;
+ if (error == Error::NONE) {
+ hidl_buffers.setToExternal(buffers.data(), buffers.size());
+ }
+ hidl_cb(error, stride, hidl_buffers);
+
+ // free the buffers
+ for (const auto& buffer : buffers) {
+ mDevice->free(mDevice, buffer.getNativeHandle());
+ }
+
+ return Void();
+}
+
+Error Gralloc0Allocator::allocateOne(const IMapper::BufferDescriptorInfo& info,
+ buffer_handle_t* outBuffer,
+ uint32_t* outStride) {
+ if (info.layerCount > 1 || (info.usage >> 32) != 0) {
+ return Error::BAD_VALUE;
+ }
+
+ buffer_handle_t buffer = nullptr;
+ int stride = 0;
+ int result = mDevice->alloc(mDevice, info.width, info.height,
+ static_cast<int>(info.format), info.usage,
+ &buffer, &stride);
+ if (result) {
+ switch (result) {
+ case -EINVAL:
+ return Error::BAD_VALUE;
+ default:
+ return Error::NO_RESOURCES;
+ }
+ }
+
+ *outBuffer = buffer;
+ *outStride = stride;
+
+ return Error::NONE;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/allocator/2.0/default/Gralloc0Allocator.h b/graphics/allocator/2.0/default/Gralloc0Allocator.h
new file mode 100644
index 0000000..0e90527
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc0Allocator.h
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC0ALLOCATOR_H
+#define ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC0ALLOCATOR_H
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <hardware/gralloc.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::mapper::V2_0::IMapper;
+using android::hardware::graphics::mapper::V2_0::BufferDescriptor;
+using android::hardware::graphics::mapper::V2_0::Error;
+
+class Gralloc0Allocator : public IAllocator {
+ public:
+ Gralloc0Allocator(const hw_module_t* module);
+ virtual ~Gralloc0Allocator();
+
+ // IAllocator interface
+ Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
+ Return<void> allocate(const BufferDescriptor& descriptor, uint32_t count,
+ allocate_cb hidl_cb) override;
+
+ private:
+ Error allocateOne(const IMapper::BufferDescriptorInfo& info,
+ buffer_handle_t* outBuffer, uint32_t* outStride);
+
+ alloc_device_t* mDevice;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC0ALLOCATOR_H
diff --git a/graphics/allocator/2.0/default/Gralloc1Allocator.cpp b/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
new file mode 100644
index 0000000..c0a5e1e
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
@@ -0,0 +1,321 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "Gralloc1Allocator"
+
+#include "Gralloc1Allocator.h"
+#include "GrallocBufferDescriptor.h"
+
+#include <vector>
+
+#include <string.h>
+
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::common::V1_0::BufferUsage;
+using android::hardware::graphics::mapper::V2_0::implementation::
+ grallocDecodeBufferDescriptor;
+
+Gralloc1Allocator::Gralloc1Allocator(const hw_module_t* module)
+ : mDevice(nullptr), mCapabilities(), mDispatch() {
+ int result = gralloc1_open(module, &mDevice);
+ if (result) {
+ LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s",
+ strerror(-result));
+ }
+
+ initCapabilities();
+ initDispatch();
+}
+
+Gralloc1Allocator::~Gralloc1Allocator() {
+ gralloc1_close(mDevice);
+}
+
+void Gralloc1Allocator::initCapabilities() {
+ uint32_t count = 0;
+ mDevice->getCapabilities(mDevice, &count, nullptr);
+
+ std::vector<int32_t> capabilities(count);
+ mDevice->getCapabilities(mDevice, &count, capabilities.data());
+ capabilities.resize(count);
+
+ for (auto capability : capabilities) {
+ if (capability == GRALLOC1_CAPABILITY_LAYERED_BUFFERS) {
+ mCapabilities.layeredBuffers = true;
+ break;
+ }
+ }
+}
+
+template <typename T>
+void Gralloc1Allocator::initDispatch(gralloc1_function_descriptor_t desc,
+ T* outPfn) {
+ auto pfn = mDevice->getFunction(mDevice, desc);
+ if (!pfn) {
+ LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc);
+ }
+
+ *outPfn = reinterpret_cast<T>(pfn);
+}
+
+void Gralloc1Allocator::initDispatch() {
+ initDispatch(GRALLOC1_FUNCTION_DUMP, &mDispatch.dump);
+ initDispatch(GRALLOC1_FUNCTION_CREATE_DESCRIPTOR,
+ &mDispatch.createDescriptor);
+ initDispatch(GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR,
+ &mDispatch.destroyDescriptor);
+ initDispatch(GRALLOC1_FUNCTION_SET_DIMENSIONS, &mDispatch.setDimensions);
+ initDispatch(GRALLOC1_FUNCTION_SET_FORMAT, &mDispatch.setFormat);
+ if (mCapabilities.layeredBuffers) {
+ initDispatch(GRALLOC1_FUNCTION_SET_LAYER_COUNT,
+ &mDispatch.setLayerCount);
+ }
+ initDispatch(GRALLOC1_FUNCTION_SET_CONSUMER_USAGE,
+ &mDispatch.setConsumerUsage);
+ initDispatch(GRALLOC1_FUNCTION_SET_PRODUCER_USAGE,
+ &mDispatch.setProducerUsage);
+ initDispatch(GRALLOC1_FUNCTION_GET_STRIDE, &mDispatch.getStride);
+ initDispatch(GRALLOC1_FUNCTION_ALLOCATE, &mDispatch.allocate);
+ initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release);
+}
+
+Return<void> Gralloc1Allocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
+ uint32_t len = 0;
+ mDispatch.dump(mDevice, &len, nullptr);
+
+ std::vector<char> buf(len + 1);
+ mDispatch.dump(mDevice, &len, buf.data());
+ buf.resize(len + 1);
+ buf[len] = '\0';
+
+ hidl_string reply;
+ reply.setToExternal(buf.data(), len);
+ hidl_cb(reply);
+
+ return Void();
+}
+
+Return<void> Gralloc1Allocator::allocate(const BufferDescriptor& descriptor,
+ uint32_t count, allocate_cb hidl_cb) {
+ IMapper::BufferDescriptorInfo descriptorInfo;
+ if (!grallocDecodeBufferDescriptor(descriptor, &descriptorInfo)) {
+ hidl_cb(Error::BAD_DESCRIPTOR, 0, hidl_vec<hidl_handle>());
+ return Void();
+ }
+
+ gralloc1_buffer_descriptor_t desc;
+ Error error = createDescriptor(descriptorInfo, &desc);
+ if (error != Error::NONE) {
+ hidl_cb(error, 0, hidl_vec<hidl_handle>());
+ return Void();
+ }
+
+ uint32_t stride = 0;
+ std::vector<hidl_handle> buffers;
+ buffers.reserve(count);
+
+ // allocate the buffers
+ for (uint32_t i = 0; i < count; i++) {
+ buffer_handle_t tmpBuffer;
+ uint32_t tmpStride;
+ error = allocateOne(desc, &tmpBuffer, &tmpStride);
+ if (error != Error::NONE) {
+ break;
+ }
+
+ if (stride == 0) {
+ stride = tmpStride;
+ } else if (stride != tmpStride) {
+ // non-uniform strides
+ mDispatch.release(mDevice, tmpBuffer);
+ stride = 0;
+ error = Error::UNSUPPORTED;
+ break;
+ }
+
+ buffers.emplace_back(hidl_handle(tmpBuffer));
+ }
+
+ mDispatch.destroyDescriptor(mDevice, desc);
+
+ // return the buffers
+ hidl_vec<hidl_handle> hidl_buffers;
+ if (error == Error::NONE) {
+ hidl_buffers.setToExternal(buffers.data(), buffers.size());
+ }
+ hidl_cb(error, stride, hidl_buffers);
+
+ // free the buffers
+ for (const auto& buffer : buffers) {
+ mDispatch.release(mDevice, buffer.getNativeHandle());
+ }
+
+ return Void();
+}
+
+Error Gralloc1Allocator::toError(int32_t error) {
+ switch (error) {
+ case GRALLOC1_ERROR_NONE:
+ return Error::NONE;
+ case GRALLOC1_ERROR_BAD_DESCRIPTOR:
+ return Error::BAD_DESCRIPTOR;
+ case GRALLOC1_ERROR_BAD_HANDLE:
+ return Error::BAD_BUFFER;
+ case GRALLOC1_ERROR_BAD_VALUE:
+ return Error::BAD_VALUE;
+ case GRALLOC1_ERROR_NOT_SHARED:
+ return Error::NONE; // this is fine
+ case GRALLOC1_ERROR_NO_RESOURCES:
+ return Error::NO_RESOURCES;
+ case GRALLOC1_ERROR_UNDEFINED:
+ case GRALLOC1_ERROR_UNSUPPORTED:
+ default:
+ return Error::UNSUPPORTED;
+ }
+}
+
+uint64_t Gralloc1Allocator::toProducerUsage(uint64_t usage) {
+ // this is potentially broken as we have no idea which private flags
+ // should be filtered out
+ uint64_t producerUsage =
+ usage &
+ ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK |
+ BufferUsage::CPU_WRITE_MASK);
+
+ switch (usage & BufferUsage::CPU_WRITE_MASK) {
+ case static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY):
+ producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE;
+ break;
+ case static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN):
+ producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
+ break;
+ default:
+ break;
+ }
+
+ switch (usage & BufferUsage::CPU_READ_MASK) {
+ case static_cast<uint64_t>(BufferUsage::CPU_READ_RARELY):
+ producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_READ;
+ break;
+ case static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN):
+ producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN;
+ break;
+ default:
+ break;
+ }
+
+ return producerUsage;
+}
+
+uint64_t Gralloc1Allocator::toConsumerUsage(uint64_t usage) {
+ // this is potentially broken as we have no idea which private flags
+ // should be filtered out
+ uint64_t consumerUsage =
+ usage &
+ ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK |
+ BufferUsage::CPU_WRITE_MASK);
+
+ switch (usage & BufferUsage::CPU_READ_MASK) {
+ case static_cast<uint64_t>(BufferUsage::CPU_READ_RARELY):
+ consumerUsage |= GRALLOC1_CONSUMER_USAGE_CPU_READ;
+ break;
+ case static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN):
+ consumerUsage |= GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN;
+ break;
+ default:
+ break;
+ }
+
+ return consumerUsage;
+}
+
+Error Gralloc1Allocator::createDescriptor(
+ const IMapper::BufferDescriptorInfo& info,
+ gralloc1_buffer_descriptor_t* outDescriptor) {
+ gralloc1_buffer_descriptor_t descriptor;
+
+ int32_t error = mDispatch.createDescriptor(mDevice, &descriptor);
+
+ if (error == GRALLOC1_ERROR_NONE) {
+ error = mDispatch.setDimensions(mDevice, descriptor, info.width,
+ info.height);
+ }
+ if (error == GRALLOC1_ERROR_NONE) {
+ error = mDispatch.setFormat(mDevice, descriptor,
+ static_cast<int32_t>(info.format));
+ }
+ if (error == GRALLOC1_ERROR_NONE) {
+ if (mCapabilities.layeredBuffers) {
+ error =
+ mDispatch.setLayerCount(mDevice, descriptor, info.layerCount);
+ } else if (info.layerCount > 1) {
+ error = GRALLOC1_ERROR_UNSUPPORTED;
+ }
+ }
+ if (error == GRALLOC1_ERROR_NONE) {
+ error = mDispatch.setProducerUsage(mDevice, descriptor,
+ toProducerUsage(info.usage));
+ }
+ if (error == GRALLOC1_ERROR_NONE) {
+ error = mDispatch.setConsumerUsage(mDevice, descriptor,
+ toConsumerUsage(info.usage));
+ }
+
+ if (error == GRALLOC1_ERROR_NONE) {
+ *outDescriptor = descriptor;
+ } else {
+ mDispatch.destroyDescriptor(mDevice, descriptor);
+ }
+
+ return toError(error);
+}
+
+Error Gralloc1Allocator::allocateOne(gralloc1_buffer_descriptor_t descriptor,
+ buffer_handle_t* outBuffer,
+ uint32_t* outStride) {
+ buffer_handle_t buffer = nullptr;
+ int32_t error = mDispatch.allocate(mDevice, 1, &descriptor, &buffer);
+ if (error != GRALLOC1_ERROR_NONE && error != GRALLOC1_ERROR_NOT_SHARED) {
+ return toError(error);
+ }
+
+ uint32_t stride = 0;
+ error = mDispatch.getStride(mDevice, buffer, &stride);
+ if (error != GRALLOC1_ERROR_NONE && error != GRALLOC1_ERROR_UNDEFINED) {
+ mDispatch.release(mDevice, buffer);
+ return toError(error);
+ }
+
+ *outBuffer = buffer;
+ *outStride = stride;
+
+ return Error::NONE;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/allocator/2.0/default/Gralloc1Allocator.h b/graphics/allocator/2.0/default/Gralloc1Allocator.h
new file mode 100644
index 0000000..7b5a966
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc1Allocator.h
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC1ALLOCATOR_H
+#define ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC1ALLOCATOR_H
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <hardware/gralloc1.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::mapper::V2_0::IMapper;
+using android::hardware::graphics::mapper::V2_0::BufferDescriptor;
+using android::hardware::graphics::mapper::V2_0::Error;
+
+class Gralloc1Allocator : public IAllocator {
+ public:
+ Gralloc1Allocator(const hw_module_t* module);
+ virtual ~Gralloc1Allocator();
+
+ // IAllocator interface
+ Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
+ Return<void> allocate(const BufferDescriptor& descriptor, uint32_t count,
+ allocate_cb hidl_cb) override;
+
+ private:
+ void initCapabilities();
+
+ template <typename T>
+ void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
+ void initDispatch();
+
+ static Error toError(int32_t error);
+ static uint64_t toProducerUsage(uint64_t usage);
+ static uint64_t toConsumerUsage(uint64_t usage);
+
+ Error createDescriptor(const IMapper::BufferDescriptorInfo& info,
+ gralloc1_buffer_descriptor_t* outDescriptor);
+ Error allocateOne(gralloc1_buffer_descriptor_t descriptor,
+ buffer_handle_t* outBuffer, uint32_t* outStride);
+
+ gralloc1_device_t* mDevice;
+
+ struct {
+ bool layeredBuffers;
+ } mCapabilities;
+
+ struct {
+ GRALLOC1_PFN_DUMP dump;
+ GRALLOC1_PFN_CREATE_DESCRIPTOR createDescriptor;
+ GRALLOC1_PFN_DESTROY_DESCRIPTOR destroyDescriptor;
+ GRALLOC1_PFN_SET_DIMENSIONS setDimensions;
+ GRALLOC1_PFN_SET_FORMAT setFormat;
+ GRALLOC1_PFN_SET_LAYER_COUNT setLayerCount;
+ GRALLOC1_PFN_SET_CONSUMER_USAGE setConsumerUsage;
+ GRALLOC1_PFN_SET_PRODUCER_USAGE setProducerUsage;
+ GRALLOC1_PFN_GET_STRIDE getStride;
+ GRALLOC1_PFN_ALLOCATE allocate;
+ GRALLOC1_PFN_RELEASE release;
+ } mDispatch;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC1ALLOCATOR_H
diff --git a/graphics/allocator/2.0/types.hal b/graphics/allocator/2.0/types.hal
deleted file mode 100644
index d9b184b..0000000
--- a/graphics/allocator/2.0/types.hal
+++ /dev/null
@@ -1,148 +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.
- */
-
-package android.hardware.graphics.allocator@2.0;
-
-enum Error : int32_t {
- NONE = 0, /** no error */
- BAD_DESCRIPTOR = 1, /** invalid BufferDescriptor */
- BAD_BUFFER = 2, /** invalid Buffer */
- BAD_VALUE = 3, /** invalid width, height, etc. */
- NOT_SHARED = 4, /** buffers not sharing backing store */
- NO_RESOURCES = 5, /** temporary failure due to resource contention */
- UNDEFINED = 6, /** an operation has no defined meaning */
- UNSUPPORTED = 7, /** permanent failure */
-};
-
-enum ProducerUsage : uint64_t {
- /** bit 0 is reserved */
-
- /** buffer is read by CPU occasionally */
- CPU_READ = 1ULL << 1,
- /** buffer is read by CPU frequently */
- CPU_READ_OFTEN = 1ULL << 2,
-
- /** bit 3 is reserved */
- /** bit 4 is reserved */
-
- /** buffer is written by CPU occasionally */
- CPU_WRITE = 1ULL << 5,
- /** buffer is written by CPU frequently */
- CPU_WRITE_OFTEN = 1ULL << 6,
-
- /** bit 7 is reserved */
- /** bit 8 is reserved */
-
- /** buffer is used as a GPU render target */
- GPU_RENDER_TARGET = 1ULL << 9,
-
- /** bit 10 is reserved */
- /** bit 11 is reserved */
- /** bit 12 is reserved */
- /** bit 13 is reserved */
-
- /**
- * Buffer is allocated with hardware-level protection against copying the
- * contents (or information derived from the contents) into unprotected
- * memory.
- */
- PROTECTED = 1ULL << 14,
-
- /** bit 15 is reserved */
- /** bit 16 is reserved */
-
- /** buffer is used as a camera HAL output */
- CAMERA = 1ULL << 17,
-
- /** bit 18 is reserved */
- /** bit 19 is reserved */
- /** bit 20 is reserved */
- /** bit 21 is reserved */
-
- /** buffer is used as a video decoder output */
- VIDEO_DECODER = 1ULL << 22,
-
- /** buffer is used as a sensor direct report output */
- SENSOR_DIRECT_DATA = 1ULL << 23,
-
- /** bits 24-27 are reserved for future versions */
- /** bits 28-31 are reserved for vendor extensions */
-
- /** bits 32-47 are reserved for future versions */
- /** bits 48-63 are reserved for vendor extensions */
-};
-
-enum ConsumerUsage : uint64_t {
- /** bit 0 is reserved */
-
- /** buffer is read by CPU occasionally */
- CPU_READ = 1ULL << 1,
- /** buffer is read by CPU frequently */
- CPU_READ_OFTEN = 1ULL << 2,
-
- /** bit 3 is reserved */
- /** bit 4 is reserved */
- /** bit 5 is reserved */
- /** bit 6 is reserved */
- /** bit 7 is reserved */
-
- /** buffer is used as a GPU texture */
- GPU_TEXTURE = 1ULL << 8,
-
- /** bit 9 is reserved */
- /** bit 10 is reserved */
-
- /** buffer is used by hwcomposer HAL */
- HWCOMPOSER = 1ULL << 11,
- /** buffer is a hwcomposer HAL client target */
- CLIENT_TARGET = 1ULL << 12,
-
- /** bit 13 is reserved */
- /** bit 14 is reserved */
-
- /** buffer is used as a hwcomposer HAL cursor */
- CURSOR = 1ULL << 15,
-
- /** buffer is used as a video encoder input */
- VIDEO_ENCODER = 1ULL << 16,
-
- /** bit 17 is reserved */
-
- /** buffer is used as a camera HAL input */
- CAMERA = 1ULL << 18,
-
- /** bit 19 is reserved */
-
- /** buffer is used as a renderscript allocation */
- RENDERSCRIPT = 1ULL << 20,
-
- /** bit 21 is reserved */
- /** bit 22 is reserved */
-
- /**
- * buffer is used as as an OpenGL shader storage or uniform
- buffer object */
- GPU_DATA_BUFFER = 1ULL << 23,
-
- /** bits 24-27 are reserved for future versions */
- /** bits 28-31 are reserved for vendor extensions */
-
- /** bits 32-47 are reserved for future versions */
- /** bits 48-63 are reserved for vendor extensions */
-};
-
-typedef uint64_t BufferDescriptor;
-typedef uint64_t Buffer;
diff --git a/graphics/allocator/2.0/vts/functional/Android.bp b/graphics/allocator/2.0/vts/functional/Android.bp
deleted file mode 100644
index fb77ab3..0000000
--- a/graphics/allocator/2.0/vts/functional/Android.bp
+++ /dev/null
@@ -1,62 +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.
-//
-
-cc_library_static {
- name: "libVtsHalGraphicsAllocatorTestUtils",
- defaults: ["hidl_defaults"],
- srcs: ["VtsHalGraphicsAllocatorTestUtils.cpp"],
- shared_libs: [
- "android.hardware.graphics.allocator@2.0",
- ],
- static_libs: [
- "VtsHalHidlTargetTestBase",
- ],
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
- "-O0",
- "-g",
- ],
- export_include_dirs: ["."],
-}
-
-cc_test {
- name: "VtsHalGraphicsAllocatorV2_0TargetTest",
- defaults: ["hidl_defaults"],
- srcs: ["VtsHalGraphicsAllocatorV2_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.graphics.allocator@2.0",
- ],
- static_libs: [
- "libVtsHalGraphicsAllocatorTestUtils",
- "VtsHalHidlTargetTestBase",
- ],
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
- "-O0",
- "-g",
- ]
-}
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
deleted file mode 100644
index 0dc43be..0000000
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
+++ /dev/null
@@ -1,183 +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.
- */
-
-#include <VtsHalHidlTargetTestBase.h>
-
-#include "VtsHalGraphicsAllocatorTestUtils.h"
-
-namespace android {
-namespace hardware {
-namespace graphics {
-namespace allocator {
-namespace V2_0 {
-namespace tests {
-
-Allocator::Allocator() { init(); }
-
-void Allocator::init() {
- mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>();
- ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
-
- std::vector<IAllocator::Capability> capabilities = getCapabilities();
- mCapabilities.insert(capabilities.begin(), capabilities.end());
-}
-
-sp<IAllocator> Allocator::getRaw() const { return mAllocator; }
-
-bool Allocator::hasCapability(IAllocator::Capability capability) const {
- return mCapabilities.count(capability) > 0;
-}
-
-std::vector<IAllocator::Capability> Allocator::getCapabilities() {
- std::vector<IAllocator::Capability> capabilities;
- mAllocator->getCapabilities(
- [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
-
- return capabilities;
-}
-
-std::string Allocator::dumpDebugInfo() {
- std::string debugInfo;
- mAllocator->dumpDebugInfo(
- [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
-
- return debugInfo;
-}
-
-std::unique_ptr<AllocatorClient> Allocator::createClient() {
- std::unique_ptr<AllocatorClient> client;
- mAllocator->createClient([&](const auto& tmpError, const auto& tmpClient) {
- ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
- client = std::make_unique<AllocatorClient>(tmpClient);
- });
-
- return client;
-}
-
-AllocatorClient::AllocatorClient(const sp<IAllocatorClient>& client)
- : mClient(client) {}
-
-AllocatorClient::~AllocatorClient() {
- for (auto buffer : mBuffers) {
- EXPECT_EQ(Error::NONE, mClient->free(buffer))
- << "failed to free buffer " << buffer;
- }
- mBuffers.clear();
-
- for (auto descriptor : mDescriptors) {
- EXPECT_EQ(Error::NONE, mClient->destroyDescriptor(descriptor))
- << "failed to destroy descriptor " << descriptor;
- }
- mDescriptors.clear();
-}
-
-sp<IAllocatorClient> AllocatorClient::getRaw() const { return mClient; }
-
-BufferDescriptor AllocatorClient::createDescriptor(
- const IAllocatorClient::BufferDescriptorInfo& info) {
- BufferDescriptor descriptor = 0;
- mClient->createDescriptor(
- info, [&](const auto& tmpError, const auto& tmpDescriptor) {
- ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor";
- descriptor = tmpDescriptor;
-
- EXPECT_TRUE(mDescriptors.insert(descriptor).second)
- << "duplicated descriptor id " << descriptor;
- });
-
- return descriptor;
-}
-
-void AllocatorClient::destroyDescriptor(BufferDescriptor descriptor) {
- ASSERT_EQ(Error::NONE, mClient->destroyDescriptor(descriptor))
- << "failed to destroy descriptor " << descriptor;
-
- mDescriptors.erase(descriptor);
-}
-
-Error AllocatorClient::testAllocate(
- const std::vector<BufferDescriptor>& descriptors) {
- return mClient->testAllocate(descriptors);
-}
-
-bool AllocatorClient::testAllocate(BufferDescriptor descriptor) {
- std::vector<BufferDescriptor> descriptors(1, descriptor);
- Error error = testAllocate(descriptors);
- return (error == Error::NONE || error == Error::NOT_SHARED);
-}
-
-Error AllocatorClient::allocate(
- const std::vector<BufferDescriptor>& descriptors,
- std::vector<Buffer>& buffers) {
- Error error = Error::NO_RESOURCES;
- mClient->allocate(descriptors, [&](const auto& tmpError,
- const auto& tmpBuffers) {
- ASSERT_TRUE(tmpError == Error::NONE || tmpError == Error::NOT_SHARED)
- << "failed to allocate buffer";
- ASSERT_EQ(descriptors.size(), tmpBuffers.size()) << "invalid buffer count";
-
- error = tmpError;
- buffers = tmpBuffers;
-
- for (auto buffer : buffers) {
- EXPECT_TRUE(mBuffers.insert(buffer).second)
- << "duplicated buffer id " << buffer;
- }
- });
-
- return error;
-}
-
-Buffer AllocatorClient::allocate(BufferDescriptor descriptor) {
- std::vector<BufferDescriptor> descriptors(1, descriptor);
- std::vector<Buffer> buffers;
- allocate(descriptors, buffers);
- if (::testing::Test::HasFatalFailure()) {
- return 0;
- }
-
- return buffers[0];
-}
-
-void AllocatorClient::free(Buffer buffer) {
- ASSERT_EQ(Error::NONE, mClient->free(buffer))
- << "failed to free buffer " << buffer;
-
- mBuffers.erase(buffer);
-}
-
-native_handle_t* AllocatorClient::exportHandle(BufferDescriptor descriptor,
- Buffer buffer) {
- native_handle_t* handle;
- mClient->exportHandle(
- descriptor, buffer, [&](const auto& tmpError, const auto& tmpHandle) {
- ASSERT_EQ(Error::NONE, tmpError) << "failed to export buffer handle";
- ASSERT_NE(nullptr, tmpHandle.getNativeHandle())
- << "invalid buffer handle";
-
- handle = native_handle_clone(tmpHandle.getNativeHandle());
- ASSERT_NE(nullptr, handle) << "failed to clone handle";
- });
-
- return handle;
-}
-
-} // namespace tests
-} // namespace V2_0
-} // namespace allocator
-} // namespace graphics
-} // namespace hardware
-} // namespace android
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h
deleted file mode 100644
index c9bfe8f..0000000
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h
+++ /dev/null
@@ -1,98 +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.
- */
-
-#ifndef VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
-#define VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
-
-#include <memory>
-#include <string>
-#include <unordered_set>
-#include <vector>
-
-#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-namespace hardware {
-namespace graphics {
-namespace allocator {
-namespace V2_0 {
-namespace tests {
-
-class AllocatorClient;
-
-// A wrapper to IAllocator.
-class Allocator {
- public:
- Allocator();
-
- sp<IAllocator> getRaw() const;
-
- // Returns true when the allocator supports the specified capability.
- bool hasCapability(IAllocator::Capability capability) const;
-
- std::vector<IAllocator::Capability> getCapabilities();
- std::string dumpDebugInfo();
- std::unique_ptr<AllocatorClient> createClient();
-
- private:
- void init();
-
- sp<IAllocator> mAllocator;
- std::unordered_set<IAllocator::Capability> mCapabilities;
-};
-
-// A wrapper to IAllocatorClient.
-class AllocatorClient {
- public:
- AllocatorClient(const sp<IAllocatorClient>& client);
- ~AllocatorClient();
-
- sp<IAllocatorClient> getRaw() const;
-
- BufferDescriptor createDescriptor(
- const IAllocatorClient::BufferDescriptorInfo& info);
- void destroyDescriptor(BufferDescriptor descriptor);
-
- Error testAllocate(const std::vector<BufferDescriptor>& descriptors);
- bool testAllocate(BufferDescriptor descriptor);
-
- Error allocate(const std::vector<BufferDescriptor>& descriptors,
- std::vector<Buffer>& buffers);
- Buffer allocate(BufferDescriptor descriptor);
- void free(Buffer buffer);
-
- // Returns a handle to the buffer. The ownership of the handle is
- // transferred to the caller.
- native_handle_t* exportHandle(BufferDescriptor descriptor, Buffer buffer);
-
- private:
- sp<IAllocatorClient> mClient;
-
- // Keep track of all descriptors and buffers. When a test fails with
- // ASSERT_*, the destructor will clean up the resources for the test.
- std::unordered_set<BufferDescriptor> mDescriptors;
- std::unordered_set<Buffer> mBuffers;
-};
-
-} // namespace tests
-} // namespace V2_0
-} // namespace allocator
-} // namespace graphics
-} // namespace hardware
-} // namespace android
-
-#endif // VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
deleted file mode 100644
index b1c764f..0000000
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
+++ /dev/null
@@ -1,186 +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.
- */
-
-#define LOG_TAG "graphics_allocator_hidl_hal_test"
-
-#include <android-base/logging.h>
-#include <VtsHalHidlTargetTestBase.h>
-
-#include "VtsHalGraphicsAllocatorTestUtils.h"
-
-namespace android {
-namespace hardware {
-namespace graphics {
-namespace allocator {
-namespace V2_0 {
-namespace tests {
-namespace {
-
-using android::hardware::graphics::common::V1_0::PixelFormat;
-
-#define CHECK_FEATURE_OR_SKIP(FEATURE_NAME) \
- do { \
- if (!mAllocator->hasCapability(FEATURE_NAME)) { \
- std::cout << "[ SKIPPED ] Feature " << #FEATURE_NAME \
- << " not supported" << std::endl; \
- return; \
- } \
- } while (0)
-
-class GraphicsAllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- protected:
- void SetUp() override {
- ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
- ASSERT_NO_FATAL_FAILURE(mClient = mAllocator->createClient());
-
- mDummyDescriptorInfo.width = 64;
- mDummyDescriptorInfo.height = 64;
- mDummyDescriptorInfo.layerCount = 1;
- mDummyDescriptorInfo.format = PixelFormat::RGBA_8888;
- mDummyDescriptorInfo.producerUsageMask =
- static_cast<uint64_t>(ProducerUsage::CPU_WRITE);
- mDummyDescriptorInfo.consumerUsageMask =
- static_cast<uint64_t>(ConsumerUsage::CPU_READ);
- }
-
- void TearDown() override {}
-
- std::unique_ptr<Allocator> mAllocator;
- std::unique_ptr<AllocatorClient> mClient;
- IAllocatorClient::BufferDescriptorInfo mDummyDescriptorInfo{};
-};
-
-TEST_F(GraphicsAllocatorHidlTest, GetCapabilities) {
- auto capabilities = mAllocator->getCapabilities();
- for (auto cap : capabilities) {
- EXPECT_NE(IAllocator::Capability::INVALID, cap);
- }
-}
-
-TEST_F(GraphicsAllocatorHidlTest, DumpDebugInfo) {
- mAllocator->dumpDebugInfo();
-}
-
-TEST_F(GraphicsAllocatorHidlTest, CreateDestroyDescriptor) {
- BufferDescriptor descriptor;
- ASSERT_NO_FATAL_FAILURE(descriptor =
- mClient->createDescriptor(mDummyDescriptorInfo));
- mClient->destroyDescriptor(descriptor);
-}
-
-/**
- * Test testAllocate with a single buffer descriptor.
- */
-TEST_F(GraphicsAllocatorHidlTest, TestAllocateBasic) {
- CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
-
- BufferDescriptor descriptor;
- ASSERT_NO_FATAL_FAILURE(descriptor =
- mClient->createDescriptor(mDummyDescriptorInfo));
-
- ASSERT_TRUE(mClient->testAllocate(descriptor));
-}
-
-/**
- * Test testAllocate with two buffer descriptors.
- */
-TEST_F(GraphicsAllocatorHidlTest, TestAllocateArray) {
- CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
-
- BufferDescriptor descriptor;
- ASSERT_NO_FATAL_FAILURE(descriptor =
- mClient->createDescriptor(mDummyDescriptorInfo));
-
- hidl_vec<BufferDescriptor> descriptors;
- descriptors.resize(2);
- descriptors[0] = descriptor;
- descriptors[1] = descriptor;
-
- auto error = mClient->testAllocate(descriptors);
- ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
-}
-
-/**
- * Test allocate/free with a single buffer descriptor.
- */
-TEST_F(GraphicsAllocatorHidlTest, AllocateFreeBasic) {
- BufferDescriptor descriptor;
- ASSERT_NO_FATAL_FAILURE(descriptor =
- mClient->createDescriptor(mDummyDescriptorInfo));
-
- Buffer buffer;
- ASSERT_NO_FATAL_FAILURE(buffer = mClient->allocate(descriptor));
-
- mClient->free(buffer);
-}
-
-/**
- * Test allocate/free with an array of buffer descriptors.
- */
-TEST_F(GraphicsAllocatorHidlTest, AllocateFreeArray) {
- BufferDescriptor descriptor1;
- ASSERT_NO_FATAL_FAILURE(descriptor1 =
- mClient->createDescriptor(mDummyDescriptorInfo));
-
- BufferDescriptor descriptor2;
- ASSERT_NO_FATAL_FAILURE(descriptor2 =
- mClient->createDescriptor(mDummyDescriptorInfo));
-
- hidl_vec<BufferDescriptor> descriptors;
- descriptors.resize(3);
- descriptors[0] = descriptor1;
- descriptors[1] = descriptor1;
- descriptors[2] = descriptor2;
-
- std::vector<Buffer> buffers;
- ASSERT_NO_FATAL_FAILURE(mClient->allocate(descriptors, buffers));
-
- for (auto buf : buffers) {
- mClient->free(buf);
- }
-}
-
-TEST_F(GraphicsAllocatorHidlTest, ExportHandle) {
- BufferDescriptor descriptor;
- ASSERT_NO_FATAL_FAILURE(descriptor =
- mClient->createDescriptor(mDummyDescriptorInfo));
-
- Buffer buffer;
- ASSERT_NO_FATAL_FAILURE(buffer = mClient->allocate(descriptor));
-
- native_handle_t* handle;
- ASSERT_NO_FATAL_FAILURE(handle = mClient->exportHandle(descriptor, buffer));
-
- native_handle_close(handle);
- native_handle_delete(handle);
-}
-
-} // namespace anonymous
-} // namespace tests
-} // namespace V2_0
-} // namespace allocator
-} // namespace graphics
-} // namespace hardware
-} // namespace android
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
-
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
-
- return status;
-}
diff --git a/graphics/bufferqueue/1.0/Android.bp b/graphics/bufferqueue/1.0/Android.bp
index 4ba764f..e7adee6 100644
--- a/graphics/bufferqueue/1.0/Android.bp
+++ b/graphics/bufferqueue/1.0/Android.bp
@@ -47,6 +47,7 @@
generated_sources: ["android.hardware.graphics.bufferqueue@1.0_genc++"],
generated_headers: ["android.hardware.graphics.bufferqueue@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.graphics.bufferqueue@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/graphics/common/1.0/Android.bp b/graphics/common/1.0/Android.bp
index 25995cd..69c8844 100644
--- a/graphics/common/1.0/Android.bp
+++ b/graphics/common/1.0/Android.bp
@@ -37,6 +37,7 @@
generated_sources: ["android.hardware.graphics.common@1.0_genc++"],
generated_headers: ["android.hardware.graphics.common@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.graphics.common@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/graphics/common/1.0/Android.mk b/graphics/common/1.0/Android.mk
index c08053d..569a5f4 100644
--- a/graphics/common/1.0/Android.mk
+++ b/graphics/common/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.graphics.common@1.0-java
+LOCAL_MODULE := android.hardware.graphics.common-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,6 +13,25 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
#
+# Build types.hal (BufferUsage)
+#
+GEN := $(intermediates)/android/hardware/graphics/common/V1_0/BufferUsage.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.graphics.common@1.0::types.BufferUsage
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (ColorMode)
#
GEN := $(intermediates)/android/hardware/graphics/common/V1_0/ColorMode.java
@@ -131,7 +150,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.graphics.common@1.0-java-static
+LOCAL_MODULE := android.hardware.graphics.common-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -139,6 +158,25 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
#
+# Build types.hal (BufferUsage)
+#
+GEN := $(intermediates)/android/hardware/graphics/common/V1_0/BufferUsage.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.graphics.common@1.0::types.BufferUsage
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (ColorMode)
#
GEN := $(intermediates)/android/hardware/graphics/common/V1_0/ColorMode.java
@@ -257,7 +295,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.graphics.common@1.0-java-constants
+LOCAL_MODULE := android.hardware.graphics.common-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/graphics/common/1.0/types.hal b/graphics/common/1.0/types.hal
index 8aa0779..3bd1ec1 100644
--- a/graphics/common/1.0/types.hal
+++ b/graphics/common/1.0/types.hal
@@ -450,6 +450,90 @@
};
/**
+ * Buffer usage definitions.
+ */
+enum BufferUsage : uint64_t {
+ /** bit 0-3 is an enum */
+ CPU_READ_MASK = 0xfULL,
+ /** buffer is never read by CPU */
+ CPU_READ_NEVER = 0,
+ /** buffer is rarely read by CPU */
+ CPU_READ_RARELY = 2,
+ /** buffer is often read by CPU */
+ CPU_READ_OFTEN = 3,
+
+ /** bit 4-7 is an enum */
+ CPU_WRITE_MASK = 0xfULL << 4,
+ /** buffer is never written by CPU */
+ CPU_WRITE_NEVER = 0 << 4,
+ /** buffer is rarely written by CPU */
+ CPU_WRITE_RARELY = 2 << 4,
+ /** buffer is often written by CPU */
+ CPU_WRITE_OFTEN = 3 << 4,
+
+ /** buffer is used as a GPU texture */
+ GPU_TEXTURE = 1ULL << 8,
+
+ /** buffer is used as a GPU render target */
+ GPU_RENDER_TARGET = 1ULL << 9,
+
+ /** bit 10 must be zero */
+
+ /** buffer is used as a composer HAL overlay layer */
+ COMPOSER_OVERLAY = 1ULL << 11,
+ /** buffer is used as a composer HAL client target */
+ COMPOSER_CLIENT_TARGET = 1ULL << 12,
+
+ /** bit 13 must be zero */
+
+ /**
+ * Buffer is allocated with hardware-level protection against copying the
+ * contents (or information derived from the contents) into unprotected
+ * memory.
+ */
+ PROTECTED = 1ULL << 14,
+
+ /** buffer is used as a hwcomposer HAL cursor layer */
+ COMPOSER_CURSOR = 1ULL << 15,
+
+ /** buffer is used as a video encoder input */
+ VIDEO_ENCODER = 1ULL << 16,
+
+ /** buffer is used as a camera HAL output */
+ CAMERA_OUTPUT = 1ULL << 17,
+
+ /** buffer is used as a camera HAL input */
+ CAMERA_INPUT = 1ULL << 18,
+
+ /** bit 19 must be zero */
+
+ /** buffer is used as a renderscript allocation */
+ RENDERSCRIPT = 1ULL << 20,
+
+ /** bit 21 must be zero */
+
+ /** buffer is used as a video decoder output */
+ VIDEO_DECODER = 1ULL << 22,
+
+ /** buffer is used as a sensor direct report output */
+ SENSOR_DIRECT_DATA = 1ULL << 23,
+
+ /**
+ * buffer is used as as an OpenGL shader storage or uniform
+ * buffer object
+ */
+ GPU_DATA_BUFFER = 1ULL << 24,
+
+ /** bits 25-27 must be zero and are reserved for future versions */
+ /** bits 28-31 are reserved for vendor extensions */
+ VENDOR_MASK = 0xfULL << 28,
+
+ /** bits 32-47 must be zero and are reserved for future versions */
+ /** bits 48-63 are reserved for vendor extensions */
+ VENDOR_MASK_HI = 0xffffULL << 48,
+};
+
+/**
* Transformation definitions
*
* IMPORTANT NOTE:
diff --git a/graphics/composer/2.1/Android.bp b/graphics/composer/2.1/Android.bp
index f5ab965..a3d76d5 100644
--- a/graphics/composer/2.1/Android.bp
+++ b/graphics/composer/2.1/Android.bp
@@ -58,6 +58,7 @@
generated_sources: ["android.hardware.graphics.composer@2.1_genc++"],
generated_headers: ["android.hardware.graphics.composer@2.1_genc++_headers"],
export_generated_headers: ["android.hardware.graphics.composer@2.1_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/graphics/composer/2.1/IComposer.hal b/graphics/composer/2.1/IComposer.hal
index b3ac761..e2aa5cd 100644
--- a/graphics/composer/2.1/IComposer.hal
+++ b/graphics/composer/2.1/IComposer.hal
@@ -44,6 +44,12 @@
* applying the color transform during its composition step.
*/
SKIP_CLIENT_COLOR_TRANSFORM = 2,
+
+ /**
+ * Specifies that the present fence must not be used as an accurate
+ * representation of the actual present time of a frame.
+ */
+ PRESENT_FENCE_IS_NOT_RELIABLE = 3,
};
/**
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
index 0367fcd..fb75beb 100644
--- a/graphics/composer/2.1/default/Android.bp
+++ b/graphics/composer/2.1/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_static {
name: "libhwcomposer-client",
+ vendor_available: true,
defaults: ["hidl_defaults"],
export_include_dirs: ["."],
srcs: ["ComposerClient.cpp"],
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
index 1497065..8ca0eb3 100644
--- a/graphics/composer/2.1/default/Hwc.cpp
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -65,6 +65,12 @@
}
initCapabilities();
+ if (majorVersion >= 2 &&
+ hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
+ ALOGE("Present fence must be reliable from HWC2 on.");
+ abort();
+ }
+
initDispatch();
}
diff --git a/graphics/composer/2.1/default/service.cpp b/graphics/composer/2.1/default/service.cpp
index 712dac1..aa0604a 100644
--- a/graphics/composer/2.1/default/service.cpp
+++ b/graphics/composer/2.1/default/service.cpp
@@ -28,6 +28,7 @@
int main() {
// the conventional HAL might start binder services
+ android::ProcessState::initWithDriver("/dev/vndbinder");
android::ProcessState::self()->setThreadPoolMaxThreadCount(4);
android::ProcessState::self()->startThreadPool();
diff --git a/graphics/composer/2.1/vts/functional/Android.bp b/graphics/composer/2.1/vts/functional/Android.bp
index 8e1f925..66323d4 100644
--- a/graphics/composer/2.1/vts/functional/Android.bp
+++ b/graphics/composer/2.1/vts/functional/Android.bp
@@ -52,7 +52,6 @@
],
static_libs: [
"libhwcomposer-command-buffer",
- "libVtsHalGraphicsAllocatorTestUtils",
"libVtsHalGraphicsComposerTestUtils",
"libVtsHalGraphicsMapperTestUtils",
"VtsHalHidlTargetTestBase",
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index 0da3a33..387222f 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -18,7 +18,6 @@
#include <IComposerCommandBuffer.h>
#include <android-base/logging.h>
-#include "VtsHalGraphicsAllocatorTestUtils.h"
#include "VtsHalGraphicsComposerTestUtils.h"
#include "VtsHalGraphicsMapperTestUtils.h"
@@ -40,22 +39,15 @@
namespace tests {
namespace {
-using android::hardware::graphics::allocator::V2_0::Buffer;
-using android::hardware::graphics::allocator::V2_0::BufferDescriptor;
-using android::hardware::graphics::allocator::V2_0::ConsumerUsage;
-using android::hardware::graphics::allocator::V2_0::IAllocator;
-using android::hardware::graphics::allocator::V2_0::IAllocatorClient;
-using android::hardware::graphics::allocator::V2_0::ProducerUsage;
-using android::hardware::graphics::allocator::V2_0::tests::Allocator;
-using android::hardware::graphics::allocator::V2_0::tests::AllocatorClient;
+using android::hardware::graphics::common::V1_0::BufferUsage;
using android::hardware::graphics::common::V1_0::ColorMode;
using android::hardware::graphics::common::V1_0::ColorTransform;
using android::hardware::graphics::common::V1_0::Dataspace;
using android::hardware::graphics::common::V1_0::PixelFormat;
using android::hardware::graphics::common::V1_0::Transform;
using android::hardware::graphics::mapper::V2_0::IMapper;
-using android::hardware::graphics::mapper::V2_0::tests::Mapper;
-using GrallocError = android::hardware::graphics::allocator::V2_0::Error;
+using android::hardware::graphics::mapper::V2_0::tests::Gralloc;
+using GrallocError = android::hardware::graphics::mapper::V2_0::Error;
// IComposerCallback to be installed with IComposerClient::registerCallback.
class GraphicsComposerCallback : public IComposerCallback {
@@ -409,9 +401,7 @@
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::SetUp());
- ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
- ASSERT_NO_FATAL_FAILURE(mAllocatorClient = mAllocator->createClient());
- ASSERT_NO_FATAL_FAILURE(mMapper = std::make_unique<Mapper>());
+ ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>());
mWriter = std::make_unique<CommandWriterBase>(1024);
mReader = std::make_unique<CommandReader>();
@@ -422,15 +412,15 @@
}
const native_handle_t* allocate() {
- IAllocatorClient::BufferDescriptorInfo info{};
- info.width = 64;
- info.height = 64;
- info.layerCount = 1;
- info.format = PixelFormat::RGBA_8888;
- info.producerUsageMask = static_cast<uint64_t>(ProducerUsage::CPU_WRITE);
- info.consumerUsageMask = static_cast<uint64_t>(ConsumerUsage::CPU_READ);
+ IMapper::BufferDescriptorInfo info{};
+ info.width = 64;
+ info.height = 64;
+ info.layerCount = 1;
+ info.format = PixelFormat::RGBA_8888;
+ info.usage = static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN |
+ BufferUsage::CPU_READ_OFTEN);
- return mMapper->allocate(mAllocatorClient, info);
+ return mGralloc->allocate(info);
}
void execute() {
@@ -507,9 +497,7 @@
std::unique_ptr<CommandReader> mReader;
private:
- std::unique_ptr<Allocator> mAllocator;
- std::unique_ptr<AllocatorClient> mAllocatorClient;
- std::unique_ptr<Mapper> mMapper;
+ std::unique_ptr<Gralloc> mGralloc;
};
/**
diff --git a/graphics/mapper/2.0/Android.bp b/graphics/mapper/2.0/Android.bp
index 98a509b..b95c54d 100644
--- a/graphics/mapper/2.0/Android.bp
+++ b/graphics/mapper/2.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.graphics.mapper@2.0_genc++"],
generated_headers: ["android.hardware.graphics.mapper@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.graphics.mapper@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
@@ -51,7 +52,6 @@
"liblog",
"libutils",
"libcutils",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
@@ -60,7 +60,6 @@
"libhidltransport",
"libhwbinder",
"libutils",
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
diff --git a/graphics/mapper/2.0/IMapper.hal b/graphics/mapper/2.0/IMapper.hal
index 573dcd0..246be24 100644
--- a/graphics/mapper/2.0/IMapper.hal
+++ b/graphics/mapper/2.0/IMapper.hal
@@ -16,10 +16,39 @@
package android.hardware.graphics.mapper@2.0;
-import android.hardware.graphics.common@1.0::PixelFormat;
-import android.hardware.graphics.allocator@2.0;
+import android.hardware.graphics.common@1.0;
interface IMapper {
+ struct BufferDescriptorInfo {
+ /**
+ * The width specifies how many columns of pixels must be in the
+ * allocated buffer, but does not necessarily represent the offset in
+ * columns between the same column in adjacent rows. The rows may be
+ * padded.
+ */
+ uint32_t width;
+
+ /**
+ * The height specifies how many rows of pixels must be in the
+ * allocated buffer.
+ */
+ uint32_t height;
+
+ /**
+ * The number of image layers that must be in the allocated buffer.
+ */
+ uint32_t layerCount;
+
+ /** Buffer pixel format. */
+ PixelFormat format;
+
+ /**
+ * Buffer usage mask; valid flags can be found in the definition of
+ * BufferUsage.
+ */
+ bitfield<BufferUsage> usage;
+ };
+
struct Rect {
int32_t left;
int32_t top;
@@ -28,170 +57,76 @@
};
/**
- * Adds a reference to the given buffer handle.
+ * Creates a buffer descriptor. The descriptor can be used with IAllocator
+ * to allocate buffers.
*
- * A buffer handle received from a remote process or exported by
- * IAllocator::exportHandle is unknown to the mapper. There is also no
- * guarantee that the buffer's backing store will stay alive. This
- * function must be called at least once in both cases to intrdouce the
- * buffer handle to the mapper and to secure the backing store. It may
- * also be called more than once to increase the reference count if two
- * components in the same process want to interact with the buffer
- * independently.
+ * Since the buffer descriptor fully describes a buffer, any device
+ * dependent or device independent checks must be performed here whenever
+ * possible. Specifically, when layered buffers are not supported, this
+ * function must return UNSUPPORTED if layerCount is great than 1.
*
- * @param bufferHandle is the buffer to which a reference must be added.
+ * @param descriptorInfo specifies the attributes of the descriptor.
* @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid
- * NO_RESOURCES when it is not possible to add a
- * reference to this buffer at this time
+ * BAD_VALUE when any of the specified attributes is
+ * invalid or conflicting.
+ * NO_RESOURCES when the creation cannot be fullfilled at
+ * this time.
+ * UNSUPPORTED when any of the specified attributes is
+ * not supported.
+ * @return descriptor is the newly created buffer descriptor.
*/
@entry
@callflow(next="*")
- retain(handle bufferHandle) generates (Error error);
+ createDescriptor(BufferDescriptorInfo descriptorInfo)
+ generates (Error error,
+ BufferDescriptor descriptor);
/**
- * Removes a reference from the given buffer buffer.
+ * Imports a raw buffer handle to create an imported buffer handle for use
+ * with the rest of the mapper or with other in-process libraries.
*
- * If no references remain, the buffer handle must be freed with
- * native_handle_close/native_handle_delete by the mapper. When the last
- * buffer handle referring to a particular backing store is freed, that
- * backing store must also be freed.
+ * A buffer handle is considered raw when it is cloned or when it is
+ * received from another HAL or another process. A raw buffer handle must
+ * not be used to access the underlying graphics buffer. It must be
+ * imported to create an imported handle first.
*
- * @param bufferHandle is the buffer from which a reference must be
- * removed.
+ * This function must at least validate the raw handle before creating the
+ * imported handle. It must also support importing the same raw handle
+ * multiple times to create multiple imported handles. The imported handle
+ * must be considered valid everywhere in the process, including in
+ * another instance of the mapper.
+ *
+ * @param rawHandle is the raw buffer handle to import.
* @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
+ * BAD_BUFFER when the raw handle is invalid.
+ * NO_RESOURCES when the raw handle cannot be imported at
+ * this time.
+ * @return buffer is the imported buffer handle and has the type
+ * buffer_handle_t.
+ */
+ @entry
+ @callflow(next="*")
+ importBuffer(handle rawHandle) generates (Error error, pointer buffer);
+
+ /**
+ * Frees a buffer handle. Buffer handles returned by importBuffer must be
+ * freed with this function when no longer needed.
+ *
+ * This function must free up all resources allocated by importBuffer for
+ * the imported handle. For example, if the imported handle was created
+ * with native_handle_create, this function must call native_handle_close
+ * and native_handle_delete.
+ *
+ * @return error is NONE upon success. Otherwise,
+ * BAD_BUFFER when the buffer is invalid.
*/
@exit
- release(handle bufferHandle) generates (Error error);
-
- /**
- * Gets the width and height of the buffer in pixels.
- *
- * See IAllocator::BufferDescriptorInfo for more information.
- *
- * @param bufferHandle is the buffer from which to get the dimensions.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return width is the width of the buffer in pixels.
- * @return height is the height of the buffer in pixels.
- */
@callflow(next="*")
- getDimensions(handle bufferHandle)
- generates (Error error,
- uint32_t width,
- uint32_t height);
-
- /**
- * Gets the format of the buffer.
- *
- * See IAllocator::BufferDescriptorInfo for more information.
- *
- * @param bufferHandle is the buffer from which to get format.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return format is the format of the buffer.
- */
- @callflow(next="*")
- getFormat(handle bufferHandle)
- generates (Error error,
- PixelFormat format);
-
- /**
- * Gets the number of layers of the buffer.
- *
- * See IAllocator::BufferDescriptorInfo for more information.
- *
- * @param bufferHandle is the buffer from which to get format.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return layerCount is the number of layers of the buffer.
- */
- @callflow(next="*")
- getLayerCount(handle bufferHandle)
- generates (Error error,
- uint32_t layerCount);
-
- /**
- * Gets the producer usage flags which were used to allocate this buffer.
- *
- * See IAllocator::BufferDescriptorInfo for more information.
- *
- * @param bufferHandle is the buffer from which to get the producer usage
- * flags.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return usageMask contains the producer usage flags of the buffer.
- */
- @callflow(next="*")
- getProducerUsageMask(handle bufferHandle)
- generates (Error error,
- uint64_t usageMask);
-
- /**
- * Gets the consumer usage flags which were used to allocate this buffer.
- *
- * See IAllocator::BufferDescriptorInfo for more information.
- *
- * @param bufferHandle is the buffer from which to get the consumer usage
- * flags.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return usageMask contains the consumer usage flags of the buffer.
- */
- @callflow(next="*")
- getConsumerUsageMask(handle bufferHandle)
- generates (Error error,
- uint64_t usageMask);
-
- /**
- * Gets a value that uniquely identifies the backing store of the given
- * buffer.
- *
- * Buffers which share a backing store should return the same value from
- * this function. If the buffer is present in more than one process, the
- * backing store value for that buffer is not required to be the same in
- * every process.
- *
- * @param device is the mapper device.
- * @param bufferHandle is the buffer from which to get the backing store
- * identifier.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return store is the backing store identifier for this buffer.
- */
- @callflow(next="*")
- getBackingStore(handle bufferHandle)
- generates (Error error,
- BackingStore store);
-
- /**
- * Gets the stride of the buffer in pixels.
- *
- * The stride is the offset in pixel-sized elements between the same
- * column in two adjacent rows of pixels. This may not be equal to the
- * width of the buffer.
- *
- * @param device is the mapper device.
- * @param bufferHandle is the buffer from which to get the stride.
- * @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * UNDEFINED when the notion of a stride is not
- * meaningful for the buffer format.
- * @return store is the stride in pixels.
- */
- @callflow(next="*")
- getStride(handle bufferHandle)
- generates (Error error,
- uint32_t stride);
+ freeBuffer(pointer buffer) generates (Error error);
/**
* Locks the given buffer for the specified CPU usage.
*
- * Exactly one of producerUsageMask and consumerUsageMask must be 0. The
- * usage which is not 0 must be one of the *Usage::CPU* values, as
- * applicable. Locking a buffer for a non-CPU usage is not supported.
- *
* Locking the same buffer simultaneously from multiple threads is
* permitted, but if any of the threads attempt to lock the buffer for
* writing, the behavior is undefined, except that it must not cause
@@ -209,39 +144,27 @@
* address will represent the top-left corner of the entire buffer, even
* if accessRegion does not begin at the top-left corner.
*
- * acquireFence is a file descriptor referring to a acquire sync fence
- * object, which will be signaled when it is safe for the device to access
- * the contents of the buffer (prior to locking). If it is already safe to
- * access the buffer contents, -1 may be passed instead.
- *
- * @param bufferHandle is the buffer to lock.
- * @param producerUsageMask contains the producer usage flags to request;
- * either this or consumerUsagemask must be 0, and the other must
- * be a CPU usage.
- * @param consumerUsageMask contains the consumer usage flags to request;
- * either this or producerUsageMask must be 0, and the other must
- * be a CPU usage.
+ * @param buffer is the buffer to lock.
+ * @param cpuUsage specifies one or more CPU usage flags to request.
* @param accessRegion is the portion of the buffer that the client
* intends to access.
- * @param acquireFence is a sync fence file descriptor as described above.
+ * @param acquireFence, when non-empty, is a handle containing a file
+ * descriptor referring to a sync fence object, which will be
+ * signaled when it is safe for the mapper to lock the buffer. If
+ * it is already safe to lock, acquireFence is empty.
* @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * BAD_VALUE when neither or both of producerUsageMask
- * and consumerUsageMask were 0, or the usage
- * which was not 0 was not a CPU usage.
+ * BAD_BUFFER when the buffer is invalid or is
+ * incompatible with this function.
+ * BAD_VALUE when cpuUsage is 0, contains non-CPU usage
+ * flags, or is incompatible with the buffer.
* NO_RESOURCES when the buffer cannot be locked at this
* time, but locking may succeed at a future
* time.
- * UNSUPPORTED when the buffer cannot be locked with the
- * given usage, and any future attempts at
- * locking will also fail.
- * @return data will be filled with a CPU-accessible pointer to the buffer
- * data.
+ * @return data is a CPU-accessible pointer to the buffer data.
*/
@callflow(next="unlock")
- lock(handle bufferHandle,
- uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
+ lock(pointer buffer,
+ bitfield<BufferUsage> cpuUsage,
Rect accessRegion,
handle acquireFence)
generates (Error error,
@@ -249,7 +172,7 @@
/**
* This is largely the same as lock(), except that instead of returning a
- * pointer directly to the buffer data, it returns an FlexLayout struct
+ * pointer directly to the buffer data, it returns an YCbCrLayout struct
* describing how to access the data planes.
*
* This function must work on buffers with PixelFormat::YCbCr_*_888 if
@@ -257,67 +180,46 @@
* multimedia codecs when they are configured with a
* flexible-YUV-compatible color format.
*
- * This function may also be called on buffers of other formats, including
- * non-YUV formats, but if the buffer format is not compatible with a
- * flexible representation, it may return UNSUPPORTED.
- *
- * @param device is the mapper device.
- * @param bufferHandle is the buffer to lock.
- * @param producerUsageMask contains the producer usage flags to request;
- * either this or consumerUsagemask must be 0, and the other must
- * be a CPU usage.
- * @param consumerUsageMask contains the consumer usage flags to request;
- * either this or producerUsageMask must be 0, and the other must
- * be a CPU usage.
+ * @param buffer is the buffer to lock.
+ * @param cpuUsage specifies one or more CPU usage flags to request.
* @param accessRegion is the portion of the buffer that the client
* intends to access.
- * @param acquireFence is a sync fence file descriptor as described in
- * lock().
+ * @param acquireFence, when non-empty, is a handle containing a file
+ * descriptor referring to a sync fence object, which will be
+ * signaled when it is safe for the mapper to lock the buffer. If
+ * it is already safe to lock, acquireFence is empty.
* @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * BAD_VALUE when neither or both of producerUsageMask
- * and consumerUsageMask were 0, or the usage
- * which was not 0 was not a CPU usage.
+ * BAD_BUFFER when the buffer is invalid or is
+ * incompatible with this function.
+ * BAD_VALUE when cpuUsage is 0, contains non-CPU usage
+ * flags, or is incompatible with the buffer.
* NO_RESOURCES when the buffer cannot be locked at this
* time, but locking may succeed at a future
* time.
- * UNSUPPORTED when the buffer cannot be locked with the
- * given usage, and any future attempts at
- * locking will also fail.
- * @return flexLayout will be filled with the description of the planes in
- * the buffer.
+ * @return layout is the data layout of the buffer.
*/
@callflow(next="unlock")
- lockFlex(handle bufferHandle,
- uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
- Rect accessRegion,
- handle acquireFence)
+ lockYCbCr(pointer buffer,
+ bitfield<BufferUsage> cpuUsage,
+ Rect accessRegion,
+ handle acquireFence)
generates (Error error,
- FlexLayout layout);
+ YCbCrLayout layout);
/**
- * This function indicates to the device that the client will be done with
- * the buffer when releaseFence signals.
+ * Unlocks a buffer to indicate all CPU accesses to the buffer have
+ * completed.
*
- * releaseFence will be filled with a file descriptor referring to a
- * release sync fence object, which will be signaled when it is safe to
- * access the contents of the buffer (after the buffer has been unlocked).
- * If it is already safe to access the buffer contents, then -1 may be
- * returned instead.
- *
- * This function is used to unlock both buffers locked by lock() and those
- * locked by lockFlex().
- *
- * @param device is the mapper device.
- * @param bufferHandle is the buffer to unlock.
+ * @param buffer is the buffer to unlock.
* @return error is NONE upon success. Otherwise,
- * BAD_BUFFER when the buffer handle is invalid.
- * @return releaseFence is a sync fence file descriptor as described
- * above.
+ * BAD_BUFFER when the buffer is invalid or not locked.
+ * @return releaseFence, when non-empty, is a handle containing a file
+ * descriptor referring to a sync fence object. The sync fence
+ * object will be signaled when the mapper has completed any
+ * pending work.
*/
@callflow(next="*")
- unlock(handle bufferHandle)
+ unlock(pointer buffer)
generates (Error error,
handle releaseFence);
};
diff --git a/graphics/mapper/2.0/default/Android.bp b/graphics/mapper/2.0/default/Android.bp
index 1dc5aea..677d966 100644
--- a/graphics/mapper/2.0/default/Android.bp
+++ b/graphics/mapper/2.0/default/Android.bp
@@ -16,12 +16,11 @@
cc_library_shared {
name: "android.hardware.graphics.mapper@2.0-impl",
defaults: ["hidl_defaults"],
- proprietary: true,
+ vendor: true,
relative_install_path: "hw",
- srcs: ["GrallocMapper.cpp"],
+ srcs: ["GrallocMapper.cpp", "Gralloc0Mapper.cpp", "Gralloc1Mapper.cpp"],
cppflags: ["-Wall", "-Wextra"],
shared_libs: [
- "android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.mapper@2.0",
"libbase",
"libcutils",
@@ -29,6 +28,13 @@
"libhidlbase",
"libhidltransport",
"liblog",
+ "libsync",
"libutils",
],
}
+
+cc_library_headers {
+ name: "libgrallocmapperincludes",
+ vendor: true,
+ export_include_dirs: ["."],
+}
diff --git a/graphics/mapper/2.0/default/Gralloc0Mapper.cpp b/graphics/mapper/2.0/default/Gralloc0Mapper.cpp
new file mode 100644
index 0000000..28f5016
--- /dev/null
+++ b/graphics/mapper/2.0/default/Gralloc0Mapper.cpp
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "Gralloc0Mapper"
+
+#include "Gralloc0Mapper.h"
+
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace implementation {
+
+Gralloc0Mapper::Gralloc0Mapper(const hw_module_t* module)
+ : mModule(reinterpret_cast<const gralloc_module_t*>(module)),
+ mMinor(module->module_api_version & 0xff) {
+ mCapabilities.highUsageBits = false;
+ mCapabilities.layeredBuffers = false;
+ mCapabilities.unregisterImplyDelete = false;
+}
+
+Error Gralloc0Mapper::registerBuffer(buffer_handle_t bufferHandle) {
+ int result = mModule->registerBuffer(mModule, bufferHandle);
+ return result ? Error::BAD_BUFFER : Error::NONE;
+}
+
+void Gralloc0Mapper::unregisterBuffer(buffer_handle_t bufferHandle) {
+ mModule->unregisterBuffer(mModule, bufferHandle);
+}
+
+Error Gralloc0Mapper::lockBuffer(buffer_handle_t bufferHandle,
+ uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ void** outData) {
+ int result;
+ void* data = nullptr;
+ if (mMinor >= 3 && mModule->lockAsync) {
+ // Dup fenceFd as it is going to be owned by gralloc. Note that it is
+ // gralloc's responsibility to close it, even on locking errors.
+ if (fenceFd >= 0) {
+ fenceFd = dup(fenceFd);
+ if (fenceFd < 0) {
+ return Error::NO_RESOURCES;
+ }
+ }
+
+ result = mModule->lockAsync(mModule, bufferHandle, cpuUsage,
+ accessRegion.left, accessRegion.top,
+ accessRegion.width, accessRegion.height,
+ &data, fenceFd);
+ } else {
+ waitFenceFd(fenceFd, "Gralloc0Mapper::lock");
+
+ result = mModule->lock(mModule, bufferHandle, cpuUsage,
+ accessRegion.left, accessRegion.top,
+ accessRegion.width, accessRegion.height, &data);
+ }
+
+ if (result) {
+ return Error::BAD_VALUE;
+ } else {
+ *outData = data;
+ return Error::NONE;
+ }
+}
+
+Error Gralloc0Mapper::lockBuffer(buffer_handle_t bufferHandle,
+ uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ YCbCrLayout* outLayout) {
+ int result;
+ android_ycbcr ycbcr = {};
+ if (mMinor >= 3 && mModule->lockAsync_ycbcr) {
+ // Dup fenceFd as it is going to be owned by gralloc. Note that it is
+ // gralloc's responsibility to close it, even on locking errors.
+ if (fenceFd >= 0) {
+ fenceFd = dup(fenceFd);
+ if (fenceFd < 0) {
+ return Error::NO_RESOURCES;
+ }
+ }
+
+ result = mModule->lockAsync_ycbcr(mModule, bufferHandle, cpuUsage,
+ accessRegion.left, accessRegion.top,
+ accessRegion.width,
+ accessRegion.height, &ycbcr, fenceFd);
+ } else {
+ waitFenceFd(fenceFd, "Gralloc0Mapper::lockYCbCr");
+
+ if (mModule->lock_ycbcr) {
+ result = mModule->lock_ycbcr(mModule, bufferHandle, cpuUsage,
+ accessRegion.left, accessRegion.top,
+ accessRegion.width,
+ accessRegion.height, &ycbcr);
+ } else {
+ result = -EINVAL;
+ }
+ }
+
+ if (result) {
+ return Error::BAD_VALUE;
+ } else {
+ outLayout->y = ycbcr.y;
+ outLayout->cb = ycbcr.cb;
+ outLayout->cr = ycbcr.cr;
+ outLayout->yStride = ycbcr.ystride;
+ outLayout->cStride = ycbcr.cstride;
+ outLayout->chromaStep = ycbcr.chroma_step;
+ return Error::NONE;
+ }
+}
+
+Error Gralloc0Mapper::unlockBuffer(buffer_handle_t bufferHandle,
+ int* outFenceFd) {
+ int result;
+ int fenceFd = -1;
+ if (mMinor >= 3 && mModule->unlockAsync) {
+ result = mModule->unlockAsync(mModule, bufferHandle, &fenceFd);
+ } else {
+ result = mModule->unlock(mModule, bufferHandle);
+ }
+
+ if (result) {
+ // we always own the fenceFd even when unlock failed
+ if (fenceFd >= 0) {
+ close(fenceFd);
+ }
+
+ return Error::BAD_VALUE;
+ } else {
+ *outFenceFd = fenceFd;
+ return Error::NONE;
+ }
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/mapper/2.0/default/Gralloc0Mapper.h b/graphics/mapper/2.0/default/Gralloc0Mapper.h
new file mode 100644
index 0000000..e792a69
--- /dev/null
+++ b/graphics/mapper/2.0/default/Gralloc0Mapper.h
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC0MAPPER_H
+#define ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC0MAPPER_H
+
+#include "GrallocMapper.h"
+
+#include <hardware/gralloc.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace implementation {
+
+class Gralloc0Mapper : public GrallocMapper {
+ public:
+ Gralloc0Mapper(const hw_module_t* module);
+
+ private:
+ Error registerBuffer(buffer_handle_t bufferHandle) override;
+ void unregisterBuffer(buffer_handle_t bufferHandle) override;
+ Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ void** outData) override;
+ Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ YCbCrLayout* outLayout) override;
+ Error unlockBuffer(buffer_handle_t bufferHandle, int* outFenceFd) override;
+
+ const gralloc_module_t* mModule;
+ uint8_t mMinor;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC0MAPPER_H
diff --git a/graphics/mapper/2.0/default/Gralloc1Mapper.cpp b/graphics/mapper/2.0/default/Gralloc1Mapper.cpp
new file mode 100644
index 0000000..c1e5adc
--- /dev/null
+++ b/graphics/mapper/2.0/default/Gralloc1Mapper.cpp
@@ -0,0 +1,273 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "Gralloc1Mapper"
+
+#include "Gralloc1Mapper.h"
+
+#include <vector>
+
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::common::V1_0::BufferUsage;
+
+Gralloc1Mapper::Gralloc1Mapper(const hw_module_t* module)
+ : mDevice(nullptr), mDispatch() {
+ int result = gralloc1_open(module, &mDevice);
+ if (result) {
+ LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s",
+ strerror(-result));
+ }
+
+ initCapabilities();
+ initDispatch();
+}
+
+Gralloc1Mapper::~Gralloc1Mapper() {
+ gralloc1_close(mDevice);
+}
+
+void Gralloc1Mapper::initCapabilities() {
+ mCapabilities.highUsageBits = true;
+ mCapabilities.layeredBuffers = false;
+ mCapabilities.unregisterImplyDelete = false;
+
+ uint32_t count = 0;
+ mDevice->getCapabilities(mDevice, &count, nullptr);
+
+ std::vector<int32_t> capabilities(count);
+ mDevice->getCapabilities(mDevice, &count, capabilities.data());
+ capabilities.resize(count);
+
+ for (auto capability : capabilities) {
+ switch (capability) {
+ case GRALLOC1_CAPABILITY_LAYERED_BUFFERS:
+ mCapabilities.layeredBuffers = true;
+ break;
+ case GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE:
+ mCapabilities.unregisterImplyDelete = true;
+ break;
+ }
+ }
+}
+
+template <typename T>
+void Gralloc1Mapper::initDispatch(gralloc1_function_descriptor_t desc,
+ T* outPfn) {
+ auto pfn = mDevice->getFunction(mDevice, desc);
+ if (!pfn) {
+ LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc);
+ }
+
+ *outPfn = reinterpret_cast<T>(pfn);
+}
+
+void Gralloc1Mapper::initDispatch() {
+ initDispatch(GRALLOC1_FUNCTION_RETAIN, &mDispatch.retain);
+ initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release);
+ initDispatch(GRALLOC1_FUNCTION_GET_NUM_FLEX_PLANES,
+ &mDispatch.getNumFlexPlanes);
+ initDispatch(GRALLOC1_FUNCTION_LOCK, &mDispatch.lock);
+ initDispatch(GRALLOC1_FUNCTION_LOCK_FLEX, &mDispatch.lockFlex);
+ initDispatch(GRALLOC1_FUNCTION_UNLOCK, &mDispatch.unlock);
+}
+
+Error Gralloc1Mapper::toError(int32_t error) {
+ switch (error) {
+ case GRALLOC1_ERROR_NONE:
+ return Error::NONE;
+ case GRALLOC1_ERROR_BAD_DESCRIPTOR:
+ return Error::BAD_DESCRIPTOR;
+ case GRALLOC1_ERROR_BAD_HANDLE:
+ return Error::BAD_BUFFER;
+ case GRALLOC1_ERROR_BAD_VALUE:
+ return Error::BAD_VALUE;
+ case GRALLOC1_ERROR_NOT_SHARED:
+ return Error::NONE; // this is fine
+ case GRALLOC1_ERROR_NO_RESOURCES:
+ return Error::NO_RESOURCES;
+ case GRALLOC1_ERROR_UNDEFINED:
+ case GRALLOC1_ERROR_UNSUPPORTED:
+ default:
+ return Error::UNSUPPORTED;
+ }
+}
+
+bool Gralloc1Mapper::toYCbCrLayout(const android_flex_layout& flex,
+ YCbCrLayout* outLayout) {
+ // must be YCbCr
+ if (flex.format != FLEX_FORMAT_YCbCr || flex.num_planes < 3) {
+ return false;
+ }
+
+ for (int i = 0; i < 3; i++) {
+ const auto& plane = flex.planes[i];
+ // must have 8-bit depth
+ if (plane.bits_per_component != 8 || plane.bits_used != 8) {
+ return false;
+ }
+
+ if (plane.component == FLEX_COMPONENT_Y) {
+ // Y must not be interleaved
+ if (plane.h_increment != 1) {
+ return false;
+ }
+ } else {
+ // Cb and Cr can be interleaved
+ if (plane.h_increment != 1 && plane.h_increment != 2) {
+ return false;
+ }
+ }
+
+ if (!plane.v_increment) {
+ return false;
+ }
+ }
+
+ if (flex.planes[0].component != FLEX_COMPONENT_Y ||
+ flex.planes[1].component != FLEX_COMPONENT_Cb ||
+ flex.planes[2].component != FLEX_COMPONENT_Cr) {
+ return false;
+ }
+
+ const auto& y = flex.planes[0];
+ const auto& cb = flex.planes[1];
+ const auto& cr = flex.planes[2];
+
+ if (cb.h_increment != cr.h_increment || cb.v_increment != cr.v_increment) {
+ return false;
+ }
+
+ outLayout->y = y.top_left;
+ outLayout->cb = cb.top_left;
+ outLayout->cr = cr.top_left;
+ outLayout->yStride = y.v_increment;
+ outLayout->cStride = cb.v_increment;
+ outLayout->chromaStep = cb.h_increment;
+
+ return true;
+}
+
+gralloc1_rect_t Gralloc1Mapper::asGralloc1Rect(const IMapper::Rect& rect) {
+ return gralloc1_rect_t{rect.left, rect.top, rect.width, rect.height};
+}
+
+Error Gralloc1Mapper::registerBuffer(buffer_handle_t bufferHandle) {
+ return toError(mDispatch.retain(mDevice, bufferHandle));
+}
+
+void Gralloc1Mapper::unregisterBuffer(buffer_handle_t bufferHandle) {
+ mDispatch.release(mDevice, bufferHandle);
+}
+
+Error Gralloc1Mapper::lockBuffer(buffer_handle_t bufferHandle,
+ uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ void** outData) {
+ // Dup fenceFd as it is going to be owned by gralloc. Note that it is
+ // gralloc's responsibility to close it, even on locking errors.
+ if (fenceFd >= 0) {
+ fenceFd = dup(fenceFd);
+ if (fenceFd < 0) {
+ return Error::NO_RESOURCES;
+ }
+ }
+
+ const uint64_t consumerUsage =
+ cpuUsage & ~static_cast<uint64_t>(BufferUsage::CPU_WRITE_MASK);
+ const auto accessRect = asGralloc1Rect(accessRegion);
+ void* data = nullptr;
+ int32_t error = mDispatch.lock(mDevice, bufferHandle, cpuUsage,
+ consumerUsage, &accessRect, &data, fenceFd);
+
+ if (error == GRALLOC1_ERROR_NONE) {
+ *outData = data;
+ }
+
+ return toError(error);
+}
+
+Error Gralloc1Mapper::lockBuffer(buffer_handle_t bufferHandle,
+ uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ YCbCrLayout* outLayout) {
+ // prepare flex layout
+ android_flex_layout flex = {};
+ int32_t error =
+ mDispatch.getNumFlexPlanes(mDevice, bufferHandle, &flex.num_planes);
+ if (error != GRALLOC1_ERROR_NONE) {
+ return toError(error);
+ }
+ std::vector<android_flex_plane_t> flexPlanes(flex.num_planes);
+ flex.planes = flexPlanes.data();
+
+ // Dup fenceFd as it is going to be owned by gralloc. Note that it is
+ // gralloc's responsibility to close it, even on locking errors.
+ if (fenceFd >= 0) {
+ fenceFd = dup(fenceFd);
+ if (fenceFd < 0) {
+ return Error::NO_RESOURCES;
+ }
+ }
+
+ const uint64_t consumerUsage =
+ cpuUsage & ~static_cast<uint64_t>(BufferUsage::CPU_WRITE_MASK);
+ const auto accessRect = asGralloc1Rect(accessRegion);
+ error = mDispatch.lockFlex(mDevice, bufferHandle, cpuUsage, consumerUsage,
+ &accessRect, &flex, fenceFd);
+ if (error == GRALLOC1_ERROR_NONE && !toYCbCrLayout(flex, outLayout)) {
+ ALOGD("unable to convert android_flex_layout to YCbCrLayout");
+
+ // undo the lock
+ fenceFd = -1;
+ mDispatch.unlock(mDevice, bufferHandle, &fenceFd);
+ if (fenceFd >= 0) {
+ close(fenceFd);
+ }
+
+ error = GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ return toError(error);
+}
+
+Error Gralloc1Mapper::unlockBuffer(buffer_handle_t bufferHandle,
+ int* outFenceFd) {
+ int fenceFd = -1;
+ int32_t error = mDispatch.unlock(mDevice, bufferHandle, &fenceFd);
+
+ if (error == GRALLOC1_ERROR_NONE) {
+ *outFenceFd = fenceFd;
+ } else if (fenceFd >= 0) {
+ // we always own the fenceFd even when unlock failed
+ close(fenceFd);
+ }
+
+ return toError(error);
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/mapper/2.0/default/Gralloc1Mapper.h b/graphics/mapper/2.0/default/Gralloc1Mapper.h
new file mode 100644
index 0000000..452afdf
--- /dev/null
+++ b/graphics/mapper/2.0/default/Gralloc1Mapper.h
@@ -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.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC1MAPPER_H
+#define ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC1MAPPER_H
+
+#include "GrallocMapper.h"
+
+#include <hardware/gralloc1.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace implementation {
+
+class Gralloc1Mapper : public GrallocMapper {
+ public:
+ Gralloc1Mapper(const hw_module_t* module);
+ ~Gralloc1Mapper();
+
+ private:
+ void initCapabilities();
+
+ template <typename T>
+ void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
+ void initDispatch();
+
+ static Error toError(int32_t error);
+ static bool toYCbCrLayout(const android_flex_layout& flex,
+ YCbCrLayout* outLayout);
+ static gralloc1_rect_t asGralloc1Rect(const IMapper::Rect& rect);
+
+ Error registerBuffer(buffer_handle_t bufferHandle) override;
+ void unregisterBuffer(buffer_handle_t bufferHandle) override;
+ Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ void** outData) override;
+ Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ YCbCrLayout* outLayout) override;
+ Error unlockBuffer(buffer_handle_t bufferHandle, int* outFenceFd) override;
+
+ gralloc1_device_t* mDevice;
+
+ struct {
+ GRALLOC1_PFN_RETAIN retain;
+ GRALLOC1_PFN_RELEASE release;
+ GRALLOC1_PFN_GET_NUM_FLEX_PLANES getNumFlexPlanes;
+ GRALLOC1_PFN_LOCK lock;
+ GRALLOC1_PFN_LOCK_FLEX lockFlex;
+ GRALLOC1_PFN_UNLOCK unlock;
+ } mDispatch;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC1MAPPER_H
diff --git a/graphics/mapper/2.0/default/GrallocBufferDescriptor.h b/graphics/mapper/2.0/default/GrallocBufferDescriptor.h
new file mode 100644
index 0000000..9b5ab04
--- /dev/null
+++ b/graphics/mapper/2.0/default/GrallocBufferDescriptor.h
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOCBUFFERDESCRIPTOR_H
+#define ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOCBUFFERDESCRIPTOR_H
+
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::common::V1_0::PixelFormat;
+
+/**
+ * BufferDescriptor is created by IMapper and consumed by IAllocator. It is
+ * versioned so that IMapper and IAllocator can be updated independently.
+ */
+constexpr uint32_t grallocBufferDescriptorSize = 7;
+constexpr uint32_t grallocBufferDescriptorMagicVersion = ((0x9487 << 16) | 0);
+
+inline BufferDescriptor grallocEncodeBufferDescriptor(
+ const IMapper::BufferDescriptorInfo& descriptorInfo) {
+ BufferDescriptor descriptor;
+ descriptor.resize(grallocBufferDescriptorSize);
+ descriptor[0] = grallocBufferDescriptorMagicVersion;
+ descriptor[1] = descriptorInfo.width;
+ descriptor[2] = descriptorInfo.height;
+ descriptor[3] = descriptorInfo.layerCount;
+ descriptor[4] = static_cast<uint32_t>(descriptorInfo.format);
+ descriptor[5] = static_cast<uint32_t>(descriptorInfo.usage);
+ descriptor[6] = static_cast<uint32_t>(descriptorInfo.usage >> 32);
+
+ return descriptor;
+}
+
+inline bool grallocDecodeBufferDescriptor(
+ const BufferDescriptor& descriptor,
+ IMapper::BufferDescriptorInfo* outDescriptorInfo) {
+ if (descriptor.size() != grallocBufferDescriptorSize ||
+ descriptor[0] != grallocBufferDescriptorMagicVersion) {
+ return false;
+ }
+
+ *outDescriptorInfo = IMapper::BufferDescriptorInfo{
+ descriptor[1],
+ descriptor[2],
+ descriptor[3],
+ static_cast<PixelFormat>(descriptor[4]),
+ (static_cast<uint64_t>(descriptor[6]) << 32) | descriptor[5],
+ };
+
+ return true;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOCBUFFERDESCRIPTOR_H
diff --git a/graphics/mapper/2.0/default/GrallocMapper.cpp b/graphics/mapper/2.0/default/GrallocMapper.cpp
index 526aca2..339317a 100644
--- a/graphics/mapper/2.0/default/GrallocMapper.cpp
+++ b/graphics/mapper/2.0/default/GrallocMapper.cpp
@@ -17,14 +17,14 @@
#include "GrallocMapper.h"
-#include <mutex>
-#include <vector>
-#include <unordered_map>
+#include "Gralloc0Mapper.h"
+#include "Gralloc1Mapper.h"
+#include "GrallocBufferDescriptor.h"
-#include <string.h>
+#include <inttypes.h>
-#include <hardware/gralloc1.h>
#include <log/log.h>
+#include <sync/sync.h>
namespace android {
namespace hardware {
@@ -33,374 +33,251 @@
namespace V2_0 {
namespace implementation {
-namespace {
-
-using android::hardware::graphics::allocator::V2_0::Error;
+using android::hardware::graphics::common::V1_0::BufferUsage;
using android::hardware::graphics::common::V1_0::PixelFormat;
-class GrallocMapperHal : public IMapper {
-public:
- GrallocMapperHal(const hw_module_t* module);
- ~GrallocMapperHal();
+std::mutex GrallocMapper::mMutex;
+std::unordered_set<buffer_handle_t> GrallocMapper::mRegisteredHandles;
- // IMapper interface
- Return<Error> retain(const hidl_handle& bufferHandle) override;
- Return<Error> release(const hidl_handle& bufferHandle) override;
- Return<void> getDimensions(const hidl_handle& bufferHandle,
- getDimensions_cb hidl_cb) override;
- Return<void> getFormat(const hidl_handle& bufferHandle,
- getFormat_cb hidl_cb) override;
- Return<void> getLayerCount(const hidl_handle& bufferHandle,
- getLayerCount_cb hidl_cb) override;
- Return<void> getProducerUsageMask(const hidl_handle& bufferHandle,
- getProducerUsageMask_cb hidl_cb) override;
- Return<void> getConsumerUsageMask(const hidl_handle& bufferHandle,
- getConsumerUsageMask_cb hidl_cb) override;
- Return<void> getBackingStore(const hidl_handle& bufferHandle,
- getBackingStore_cb hidl_cb) override;
- Return<void> getStride(const hidl_handle& bufferHandle,
- getStride_cb hidl_cb) override;
- Return<void> lock(const hidl_handle& bufferHandle,
- uint64_t producerUsageMask, uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion, const hidl_handle& acquireFence,
- lock_cb hidl_cb) override;
- Return<void> lockFlex(const hidl_handle& bufferHandle,
- uint64_t producerUsageMask, uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion, const hidl_handle& acquireFence,
- lockFlex_cb hidl_cb) override;
- Return<void> unlock(const hidl_handle& bufferHandle,
- unlock_cb hidl_cb) override;
+bool GrallocMapper::validateDescriptorInfo(
+ const BufferDescriptorInfo& descriptorInfo) const {
+ const uint64_t validUsageBits =
+ BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK |
+ BufferUsage::GPU_TEXTURE | BufferUsage::GPU_RENDER_TARGET |
+ BufferUsage::COMPOSER_OVERLAY | BufferUsage::COMPOSER_CLIENT_TARGET |
+ BufferUsage::PROTECTED | BufferUsage::COMPOSER_CURSOR |
+ BufferUsage::VIDEO_ENCODER | BufferUsage::CAMERA_OUTPUT |
+ BufferUsage::CAMERA_INPUT | BufferUsage::RENDERSCRIPT |
+ BufferUsage::VIDEO_DECODER | BufferUsage::SENSOR_DIRECT_DATA |
+ BufferUsage::GPU_DATA_BUFFER | BufferUsage::VENDOR_MASK |
+ (mCapabilities.highUsageBits ? BufferUsage::VENDOR_MASK_HI
+ : static_cast<BufferUsage>(0));
-private:
- void initCapabilities();
-
- template<typename T>
- void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
- void initDispatch();
-
- static gralloc1_rect_t asGralloc1Rect(const IMapper::Rect& rect);
- static bool dupFence(const hidl_handle& fenceHandle, int* outFd);
-
- gralloc1_device_t* mDevice;
-
- struct {
- bool layeredBuffers;
- } mCapabilities;
-
- struct {
- GRALLOC1_PFN_RETAIN retain;
- GRALLOC1_PFN_RELEASE release;
- GRALLOC1_PFN_GET_DIMENSIONS getDimensions;
- GRALLOC1_PFN_GET_FORMAT getFormat;
- GRALLOC1_PFN_GET_LAYER_COUNT getLayerCount;
- GRALLOC1_PFN_GET_PRODUCER_USAGE getProducerUsage;
- GRALLOC1_PFN_GET_CONSUMER_USAGE getConsumerUsage;
- GRALLOC1_PFN_GET_BACKING_STORE getBackingStore;
- GRALLOC1_PFN_GET_STRIDE getStride;
- GRALLOC1_PFN_GET_NUM_FLEX_PLANES getNumFlexPlanes;
- GRALLOC1_PFN_LOCK lock;
- GRALLOC1_PFN_LOCK_FLEX lockFlex;
- GRALLOC1_PFN_UNLOCK unlock;
- } mDispatch;
-
- std::mutex mMutex;
- std::unordered_map<buffer_handle_t, size_t> mBufferReferenceCounts;
-};
-
-GrallocMapperHal::GrallocMapperHal(const hw_module_t* module)
- : mDevice(nullptr), mCapabilities(), mDispatch()
-{
- int status = gralloc1_open(module, &mDevice);
- if (status) {
- LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s",
- strerror(-status));
- }
-
- initCapabilities();
- initDispatch();
-}
-
-GrallocMapperHal::~GrallocMapperHal()
-{
- gralloc1_close(mDevice);
-}
-
-void GrallocMapperHal::initCapabilities()
-{
- uint32_t count = 0;
- mDevice->getCapabilities(mDevice, &count, nullptr);
-
- std::vector<int32_t> caps(count);
- mDevice->getCapabilities(mDevice, &count, caps.data());
- caps.resize(count);
-
- for (auto cap : caps) {
- switch (cap) {
- case GRALLOC1_CAPABILITY_LAYERED_BUFFERS:
- mCapabilities.layeredBuffers = true;
- break;
- default:
- break;
- }
- }
-}
-
-template<typename T>
-void GrallocMapperHal::initDispatch(gralloc1_function_descriptor_t desc,
- T* outPfn)
-{
- auto pfn = mDevice->getFunction(mDevice, desc);
- if (!pfn) {
- LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc);
- }
-
- *outPfn = reinterpret_cast<T>(pfn);
-}
-
-void GrallocMapperHal::initDispatch()
-{
- initDispatch(GRALLOC1_FUNCTION_RETAIN, &mDispatch.retain);
- initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release);
- initDispatch(GRALLOC1_FUNCTION_GET_DIMENSIONS, &mDispatch.getDimensions);
- initDispatch(GRALLOC1_FUNCTION_GET_FORMAT, &mDispatch.getFormat);
- if (mCapabilities.layeredBuffers) {
- initDispatch(GRALLOC1_FUNCTION_GET_LAYER_COUNT,
- &mDispatch.getLayerCount);
- }
- initDispatch(GRALLOC1_FUNCTION_GET_PRODUCER_USAGE,
- &mDispatch.getProducerUsage);
- initDispatch(GRALLOC1_FUNCTION_GET_CONSUMER_USAGE,
- &mDispatch.getConsumerUsage);
- initDispatch(GRALLOC1_FUNCTION_GET_BACKING_STORE,
- &mDispatch.getBackingStore);
- initDispatch(GRALLOC1_FUNCTION_GET_STRIDE, &mDispatch.getStride);
- initDispatch(GRALLOC1_FUNCTION_GET_NUM_FLEX_PLANES,
- &mDispatch.getNumFlexPlanes);
- initDispatch(GRALLOC1_FUNCTION_LOCK, &mDispatch.lock);
- initDispatch(GRALLOC1_FUNCTION_LOCK_FLEX, &mDispatch.lockFlex);
- initDispatch(GRALLOC1_FUNCTION_UNLOCK, &mDispatch.unlock);
-}
-
-gralloc1_rect_t GrallocMapperHal::asGralloc1Rect(const IMapper::Rect& rect)
-{
- return gralloc1_rect_t{rect.left, rect.top, rect.width, rect.height};
-}
-
-bool GrallocMapperHal::dupFence(const hidl_handle& fenceHandle, int* outFd)
-{
- auto handle = fenceHandle.getNativeHandle();
- if (!handle || handle->numFds == 0) {
- *outFd = -1;
- return true;
- }
-
- if (handle->numFds > 1) {
- ALOGE("invalid fence handle with %d fds", handle->numFds);
+ if (!descriptorInfo.width || !descriptorInfo.height ||
+ !descriptorInfo.layerCount) {
return false;
}
- *outFd = dup(handle->data[0]);
- return (*outFd >= 0);
-}
-
-Return<Error> GrallocMapperHal::retain(const hidl_handle& bufferHandle)
-{
- int32_t err = mDispatch.retain(mDevice, bufferHandle);
- if (err == GRALLOC1_ERROR_NONE) {
- auto nativeHandle = bufferHandle.getNativeHandle();
- std::lock_guard<std::mutex> lock(mMutex);
-
- ++mBufferReferenceCounts[nativeHandle];
- }
- return static_cast<Error>(err);
-}
-
-Return<Error> GrallocMapperHal::release(const hidl_handle& bufferHandle)
-{
- int32_t err = mDispatch.release(mDevice, bufferHandle);
- if (err == GRALLOC1_ERROR_NONE) {
- auto nativeHandle = bufferHandle.getNativeHandle();
- std::lock_guard<std::mutex> lock(mMutex);
-
- auto iter = mBufferReferenceCounts.find(bufferHandle);
- if (iter == mBufferReferenceCounts.end()) {
- // this should never happen
- err = GRALLOC1_ERROR_BAD_HANDLE;
- } else if (--iter->second == 0) {
- native_handle_close(nativeHandle);
- native_handle_delete(const_cast<native_handle_t*>(nativeHandle));
-
- mBufferReferenceCounts.erase(iter);
- }
+ if (!mCapabilities.layeredBuffers && descriptorInfo.layerCount > 1) {
+ return false;
}
- return static_cast<Error>(err);
-}
-
-Return<void> GrallocMapperHal::getDimensions(const hidl_handle& bufferHandle,
- getDimensions_cb hidl_cb)
-{
- uint32_t width = 0;
- uint32_t height = 0;
- int32_t err = mDispatch.getDimensions(mDevice, bufferHandle,
- &width, &height);
-
- hidl_cb(static_cast<Error>(err), width, height);
- return Void();
-}
-
-Return<void> GrallocMapperHal::getFormat(const hidl_handle& bufferHandle,
- getFormat_cb hidl_cb)
-{
- int32_t format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
- int32_t err = mDispatch.getFormat(mDevice, bufferHandle, &format);
-
- hidl_cb(static_cast<Error>(err), static_cast<PixelFormat>(format));
- return Void();
-}
-
-Return<void> GrallocMapperHal::getLayerCount(const hidl_handle& bufferHandle,
- getLayerCount_cb hidl_cb)
-{
- int32_t err = GRALLOC1_ERROR_NONE;
- uint32_t count = 1;
- if (mCapabilities.layeredBuffers) {
- err = mDispatch.getLayerCount(mDevice, bufferHandle, &count);
+ if (descriptorInfo.format == static_cast<PixelFormat>(0)) {
+ return false;
}
- hidl_cb(static_cast<Error>(err), count);
+ if (descriptorInfo.usage & ~validUsageBits) {
+ // could not fail as gralloc may use the reserved bits...
+ ALOGW("buffer descriptor with invalid usage bits 0x%" PRIx64,
+ descriptorInfo.usage & ~validUsageBits);
+ }
+
+ return true;
+}
+
+Return<void> GrallocMapper::createDescriptor(
+ const BufferDescriptorInfo& descriptorInfo, createDescriptor_cb hidl_cb) {
+ if (validateDescriptorInfo(descriptorInfo)) {
+ hidl_cb(Error::NONE, grallocEncodeBufferDescriptor(descriptorInfo));
+ } else {
+ hidl_cb(Error::BAD_VALUE, BufferDescriptor());
+ }
+
return Void();
}
-Return<void> GrallocMapperHal::getProducerUsageMask(
- const hidl_handle& bufferHandle, getProducerUsageMask_cb hidl_cb)
-{
- uint64_t mask = 0x0;
- int32_t err = mDispatch.getProducerUsage(mDevice, bufferHandle, &mask);
-
- hidl_cb(static_cast<Error>(err), mask);
- return Void();
+bool GrallocMapper::addRegisteredHandle(buffer_handle_t bufferHandle) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ return mRegisteredHandles.insert(bufferHandle).second;
}
-Return<void> GrallocMapperHal::getConsumerUsageMask(
- const hidl_handle& bufferHandle, getConsumerUsageMask_cb hidl_cb)
-{
- uint64_t mask = 0x0;
- int32_t err = mDispatch.getConsumerUsage(mDevice, bufferHandle, &mask);
+native_handle_t* GrallocMapper::popRegisteredHandle(void* buffer) {
+ auto bufferHandle = static_cast<native_handle_t*>(buffer);
- hidl_cb(static_cast<Error>(err), mask);
- return Void();
+ std::lock_guard<std::mutex> lock(mMutex);
+ return mRegisteredHandles.erase(bufferHandle) == 1 ? bufferHandle : nullptr;
}
-Return<void> GrallocMapperHal::getBackingStore(
- const hidl_handle& bufferHandle, getBackingStore_cb hidl_cb)
-{
- uint64_t store = 0;
- int32_t err = mDispatch.getBackingStore(mDevice, bufferHandle, &store);
+buffer_handle_t GrallocMapper::getRegisteredHandle(const void* buffer) {
+ auto bufferHandle = static_cast<buffer_handle_t>(buffer);
- hidl_cb(static_cast<Error>(err), store);
- return Void();
+ std::lock_guard<std::mutex> lock(mMutex);
+ return mRegisteredHandles.count(bufferHandle) == 1 ? bufferHandle : nullptr;
}
-Return<void> GrallocMapperHal::getStride(const hidl_handle& bufferHandle,
- getStride_cb hidl_cb)
-{
- uint32_t stride = 0;
- int32_t err = mDispatch.getStride(mDevice, bufferHandle, &stride);
+Return<void> GrallocMapper::importBuffer(const hidl_handle& rawHandle,
+ importBuffer_cb hidl_cb) {
+ // importing an already imported handle rather than a raw handle
+ if (getRegisteredHandle(rawHandle.getNativeHandle())) {
+ hidl_cb(Error::BAD_BUFFER, nullptr);
+ return Void();
+ }
- hidl_cb(static_cast<Error>(err), stride);
- return Void();
-}
+ if (!rawHandle.getNativeHandle()) {
+ hidl_cb(Error::BAD_BUFFER, nullptr);
+ return Void();
+ }
-Return<void> GrallocMapperHal::lock(const hidl_handle& bufferHandle,
- uint64_t producerUsageMask, uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion, const hidl_handle& acquireFence,
- lock_cb hidl_cb)
-{
- gralloc1_rect_t rect = asGralloc1Rect(accessRegion);
-
- int fence = -1;
- if (!dupFence(acquireFence, &fence)) {
+ native_handle_t* bufferHandle =
+ native_handle_clone(rawHandle.getNativeHandle());
+ if (!bufferHandle) {
hidl_cb(Error::NO_RESOURCES, nullptr);
return Void();
}
+ Error error = registerBuffer(bufferHandle);
+ if (error != Error::NONE) {
+ native_handle_close(bufferHandle);
+ native_handle_delete(bufferHandle);
+
+ hidl_cb(error, nullptr);
+ return Void();
+ }
+
+ // The newly cloned handle is already registered? This can only happen
+ // when a handle previously registered was native_handle_delete'd instead
+ // of freeBuffer'd.
+ if (!addRegisteredHandle(bufferHandle)) {
+ ALOGE("handle %p has already been imported; potential fd leaking",
+ bufferHandle);
+ unregisterBuffer(bufferHandle);
+ if (!mCapabilities.unregisterImplyDelete) {
+ native_handle_close(bufferHandle);
+ native_handle_delete(bufferHandle);
+ }
+
+ hidl_cb(Error::NO_RESOURCES, nullptr);
+ return Void();
+ }
+
+ hidl_cb(Error::NONE, bufferHandle);
+ return Void();
+}
+
+Return<Error> GrallocMapper::freeBuffer(void* buffer) {
+ native_handle_t* bufferHandle = popRegisteredHandle(buffer);
+ if (!bufferHandle) {
+ return Error::BAD_BUFFER;
+ }
+
+ unregisterBuffer(bufferHandle);
+ if (!mCapabilities.unregisterImplyDelete) {
+ native_handle_close(bufferHandle);
+ native_handle_delete(bufferHandle);
+ }
+
+ return Error::NONE;
+}
+
+void GrallocMapper::waitFenceFd(int fenceFd, const char* logname) {
+ if (fenceFd < 0) {
+ return;
+ }
+
+ const int warningTimeout = 3500;
+ const int error = sync_wait(fenceFd, warningTimeout);
+ if (error < 0 && errno == ETIME) {
+ ALOGE("%s: fence %d didn't signal in %u ms", logname, fenceFd,
+ warningTimeout);
+ sync_wait(fenceFd, -1);
+ }
+}
+
+bool GrallocMapper::getFenceFd(const hidl_handle& fenceHandle,
+ int* outFenceFd) {
+ auto handle = fenceHandle.getNativeHandle();
+ if (handle && handle->numFds > 1) {
+ ALOGE("invalid fence handle with %d fds", handle->numFds);
+ return false;
+ }
+
+ *outFenceFd = (handle && handle->numFds == 1) ? handle->data[0] : -1;
+ return true;
+}
+
+hidl_handle GrallocMapper::getFenceHandle(int fenceFd, char* handleStorage) {
+ native_handle_t* handle = nullptr;
+ if (fenceFd >= 0) {
+ handle = native_handle_init(handleStorage, 1, 0);
+ handle->data[0] = fenceFd;
+ }
+
+ return hidl_handle(handle);
+}
+
+Return<void> GrallocMapper::lock(void* buffer, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion,
+ const hidl_handle& acquireFence,
+ lock_cb hidl_cb) {
+ buffer_handle_t bufferHandle = getRegisteredHandle(buffer);
+ if (!bufferHandle) {
+ hidl_cb(Error::BAD_BUFFER, nullptr);
+ return Void();
+ }
+
+ int fenceFd;
+ if (!getFenceFd(acquireFence, &fenceFd)) {
+ hidl_cb(Error::BAD_VALUE, nullptr);
+ return Void();
+ }
+
void* data = nullptr;
- int32_t err = mDispatch.lock(mDevice, bufferHandle, producerUsageMask,
- consumerUsageMask, &rect, &data, fence);
- if (err != GRALLOC1_ERROR_NONE) {
- close(fence);
- }
+ Error error =
+ lockBuffer(bufferHandle, cpuUsage, accessRegion, fenceFd, &data);
- hidl_cb(static_cast<Error>(err), data);
+ hidl_cb(error, data);
return Void();
}
-Return<void> GrallocMapperHal::lockFlex(const hidl_handle& bufferHandle,
- uint64_t producerUsageMask, uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion, const hidl_handle& acquireFence,
- lockFlex_cb hidl_cb)
-{
- FlexLayout layout_reply{};
+Return<void> GrallocMapper::lockYCbCr(void* buffer, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion,
+ const hidl_handle& acquireFence,
+ lockYCbCr_cb hidl_cb) {
+ YCbCrLayout layout = {};
- uint32_t planeCount = 0;
- int32_t err = mDispatch.getNumFlexPlanes(mDevice, bufferHandle,
- &planeCount);
- if (err != GRALLOC1_ERROR_NONE) {
- hidl_cb(static_cast<Error>(err), layout_reply);
+ buffer_handle_t bufferHandle = getRegisteredHandle(buffer);
+ if (!bufferHandle) {
+ hidl_cb(Error::BAD_BUFFER, layout);
return Void();
}
- gralloc1_rect_t rect = asGralloc1Rect(accessRegion);
-
- int fence = -1;
- if (!dupFence(acquireFence, &fence)) {
- hidl_cb(Error::NO_RESOURCES, layout_reply);
+ int fenceFd;
+ if (!getFenceFd(acquireFence, &fenceFd)) {
+ hidl_cb(Error::BAD_VALUE, layout);
return Void();
}
- std::vector<android_flex_plane_t> planes(planeCount);
- android_flex_layout_t layout{};
- layout.num_planes = planes.size();
- layout.planes = planes.data();
+ Error error =
+ lockBuffer(bufferHandle, cpuUsage, accessRegion, fenceFd, &layout);
- err = mDispatch.lockFlex(mDevice, bufferHandle, producerUsageMask,
- consumerUsageMask, &rect, &layout, fence);
- if (err == GRALLOC1_ERROR_NONE) {
- layout_reply.format = static_cast<FlexFormat>(layout.format);
+ hidl_cb(error, layout);
+ return Void();
+}
- planes.resize(layout.num_planes);
- layout_reply.planes.setToExternal(
- reinterpret_cast<FlexPlane*>(planes.data()), planes.size());
+Return<void> GrallocMapper::unlock(void* buffer, unlock_cb hidl_cb) {
+ buffer_handle_t bufferHandle = getRegisteredHandle(buffer);
+ if (!bufferHandle) {
+ hidl_cb(Error::BAD_BUFFER, nullptr);
+ return Void();
+ }
+
+ int fenceFd;
+ Error error = unlockBuffer(bufferHandle, &fenceFd);
+ if (error == Error::NONE) {
+ NATIVE_HANDLE_DECLARE_STORAGE(fenceStorage, 1, 0);
+
+ hidl_cb(error, getFenceHandle(fenceFd, fenceStorage));
+
+ if (fenceFd >= 0) {
+ close(fenceFd);
+ }
} else {
- close(fence);
+ hidl_cb(error, nullptr);
}
- hidl_cb(static_cast<Error>(err), layout_reply);
return Void();
}
-Return<void> GrallocMapperHal::unlock(const hidl_handle& bufferHandle,
- unlock_cb hidl_cb)
-{
- int32_t fence = -1;
- int32_t err = mDispatch.unlock(mDevice, bufferHandle, &fence);
-
- NATIVE_HANDLE_DECLARE_STORAGE(fenceStorage, 1, 0);
- hidl_handle fenceHandle;
- if (err == GRALLOC1_ERROR_NONE && fence >= 0) {
- auto nativeHandle = native_handle_init(fenceStorage, 1, 0);
- nativeHandle->data[0] = fence;
-
- fenceHandle = nativeHandle;
- }
-
- hidl_cb(static_cast<Error>(err), fenceHandle);
- return Void();
-}
-
-} // anonymous namespace
-
IMapper* HIDL_FETCH_IMapper(const char* /* name */) {
const hw_module_t* module = nullptr;
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
@@ -410,12 +287,15 @@
}
uint8_t major = (module->module_api_version >> 8) & 0xff;
- if (major != 1) {
- ALOGE("unknown gralloc module major version %d", major);
- return nullptr;
+ switch (major) {
+ case 1:
+ return new Gralloc1Mapper(module);
+ case 0:
+ return new Gralloc0Mapper(module);
+ default:
+ ALOGE("unknown gralloc module major version %d", major);
+ return nullptr;
}
-
- return new GrallocMapperHal(module);
}
} // namespace implementation
diff --git a/graphics/mapper/2.0/default/GrallocMapper.h b/graphics/mapper/2.0/default/GrallocMapper.h
index a2f89d1..c9c6d8a 100644
--- a/graphics/mapper/2.0/default/GrallocMapper.h
+++ b/graphics/mapper/2.0/default/GrallocMapper.h
@@ -18,6 +18,10 @@
#define ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_GRALLOC_MAPPER_H
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <system/window.h>
+
+#include <mutex>
+#include <unordered_set>
namespace android {
namespace hardware {
@@ -26,6 +30,68 @@
namespace V2_0 {
namespace implementation {
+class GrallocMapper : public IMapper {
+ public:
+ // IMapper interface
+ Return<void> createDescriptor(const BufferDescriptorInfo& descriptorInfo,
+ createDescriptor_cb hidl_cb) override;
+ Return<void> importBuffer(const hidl_handle& rawHandle,
+ importBuffer_cb hidl_cb) override;
+ Return<Error> freeBuffer(void* buffer) override;
+ Return<void> lock(void* buffer, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion,
+ const hidl_handle& acquireFence,
+ lock_cb hidl_cb) override;
+ Return<void> lockYCbCr(void* buffer, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion,
+ const hidl_handle& acquireFence,
+ lockYCbCr_cb hidl_cb) override;
+ Return<void> unlock(void* buffer, unlock_cb hidl_cb) override;
+
+ protected:
+ static void waitFenceFd(int fenceFd, const char* logname);
+
+ struct {
+ bool highUsageBits;
+ bool layeredBuffers;
+ bool unregisterImplyDelete;
+ } mCapabilities = {};
+
+ private:
+ virtual bool validateDescriptorInfo(
+ const BufferDescriptorInfo& descriptorInfo) const;
+
+ // Register a buffer. The handle is already cloned by the caller.
+ virtual Error registerBuffer(buffer_handle_t bufferHandle) = 0;
+
+ // Unregister a buffer. The handle is closed and deleted by the
+ // callee if and only if mCapabilities.unregisterImplyDelete is set.
+ virtual void unregisterBuffer(buffer_handle_t bufferHandle) = 0;
+
+ // Lock a buffer. The fence is owned by the caller.
+ virtual Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ void** outData) = 0;
+ virtual Error lockBuffer(buffer_handle_t bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int fenceFd,
+ YCbCrLayout* outLayout) = 0;
+
+ // Unlock a buffer. The returned fence is owned by the caller.
+ virtual Error unlockBuffer(buffer_handle_t bufferHandle,
+ int* outFenceFd) = 0;
+
+ static bool addRegisteredHandle(buffer_handle_t bufferHandle);
+ static buffer_handle_t getRegisteredHandle(const void* buffer);
+ static native_handle_t* popRegisteredHandle(void* buffer);
+
+ static bool getFenceFd(const hidl_handle& fenceHandle, int* outFenceFd);
+ static hidl_handle getFenceHandle(int fenceFd, char* handleStorage);
+
+ // these are static and shared by all mappers
+ static std::mutex mMutex;
+ static std::unordered_set<buffer_handle_t> mRegisteredHandles;
+};
+
extern "C" IMapper* HIDL_FETCH_IMapper(const char* name);
} // namespace implementation
diff --git a/graphics/mapper/2.0/types.hal b/graphics/mapper/2.0/types.hal
index 2946e85..e9b2f3a 100644
--- a/graphics/mapper/2.0/types.hal
+++ b/graphics/mapper/2.0/types.hal
@@ -16,101 +16,50 @@
package android.hardware.graphics.mapper@2.0;
+enum Error : int32_t {
+ NONE = 0, /** no error */
+ BAD_DESCRIPTOR = 1, /** invalid BufferDescriptor */
+ BAD_BUFFER = 2, /** invalid buffer handle */
+ BAD_VALUE = 3, /** invalid width, height, etc. */
+ /* 4 is reserved */
+ NO_RESOURCES = 5, /** temporary failure due to resource contention */
+ /* 6 is reserved */
+ UNSUPPORTED = 7, /** permanent failure */
+};
+
/**
- * Structures for describing flexible YUVA/RGBA formats for consumption by
- * applications. Such flexible formats contain a plane for each component (e.g.
- * red, green, blue), where each plane is laid out in a grid-like pattern
- * occupying unique byte addresses and with consistent byte offsets between
- * neighboring pixels.
- *
- * The FlexLayout structure is used with any pixel format that can be
- * represented by it, such as:
- * - PixelFormat::YCBCR_*_888
- * - PixelFormat::FLEX_RGB*_888
- * - PixelFormat::RGB[AX]_888[8],BGRA_8888,RGB_888
- * - PixelFormat::YV12,Y8,Y16,YCBCR_422_SP/I,YCRCB_420_SP
- * - even implementation defined formats that can be represented by
- * the structures
- *
- * Vertical increment (aka. row increment or stride) describes the distance in
- * bytes from the first pixel of one row to the first pixel of the next row
- * (below) for the component plane. This can be negative.
- *
- * Horizontal increment (aka. column or pixel increment) describes the distance
- * in bytes from one pixel to the next pixel (to the right) on the same row for
- * the component plane. This can be negative.
- *
- * Each plane can be subsampled either vertically or horizontally by
- * a power-of-two factor.
- *
- * The bit-depth of each component can be arbitrary, as long as the pixels are
- * laid out on whole bytes, in native byte-order, using the most significant
- * bits of each unit.
+ * A buffer descriptor is an implementation-defined opaque data returned by
+ * createDescriptor. It describes the properties of a buffer and is consumed
+ * by the allocator.
*/
+typedef vec<uint32_t> BufferDescriptor;
-enum FlexComponent : int32_t {
- Y = 1 << 0, /** luma */
- CB = 1 << 1, /** chroma blue */
- CR = 1 << 2, /** chroma red */
-
- R = 1 << 10, /** red */
- G = 1 << 11, /** green */
- B = 1 << 12, /** blue */
-
- A = 1 << 30, /** alpha */
+/**
+ * Structure for describing YCbCr formats for consumption by applications.
+ * This is used with PixelFormat::YCBCR_*_888.
+ *
+ * Buffer chroma subsampling is defined in the format.
+ * e.g. PixelFormat::YCBCR_420_888 has subsampling 4:2:0.
+ *
+ * Buffers must have a 8 bit depth.
+ *
+ * y, cb, and cr point to the first byte of their respective planes.
+ *
+ * Stride describes the distance in bytes from the first value of one row of
+ * the image to the first value of the next row. It includes the width of the
+ * image plus padding.
+ * yStride is the stride of the luma plane.
+ * cStride is the stride of the chroma planes.
+ *
+ * chromaStep is the distance in bytes from one chroma pixel value to the
+ * next. This is 2 bytes for semiplanar (because chroma values are interleaved
+ * and each chroma value is one byte) and 1 for planar.
+ */
+struct YCbCrLayout {
+ pointer y;
+ pointer cb;
+ pointer cr;
+ uint32_t yStride;
+ uint32_t cStride;
+ uint32_t chromaStep;
};
-
-enum FlexFormat : int32_t {
- /** not a flexible format */
- INVALID = 0x0,
-
- Y = FlexComponent:Y,
- YCBCR = Y | FlexComponent:CB | FlexComponent:CR,
- YCBCRA = YCBCR | FlexComponent:A,
-
- RGB = FlexComponent:R | FlexComponent:G | FlexComponent:B,
- RGBA = RGB | FlexComponent:A,
-};
-
-struct FlexPlane {
- /** Pointer to the first byte of the top-left pixel of the plane. */
- pointer topLeft;
-
- FlexComponent component;
-
- /**
- * Bits allocated for the component in each pixel. Must be a positive
- * multiple of 8.
- */
- int32_t bitsPerComponent;
-
- /**
- * Number of the most significant bits used in the format for this
- * component. Must be between 1 and bitsPerComponent, inclusive.
- */
- int32_t bitsUsed;
-
- /** Horizontal increment. */
- int32_t hIncrement;
- /** Vertical increment. */
- int32_t vIncrement;
- /** Horizontal subsampling. Must be a positive power of 2. */
- int32_t hSubsampling;
- /** Vertical subsampling. Must be a positive power of 2. */
- int32_t vSubsampling;
-};
-
-struct FlexLayout {
- /** The kind of flexible format. */
- FlexFormat format;
-
- /**
- * A plane for each component; ordered in increasing component value
- * order. E.g. FlexFormat::RGBA maps 0 -> R, 1 -> G, etc. Can have size 0
- * for FlexFormat::INVALID.
- */
- vec<FlexPlane> planes;
-};
-
-/** Backing store ID of a buffer. See IMapper::getBackingStore. */
-typedef uint64_t BackingStore;
diff --git a/graphics/mapper/2.0/vts/functional/Android.bp b/graphics/mapper/2.0/vts/functional/Android.bp
index e26f087..1c0e4c5 100644
--- a/graphics/mapper/2.0/vts/functional/Android.bp
+++ b/graphics/mapper/2.0/vts/functional/Android.bp
@@ -24,7 +24,6 @@
],
static_libs: [
"VtsHalHidlTargetTestBase",
- "libVtsHalGraphicsAllocatorTestUtils",
],
cflags: [
"-Wall",
@@ -54,7 +53,6 @@
"android.hardware.graphics.common@1.0",
],
static_libs: [
- "libVtsHalGraphicsAllocatorTestUtils",
"libVtsHalGraphicsMapperTestUtils",
"VtsHalHidlTargetTestBase",
],
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
index f6a26ac..c534889 100644
--- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
@@ -25,228 +25,233 @@
namespace V2_0 {
namespace tests {
-using android::hardware::graphics::allocator::V2_0::Buffer;
-using android::hardware::graphics::allocator::V2_0::BufferDescriptor;
-using android::hardware::graphics::allocator::V2_0::Error;
-
-Mapper::Mapper() { init(); }
-
-void Mapper::init() {
- mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>();
- ASSERT_NE(nullptr, mMapper.get()) << "failed to get mapper service";
- ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
+Gralloc::Gralloc() {
+ init();
}
-Mapper::~Mapper() {
- for (auto it : mHandles) {
- while (it.second) {
- EXPECT_EQ(Error::NONE, mMapper->release(it.first))
- << "failed to release handle " << it.first;
- it.second--;
+void Gralloc::init() {
+ mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>();
+ ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
+
+ mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>();
+ ASSERT_NE(nullptr, mMapper.get()) << "failed to get mapper service";
+ ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
+}
+
+Gralloc::~Gralloc() {
+ for (auto bufferHandle : mClonedBuffers) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+ native_handle_close(buffer);
+ native_handle_delete(buffer);
}
- }
- mHandles.clear();
+ mClonedBuffers.clear();
+
+ for (auto bufferHandle : mImportedBuffers) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+ EXPECT_EQ(Error::NONE, mMapper->freeBuffer(buffer))
+ << "failed to free buffer " << buffer;
+ }
+ mImportedBuffers.clear();
}
-sp<IMapper> Mapper::getRaw() const { return mMapper; }
-
-void Mapper::retain(const native_handle_t* handle) {
- Error error = mMapper->retain(handle);
- ASSERT_EQ(Error::NONE, error) << "failed to retain handle " << handle;
-
- mHandles[handle]++;
+sp<IAllocator> Gralloc::getAllocator() const {
+ return mAllocator;
}
-void Mapper::release(const native_handle_t* handle) {
- Error error = mMapper->release(handle);
- ASSERT_EQ(Error::NONE, error) << "failed to release handle " << handle;
+std::string Gralloc::dumpDebugInfo() {
+ std::string debugInfo;
+ mAllocator->dumpDebugInfo(
+ [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
- if (--mHandles[handle] == 0) {
- mHandles.erase(handle);
- }
+ return debugInfo;
}
-Mapper::Dimensions Mapper::getDimensions(const native_handle_t* handle) {
- Dimensions dimensions = {};
- mMapper->getDimensions(handle, [&](const auto& tmpError, const auto& tmpWidth,
- const auto& tmpHeight) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get dimensions for handle " << handle;
- dimensions.width = tmpWidth;
- dimensions.height = tmpHeight;
- });
+const native_handle_t* Gralloc::cloneBuffer(const hidl_handle& rawHandle) {
+ const native_handle_t* bufferHandle =
+ native_handle_clone(rawHandle.getNativeHandle());
+ EXPECT_NE(nullptr, bufferHandle);
- return dimensions;
+ if (bufferHandle) {
+ mClonedBuffers.insert(bufferHandle);
+ }
+
+ return bufferHandle;
}
-PixelFormat Mapper::getFormat(const native_handle_t* handle) {
- PixelFormat format = static_cast<PixelFormat>(0);
- mMapper->getFormat(handle, [&](const auto& tmpError, const auto& tmpFormat) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get format for handle " << handle;
- format = tmpFormat;
- });
+std::vector<const native_handle_t*> Gralloc::allocate(
+ const BufferDescriptor& descriptor, uint32_t count, bool import,
+ uint32_t* outStride) {
+ std::vector<const native_handle_t*> bufferHandles;
+ bufferHandles.reserve(count);
+ mAllocator->allocate(
+ descriptor, count, [&](const auto& tmpError, const auto& tmpStride,
+ const auto& tmpBuffers) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to allocate buffers";
+ ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array";
- return format;
+ for (uint32_t i = 0; i < count; i++) {
+ if (import) {
+ ASSERT_NO_FATAL_FAILURE(
+ bufferHandles.push_back(importBuffer(tmpBuffers[i])));
+ } else {
+ ASSERT_NO_FATAL_FAILURE(
+ bufferHandles.push_back(cloneBuffer(tmpBuffers[i])));
+ }
+ }
+
+ if (outStride) {
+ *outStride = tmpStride;
+ }
+ });
+
+ if (::testing::Test::HasFatalFailure()) {
+ bufferHandles.clear();
+ }
+
+ return bufferHandles;
}
-uint32_t Mapper::getLayerCount(const native_handle_t* handle) {
- uint32_t count = 0;
- mMapper->getLayerCount(
- handle, [&](const auto& tmpError, const auto& tmpCount) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get layer count for handle " << handle;
- count = tmpCount;
- });
+const native_handle_t* Gralloc::allocate(
+ const IMapper::BufferDescriptorInfo& descriptorInfo, bool import,
+ uint32_t* outStride) {
+ BufferDescriptor descriptor = createDescriptor(descriptorInfo);
+ if (::testing::Test::HasFatalFailure()) {
+ return nullptr;
+ }
- return count;
+ auto buffers = allocate(descriptor, 1, import, outStride);
+ if (::testing::Test::HasFatalFailure()) {
+ return nullptr;
+ }
+
+ return buffers[0];
}
-uint64_t Mapper::getProducerUsageMask(const native_handle_t* handle) {
- uint64_t usageMask = 0;
- mMapper->getProducerUsageMask(
- handle, [&](const auto& tmpError, const auto& tmpUsageMask) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get producer usage mask for handle " << handle;
- usageMask = tmpUsageMask;
- });
-
- return usageMask;
+sp<IMapper> Gralloc::getMapper() const {
+ return mMapper;
}
-uint64_t Mapper::getConsumerUsageMask(const native_handle_t* handle) {
- uint64_t usageMask = 0;
- mMapper->getConsumerUsageMask(
- handle, [&](const auto& tmpError, const auto& tmpUsageMask) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get consumer usage mask for handle " << handle;
- usageMask = tmpUsageMask;
- });
+BufferDescriptor Gralloc::createDescriptor(
+ const IMapper::BufferDescriptorInfo& descriptorInfo) {
+ BufferDescriptor descriptor;
+ mMapper->createDescriptor(
+ descriptorInfo, [&](const auto& tmpError, const auto& tmpDescriptor) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor";
+ descriptor = tmpDescriptor;
+ });
- return usageMask;
+ return descriptor;
}
-BackingStore Mapper::getBackingStore(const native_handle_t* handle) {
- BackingStore backingStore = 0;
- mMapper->getBackingStore(
- handle, [&](const auto& tmpError, const auto& tmpBackingStore) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get backing store for handle " << handle;
- backingStore = tmpBackingStore;
- });
+const native_handle_t* Gralloc::importBuffer(const hidl_handle& rawHandle) {
+ const native_handle_t* bufferHandle = nullptr;
+ mMapper->importBuffer(
+ rawHandle, [&](const auto& tmpError, const auto& tmpBuffer) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to import buffer %p"
+ << rawHandle.getNativeHandle();
+ bufferHandle = static_cast<const native_handle_t*>(tmpBuffer);
+ });
- return backingStore;
+ if (bufferHandle) {
+ mImportedBuffers.insert(bufferHandle);
+ }
+
+ return bufferHandle;
}
-uint32_t Mapper::getStride(const native_handle_t* handle) {
- uint32_t stride = 0;
- mMapper->getStride(handle, [&](const auto& tmpError, const auto& tmpStride) {
- ASSERT_EQ(Error::NONE, tmpError)
- << "failed to get stride for handle " << handle;
- stride = tmpStride;
- });
+void Gralloc::freeBuffer(const native_handle_t* bufferHandle) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
- return stride;
+ if (mImportedBuffers.erase(bufferHandle)) {
+ Error error = mMapper->freeBuffer(buffer);
+ ASSERT_EQ(Error::NONE, error) << "failed to free buffer " << buffer;
+ } else {
+ mClonedBuffers.erase(bufferHandle);
+ native_handle_close(buffer);
+ native_handle_delete(buffer);
+ }
}
-void* Mapper::lock(const native_handle_t* handle, uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion, int acquireFence) {
- NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 0, 1);
- native_handle_t* acquireFenceHandle = nullptr;
- if (acquireFence >= 0) {
- acquireFenceHandle = native_handle_init(acquireFenceStorage, 0, 1);
- acquireFenceHandle->data[0] = acquireFence;
- }
+void* Gralloc::lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int acquireFence) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
- void* data = nullptr;
- mMapper->lock(
- handle, producerUsageMask, consumerUsageMask, accessRegion,
- acquireFenceHandle, [&](const auto& tmpError, const auto& tmpData) {
- ASSERT_EQ(Error::NONE, tmpError) << "failed to lock handle " << handle;
- data = tmpData;
- });
+ NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 1, 0);
+ hidl_handle acquireFenceHandle;
+ if (acquireFence >= 0) {
+ auto h = native_handle_init(acquireFenceStorage, 1, 0);
+ h->data[0] = acquireFence;
+ acquireFenceHandle = h;
+ }
- if (acquireFence >= 0) {
- close(acquireFence);
- }
-
- return data;
-}
-
-FlexLayout Mapper::lockFlex(const native_handle_t* handle,
- uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion,
- int acquireFence) {
- NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 0, 1);
- native_handle_t* acquireFenceHandle = nullptr;
- if (acquireFence >= 0) {
- acquireFenceHandle = native_handle_init(acquireFenceStorage, 0, 1);
- acquireFenceHandle->data[0] = acquireFence;
- }
-
- FlexLayout layout = {};
- mMapper->lockFlex(handle, producerUsageMask, consumerUsageMask, accessRegion,
- acquireFenceHandle,
- [&](const auto& tmpError, const auto& tmpLayout) {
+ void* data = nullptr;
+ mMapper->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpData) {
ASSERT_EQ(Error::NONE, tmpError)
- << "failed to lockFlex handle " << handle;
- layout = tmpLayout;
- });
+ << "failed to lock buffer " << buffer;
+ data = tmpData;
+ });
- if (acquireFence >= 0) {
- close(acquireFence);
- }
-
- return layout;
-}
-
-int Mapper::unlock(const native_handle_t* handle) {
- int releaseFence = -1;
- mMapper->unlock(handle, [&](const auto& tmpError,
- const auto& tmpReleaseFence) {
- ASSERT_EQ(Error::NONE, tmpError) << "failed to unlock handle " << handle;
-
- auto handle = tmpReleaseFence.getNativeHandle();
- if (handle) {
- ASSERT_EQ(0, handle->numInts) << "invalid fence handle " << handle;
- if (handle->numFds == 1) {
- releaseFence = dup(handle->data[0]);
- ASSERT_LT(0, releaseFence) << "failed to dup fence fd";
- } else {
- ASSERT_EQ(0, handle->numFds) << " invalid fence handle " << handle;
- }
+ if (acquireFence >= 0) {
+ close(acquireFence);
}
- });
- return releaseFence;
+ return data;
}
-const native_handle_t* Mapper::allocate(
- std::unique_ptr<AllocatorClient>& allocatorClient,
- const IAllocatorClient::BufferDescriptorInfo& info) {
- BufferDescriptor descriptor = allocatorClient->createDescriptor(info);
- if (::testing::Test::HasFatalFailure()) {
- return nullptr;
- }
+YCbCrLayout Gralloc::lockYCbCr(const native_handle_t* bufferHandle,
+ uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion,
+ int acquireFence) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
- Buffer buffer = allocatorClient->allocate(descriptor);
- if (::testing::Test::HasFatalFailure()) {
- allocatorClient->destroyDescriptor(descriptor);
- return nullptr;
- }
+ NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 1, 0);
+ hidl_handle acquireFenceHandle;
+ if (acquireFence >= 0) {
+ auto h = native_handle_init(acquireFenceStorage, 1, 0);
+ h->data[0] = acquireFence;
+ acquireFenceHandle = h;
+ }
- const native_handle_t* handle =
- allocatorClient->exportHandle(descriptor, buffer);
- if (handle) {
- retain(handle);
- }
+ YCbCrLayout layout = {};
+ mMapper->lockYCbCr(buffer, cpuUsage, accessRegion, acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpLayout) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to lockYCbCr buffer " << buffer;
+ layout = tmpLayout;
+ });
- allocatorClient->free(buffer);
- allocatorClient->destroyDescriptor(descriptor);
+ if (acquireFence >= 0) {
+ close(acquireFence);
+ }
- return handle;
+ return layout;
+}
+
+int Gralloc::unlock(const native_handle_t* bufferHandle) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+
+ int releaseFence = -1;
+ mMapper->unlock(
+ buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to unlock buffer "
+ << buffer;
+
+ auto fenceHandle = tmpReleaseFence.getNativeHandle();
+ if (fenceHandle) {
+ ASSERT_EQ(0, fenceHandle->numInts) << "invalid fence handle "
+ << fenceHandle;
+ if (fenceHandle->numFds == 1) {
+ releaseFence = dup(fenceHandle->data[0]);
+ ASSERT_LT(0, releaseFence) << "failed to dup fence fd";
+ } else {
+ ASSERT_EQ(0, fenceHandle->numFds)
+ << " invalid fence handle " << fenceHandle;
+ }
+ }
+ });
+
+ return releaseFence;
}
} // namespace tests
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h
index c186b00..757f20b 100644
--- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h
@@ -17,14 +17,12 @@
#ifndef VTS_HAL_GRAPHICS_MAPPER_UTILS
#define VTS_HAL_GRAPHICS_MAPPER_UTILS
-#include <memory>
-#include <unordered_map>
+#include <unordered_set>
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <utils/StrongPointer.h>
-#include "VtsHalGraphicsAllocatorTestUtils.h"
-
namespace android {
namespace hardware {
namespace graphics {
@@ -32,59 +30,62 @@
namespace V2_0 {
namespace tests {
-using android::hardware::graphics::common::V1_0::PixelFormat;
-using android::hardware::graphics::allocator::V2_0::IAllocatorClient;
-using android::hardware::graphics::allocator::V2_0::tests::AllocatorClient;
+using android::hardware::graphics::allocator::V2_0::IAllocator;
-// A wrapper to IMapper.
-class Mapper {
- public:
- Mapper();
- ~Mapper();
+// A wrapper to IAllocator and IMapper.
+class Gralloc {
+ public:
+ Gralloc();
+ ~Gralloc();
- sp<IMapper> getRaw() const;
+ // IAllocator methods
- void retain(const native_handle_t* handle);
- void release(const native_handle_t* handle);
+ sp<IAllocator> getAllocator() const;
- struct Dimensions {
- uint32_t width;
- uint32_t height;
- };
- Dimensions getDimensions(const native_handle_t* handle);
+ std::string dumpDebugInfo();
- PixelFormat getFormat(const native_handle_t* handle);
- uint32_t getLayerCount(const native_handle_t* handle);
- uint64_t getProducerUsageMask(const native_handle_t* handle);
- uint64_t getConsumerUsageMask(const native_handle_t* handle);
- BackingStore getBackingStore(const native_handle_t* handle);
- uint32_t getStride(const native_handle_t* handle);
+ // When import is false, this simply calls IAllocator::allocate. When import
+ // is true, the returned buffers are also imported into the mapper.
+ //
+ // Either case, the returned buffers must be freed with freeBuffer.
+ std::vector<const native_handle_t*> allocate(
+ const BufferDescriptor& descriptor, uint32_t count, bool import = true,
+ uint32_t* outStride = nullptr);
+ const native_handle_t* allocate(
+ const IMapper::BufferDescriptorInfo& descriptorInfo, bool import = true,
+ uint32_t* outStride = nullptr);
- // We use fd instead of hidl_handle in these functions to pass fences
- // in and out of the mapper. The ownership of the fd is always transferred
- // with each of these functions.
- void* lock(const native_handle_t* handle, uint64_t producerUsageMask,
- uint64_t consumerUsageMask, const IMapper::Rect& accessRegion,
- int acquireFence);
- FlexLayout lockFlex(const native_handle_t* handle, uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion, int acquireFence);
- int unlock(const native_handle_t* handle);
+ // IMapper methods
- // Requests AllocatorClient to allocate a buffer, export the handle, and
- // register the handle with mapper.
- const native_handle_t* allocate(
- std::unique_ptr<AllocatorClient>& allocatorClient,
- const IAllocatorClient::BufferDescriptorInfo& info);
+ sp<IMapper> getMapper() const;
- private:
- void init();
+ BufferDescriptor createDescriptor(
+ const IMapper::BufferDescriptorInfo& descriptorInfo);
- sp<IMapper> mMapper;
+ const native_handle_t* importBuffer(const hidl_handle& rawHandle);
+ void freeBuffer(const native_handle_t* bufferHandle);
- // Keep track of all registered (retained) handles. When a test fails with
- // ASSERT_*, the destructor will release the handles for the test.
- std::unordered_map<const native_handle_t*, uint64_t> mHandles;
+ // We use fd instead of hidl_handle in these functions to pass fences
+ // in and out of the mapper. The ownership of the fd is always transferred
+ // with each of these functions.
+ void* lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
+ const IMapper::Rect& accessRegion, int acquireFence);
+ YCbCrLayout lockYCbCr(const native_handle_t* bufferHandle,
+ uint64_t cpuUsage, const IMapper::Rect& accessRegion,
+ int acquireFence);
+ int unlock(const native_handle_t* bufferHandle);
+
+ private:
+ void init();
+ const native_handle_t* cloneBuffer(const hidl_handle& rawHandle);
+
+ sp<IAllocator> mAllocator;
+ sp<IMapper> mMapper;
+
+ // Keep track of all cloned and imported handles. When a test fails with
+ // ASSERT_*, the destructor will free the handles for the test.
+ std::unordered_set<const native_handle_t*> mClonedBuffers;
+ std::unordered_set<const native_handle_t*> mImportedBuffers;
};
} // namespace tests
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
index 92d74d5..f066a1e 100644
--- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#define LOG_TAG "graphics_mapper_hidl_hal_test"
+#define LOG_TAG "VtsHalGraphicsMapperV2_0TargetTest"
-#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <android-base/logging.h>
#include <sync/sync.h>
#include "VtsHalGraphicsMapperTestUtils.h"
@@ -29,202 +29,384 @@
namespace tests {
namespace {
-using namespace android::hardware::graphics::allocator::V2_0;
-using namespace android::hardware::graphics::allocator::V2_0::tests;
+using android::hardware::graphics::common::V1_0::BufferUsage;
+using android::hardware::graphics::common::V1_0::PixelFormat;
class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
- ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
- ASSERT_NO_FATAL_FAILURE(mAllocatorClient = mAllocator->createClient());
- ASSERT_NO_FATAL_FAILURE(mMapper = std::make_unique<Mapper>());
+ ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>());
- mDummyDescriptorInfo.width = 64;
- mDummyDescriptorInfo.height = 64;
- mDummyDescriptorInfo.layerCount = 1;
- mDummyDescriptorInfo.format = PixelFormat::RGBA_8888;
- mDummyDescriptorInfo.producerUsageMask =
- static_cast<uint64_t>(ProducerUsage::CPU_WRITE);
- mDummyDescriptorInfo.consumerUsageMask =
- static_cast<uint64_t>(ConsumerUsage::CPU_READ);
+ mDummyDescriptorInfo.width = 64;
+ mDummyDescriptorInfo.height = 64;
+ mDummyDescriptorInfo.layerCount = 1;
+ mDummyDescriptorInfo.format = PixelFormat::RGBA_8888;
+ mDummyDescriptorInfo.usage = static_cast<uint64_t>(
+ BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
}
void TearDown() override {}
- std::unique_ptr<Allocator> mAllocator;
- std::unique_ptr<AllocatorClient> mAllocatorClient;
- std::unique_ptr<Mapper> mMapper;
- IAllocatorClient::BufferDescriptorInfo mDummyDescriptorInfo{};
+ std::unique_ptr<Gralloc> mGralloc;
+ IMapper::BufferDescriptorInfo mDummyDescriptorInfo{};
};
/**
- * Test IMapper::retain and IMapper::release.
+ * Test IAllocator::dumpDebugInfo by calling it.
*/
-TEST_F(GraphicsMapperHidlTest, RetainRelease) {
- const native_handle_t* buffer;
- ASSERT_NO_FATAL_FAILURE(
- buffer = mMapper->allocate(mAllocatorClient, mDummyDescriptorInfo));
-
- const int maxRefs = 10;
- for (int i = 0; i < maxRefs; i++) {
- ASSERT_NO_FATAL_FAILURE(mMapper->retain(buffer));
- }
- for (int i = 0; i < maxRefs; i++) {
- ASSERT_NO_FATAL_FAILURE(mMapper->release(buffer));
- }
-
- ASSERT_NO_FATAL_FAILURE(mMapper->release(buffer));
+TEST_F(GraphicsMapperHidlTest, AllocatorDumpDebugInfo) {
+ mGralloc->dumpDebugInfo();
}
/**
- * Test IMapper::get* getters.
+ * Test IAllocator::allocate with valid buffer descriptors.
*/
-TEST_F(GraphicsMapperHidlTest, Getters) {
- const native_handle_t* buffer;
- ASSERT_NO_FATAL_FAILURE(
- buffer = mMapper->allocate(mAllocatorClient, mDummyDescriptorInfo));
+TEST_F(GraphicsMapperHidlTest, AllocatorAllocate) {
+ BufferDescriptor descriptor;
+ ASSERT_NO_FATAL_FAILURE(
+ descriptor = mGralloc->createDescriptor(mDummyDescriptorInfo));
- IAllocatorClient::BufferDescriptorInfo info = {};
+ for (uint32_t count = 0; count < 5; count++) {
+ std::vector<const native_handle_t*> bufferHandles;
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(bufferHandles = mGralloc->allocate(
+ descriptor, count, false, &stride));
- Mapper::Dimensions dimensions;
- ASSERT_NO_FATAL_FAILURE(dimensions = mMapper->getDimensions(buffer));
- info.width = dimensions.width;
- info.height = dimensions.height;
+ if (count >= 1) {
+ EXPECT_LE(mDummyDescriptorInfo.width, stride)
+ << "invalid buffer stride";
+ }
- ASSERT_NO_FATAL_FAILURE(info.format = mMapper->getFormat(buffer));
- ASSERT_NO_FATAL_FAILURE(info.producerUsageMask =
- mMapper->getProducerUsageMask(buffer));
- ASSERT_NO_FATAL_FAILURE(info.consumerUsageMask =
- mMapper->getConsumerUsageMask(buffer));
+ for (auto bufferHandle : bufferHandles) {
+ mGralloc->freeBuffer(bufferHandle);
+ }
+ }
+}
- EXPECT_EQ(mDummyDescriptorInfo.width, info.width);
- EXPECT_EQ(mDummyDescriptorInfo.height, info.height);
- EXPECT_EQ(mDummyDescriptorInfo.format, info.format);
- EXPECT_EQ(mDummyDescriptorInfo.producerUsageMask, info.producerUsageMask);
- EXPECT_EQ(mDummyDescriptorInfo.consumerUsageMask, info.consumerUsageMask);
+/**
+ * Test IAllocator::allocate with invalid buffer descriptors.
+ */
+TEST_F(GraphicsMapperHidlTest, AllocatorAllocateNegative) {
+ // this assumes any valid descriptor is non-empty
+ BufferDescriptor descriptor;
+ mGralloc->getAllocator()->allocate(
+ descriptor, 1, [&](const auto& tmpError, const auto&, const auto&) {
+ EXPECT_EQ(Error::BAD_DESCRIPTOR, tmpError);
+ });
+}
- ASSERT_NO_FATAL_FAILURE(mMapper->getBackingStore(buffer));
+/**
+ * Test IAllocator::allocate does not leak.
+ */
+TEST_F(GraphicsMapperHidlTest, AllocatorAllocateNoLeak) {
+ auto info = mDummyDescriptorInfo;
+ info.width = 1024;
+ info.height = 1024;
- uint32_t stride;
- ASSERT_NO_FATAL_FAILURE(stride = mMapper->getStride(buffer));
- EXPECT_LE(info.width, stride);
+ for (int i = 0; i < 2048; i++) {
+ auto bufferHandle = mGralloc->allocate(info, false);
+ mGralloc->freeBuffer(bufferHandle);
+ }
+}
+
+/**
+ * Test IMapper::createDescriptor with valid descriptor info.
+ */
+TEST_F(GraphicsMapperHidlTest, CreateDescriptorBasic) {
+ ASSERT_NO_FATAL_FAILURE(mGralloc->createDescriptor(mDummyDescriptorInfo));
+}
+
+/**
+ * Test IMapper::createDescriptor with invalid descriptor info.
+ */
+TEST_F(GraphicsMapperHidlTest, CreateDescriptorNegative) {
+ auto info = mDummyDescriptorInfo;
+ info.width = 0;
+ mGralloc->getMapper()->createDescriptor(
+ info, [&](const auto& tmpError, const auto&) {
+ EXPECT_EQ(Error::BAD_VALUE, tmpError)
+ << "createDescriptor did not fail with BAD_VALUE";
+ });
+}
+
+/**
+ * Test IMapper::importBuffer and IMapper::freeBuffer with allocated buffers.
+ */
+TEST_F(GraphicsMapperHidlTest, ImportFreeBufferBasic) {
+ const native_handle_t* bufferHandle;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle =
+ mGralloc->allocate(mDummyDescriptorInfo, true));
+ ASSERT_NO_FATAL_FAILURE(mGralloc->freeBuffer(bufferHandle));
+}
+
+/**
+ * Test IMapper::importBuffer and IMapper::freeBuffer with cloned buffers.
+ */
+TEST_F(GraphicsMapperHidlTest, ImportFreeBufferClone) {
+ const native_handle_t* clonedBufferHandle;
+ ASSERT_NO_FATAL_FAILURE(
+ clonedBufferHandle = mGralloc->allocate(mDummyDescriptorInfo, false));
+
+ // A cloned handle is a raw handle. Check that we can import it multiple
+ // times.
+ const native_handle_t* importedBufferHandles[2];
+ ASSERT_NO_FATAL_FAILURE(importedBufferHandles[0] =
+ mGralloc->importBuffer(clonedBufferHandle));
+ ASSERT_NO_FATAL_FAILURE(importedBufferHandles[1] =
+ mGralloc->importBuffer(clonedBufferHandle));
+ ASSERT_NO_FATAL_FAILURE(mGralloc->freeBuffer(importedBufferHandles[0]));
+ ASSERT_NO_FATAL_FAILURE(mGralloc->freeBuffer(importedBufferHandles[1]));
+
+ ASSERT_NO_FATAL_FAILURE(mGralloc->freeBuffer(clonedBufferHandle));
+}
+
+/**
+ * Test IMapper::importBuffer and IMapper::freeBuffer cross mapper instances.
+ */
+TEST_F(GraphicsMapperHidlTest, ImportFreeBufferSingleton) {
+ const native_handle_t* rawHandle;
+ ASSERT_NO_FATAL_FAILURE(
+ rawHandle = mGralloc->allocate(mDummyDescriptorInfo, false));
+
+ native_handle_t* importedHandle = nullptr;
+ mGralloc->getMapper()->importBuffer(
+ rawHandle, [&](const auto& tmpError, const auto& buffer) {
+ ASSERT_EQ(Error::NONE, tmpError);
+ importedHandle = static_cast<native_handle_t*>(buffer);
+ });
+
+ // free the imported handle with another mapper
+ std::unique_ptr<Gralloc> anotherGralloc;
+ ASSERT_NO_FATAL_FAILURE(anotherGralloc = std::make_unique<Gralloc>());
+ Error error = mGralloc->getMapper()->freeBuffer(importedHandle);
+ ASSERT_EQ(Error::NONE, error);
+
+ ASSERT_NO_FATAL_FAILURE(mGralloc->freeBuffer(rawHandle));
+}
+
+/**
+ * Test IMapper::importBuffer and IMapper::freeBuffer do not leak.
+ */
+TEST_F(GraphicsMapperHidlTest, ImportFreeBufferNoLeak) {
+ auto info = mDummyDescriptorInfo;
+ info.width = 1024;
+ info.height = 1024;
+
+ for (int i = 0; i < 2048; i++) {
+ auto bufferHandle = mGralloc->allocate(info, true);
+ mGralloc->freeBuffer(bufferHandle);
+ }
+}
+
+/**
+ * Test IMapper::importBuffer with invalid buffers.
+ */
+TEST_F(GraphicsMapperHidlTest, ImportBufferNegative) {
+ native_handle_t* invalidHandle = nullptr;
+ mGralloc->getMapper()->importBuffer(
+ invalidHandle, [&](const auto& tmpError, const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "importBuffer with nullptr did not fail with BAD_BUFFER";
+ });
+
+ invalidHandle = native_handle_create(0, 0);
+ mGralloc->getMapper()->importBuffer(invalidHandle, [&](const auto& tmpError,
+ const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "importBuffer with invalid handle did not fail with BAD_BUFFER";
+ });
+ native_handle_delete(invalidHandle);
+
+ const native_handle_t* importedHandle;
+ ASSERT_NO_FATAL_FAILURE(importedHandle =
+ mGralloc->allocate(mDummyDescriptorInfo, true));
+ mGralloc->getMapper()->importBuffer(
+ importedHandle, [&](const auto& tmpError, const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "importBuffer with an "
+ "already imported handle did "
+ "not fail with BAD_BUFFER";
+ });
+ mGralloc->freeBuffer(importedHandle);
+}
+
+/**
+ * Test IMapper::freeBuffer with invalid buffers.
+ */
+TEST_F(GraphicsMapperHidlTest, FreeBufferNegative) {
+ native_handle_t* invalidHandle = nullptr;
+ Error error = mGralloc->getMapper()->freeBuffer(invalidHandle);
+ EXPECT_EQ(Error::BAD_BUFFER, error)
+ << "freeBuffer with nullptr did not fail with BAD_BUFFER";
+
+ invalidHandle = native_handle_create(0, 0);
+ error = mGralloc->getMapper()->freeBuffer(invalidHandle);
+ EXPECT_EQ(Error::BAD_BUFFER, error)
+ << "freeBuffer with invalid handle did not fail with BAD_BUFFER";
+ native_handle_delete(invalidHandle);
+
+ const native_handle_t* clonedBufferHandle;
+ ASSERT_NO_FATAL_FAILURE(
+ clonedBufferHandle = mGralloc->allocate(mDummyDescriptorInfo, false));
+ error = mGralloc->getMapper()->freeBuffer(invalidHandle);
+ EXPECT_EQ(Error::BAD_BUFFER, error)
+ << "freeBuffer with un-imported handle did not fail with BAD_BUFFER";
+
+ mGralloc->freeBuffer(clonedBufferHandle);
}
/**
* Test IMapper::lock and IMapper::unlock.
*/
-TEST_F(GraphicsMapperHidlTest, LockBasic) {
- const auto& info = mDummyDescriptorInfo;
+TEST_F(GraphicsMapperHidlTest, LockUnlockBasic) {
+ const auto& info = mDummyDescriptorInfo;
- const native_handle_t* buffer;
- ASSERT_NO_FATAL_FAILURE(
- buffer = mMapper->allocate(mAllocatorClient, mDummyDescriptorInfo));
+ const native_handle_t* bufferHandle;
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle =
+ mGralloc->allocate(info, true, &stride));
- uint32_t stride;
- ASSERT_NO_FATAL_FAILURE(stride = mMapper->getStride(buffer));
+ // lock buffer for writing
+ const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
+ static_cast<int32_t>(info.height)};
+ int fence = -1;
+ uint8_t* data;
+ ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(
+ bufferHandle, info.usage, region, fence)));
- // lock buffer for writing
- const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
- static_cast<int32_t>(info.height)};
- int fence = -1;
- uint32_t* data;
- ASSERT_NO_FATAL_FAILURE(
- data = static_cast<uint32_t*>(
- mMapper->lock(buffer, info.producerUsageMask, 0, region, fence)));
+ // RGBA_8888
+ size_t strideInBytes = stride * 4;
+ size_t writeInBytes = info.width * 4;
- for (uint32_t y = 0; y < info.height; y++) {
- for (uint32_t x = 0; x < info.width; x++) {
- data[stride * y + x] = info.height * y + x;
+ for (uint32_t y = 0; y < info.height; y++) {
+ memset(data, y, writeInBytes);
+ data += strideInBytes;
}
- }
- ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
+ ASSERT_NO_FATAL_FAILURE(fence = mGralloc->unlock(bufferHandle));
- // lock buffer for reading
- ASSERT_NO_FATAL_FAILURE(
- data = static_cast<uint32_t*>(
- mMapper->lock(buffer, 0, info.consumerUsageMask, region, fence)));
- for (uint32_t y = 0; y < info.height; y++) {
- for (uint32_t x = 0; x < info.width; x++) {
- EXPECT_EQ(info.height * y + x, data[stride * y + x]);
+ // lock again for reading
+ ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(
+ bufferHandle, info.usage, region, fence)));
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (size_t i = 0; i < writeInBytes; i++) {
+ EXPECT_EQ(static_cast<uint8_t>(y), data[i]);
+ }
+ data += strideInBytes;
}
- }
- ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
- if (fence >= 0) {
- close(fence);
- }
+ ASSERT_NO_FATAL_FAILURE(fence = mGralloc->unlock(bufferHandle));
+ if (fence >= 0) {
+ close(fence);
+ }
}
/**
- * Test IMapper::lockFlex. This locks a YV12 buffer, and makes sure we can
+ * Test IMapper::lockYCbCr. This locks a YV12 buffer, and makes sure we can
* write to and read from it.
*/
-TEST_F(GraphicsMapperHidlTest, LockFlexBasic) {
- auto info = mDummyDescriptorInfo;
- info.format = PixelFormat::YV12;
+TEST_F(GraphicsMapperHidlTest, LockYCbCrBasic) {
+ auto info = mDummyDescriptorInfo;
+ info.format = PixelFormat::YV12;
- const native_handle_t* buffer;
- ASSERT_NO_FATAL_FAILURE(buffer = mMapper->allocate(mAllocatorClient, info));
+ const native_handle_t* bufferHandle;
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(bufferHandle =
+ mGralloc->allocate(info, true, &stride));
- // lock buffer for writing
- const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
- static_cast<int32_t>(info.height)};
- int fence = -1;
- FlexLayout layout;
- ASSERT_NO_FATAL_FAILURE(
- layout =
- mMapper->lockFlex(buffer, info.producerUsageMask, 0, region, fence));
- ASSERT_EQ(FlexFormat::YCBCR, layout.format);
- ASSERT_EQ(3u, layout.planes.size());
+ // lock buffer for writing
+ const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
+ static_cast<int32_t>(info.height)};
+ int fence = -1;
+ YCbCrLayout layout;
+ ASSERT_NO_FATAL_FAILURE(
+ layout = mGralloc->lockYCbCr(bufferHandle, info.usage, region, fence));
- const auto y_stride = layout.planes[0].vIncrement;
- const auto c_stride = layout.planes[1].vIncrement;
- auto y_data = static_cast<uint8_t*>(layout.planes[0].topLeft);
- auto cb_data = static_cast<uint8_t*>(layout.planes[1].topLeft);
- auto cr_data = static_cast<uint8_t*>(layout.planes[2].topLeft);
+ auto yData = static_cast<uint8_t*>(layout.y);
+ auto cbData = static_cast<uint8_t*>(layout.cb);
+ auto crData = static_cast<uint8_t*>(layout.cr);
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (uint32_t x = 0; x < info.width; x++) {
+ auto val = static_cast<uint8_t>(info.height * y + x);
- for (uint32_t y = 0; y < info.height; y++) {
- for (uint32_t x = 0; x < info.width; x++) {
- auto val = static_cast<uint8_t>(info.height * y + x);
-
- y_data[y_stride * y + x] = val;
- if (y % 2 == 0 && x % 2 == 0) {
- cb_data[c_stride * y / 2 + x / 2] = val;
- cr_data[c_stride * y / 2 + x / 2] = val;
- }
+ yData[layout.yStride * y + x] = val;
+ if (y % 2 == 0 && x % 2 == 0) {
+ cbData[layout.cStride * y / 2 + x / 2] = val;
+ crData[layout.cStride * y / 2 + x / 2] = val;
+ }
+ }
}
- }
- ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
+ ASSERT_NO_FATAL_FAILURE(fence = mGralloc->unlock(bufferHandle));
- // lock buffer for reading
- ASSERT_NO_FATAL_FAILURE(
- layout =
- mMapper->lockFlex(buffer, 0, info.consumerUsageMask, region, fence));
+ // lock again for reading
+ ASSERT_NO_FATAL_FAILURE(
+ layout = mGralloc->lockYCbCr(bufferHandle, info.usage, region, fence));
- y_data = static_cast<uint8_t*>(layout.planes[0].topLeft);
- cb_data = static_cast<uint8_t*>(layout.planes[1].topLeft);
- cr_data = static_cast<uint8_t*>(layout.planes[2].topLeft);
- for (uint32_t y = 0; y < info.height; y++) {
- for (uint32_t x = 0; x < info.width; x++) {
- auto val = static_cast<uint8_t>(info.height * y + x);
+ yData = static_cast<uint8_t*>(layout.y);
+ cbData = static_cast<uint8_t*>(layout.cb);
+ crData = static_cast<uint8_t*>(layout.cr);
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (uint32_t x = 0; x < info.width; x++) {
+ auto val = static_cast<uint8_t>(info.height * y + x);
- EXPECT_EQ(val, y_data[y_stride * y + x]);
- if (y % 2 == 0 && x % 2 == 0) {
- EXPECT_EQ(val, cb_data[c_stride * y / 2 + x / 2]);
- EXPECT_EQ(val, cr_data[c_stride * y / 2 + x / 2]);
- }
+ EXPECT_EQ(val, yData[layout.yStride * y + x]);
+ if (y % 2 == 0 && x % 2 == 0) {
+ EXPECT_EQ(val, cbData[layout.cStride * y / 2 + x / 2]);
+ EXPECT_EQ(val, crData[layout.cStride * y / 2 + x / 2]);
+ }
+ }
}
- }
- ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
- if (fence >= 0) {
- close(fence);
- }
+ ASSERT_NO_FATAL_FAILURE(fence = mGralloc->unlock(bufferHandle));
+ if (fence >= 0) {
+ close(fence);
+ }
}
-} // namespace anonymous
+/**
+ * Test IMapper::unlock with invalid buffers.
+ */
+TEST_F(GraphicsMapperHidlTest, UnlockNegative) {
+ native_handle_t* invalidHandle = nullptr;
+ mGralloc->getMapper()->unlock(
+ invalidHandle, [&](const auto& tmpError, const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "unlock with nullptr did not fail with BAD_BUFFER";
+ });
+
+ invalidHandle = native_handle_create(0, 0);
+ mGralloc->getMapper()->unlock(
+ invalidHandle, [&](const auto& tmpError, const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "unlock with invalid handle did not fail with BAD_BUFFER";
+ });
+ native_handle_delete(invalidHandle);
+
+ ASSERT_NO_FATAL_FAILURE(invalidHandle =
+ const_cast<native_handle_t*>(mGralloc->allocate(
+ mDummyDescriptorInfo, false)));
+ mGralloc->getMapper()->unlock(invalidHandle, [&](const auto& tmpError,
+ const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "unlock with un-imported handle did not fail with BAD_BUFFER";
+ });
+ mGralloc->freeBuffer(invalidHandle);
+
+// disabled as it fails on many existing drivers
+#if 0
+ ASSERT_NO_FATAL_FAILURE(invalidHandle = const_cast<native_handle_t*>(
+ mGralloc->allocate(mDummyDescriptorInfo, true)));
+ mGralloc->getMapper()->unlock(
+ invalidHandle, [&](const auto& tmpError, const auto&) {
+ EXPECT_EQ(Error::BAD_BUFFER, tmpError)
+ << "unlock with unlocked handle did not fail with BAD_BUFFER";
+ });
+ mGralloc->freeBuffer(invalidHandle);
+#endif
+}
+
+} // namespace
} // namespace tests
} // namespace V2_0
} // namespace mapper
diff --git a/health/1.0/Android.bp b/health/1.0/Android.bp
index 61f464d..16ee7e9 100644
--- a/health/1.0/Android.bp
+++ b/health/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.health@1.0_genc++"],
generated_headers: ["android.hardware.health@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.health@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/health/1.0/Android.mk b/health/1.0/Android.mk
index ebb89a7..b03b868 100644
--- a/health/1.0/Android.mk
+++ b/health/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.health@1.0-java
+LOCAL_MODULE := android.hardware.health-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -137,7 +137,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.health@1.0-java-static
+LOCAL_MODULE := android.hardware.health-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -145,7 +145,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -269,7 +269,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.health@1.0-java-constants
+LOCAL_MODULE := android.hardware.health-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/ir/1.0/Android.bp b/ir/1.0/Android.bp
index 5bff1d3..6f52736 100644
--- a/ir/1.0/Android.bp
+++ b/ir/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.ir@1.0_genc++"],
generated_headers: ["android.hardware.ir@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.ir@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/ir/1.0/Android.mk b/ir/1.0/Android.mk
index d43286c..bdb3b29 100644
--- a/ir/1.0/Android.mk
+++ b/ir/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.ir@1.0-java
+LOCAL_MODULE := android.hardware.ir-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -61,7 +61,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.ir@1.0-java-static
+LOCAL_MODULE := android.hardware.ir-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -69,7 +69,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/keymaster/3.0/Android.bp b/keymaster/3.0/Android.bp
index 2b0899d..0afee99 100644
--- a/keymaster/3.0/Android.bp
+++ b/keymaster/3.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.keymaster@3.0_genc++"],
generated_headers: ["android.hardware.keymaster@3.0_genc++_headers"],
export_generated_headers: ["android.hardware.keymaster@3.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/keymaster/3.0/default/KeymasterDevice.cpp b/keymaster/3.0/default/KeymasterDevice.cpp
index 6b4524b..58102bb 100644
--- a/keymaster/3.0/default/KeymasterDevice.cpp
+++ b/keymaster/3.0/default/KeymasterDevice.cpp
@@ -519,6 +519,7 @@
hidl_vec<hidl_vec<uint8_t>> resultCertChain;
+ bool foundAttestationApplicationId = false;
for (size_t i = 0; i < attestParams.size(); ++i) {
switch (attestParams[i].tag) {
case Tag::ATTESTATION_ID_BRAND:
@@ -532,11 +533,22 @@
// never perform any device id attestation.
_hidl_cb(ErrorCode::CANNOT_ATTEST_IDS, resultCertChain);
return Void();
+
+ case Tag::ATTESTATION_APPLICATION_ID:
+ foundAttestationApplicationId = true;
+ break;
+
default:
break;
}
}
+ // KM3 devices reject missing attest application IDs. KM2 devices do not.
+ if (!foundAttestationApplicationId) {
+ _hidl_cb(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING,
+ resultCertChain);
+ }
+
keymaster_cert_chain_t cert_chain{nullptr, 0};
auto kmKeyToAttest = hidlVec2KmKeyBlob(keyToAttest);
diff --git a/keymaster/3.0/vts/functional/attestation_record.cpp b/keymaster/3.0/vts/functional/attestation_record.cpp
index 6cdd44c..5d96fff 100644
--- a/keymaster/3.0/vts/functional/attestation_record.cpp
+++ b/keymaster/3.0/vts/functional/attestation_record.cpp
@@ -244,6 +244,8 @@
copyAuthTag(record->rsa_public_exponent, TAG_RSA_PUBLIC_EXPONENT, auth_list);
copyAuthTag(record->usage_expire_date_time, TAG_USAGE_EXPIRE_DATETIME, auth_list);
copyAuthTag(record->user_auth_type, TAG_USER_AUTH_TYPE, auth_list);
+ copyAuthTag(record->attestation_application_id,
+ TAG_ATTESTATION_APPLICATION_ID, auth_list);
return ErrorCode::OK;
}
diff --git a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
index edb1cd1..3448398 100644
--- a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
+++ b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -892,19 +892,10 @@
static hidl_string author_;
};
-uint32_t expected_keymaster_version() {
- if (!KeymasterHidlTest::IsSecure()) return 2; // SW is KM2
-
- uint32_t keymaster_version = 0;
- if (KeymasterHidlTest::SupportsSymmetric()) keymaster_version = 1;
- if (KeymasterHidlTest::SupportsAttestation()) keymaster_version = 2;
- return keymaster_version;
-}
-
-bool verify_attestation_record(const string& challenge, AuthorizationSet expected_sw_enforced,
+bool verify_attestation_record(const string& challenge, const string& app_id,
+ AuthorizationSet expected_sw_enforced,
AuthorizationSet expected_tee_enforced,
const hidl_vec<uint8_t>& attestation_cert) {
-
X509_Ptr cert(parse_cert_blob(attestation_cert));
EXPECT_TRUE(!!cert.get());
if (!cert.get()) return false;
@@ -921,6 +912,7 @@
SecurityLevel att_keymaster_security_level;
HidlBuf att_challenge;
HidlBuf att_unique_id;
+ HidlBuf att_app_id;
EXPECT_EQ(ErrorCode::OK,
parse_attestation_record(attest_rec->data, //
attest_rec->length, //
@@ -933,8 +925,28 @@
&att_tee_enforced, //
&att_unique_id));
- EXPECT_EQ(1U, att_attestation_version);
- EXPECT_EQ(expected_keymaster_version(), att_keymaster_version);
+ if (att_keymaster_version == 3) {
+ EXPECT_EQ(2U, att_attestation_version);
+ } else {
+ EXPECT_EQ(1U, att_attestation_version);
+ }
+
+ expected_sw_enforced.push_back(TAG_ATTESTATION_APPLICATION_ID,
+ HidlBuf(app_id));
+
+ if (!KeymasterHidlTest::IsSecure()) {
+ // SW is KM2
+ EXPECT_EQ(att_keymaster_version, 2U);
+ }
+
+ if (KeymasterHidlTest::SupportsSymmetric()) {
+ EXPECT_GE(att_keymaster_version, 1U);
+ }
+
+ if (KeymasterHidlTest::SupportsAttestation()) {
+ EXPECT_GE(att_keymaster_version, 2U);
+ }
+
EXPECT_EQ(KeymasterHidlTest::IsSecure() ? SecurityLevel::TRUSTED_ENVIRONMENT
: SecurityLevel::SOFTWARE,
att_keymaster_security_level);
@@ -3827,15 +3839,41 @@
.Authorization(TAG_INCLUDE_UNIQUE_ID)));
hidl_vec<hidl_vec<uint8_t>> cert_chain;
- EXPECT_EQ(ErrorCode::OK, AttestKey(AuthorizationSetBuilder().Authorization(
- TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge")),
- &cert_chain));
+ EXPECT_EQ(
+ ErrorCode::OK,
+ AttestKey(
+ AuthorizationSetBuilder()
+ .Authorization(TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge"))
+ .Authorization(TAG_ATTESTATION_APPLICATION_ID, HidlBuf("foo")),
+ &cert_chain));
EXPECT_GE(cert_chain.size(), 2U);
EXPECT_TRUE(verify_chain(cert_chain));
- EXPECT_TRUE(verify_attestation_record("challenge", //
- key_characteristics_.softwareEnforced, //
- key_characteristics_.teeEnforced, //
- cert_chain[0]));
+ EXPECT_TRUE(
+ verify_attestation_record("challenge", "foo", //
+ key_characteristics_.softwareEnforced, //
+ key_characteristics_.teeEnforced, //
+ cert_chain[0]));
+}
+
+/*
+ * AttestationTest.RsaAttestationRequiresAppId
+ *
+ * Verifies that attesting to RSA requires app ID.
+ */
+TEST_F(AttestationTest, RsaAttestationRequiresAppId) {
+ ASSERT_EQ(ErrorCode::OK,
+ GenerateKey(AuthorizationSetBuilder()
+ .Authorization(TAG_NO_AUTH_REQUIRED)
+ .RsaSigningKey(1024, 3)
+ .Digest(Digest::NONE)
+ .Padding(PaddingMode::NONE)
+ .Authorization(TAG_INCLUDE_UNIQUE_ID)));
+
+ hidl_vec<hidl_vec<uint8_t>> cert_chain;
+ EXPECT_EQ(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING,
+ AttestKey(AuthorizationSetBuilder().Authorization(
+ TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge")),
+ &cert_chain));
}
/*
@@ -3851,16 +3889,41 @@
.Authorization(TAG_INCLUDE_UNIQUE_ID)));
hidl_vec<hidl_vec<uint8_t>> cert_chain;
- EXPECT_EQ(ErrorCode::OK, AttestKey(AuthorizationSetBuilder().Authorization(
- TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge")),
- &cert_chain));
+ EXPECT_EQ(
+ ErrorCode::OK,
+ AttestKey(
+ AuthorizationSetBuilder()
+ .Authorization(TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge"))
+ .Authorization(TAG_ATTESTATION_APPLICATION_ID, HidlBuf("foo")),
+ &cert_chain));
EXPECT_GE(cert_chain.size(), 2U);
EXPECT_TRUE(verify_chain(cert_chain));
- EXPECT_TRUE(verify_attestation_record("challenge", //
- key_characteristics_.softwareEnforced, //
- key_characteristics_.teeEnforced, //
- cert_chain[0]));
+ EXPECT_TRUE(
+ verify_attestation_record("challenge", "foo", //
+ key_characteristics_.softwareEnforced, //
+ key_characteristics_.teeEnforced, //
+ cert_chain[0]));
+}
+
+/*
+ * AttestationTest.EcAttestationRequiresAttestationAppId
+ *
+ * Verifies that attesting to EC keys requires app ID
+ */
+TEST_F(AttestationTest, EcAttestationRequiresAttestationAppId) {
+ ASSERT_EQ(ErrorCode::OK,
+ GenerateKey(AuthorizationSetBuilder()
+ .Authorization(TAG_NO_AUTH_REQUIRED)
+ .EcdsaSigningKey(EcCurve::P_256)
+ .Digest(Digest::SHA_2_256)
+ .Authorization(TAG_INCLUDE_UNIQUE_ID)));
+
+ hidl_vec<hidl_vec<uint8_t>> cert_chain;
+ EXPECT_EQ(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING,
+ AttestKey(AuthorizationSetBuilder().Authorization(
+ TAG_ATTESTATION_CHALLENGE, HidlBuf("challenge")),
+ &cert_chain));
}
/*
@@ -3932,15 +3995,18 @@
AuthorizationSet begin_out_params;
if (rollback_protected) {
- EXPECT_EQ(ErrorCode::INVALID_KEY_BLOB,
- Begin(KeyPurpose::SIGN, key_blob_,
- AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE),
- &begin_out_params, &op_handle_));
+ EXPECT_EQ(
+ ErrorCode::INVALID_KEY_BLOB,
+ Begin(KeyPurpose::SIGN, key_blob_, AuthorizationSetBuilder()
+ .Digest(Digest::NONE)
+ .Padding(PaddingMode::NONE),
+ &begin_out_params, &op_handle_));
} else {
- EXPECT_EQ(ErrorCode::OK,
- Begin(KeyPurpose::SIGN, key_blob_,
- AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE),
- &begin_out_params, &op_handle_));
+ EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::SIGN, key_blob_,
+ AuthorizationSetBuilder()
+ .Digest(Digest::NONE)
+ .Padding(PaddingMode::NONE),
+ &begin_out_params, &op_handle_));
}
AbortIfNeeded();
key_blob_ = HidlBuf();
@@ -4006,15 +4072,18 @@
AuthorizationSet begin_out_params;
if (rollback_protected) {
- EXPECT_EQ(ErrorCode::INVALID_KEY_BLOB,
- Begin(KeyPurpose::SIGN, key_blob_,
- AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE),
- &begin_out_params, &op_handle_));
+ EXPECT_EQ(
+ ErrorCode::INVALID_KEY_BLOB,
+ Begin(KeyPurpose::SIGN, key_blob_, AuthorizationSetBuilder()
+ .Digest(Digest::NONE)
+ .Padding(PaddingMode::NONE),
+ &begin_out_params, &op_handle_));
} else {
- EXPECT_EQ(ErrorCode::OK,
- Begin(KeyPurpose::SIGN, key_blob_,
- AuthorizationSetBuilder().Digest(Digest::NONE).Padding(PaddingMode::NONE),
- &begin_out_params, &op_handle_));
+ EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::SIGN, key_blob_,
+ AuthorizationSetBuilder()
+ .Digest(Digest::NONE)
+ .Padding(PaddingMode::NONE),
+ &begin_out_params, &op_handle_));
}
AbortIfNeeded();
key_blob_ = HidlBuf();
diff --git a/light/2.0/Android.bp b/light/2.0/Android.bp
index b43b7b3..b830ef0 100644
--- a/light/2.0/Android.bp
+++ b/light/2.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.light@2.0_genc++"],
generated_headers: ["android.hardware.light@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.light@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/light/2.0/Android.mk b/light/2.0/Android.mk
index 7bb4293..24d7ab1 100644
--- a/light/2.0/Android.mk
+++ b/light/2.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.light@2.0-java
+LOCAL_MODULE := android.hardware.light-V2.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -137,7 +137,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.light@2.0-java-static
+LOCAL_MODULE := android.hardware.light-V2.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -145,7 +145,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/media/1.0/Android.bp b/media/1.0/Android.bp
index 21185db..04a3683 100644
--- a/media/1.0/Android.bp
+++ b/media/1.0/Android.bp
@@ -37,6 +37,7 @@
generated_sources: ["android.hardware.media@1.0_genc++"],
generated_headers: ["android.hardware.media@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.media@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/media/1.0/types.hal b/media/1.0/types.hal
index 1f9c4dc..bb1a73b 100644
--- a/media/1.0/types.hal
+++ b/media/1.0/types.hal
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 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.
diff --git a/media/Android.bp b/media/Android.bp
old mode 100644
new mode 100755
index f2abc67..2c12fb8
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -2,4 +2,7 @@
subdirs = [
"1.0",
"omx/1.0",
+ "omx/1.0/vts/functional/audio",
+ "omx/1.0/vts/functional/component",
+ "omx/1.0/vts/functional/master",
]
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index c6e0389..0ecf085 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -9,6 +9,7 @@
"IOmxBufferSource.hal",
"IOmxNode.hal",
"IOmxObserver.hal",
+ "IOmxStore.hal",
],
}
@@ -26,6 +27,7 @@
"android/hardware/media/omx/1.0/OmxBufferSourceAll.cpp",
"android/hardware/media/omx/1.0/OmxNodeAll.cpp",
"android/hardware/media/omx/1.0/OmxObserverAll.cpp",
+ "android/hardware/media/omx/1.0/OmxStoreAll.cpp",
],
}
@@ -64,6 +66,11 @@
"android/hardware/media/omx/1.0/BnHwOmxObserver.h",
"android/hardware/media/omx/1.0/BpHwOmxObserver.h",
"android/hardware/media/omx/1.0/BsOmxObserver.h",
+ "android/hardware/media/omx/1.0/IOmxStore.h",
+ "android/hardware/media/omx/1.0/IHwOmxStore.h",
+ "android/hardware/media/omx/1.0/BnHwOmxStore.h",
+ "android/hardware/media/omx/1.0/BpHwOmxStore.h",
+ "android/hardware/media/omx/1.0/BsOmxStore.h",
],
}
@@ -72,6 +79,7 @@
generated_sources: ["android.hardware.media.omx@1.0_genc++"],
generated_headers: ["android.hardware.media.omx@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.media.omx@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/media/omx/1.0/IOmx.hal b/media/omx/1.0/IOmx.hal
index 78d4b32..f5fc449 100644
--- a/media/omx/1.0/IOmx.hal
+++ b/media/omx/1.0/IOmx.hal
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 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.
@@ -26,7 +26,7 @@
/**
* Ref: frameworks/av/include/media/IOMX.h: IOMX
*
- * IOmx is the main entry point for communicating with OMX components.
+ * IOmx has the ability to create OMX nodes.
*/
interface IOmx {
@@ -41,8 +41,8 @@
/**
* List available components.
*
- * @param[out] status The status of the call.
- * @param[out] nodeList The list of ComponentInfo.
+ * @return status The status of the call.
+ * @return nodeList The list of ComponentInfo.
*/
listNodes(
) generates (
@@ -50,14 +50,15 @@
vec<ComponentInfo> nodeList
);
+
/**
- * Allocate an IOmxNode instance with the specified component name.
+ * Allocate an IOmxNode instance with the specified node name.
*
- * @param[in] name The name of the component to create.
- * @param[in] observer An observer object that will receive messages from
+ * @param name The name of the node to create.
+ * @param observer An observer object that will receive messages from
* the created instance.
- * @param[out] status The status of the call.
- * @param[out] omxNode The allocated instance of IOmxNode.
+ * @return status The status of the call.
+ * @return omxNode The allocated instance of `IOmxNode`.
*/
allocateNode(
string name,
@@ -70,8 +71,9 @@
/**
* Create an input surface for recording.
*
- * @param[out] producer The associated producer end of the buffer queue.
- * @param[out] source The associated `IGraphicBufferSource`.
+ * @return status The status of the call.
+ * @return producer The associated producer end of the buffer queue.
+ * @return source The associated `IGraphicBufferSource`.
*/
createInputSurface(
) generates (
diff --git a/media/omx/1.0/IOmxNode.hal b/media/omx/1.0/IOmxNode.hal
index 8729637..71c0da3 100644
--- a/media/omx/1.0/IOmxNode.hal
+++ b/media/omx/1.0/IOmxNode.hal
@@ -35,7 +35,7 @@
/**
* Free the node.
*
- * @param[out] status Status of the call.
+ * @return status Status of the call.
*/
freeNode(
) generates (
@@ -45,9 +45,9 @@
/**
* Invoke a command on the node.
*
- * @param[in] cmd Type of the command.
- * @param[in] param Parameter for the command.
- * @param[out] status Status of the call.
+ * @param cmd Type of the command.
+ * @param param Parameter for the command.
+ * @return status Status of the call.
*
* @see OMX_SendCommand() in the OpenMax IL standard.
*/
@@ -61,10 +61,10 @@
/**
* Retrieve a parameter setting from the node.
*
- * @param[in] index Type of the parameter to retrieve.
- * @param[in] inParams Information about the retrieval.
- * @param[out] status Status of the call.
- * @param[out] outParams Current parameter setting.
+ * @param index Type of the parameter to retrieve.
+ * @param inParams Information about the retrieval.
+ * @return status Status of the call.
+ * @return outParams Current parameter setting.
*
* @see OMX_GetParameter() in the OpenMax IL standard.
*/
@@ -79,9 +79,9 @@
/**
* Change a parameter setting of the node.
*
- * @param[in] index Type of the parameter to change.
- * @param[in] params New parameter setting.
- * @param[out] status Status of the call.
+ * @param index Type of the parameter to change.
+ * @param params New parameter setting.
+ * @return status Status of the call.
*
* @see OMX_SetParameter() in the OpenMax IL standard.
*/
@@ -95,10 +95,10 @@
/**
* Retrieve a configuration from the node.
*
- * @param[in] index Type of the configuration to retrieve.
- * @param[in] inConfig Information about the retrieval.
- * @param[out] status Status of the call.
- * @param[out] outConfig Current configuration.
+ * @param index Type of the configuration to retrieve.
+ * @param inConfig Information about the retrieval.
+ * @return status Status of the call.
+ * @return outConfig Current configuration.
*
* @see OMX_GetConfig() in the OpenMax IL standard.
*/
@@ -113,9 +113,9 @@
/**
* Change a configuration of the node.
*
- * @param[in] index Type of the configuration to change.
- * @param[in] config New configuration.
- * @param[out] status Status of the call.
+ * @param index Type of the configuration to change.
+ * @param config New configuration.
+ * @return status Status of the call.
*
* @see OMX_SetConfig() in the OpenMax IL standard.
*/
@@ -129,9 +129,9 @@
/**
* Set the mode of a port on the node.
*
- * @param[in] portIndex Index of the port.
- * @param[in] mode Target mode on the specified port.
- * @param[out] status Status of the call.
+ * @param portIndex Index of the port.
+ * @param mode Target mode on the specified port.
+ * @return status Status of the call.
*/
setPortMode(
uint32_t portIndex,
@@ -144,11 +144,11 @@
* Prepare a port for adaptive playback. This is based on the extension
* "OMX.google.android.index.prepareForAdaptivePlayback".
*
- * @param[in] portIndex Index of the port.
- * @param[in] enable Whether the adaptive playback is enabled or not.
- * @param[in] maxFrameWidth Maximum frame width.
- * @param[in] maxFrameHeight Maximum frame height.
- * @param[out] status Status of the call.
+ * @param portIndex Index of the port.
+ * @param enable Whether the adaptive playback is enabled or not.
+ * @param maxFrameWidth Maximum frame width.
+ * @param maxFrameHeight Maximum frame height.
+ * @return status Status of the call.
*/
prepareForAdaptivePlayback(
uint32_t portIndex,
@@ -163,12 +163,12 @@
* Configure a port for a tunneled playback mode. This is based on the
* extension "OMX.google.android.index.configureVideoTunnelMode".
*
- * @param[in] portIndex Index of the port.
- * @param[in] tunneled Whether the tunneled mode is used or not.
- * @param[in] audioHwSync HW SYNC ID of the audio HAL output stream to sync
+ * @param portIndex Index of the port.
+ * @param tunneled Whether the tunneled mode is used or not.
+ * @param audioHwSync HW SYNC ID of the audio HAL output stream to sync
* the video with.
- * @param[out] status Status of the call.
- * @param[out] sidebandHandle Codec-allocated sideband window handle.
+ * @return status Status of the call.
+ * @return sidebandHandle Codec-allocated sideband window handle.
*/
configureVideoTunnelMode(
uint32_t portIndex,
@@ -183,9 +183,9 @@
* Retrieve the buffer usage on a port. This is based on the extension
* "OMX.google.android.index.getAndroidNativeBufferUsage".
*
- * @param[in] portIndex Index of the port.
- * @param[out] status Status of the call.
- * @param[out] usage Current graphic buffer usage.
+ * @param portIndex Index of the port.
+ * @return status Status of the call.
+ * @return usage Current graphic buffer usage.
*/
getGraphicBufferUsage(
uint32_t portIndex
@@ -197,9 +197,9 @@
/**
* Set up a listener to events related to the input surface.
*
- * @param[in] bufferSource Listener object that implements
+ * @param bufferSource Listener object that implements
* IOmxBufferSource.
- * @param[out] status Status of the call.
+ * @return status Status of the call.
*
* @see IOmxBufferSource.
*/
@@ -212,12 +212,12 @@
/**
* Allocate an opaque buffer on a port as a native handle.
*
- * @param[in] portIndex Index of the port.
- * @param[in] size Desired size of the buffer.
- * @param[out] status Status of the call.
- * @param[out] buffer Id of the allocated buffer, which will be needed in
+ * @param portIndex Index of the port.
+ * @param size Desired size of the buffer.
+ * @return status Status of the call.
+ * @return buffer Id of the allocated buffer, which will be needed in
* other buffer-related functions.
- * @param[out] nativeHandle Native handle of the allocated buffer.
+ * @return nativeHandle Native handle of the allocated buffer.
*
* @see OMX_AllocateBuffer() in the OpenMax IL standard.
*/
@@ -233,10 +233,10 @@
/**
* Assign a buffer to a port.
*
- * @param[in] portIndex Index of the port.
- * @param[in] omxBuffer Buffer to be assigned to the port.
- * @param[out] status Status of the call.
- * @param[out] buffer Id of the assigned buffer, which will be needed in
+ * @param portIndex Index of the port.
+ * @param omxBuffer Buffer to be assigned to the port.
+ * @return status Status of the call.
+ * @return buffer Id of the assigned buffer, which will be needed in
* other buffer-related functions.
*
* @see OMX_UseBuffer() in the OpenMax IL standard.
@@ -253,9 +253,9 @@
* Free a buffer previously assigned to a port by allocateSecureBuffer() or
* useBuffer().
*
- * @param[in] portIndex Index of the port.
- * @param[in] buffer Id of the buffer to be freed.
- * @param[out] status Status of the call.
+ * @param portIndex Index of the port.
+ * @param buffer Id of the buffer to be freed.
+ * @return status Status of the call.
*
* @see OMX_FreeBuffer() in the OpenMax IL standard.
*/
@@ -275,10 +275,10 @@
* the new buffer passed in via \p omxBuffer before OMX_FillThisBuffer() is
* called. Otherwise, \p omxBuffer is not used.
*
- * @param[in] buffer Id of the buffer to fill.
- * @param[in] omxBuffer New buffer information (in metadata mode).
- * @param[in] fence Fence to wait for (if not null).
- * @param[out] status Status of the call.
+ * @param buffer Id of the buffer to fill.
+ * @param omxBuffer New buffer information (in metadata mode).
+ * @param fence Fence to wait for (if not null).
+ * @return status Status of the call.
*
* @see OMX_FillThisBuffer() in the OpenMax IL standard.
*/
@@ -299,12 +299,12 @@
* the new buffer passed in via \p omxBuffer before OMX_EmptyThisBuffer() is
* called. Otherwise, \p omxBuffer is not used.
*
- * @param[in] buffer Id of the buffer to fill.
- * @param[in] omxBuffer New buffer information (in metadata mode).
- * @param[in] flags Flags to be passed to OMX_EmptyBuffer().
- * @param[in] timestampUs Timestamp OMX_EmptyBuffer().
- * @param[in] fence Fence to wait for (if not null).
- * @param[out] status Status of the call.
+ * @param buffer Id of the buffer to fill.
+ * @param omxBuffer New buffer information (in metadata mode).
+ * @param flags Flags to be passed to OMX_EmptyBuffer().
+ * @param timestampUs Timestamp OMX_EmptyBuffer().
+ * @param fence Fence to wait for (if not null).
+ * @return status Status of the call.
*
* @see OMX_EmptyThisBuffer() in the OpenMax IL standard.
*/
@@ -321,9 +321,9 @@
/**
* Request the node to translate an extension string to an index.
*
- * @param[in] parameterName Requested extension string.
- * @param[out] status Status of the call.
- * @param[out] index Translated index.
+ * @param parameterName Requested extension string.
+ * @return status Status of the call.
+ * @return index Translated index.
*
* @see OMX_GetExtensionIndex() in the OpenMax IL standard.
*/
@@ -340,8 +340,8 @@
* receive the message in batches by the callback
* IOmxObserver::onMessages().
*
- * @param[in] msg Message to send.
- * @param[out] status Status of the call.
+ * @param msg Message to send.
+ * @return status Status of the call.
*
* @see IOmxObserver::onMessages().
*/
@@ -350,16 +350,5 @@
) generates (
Status status
);
-
- /**
- * Set quirks.
- *
- * @param[in] quirks Quirks for the component, generally obtained from
- * MediaCodecList::getQuirksFor().
- */
- oneway setQuirks(
- uint32_t quirks
- );
-
};
diff --git a/media/omx/1.0/IOmxStore.hal b/media/omx/1.0/IOmxStore.hal
new file mode 100644
index 0000000..a224b0e
--- /dev/null
+++ b/media/omx/1.0/IOmxStore.hal
@@ -0,0 +1,215 @@
+/*
+ * 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.media.omx@1.0;
+
+import IOmx;
+
+/**
+ * Ref: frameworks/av/include/media/IOMX.h: IOMX
+ *
+ * There will be two instances of IOmxStore: "platform" and "vendor".
+ *
+ * The IOmxStore service provided by the platform must present "platform" as the
+ * interface name.
+ *
+ * The IOmxStore service provided by the vendor must present "vendor" as the
+ * instance name.
+ */
+interface IOmxStore {
+
+ /**
+ * Attribute is a key-value pair of strings. The `value` member is generally
+ * a stringified value of the following:
+ * enum<v1,v2,...,vn>: v1 | v2 | ... | vn
+ * num: 0 | [1-9][0-9]*
+ * string: arbitrary string
+ * size: <num>x<num>
+ * ratio: <num>:<num>
+ * range<type>: <type>-<type>
+ * list<type>: <type> | <type>,<list<type>>
+ */
+ struct Attribute {
+ string key;
+ string value;
+ };
+
+ /**
+ * Service attribute
+ *
+ * Optional service attributes:
+ * key: 'max-video-encoder-input-buffers', value-type: num
+ * key: 'supports-multiple-secure-codecs', value-type: enum<0,1>
+ * key: 'supports-secure-with-non-secure-codec', value-type: enum<0,1>
+ *
+ * For keys with prefix 'supports-', the value of 0 means "no" (not
+ * supported) while the value of 1 means "yes" (supported).
+ */
+ typedef Attribute ServiceAttribute;
+
+ /**
+ * List attributes that are service-specific (not node-specific).
+ *
+ * @return attributes The list of `Attribute`s that are specific to this
+ * service.
+ */
+ listServiceAttributes(
+ ) generates (
+ Status status,
+ vec<ServiceAttribute> attributes
+ );
+
+ /**
+ * Node attribute
+ *
+ * Optional node attributes to describe supported values:
+ * key: 'bitrate-range', value-type: range<num>
+ * key: 'max-concurrent-instances', value-type: num
+ * key: 'max-supported-instances', value-type: num
+ *
+ * Optional node attributes for audio nodes to describe supported values:
+ * key: 'max-channel-count', value-type: num
+ * key: 'sample-rate-ranges', value-type: list<range<num>>
+ *
+ * Optional node attributes for video nodes to describe supported values:
+ * key: 'alignment', value-type: size
+ * key: 'block-aspect-ratio-range', value-type: range<ratio>
+ * key: 'block-count-range', value-type: range<num>
+ * key: 'block-size', value-type: size
+ * key: 'blocks-per-second-range', value-type: range<num>
+ * key: 'feature-can-swap-width-height', value-type: enum<0,1>
+ * key: 'frame-rate-range', value-type: range<num>
+ * key: 'pixel-aspect-ratio-range', value-type: range<ratio>
+ * key: 'size-range', value-type: range<size>
+ *
+ * Required node attributes for video nodes that are required by Android to
+ * describe measured values for this device:
+ * key: 'measured-frame-rate-<width>-<height>-range',
+ * value-type: range<num>; where width: num, height: num
+ *
+ * Optional node attributes for decoders to describe supported values:
+ * key: 'feature-adaptive-playback', value: enum<0,1>
+ * key: 'feature-secure-playback', value: enum<0,1>
+ * key: 'feature-tunneled-playback', value: enum<0,1>
+ *
+ * Optional node attributes for video decoders to describe supported values:
+ * key: 'feature-partial-frame', value: enum<0,1>
+ *
+ * Optional node attributes for encoders to describe supported values:
+ * key: 'complexity-default', value-type: num
+ * key: 'complexity-range', value-type: range<num>
+ * key: 'feature-bitrate-control', value-type: list<enum<VBR,CBR,CQ>>
+ * key: 'feature-intra-refresh', value-type: enum<0,1>
+ * key: 'quality-default', value-type: num
+ * key: 'quality-range', value-type: range<num>
+ * key: 'quality-scale', value-type: string
+ *
+ * For keys with prefix 'feature-' and value type enum<0,1>, the value of 0
+ * means "optional", while the value of 1 means "required".
+ */
+ typedef Attribute NodeAttribute;
+
+ /**
+ * Information for an IOmxNode node.
+ */
+ struct NodeInfo {
+ /**
+ * Name of this node.
+ *
+ * `name` can be supplied to `IOmx::allocateNode` of a
+ * corresponding `IOmx` instance to create the node.
+ */
+ string name;
+ /**
+ * Name of the `IOmx` instance that can create this node.
+ *
+ * To obtain the `IOmx` instance, call `getOmx(owner)`.
+ */
+ string owner;
+ /**
+ * List of node attributes.
+ */
+ vec<NodeAttribute> attributes;
+ };
+
+ /**
+ * Information about nodes provided for a supported node role
+ */
+ struct RoleInfo {
+ /**
+ * Standard OMX node role.
+ */
+ string role;
+ /**
+ * Corresponding media type (as defined in MediaFormat.MIMETYPE_*
+ * constants for types required by Android).
+ */
+ string type;
+ /**
+ * Whether this role is for an encoder or a decoder.
+ */
+ bool isEncoder;
+ /**
+ * Whether to prefer platform nodes for this role.
+ */
+ bool preferPlatformNodes;
+ /**
+ * List of nodes that support this role, ordered by preference.
+ */
+ vec<NodeInfo> nodes;
+ };
+
+ /**
+ * Return the prefix of names of supported nodes.
+ *
+ * @return prefix The prefix of the names of all nodes supported by this
+ * service.
+ */
+ getNodePrefix(
+ ) generates (
+ string prefix
+ );
+
+ /**
+ * List roles of supported nodes.
+ *
+ * The name of each node inside `NodeInfo` must start with the prefix
+ * returned by `getNodePrefix()`.
+ *
+ * @return roleList The list of `RoleInfo`s.
+ *
+ * @see RoleInfo
+ */
+ listRoles(
+ ) generates (
+ vec<RoleInfo> roleList
+ );
+
+ /**
+ * Obtain an `IOmx` instance with a specified name.
+ *
+ * @param name The name of the instance.
+ * @return omx The `IOmx` interface associated with `name`. This must be
+ * null if the name is not found.
+ */
+ getOmx(
+ string name
+ ) generates (
+ IOmx omx
+ );
+
+};
+
diff --git a/media/omx/1.0/types.hal b/media/omx/1.0/types.hal
index 5413344..76a6007 100644
--- a/media/omx/1.0/types.hal
+++ b/media/omx/1.0/types.hal
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 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.
@@ -35,6 +35,7 @@
NAME_NOT_FOUND = -2,
WOULD_BLOCK = -11,
NO_MEMORY = -12,
+ ALREADY_EXISTS = -17,
NO_INIT = -19,
BAD_VALUE = -22,
DEAD_OBJECT = -32,
diff --git a/media/omx/1.0/vts/functional/audio/Android.bp b/media/omx/1.0/vts/functional/audio/Android.bp
new file mode 100644
index 0000000..d6c73ce
--- /dev/null
+++ b/media/omx/1.0/vts/functional/audio/Android.bp
@@ -0,0 +1,79 @@
+//
+// 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: "VtsHalMediaOmxV1_0TargetAudioEncTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalMediaOmxV1_0TargetAudioEncTest.cpp",
+ "media_audio_hidl_test_common.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidlmemory",
+ "libhidltransport",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "libstagefright_foundation",
+ "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/",
+ "hardware/interfaces/media/omx/1.0/vts/functional/common",
+ ],
+}
+
+cc_test {
+ name: "VtsHalMediaOmxV1_0TargetAudioDecTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalMediaOmxV1_0TargetAudioDecTest.cpp",
+ "media_audio_hidl_test_common.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidlmemory",
+ "libhidltransport",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "libstagefright_foundation",
+ "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/",
+ "hardware/interfaces/media/omx/1.0/vts/functional/common",
+ ],
+}
+
+
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
new file mode 100644
index 0000000..7c21753
--- /dev/null
+++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
@@ -0,0 +1,687 @@
+/*
+ * 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_audio_dec_test"
+#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::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 <getopt.h>
+#include <media_audio_hidl_test_common.h>
+#include <media_hidl_test_common.h>
+#include <fstream>
+
+// A class for test environment setup
+class ComponentTestEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ ComponentTestEnvironment() : instance("default") {}
+
+ void setInstance(const char* _instance) { instance = _instance; }
+
+ void setComponent(const char* _component) { component = _component; }
+
+ void setRole(const char* _role) { role = _role; }
+
+ void setQuirks(int _quirks) { quirks = _quirks; }
+
+ const hidl_string getInstance() const { return instance; }
+
+ const hidl_string getComponent() const { return component; }
+
+ const hidl_string getRole() const { return role; }
+
+ int getQuirks() const { return quirks; }
+
+ int initFromOptions(int argc, char** argv) {
+ static struct option options[] = {
+ {"instance", required_argument, 0, 'I'},
+ {"component", required_argument, 0, 'C'},
+ {"role", required_argument, 0, 'R'},
+ {"quirks", required_argument, 0, 'Q'},
+ {0, 0, 0, 0}};
+
+ while (true) {
+ int index = 0;
+ int c = getopt_long(argc, argv, "I:C:Q:R:", options, &index);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'I':
+ setInstance(optarg);
+ break;
+ case 'C':
+ setComponent(optarg);
+ break;
+ case 'Q':
+ setQuirks(atoi(optarg));
+ break;
+ case 'R':
+ setRole(optarg);
+ break;
+ case '?':
+ break;
+ }
+ }
+
+ if (optind < argc) {
+ fprintf(stderr,
+ "unrecognized option: %s\n\n"
+ "usage: %s <gtest options> <test options>\n\n"
+ "test options are:\n\n"
+ "-I, --instance: HAL instance to test\n"
+ "-C, --component: OMX component to test\n"
+ "-R, --Role: OMX component Role\n"
+ "-Q, --quirks: Component quirks\n",
+ argv[optind ?: 1], argv[0]);
+ return 2;
+ }
+ return 0;
+ }
+
+ private:
+ hidl_string instance;
+ hidl_string component;
+ hidl_string role;
+ // to be removed when IOmxNode::setQuirks is removed
+ int quirks;
+};
+
+static ComponentTestEnvironment* gEnv = nullptr;
+
+class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ android::hardware::media::omx::V1_0::Status status;
+ omx = ::testing::VtsHalHidlTargetTestBase::getService<IOmx>(
+ gEnv->getInstance());
+ ASSERT_NE(omx, nullptr);
+ observer = new CodecObserver();
+ ASSERT_NE(observer, nullptr);
+ ASSERT_EQ(strncmp(gEnv->getComponent().c_str(), "OMX.", 4), 0)
+ << "Invalid Component Name";
+ EXPECT_TRUE(omx->allocateNode(
+ gEnv->getComponent(), observer,
+ [&](android::hardware::media::omx::V1_0::Status _s,
+ sp<IOmxNode> const& _nl) {
+ status = _s;
+ this->omxNode = _nl;
+ })
+ .isOk());
+ ASSERT_NE(omxNode, nullptr);
+ ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role";
+ struct StringToName {
+ const char* Name;
+ standardComp CompName;
+ };
+ const StringToName kStringToName[] = {
+ {"mp3", mp3}, {"amrnb", amrnb}, {"amrwb", amrwb},
+ {"aac", aac}, {"vorbis", vorbis}, {"opus", opus},
+ {"pcm", pcm}, {"flac", flac},
+ };
+ const size_t kNumStringToName =
+ sizeof(kStringToName) / sizeof(kStringToName[0]);
+ const char* pch;
+ char substring[OMX_MAX_STRINGNAME_SIZE];
+ strcpy(substring, gEnv->getRole().c_str());
+ pch = strchr(substring, '.');
+ ASSERT_NE(pch, nullptr);
+ compName = unknown_comp;
+ for (size_t i = 0; i < kNumStringToName; ++i) {
+ if (!strcasecmp(pch + 1, kStringToName[i].Name)) {
+ compName = kStringToName[i].CompName;
+ break;
+ }
+ }
+ ASSERT_NE(compName, unknown_comp);
+ struct CompToCoding {
+ standardComp CompName;
+ OMX_AUDIO_CODINGTYPE eEncoding;
+ };
+ static const CompToCoding kCompToCoding[] = {
+ {mp3, OMX_AUDIO_CodingMP3},
+ {amrnb, OMX_AUDIO_CodingAMR},
+ {amrwb, OMX_AUDIO_CodingAMR},
+ {aac, OMX_AUDIO_CodingAAC},
+ {vorbis, OMX_AUDIO_CodingVORBIS},
+ {pcm, OMX_AUDIO_CodingPCM},
+ {opus, (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAndroidOPUS},
+ {flac, OMX_AUDIO_CodingFLAC},
+ };
+ static const size_t kNumCompToCoding =
+ sizeof(kCompToCoding) / sizeof(kCompToCoding[0]);
+ size_t i;
+ for (i = 0; i < kNumCompToCoding; ++i) {
+ if (kCompToCoding[i].CompName == compName) {
+ eEncoding = kCompToCoding[i].eEncoding;
+ break;
+ }
+ }
+ ASSERT_NE(i, kNumCompToCoding);
+ }
+
+ virtual void TearDown() override {
+ if (omxNode != nullptr) {
+ EXPECT_TRUE((omxNode->freeNode()).isOk());
+ omxNode = nullptr;
+ }
+ }
+
+ enum standardComp {
+ mp3,
+ amrnb,
+ amrwb,
+ aac,
+ vorbis,
+ opus,
+ pcm,
+ flac,
+ unknown_comp,
+ };
+
+ sp<IOmx> omx;
+ sp<CodecObserver> observer;
+ sp<IOmxNode> omxNode;
+ standardComp compName;
+ OMX_AUDIO_CODINGTYPE eEncoding;
+};
+
+void setDefaultPortParam(
+ sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE eEncoding,
+ int32_t nChannels = 2, int32_t nSampleRate = 44100,
+ OMX_NUMERICALDATATYPE eNumData = OMX_NumericalDataSigned,
+ int32_t nBitPerSample = 16) {
+ 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);
+
+ portDef.format.audio.bFlagErrorConcealment = OMX_TRUE;
+ portDef.format.audio.eEncoding = eEncoding;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition, portIndex,
+ &portDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ switch ((int)eEncoding) {
+ case OMX_AUDIO_CodingPCM:
+ setupPCMPort(omxNode, portIndex, nChannels, eNumData, nBitPerSample,
+ nSampleRate);
+ break;
+ default:
+ ASSERT_TRUE(false);
+ break;
+ }
+}
+
+void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
+ OMX_AUDIO_CODINGTYPE eEncoding, int32_t* nChannels,
+ int32_t* nSampleRate) {
+ *nChannels = 0;
+ *nSampleRate = 0;
+ android::hardware::media::omx::V1_0::Status status;
+
+ switch ((int)eEncoding) {
+ case OMX_AUDIO_CodingPCM: {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioPcm,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = param.nSamplingRate;
+ break;
+ }
+ case OMX_AUDIO_CodingMP3: {
+ OMX_AUDIO_PARAM_MP3TYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioMp3,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = param.nSampleRate;
+ break;
+ }
+ case OMX_AUDIO_CodingFLAC: {
+ OMX_AUDIO_PARAM_FLACTYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioFlac,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = param.nSampleRate;
+ break;
+ }
+ case OMX_AUDIO_CodingAndroidOPUS: {
+ OMX_AUDIO_PARAM_ANDROID_OPUSTYPE param;
+ status = getPortParam(omxNode,
+ (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = param.nSampleRate;
+ break;
+ }
+ case OMX_AUDIO_CodingVORBIS: {
+ OMX_AUDIO_PARAM_VORBISTYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioVorbis,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = param.nSampleRate;
+ break;
+ }
+ case OMX_AUDIO_CodingAMR: {
+ OMX_AUDIO_PARAM_AMRTYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioAmr,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = 8000;
+ break;
+ }
+ case OMX_AUDIO_CodingAAC: {
+ OMX_AUDIO_PARAM_AACPROFILETYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioAac,
+ kPortIndexInput, ¶m);
+ ASSERT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ *nChannels = param.nChannels;
+ *nSampleRate = param.nSampleRate;
+ break;
+ }
+ default:
+ ASSERT_TRUE(false);
+ break;
+ }
+}
+
+void GetURLForComponent(AudioDecHidlTest::standardComp comp, const char** mURL,
+ const char** info) {
+ struct CompToURL {
+ AudioDecHidlTest::standardComp comp;
+ const char* mURL;
+ const char* info;
+ };
+ static const CompToURL kCompToURL[] = {
+ {AudioDecHidlTest::standardComp::mp3,
+ "/sdcard/raw/MP3_48KHz_128kbps_s_1_17_CBR.audio.mp3",
+ "/sdcard/raw/MP3_48KHz_128kbps_s_1_17_CBR.audio.info"},
+ {AudioDecHidlTest::standardComp::aac,
+ "/sdcard/raw/H264_500_AAC_128.audio.aac",
+ "/sdcard/raw/H264_500_AAC_128.audio.info"},
+ {AudioDecHidlTest::standardComp::amrnb,
+ "/sdcard/raw/H264_320_AMRNB_6.audio.amr",
+ "/sdcard/raw/H264_320_AMRNB_6.audio.info"},
+ {AudioDecHidlTest::standardComp::amrwb, "", ""},
+ {AudioDecHidlTest::standardComp::vorbis, "", ""},
+ {AudioDecHidlTest::standardComp::opus, "", ""},
+ {AudioDecHidlTest::standardComp::flac, "", ""},
+ };
+
+ for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) {
+ if (kCompToURL[i].comp == comp) {
+ *mURL = kCompToURL[i].mURL;
+ *info = kCompToURL[i].info;
+ return;
+ }
+ }
+}
+
+void flushAllPorts(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
+ 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);
+ }
+
+ 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);
+ }
+}
+
+void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
+ android::Vector<BufferInfo>* iBuffer,
+ android::Vector<BufferInfo>* oBuffer,
+ OMX_AUDIO_CODINGTYPE eEncoding, OMX_U32 kPortIndexInput,
+ OMX_U32 kPortIndexOutput, uint32_t nFrames,
+ std::ifstream& eleStream, std::ifstream& eleInfo) {
+ 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);
+ }
+ // dispatch input buffers
+ int bytesCount = 0;
+ for (size_t i = 0; i < iBuffer->size(); i++) {
+ char* ipBuffer = static_cast<char*>(
+ static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
+ if (!(eleInfo >> bytesCount)) break;
+ eleStream.read(ipBuffer, bytesCount);
+ ASSERT_EQ(eleStream.gcount(), bytesCount);
+ dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, 0, 0);
+ }
+
+ while (nFrames != 0) {
+ status =
+ observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
+ if (status == android::hardware::media::omx::V1_0::Status::OK &&
+ msg.type == Message::Type::EVENT &&
+ msg.data.eventData.event == OMX_EventPortSettingsChanged) {
+ ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput);
+
+ status = omxNode->sendCommand(
+ toRawCommandType(OMX_CommandPortDisable), kPortIndexOutput);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer,
+ oBuffer);
+ if (status ==
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT) {
+ for (size_t i = 0; i < oBuffer->size(); ++i) {
+ // test if client got all its buffers back
+ EXPECT_EQ((*oBuffer)[i].owner, client);
+ // free the buffers
+ 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_CommandPortDisable);
+ ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
+
+ // Port Reconfigurations
+ int32_t nChannels;
+ int32_t nSampleRate;
+ getInputChannelInfo(omxNode, kPortIndexInput, eEncoding,
+ &nChannels, &nSampleRate);
+ setDefaultPortParam(omxNode, kPortIndexOutput,
+ OMX_AUDIO_CodingPCM, nChannels,
+ nSampleRate);
+
+ // If you can disable a port, then you should be able to enable
+ // it as well
+ status = omxNode->sendCommand(
+ toRawCommandType(OMX_CommandPortEnable), kPortIndexOutput);
+ ASSERT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::OK);
+
+ // do not enable the port until all the buffers are supplied
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ iBuffer, oBuffer);
+ ASSERT_EQ(
+ status,
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ allocatePortBuffers(omxNode, oBuffer, kPortIndexOutput);
+ 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.data1, OMX_CommandPortEnable);
+ ASSERT_EQ(msg.data.eventData.data2, kPortIndexOutput);
+
+ // dispatch output buffers
+ for (size_t i = 0; i < oBuffer->size(); i++) {
+ dispatchOutputBuffer(omxNode, oBuffer, i);
+ }
+ } else {
+ ASSERT_TRUE(false);
+ }
+ continue;
+ }
+ size_t index = 0;
+ if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
+ char* ipBuffer = static_cast<char*>(
+ static_cast<void*>((*iBuffer)[index].mMemory->getPointer()));
+ if (!(eleInfo >> bytesCount)) break;
+ eleStream.read(ipBuffer, bytesCount);
+ ASSERT_EQ(eleStream.gcount(), bytesCount);
+ dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, 0, 0);
+ }
+ if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
+ dispatchOutputBuffer(omxNode, oBuffer, index);
+ }
+ nFrames--;
+ }
+}
+
+// Set Component Role
+TEST_F(AudioDecHidlTest, SetRole) {
+ android::hardware::media::omx::V1_0::Status status;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+// Enumerate Port Format
+TEST_F(AudioDecHidlTest, EnumeratePortFormat) {
+ 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_IndexParamAudioInit, ¶ms);
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ kPortIndexInput = params.nStartPortNumber;
+ kPortIndexOutput = kPortIndexInput + 1;
+ }
+ status = setAudioPortFormat(omxNode, kPortIndexInput, eEncoding);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = setAudioPortFormat(omxNode, kPortIndexOutput, OMX_AUDIO_CodingPCM);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+// Decode Test
+TEST_F(AudioDecHidlTest, DecodeTest) {
+ 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_IndexParamAudioInit, ¶ms);
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ kPortIndexInput = params.nStartPortNumber;
+ kPortIndexOutput = kPortIndexInput + 1;
+ }
+ const char *mURL = nullptr, *info = nullptr;
+ GetURLForComponent(compName, &mURL, &info);
+ EXPECT_NE(mURL, nullptr);
+ EXPECT_NE(info, nullptr);
+
+ std::ifstream eleStream, eleInfo;
+ eleStream.open(mURL, std::ifstream::binary);
+ ASSERT_EQ(eleStream.is_open(), true);
+ eleInfo.open(info);
+ ASSERT_EQ(eleInfo.is_open(), true);
+
+ if (eEncoding == OMX_AUDIO_CodingPCM)
+ setDefaultPortParam(omxNode, kPortIndexInput, eEncoding);
+ int32_t nChannels;
+ int32_t nSampleRate;
+ getInputChannelInfo(omxNode, kPortIndexInput, eEncoding, &nChannels,
+ &nSampleRate);
+ setDefaultPortParam(omxNode, kPortIndexOutput, OMX_AUDIO_CodingPCM,
+ nChannels, nSampleRate);
+
+ Message msg;
+ android::Vector<BufferInfo> iBuffer, oBuffer;
+
+ 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::TIMED_OUT);
+
+ allocatePortBuffers(omxNode, &iBuffer, kPortIndexInput);
+ status =
+ observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &iBuffer, &oBuffer);
+
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+ allocatePortBuffers(omxNode, &oBuffer, kPortIndexOutput);
+
+ 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);
+
+ 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, &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_StateExecuting);
+
+ // Port Reconfiguration
+ decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
+ kPortIndexInput, kPortIndexOutput, (1 << 12), eleStream,
+ eleInfo);
+
+ // flush
+ flushAllPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
+ kPortIndexOutput);
+
+ // 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);
+
+ // 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);
+
+ eleInfo.close();
+ eleStream.close();
+}
+
+int main(int argc, char** argv) {
+ gEnv = new ComponentTestEnvironment();
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = gEnv->initFromOptions(argc, argv);
+ if (status == 0) {
+ status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ }
+ return status;
+}
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
new file mode 100644
index 0000000..6a88b1a
--- /dev/null
+++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
@@ -0,0 +1,263 @@
+/*
+ * 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_audio_enc_test"
+#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::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 <getopt.h>
+#include <media_audio_hidl_test_common.h>
+#include <media_hidl_test_common.h>
+#include <fstream>
+
+// A class for test environment setup
+class ComponentTestEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ ComponentTestEnvironment() : instance("default") {}
+
+ void setInstance(const char* _instance) { instance = _instance; }
+
+ void setComponent(const char* _component) { component = _component; }
+
+ void setRole(const char* _role) { role = _role; }
+
+ void setQuirks(int _quirks) { quirks = _quirks; }
+
+ const hidl_string getInstance() const { return instance; }
+
+ const hidl_string getComponent() const { return component; }
+
+ const hidl_string getRole() const { return role; }
+
+ int getQuirks() const { return quirks; }
+
+ int initFromOptions(int argc, char** argv) {
+ static struct option options[] = {
+ {"instance", required_argument, 0, 'I'},
+ {"component", required_argument, 0, 'C'},
+ {"role", required_argument, 0, 'R'},
+ {"quirks", required_argument, 0, 'Q'},
+ {0, 0, 0, 0}};
+
+ while (true) {
+ int index = 0;
+ int c = getopt_long(argc, argv, "I:C:Q:R:", options, &index);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'I':
+ setInstance(optarg);
+ break;
+ case 'C':
+ setComponent(optarg);
+ break;
+ case 'Q':
+ setQuirks(atoi(optarg));
+ break;
+ case 'R':
+ setRole(optarg);
+ break;
+ case '?':
+ break;
+ }
+ }
+
+ if (optind < argc) {
+ fprintf(stderr,
+ "unrecognized option: %s\n\n"
+ "usage: %s <gtest options> <test options>\n\n"
+ "test options are:\n\n"
+ "-I, --instance: HAL instance to test\n"
+ "-C, --component: OMX component to test\n"
+ "-R, --Role: OMX component Role\n"
+ "-Q, --quirks: Component quirks\n",
+ argv[optind ?: 1], argv[0]);
+ return 2;
+ }
+ return 0;
+ }
+
+ private:
+ hidl_string instance;
+ hidl_string component;
+ hidl_string role;
+ // to be removed when IOmxNode::setQuirks is removed
+ int quirks;
+};
+
+static ComponentTestEnvironment* gEnv = nullptr;
+
+class AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ android::hardware::media::omx::V1_0::Status status;
+ omx = ::testing::VtsHalHidlTargetTestBase::getService<IOmx>(
+ gEnv->getInstance());
+ ASSERT_NE(omx, nullptr);
+ observer = new CodecObserver();
+ ASSERT_NE(observer, nullptr);
+ ASSERT_EQ(strncmp(gEnv->getComponent().c_str(), "OMX.", 4), 0)
+ << "Invalid Component Name";
+ EXPECT_TRUE(omx->allocateNode(
+ gEnv->getComponent(), observer,
+ [&](android::hardware::media::omx::V1_0::Status _s,
+ sp<IOmxNode> const& _nl) {
+ status = _s;
+ this->omxNode = _nl;
+ })
+ .isOk());
+ ASSERT_NE(omxNode, nullptr);
+ ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role";
+ struct StringToName {
+ const char* Name;
+ standardComp CompName;
+ };
+ const StringToName kStringToName[] = {
+ {"mp3", mp3}, {"amrnb", amrnb}, {"amrwb", amrwb},
+ {"aac", aac}, {"vorbis", vorbis}, {"opus", opus},
+ {"pcm", pcm}, {"flac", flac},
+ };
+ const size_t kNumStringToName =
+ sizeof(kStringToName) / sizeof(kStringToName[0]);
+ const char* pch;
+ char substring[OMX_MAX_STRINGNAME_SIZE];
+ strcpy(substring, gEnv->getRole().c_str());
+ pch = strchr(substring, '.');
+ ASSERT_NE(pch, nullptr);
+ compName = unknown_comp;
+ for (size_t i = 0; i < kNumStringToName; ++i) {
+ if (!strcasecmp(pch + 1, kStringToName[i].Name)) {
+ compName = kStringToName[i].CompName;
+ break;
+ }
+ }
+ ASSERT_NE(compName, unknown_comp);
+ struct CompToCoding {
+ standardComp CompName;
+ OMX_AUDIO_CODINGTYPE eEncoding;
+ };
+ static const CompToCoding kCompToCoding[] = {
+ {mp3, OMX_AUDIO_CodingMP3},
+ {amrnb, OMX_AUDIO_CodingAMR},
+ {amrwb, OMX_AUDIO_CodingAMR},
+ {aac, OMX_AUDIO_CodingAAC},
+ {vorbis, OMX_AUDIO_CodingVORBIS},
+ {pcm, OMX_AUDIO_CodingPCM},
+ {opus, (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAndroidOPUS},
+ {flac, OMX_AUDIO_CodingFLAC},
+ };
+ static const size_t kNumCompToCoding =
+ sizeof(kCompToCoding) / sizeof(kCompToCoding[0]);
+ size_t i;
+ for (i = 0; i < kNumCompToCoding; ++i) {
+ if (kCompToCoding[i].CompName == compName) {
+ eEncoding = kCompToCoding[i].eEncoding;
+ break;
+ }
+ }
+ ASSERT_NE(i, kNumCompToCoding);
+ }
+
+ virtual void TearDown() override {
+ if (omxNode != nullptr) {
+ EXPECT_TRUE((omxNode->freeNode()).isOk());
+ omxNode = nullptr;
+ }
+ }
+
+ enum standardComp {
+ mp3,
+ amrnb,
+ amrwb,
+ aac,
+ vorbis,
+ opus,
+ pcm,
+ flac,
+ unknown_comp,
+ };
+
+ sp<IOmx> omx;
+ sp<CodecObserver> observer;
+ sp<IOmxNode> omxNode;
+ standardComp compName;
+ OMX_AUDIO_CODINGTYPE eEncoding;
+};
+
+// Set Component Role
+TEST_F(AudioEncHidlTest, SetRole) {
+ android::hardware::media::omx::V1_0::Status status;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+// Enumerate Port Format
+TEST_F(AudioEncHidlTest, EnumeratePortFormat) {
+ 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_IndexParamAudioInit, ¶ms);
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ kPortIndexInput = params.nStartPortNumber;
+ kPortIndexOutput = kPortIndexInput + 1;
+ }
+ status = setAudioPortFormat(omxNode, kPortIndexInput, OMX_AUDIO_CodingPCM);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = setAudioPortFormat(omxNode, kPortIndexOutput, eEncoding);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+int main(int argc, char** argv) {
+ gEnv = new ComponentTestEnvironment();
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = gEnv->initFromOptions(argc, argv);
+ if (status == 0) {
+ status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ }
+ return status;
+}
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
new file mode 100644
index 0000000..e01e9aa
--- /dev/null
+++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.cpp
@@ -0,0 +1,316 @@
+/*
+ * 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_audio_test_common"
+#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::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_audio_hidl_test_common.h>
+#include <media_hidl_test_common.h>
+#include <memory>
+
+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, 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;
+ allocator->allocate(
+ portDef.nBufferSize,
+ [&success, &buffer](bool _s,
+ ::android::hardware::hidl_memory const& mem) {
+ success = _s;
+ buffer.omxBuffer.sharedMemory = mem;
+ });
+ ASSERT_EQ(success, true);
+ 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);
+ }
+}
+
+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();
+}
+
+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;
+}
+
+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;
+}
+
+Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
+ sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE encoding) {
+ OMX_U32 index = 0;
+ OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
+ std::vector<OMX_AUDIO_CODINGTYPE> eEncoding;
+ android::hardware::media::omx::V1_0::Status status;
+
+ while (1) {
+ portFormat.nIndex = index;
+ status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
+ &portFormat);
+ if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
+ eEncoding.push_back(portFormat.eEncoding);
+ index++;
+ if (index == 512) {
+ EXPECT_LE(index, 512U)
+ << "Expecting OMX_ErrorNoMore but not received";
+ break;
+ }
+ }
+ if (!index) return status;
+ for (index = 0; index < eEncoding.size(); index++) {
+ if (eEncoding[index] == encoding) {
+ portFormat.eEncoding = eEncoding[index];
+ break;
+ }
+ }
+ if (index == eEncoding.size()) {
+ ALOGI("setting default Port format");
+ portFormat.eEncoding = eEncoding[0];
+ }
+ // In setParam call nIndex shall be ignored as per omx-il specification.
+ // see how this holds up by corrupting nIndex
+ portFormat.nIndex = RANDOM_INDEX;
+ status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
+ &portFormat);
+ return status;
+}
+
+Return<android::hardware::media::omx::V1_0::Status> setRole(
+ sp<IOmxNode> omxNode, const char* role) {
+ OMX_PARAM_COMPONENTROLETYPE params;
+ strcpy((char*)params.cRole, role);
+ return setParam(omxNode, OMX_IndexParamStandardComponentRole, ¶ms);
+}
+
+void setupPCMPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ OMX_NUMERICALDATATYPE eNumData, int32_t nBitPerSample,
+ int32_t nSamplingRate) {
+ OMX_AUDIO_PARAM_PCMMODETYPE param;
+ android::hardware::media::omx::V1_0::Status status;
+ status = getPortParam(omxNode, OMX_IndexParamAudioPcm, portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = nChannels;
+ param.eNumData = eNumData;
+ param.eEndian = OMX_EndianBig;
+ param.bInterleaved = OMX_TRUE;
+ param.nBitPerSample = nBitPerSample;
+ param.nSamplingRate = nSamplingRate;
+ param.ePCMMode = OMX_AUDIO_PCMModeLinear;
+ switch (nChannels) {
+ case 1:
+ param.eChannelMapping[0] = OMX_AUDIO_ChannelCF;
+ break;
+ case 2:
+ param.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
+ param.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
+ break;
+ default:
+ EXPECT_TRUE(false);
+ }
+ status = setPortParam(omxNode, OMX_IndexParamAudioPcm, portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+void setupMP3Port(sp<IOmxNode> omxNode, OMX_U32 portIndex,
+ OMX_AUDIO_MP3STREAMFORMATTYPE eFormat, int32_t nChannels,
+ int32_t nBitRate, int32_t nSampleRate, bool isEncoder) {
+ if (isEncoder == false) return;
+ OMX_AUDIO_PARAM_MP3TYPE param;
+ android::hardware::media::omx::V1_0::Status status;
+ status = getPortParam(omxNode, OMX_IndexParamAudioMp3, portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = nChannels;
+ param.nBitRate = nBitRate;
+ param.nSampleRate = nSampleRate;
+ param.nAudioBandWidth = 0;
+ param.eChannelMode = (nChannels == 1) ? OMX_AUDIO_ChannelModeMono
+ : OMX_AUDIO_ChannelModeStereo;
+ param.eFormat = eFormat;
+ status = setPortParam(omxNode, OMX_IndexParamAudioMp3, portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+void setupFLACPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ int32_t nSampleRate, int32_t nCompressionLevel,
+ bool isEncoder) {
+ if (isEncoder == false) return;
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_AUDIO_PARAM_FLACTYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioFlac, portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = nChannels;
+ param.nSampleRate = nSampleRate;
+ param.nCompressionLevel = nCompressionLevel;
+ status = setPortParam(omxNode, OMX_IndexParamAudioFlac, portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+void setupOPUSPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ int32_t nBitRate, int32_t nSampleRate, bool isEncoder) {
+ if (isEncoder == false) return;
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_AUDIO_PARAM_ANDROID_OPUSTYPE param;
+ status =
+ getPortParam(omxNode, (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus,
+ portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = nChannels;
+ param.nBitRate = nBitRate;
+ param.nSampleRate = nSampleRate;
+ status =
+ setPortParam(omxNode, (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus,
+ portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+void setupAMRPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nBitRate,
+ OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode, bool isEncoder) {
+ if (isEncoder == false) return;
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_AUDIO_PARAM_AMRTYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioAmr, portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = 1;
+ param.nBitRate = nBitRate;
+ param.eAMRBandMode = eAMRBandMode;
+ status = setPortParam(omxNode, OMX_IndexParamAudioAmr, portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+void setupVORBISPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ int32_t nBitRate, int32_t nSampleRate, int32_t nQuality,
+ bool isEncoder) {
+ if (isEncoder == false) return;
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_AUDIO_PARAM_VORBISTYPE param;
+ status =
+ getPortParam(omxNode, OMX_IndexParamAudioVorbis, portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = nChannels;
+ param.nBitRate = nBitRate;
+ param.nSampleRate = nSampleRate;
+ param.nQuality = nQuality;
+ status =
+ setPortParam(omxNode, OMX_IndexParamAudioVorbis, portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+void setupAACPort(sp<IOmxNode> omxNode, OMX_U32 portIndex,
+ OMX_AUDIO_AACPROFILETYPE eAACProfile,
+ OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat,
+ int32_t nChannels, int32_t nBitRate, int32_t nSampleRate,
+ bool isEncoder) {
+ if (isEncoder == false) return;
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_AUDIO_PARAM_AACPROFILETYPE param;
+ status = getPortParam(omxNode, OMX_IndexParamAudioAac, portIndex, ¶m);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ param.nChannels = nChannels;
+ param.nSampleRate = nSampleRate;
+ param.nBitRate = nBitRate;
+ param.eAACProfile = eAACProfile;
+ param.eAACStreamFormat = eAACStreamFormat;
+ param.eChannelMode = (nChannels == 1) ? OMX_AUDIO_ChannelModeMono
+ : OMX_AUDIO_ChannelModeStereo;
+ status = setPortParam(omxNode, OMX_IndexParamAudioAac, portIndex, ¶m);
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
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
new file mode 100644
index 0000000..bdf5d52
--- /dev/null
+++ b/media/omx/1.0/vts/functional/audio/media_audio_hidl_test_common.h
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+#ifndef MEDIA_AUDIO_HIDL_TEST_COMMON_H
+#define MEDIA_AUDIO_HIDL_TEST_COMMON_H
+
+#include <media_hidl_test_common.h>
+/*
+ * Random Index used for monkey testing while get/set parameters
+ */
+#define RANDOM_INDEX 1729
+
+/*
+ * Common audio utils
+ */
+void allocatePortBuffers(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ OMX_U32 portIndex);
+
+size_t getEmptyBufferID(android::Vector<BufferInfo>* buffArray);
+
+void dispatchInputBuffer(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ size_t bufferIndex, int bytesCount, uint32_t flags,
+ uint64_t timestamp);
+
+void dispatchOutputBuffer(sp<IOmxNode> omxNode,
+ android::Vector<BufferInfo>* buffArray,
+ size_t bufferIndex);
+
+Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
+ sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE encoding);
+
+Return<android::hardware::media::omx::V1_0::Status> setRole(
+ sp<IOmxNode> omxNode, const char* role);
+
+void setupPCMPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ OMX_NUMERICALDATATYPE eNumData, int32_t nBitPerSample,
+ int32_t nSamplingRate);
+
+void setupMP3Port(sp<IOmxNode> omxNode, OMX_U32 portIndex,
+ OMX_AUDIO_MP3STREAMFORMATTYPE eFormat, int32_t nChannels,
+ int32_t nBitRate, int32_t nSampleRate, bool isEncoder);
+
+void setupFLACPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ int32_t nSampleRate, int32_t nCompressionLevel,
+ bool isEncoder);
+
+void setupOPUSPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ int32_t nBitRate, int32_t nSampleRate, bool isEncoder);
+
+void setupAMRPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nBitRate,
+ OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode, bool isEncoder);
+
+void setupVORBISPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, int32_t nChannels,
+ int32_t nBitRate, int32_t nSampleRate, int32_t nQuality,
+ bool isEncoder);
+
+void setupAACPort(sp<IOmxNode> omxNode, OMX_U32 portIndex,
+ OMX_AUDIO_AACPROFILETYPE eAACProfile,
+ OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat,
+ int32_t nChannels, int32_t nBitRate, int32_t nSampleRate,
+ bool isEncoder);
+
+#endif // MEDIA_AUDIO_HIDL_TEST_COMMON_H
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
new file mode 100644
index 0000000..9421463
--- /dev/null
+++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
@@ -0,0 +1,206 @@
+/*
+ * 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.
+ */
+
+#ifndef MEDIA_HIDL_TEST_COMMON_H
+#define MEDIA_HIDL_TEST_COMMON_H
+
+#include <media/stagefright/foundation/ALooper.h>
+#include <utils/Condition.h>
+#include <utils/List.h>
+#include <utils/Mutex.h>
+
+#include <media/openmax/OMX_Index.h>
+#include <media/openmax/OMX_Core.h>
+#include <media/openmax/OMX_Component.h>
+#include <media/openmax/OMX_IndexExt.h>
+#include <media/openmax/OMX_AudioExt.h>
+
+/*
+ * TODO: 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);
+}
+
+inline android::hardware::media::omx::V1_0::Status toStatus(
+ android::status_t l) {
+ return static_cast<android::hardware::media::omx::V1_0::Status>(l);
+}
+
+inline hidl_vec<uint8_t> inHidlBytes(void const* l, size_t size) {
+ hidl_vec<uint8_t> t;
+ t.setToExternal(static_cast<uint8_t*>(const_cast<void*>(l)), size, false);
+ return t;
+}
+
+inline uint32_t toRawCommandType(OMX_COMMANDTYPE l) {
+ return static_cast<uint32_t>(l);
+}
+
+/*
+ * Handle Callback functions EmptythisBuffer(), FillthisBuffer(),
+ * EventHandler()
+ */
+#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;
+};
+
+struct CodecObserver : public IOmxObserver {
+ public:
+ Return<void> onMessages(const hidl_vec<Message>& messages) override {
+ android::Mutex::Autolock autoLock(msgLock);
+ for (hidl_vec<Message>::const_iterator it = messages.begin();
+ it != messages.end(); ++it) {
+ msgQueue.push_back(*it);
+ }
+ msgCondition.signal();
+ return Void();
+ }
+ android::hardware::media::omx::V1_0::Status dequeueMessage(
+ Message* msg, int64_t timeoutUs,
+ android::Vector<BufferInfo>* iBuffers = nullptr,
+ android::Vector<BufferInfo>* oBuffers = nullptr) {
+ int64_t finishBy = android::ALooper::GetNowUs() + timeoutUs;
+ for (;;) {
+ android::Mutex::Autolock autoLock(msgLock);
+ android::List<Message>::iterator it = msgQueue.begin();
+ while (it != msgQueue.end()) {
+ if (it->type ==
+ android::hardware::media::omx::V1_0::Message::Type::EVENT) {
+ *msg = *it;
+ msgQueue.erase(it);
+ return ::android::hardware::media::omx::V1_0::Status::OK;
+ } else if (it->type == android::hardware::media::omx::V1_0::
+ Message::Type::FILL_BUFFER_DONE) {
+ if (oBuffers) {
+ size_t i;
+ for (i = 0; i < oBuffers->size(); ++i) {
+ if ((*oBuffers)[i].id ==
+ it->data.bufferData.buffer) {
+ oBuffers->editItemAt(i).owner = client;
+ msgQueue.erase(it);
+ break;
+ }
+ }
+ EXPECT_LE(i, oBuffers->size());
+ }
+ } else if (it->type == android::hardware::media::omx::V1_0::
+ Message::Type::EMPTY_BUFFER_DONE) {
+ if (iBuffers) {
+ size_t i;
+ for (i = 0; i < iBuffers->size(); ++i) {
+ if ((*iBuffers)[i].id ==
+ it->data.bufferData.buffer) {
+ iBuffers->editItemAt(i).owner = client;
+ msgQueue.erase(it);
+ break;
+ }
+ }
+ EXPECT_LE(i, iBuffers->size());
+ }
+ }
+ ++it;
+ }
+ android::status_t err =
+ (timeoutUs < 0)
+ ? msgCondition.wait(msgLock)
+ : msgCondition.waitRelative(
+ msgLock,
+ (finishBy - android::ALooper::GetNowUs()) * 1000);
+ if (err == android::TIMED_OUT) return toStatus(err);
+ }
+ }
+
+ android::List<Message> msgQueue;
+ android::Mutex msgLock;
+ android::Condition msgCondition;
+};
+
+/*
+ * Useful Wrapper utilities
+ */
+template <class T>
+void InitOMXParams(T* params) {
+ params->nSize = sizeof(T);
+ params->nVersion.s.nVersionMajor = 1;
+ params->nVersion.s.nVersionMinor = 0;
+ params->nVersion.s.nRevision = 0;
+ params->nVersion.s.nStep = 0;
+}
+
+template <class T>
+Return<android::hardware::media::omx::V1_0::Status> getParam(
+ sp<IOmxNode> omxNode, OMX_INDEXTYPE omxIdx, T* params) {
+ android::hardware::media::omx::V1_0::Status status;
+ InitOMXParams(params);
+ omxNode->getParameter(
+ toRawIndexType(omxIdx), inHidlBytes(params, sizeof(*params)),
+ [&status, ¶ms](android::hardware::media::omx::V1_0::Status _s,
+ hidl_vec<uint8_t> const& outParams) {
+ status = _s;
+ std::copy(outParams.data(), outParams.data() + outParams.size(),
+ static_cast<uint8_t*>(static_cast<void*>(params)));
+ });
+ return status;
+}
+
+template <class T>
+Return<android::hardware::media::omx::V1_0::Status> setParam(
+ sp<IOmxNode> omxNode, OMX_INDEXTYPE omxIdx, T* params) {
+ InitOMXParams(params);
+ return omxNode->setParameter(toRawIndexType(omxIdx),
+ inHidlBytes(params, sizeof(*params)));
+}
+
+template <class T>
+Return<android::hardware::media::omx::V1_0::Status> getPortParam(
+ sp<IOmxNode> omxNode, OMX_INDEXTYPE omxIdx, OMX_U32 nPortIndex, T* params) {
+ android::hardware::media::omx::V1_0::Status status;
+ InitOMXParams(params);
+ params->nPortIndex = nPortIndex;
+ omxNode->getParameter(
+ toRawIndexType(omxIdx), inHidlBytes(params, sizeof(*params)),
+ [&status, ¶ms](android::hardware::media::omx::V1_0::Status _s,
+ hidl_vec<uint8_t> const& outParams) {
+ status = _s;
+ std::copy(outParams.data(), outParams.data() + outParams.size(),
+ static_cast<uint8_t*>(static_cast<void*>(params)));
+ });
+ return status;
+}
+
+template <class T>
+Return<android::hardware::media::omx::V1_0::Status> setPortParam(
+ sp<IOmxNode> omxNode, OMX_INDEXTYPE omxIdx, OMX_U32 nPortIndex, T* params) {
+ InitOMXParams(params);
+ params->nPortIndex = nPortIndex;
+ return omxNode->setParameter(toRawIndexType(omxIdx),
+ inHidlBytes(params, sizeof(*params)));
+}
+
+#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
new file mode 100644
index 0000000..02fe182
--- /dev/null
+++ b/media/omx/1.0/vts/functional/component/Android.bp
@@ -0,0 +1,45 @@
+//
+// 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: "VtsHalMediaOmxV1_0TargetComponentTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalMediaOmxV1_0TargetComponentTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "libstagefright_foundation",
+ "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/",
+ "hardware/interfaces/media/omx/1.0/vts/functional/common",
+ ],
+}
+
diff --git a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
new file mode 100644
index 0000000..fdffd66
--- /dev/null
+++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
@@ -0,0 +1,1213 @@
+/*
+ * 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_component_test"
+#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::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 <getopt.h>
+#include <media_hidl_test_common.h>
+
+// A class for test environment setup
+class ComponentTestEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ ComponentTestEnvironment() : instance("default") {}
+
+ void setInstance(const char* _instance) { instance = _instance; }
+
+ void setComponent(const char* _component) { component = _component; }
+
+ void setRole(const char* _role) { role = _role; }
+
+ void setQuirks(int _quirks) { quirks = _quirks; }
+
+ const hidl_string getInstance() const { return instance; }
+
+ const hidl_string getComponent() const { return component; }
+
+ const hidl_string getRole() const { return role; }
+
+ int getQuirks() const { return quirks; }
+
+ int initFromOptions(int argc, char** argv) {
+ static struct option options[] = {
+ {"instance", required_argument, 0, 'I'},
+ {"component", required_argument, 0, 'C'},
+ {"role", required_argument, 0, 'R'},
+ {"quirks", required_argument, 0, 'Q'},
+ {0, 0, 0, 0}};
+
+ while (true) {
+ int index = 0;
+ int c = getopt_long(argc, argv, "I:C:Q:R:", options, &index);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'I':
+ setInstance(optarg);
+ break;
+ case 'C':
+ setComponent(optarg);
+ break;
+ case 'Q':
+ setQuirks(atoi(optarg));
+ break;
+ case 'R':
+ setRole(optarg);
+ break;
+ case '?':
+ break;
+ }
+ }
+
+ if (optind < argc) {
+ fprintf(stderr,
+ "unrecognized option: %s\n\n"
+ "usage: %s <gtest options> <test options>\n\n"
+ "test options are:\n\n"
+ "-I, --instance: HAL instance to test\n"
+ "-C, --component: OMX component to test\n"
+ "-R, --Role: OMX component Role\n"
+ "-Q, --quirks: Component quirks\n",
+ argv[optind ?: 1], argv[0]);
+ return 2;
+ }
+ return 0;
+ }
+
+ private:
+ hidl_string instance;
+ hidl_string component;
+ hidl_string role;
+ // to be removed when IOmxNode::setQuirks is removed
+ int quirks;
+};
+
+static ComponentTestEnvironment* gEnv = nullptr;
+
+class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ android::hardware::media::omx::V1_0::Status status;
+ omx = ::testing::VtsHalHidlTargetTestBase::getService<IOmx>(
+ gEnv->getInstance());
+ ASSERT_NE(omx, nullptr);
+ observer = new CodecObserver();
+ ASSERT_NE(observer, nullptr);
+ ASSERT_EQ(strncmp(gEnv->getComponent().c_str(), "OMX.", 4), 0)
+ << "Invalid Component Name";
+ EXPECT_TRUE(omx->allocateNode(
+ gEnv->getComponent(), observer,
+ [&](android::hardware::media::omx::V1_0::Status _s,
+ sp<IOmxNode> const& _nl) {
+ status = _s;
+ this->omxNode = _nl;
+ })
+ .isOk());
+ ASSERT_NE(omxNode, nullptr);
+ ASSERT_NE(gEnv->getRole().empty(), true) << "Invalid Component Role";
+ struct StringToClass {
+ const char* Class;
+ standardCompClass CompClass;
+ };
+ const StringToClass kStringToClass[] = {
+ {"audio_decoder", audio_decoder},
+ {"audio_encoder", audio_encoder},
+ {"video_decoder", video_decoder},
+ {"video_encoder", video_encoder},
+ };
+ const size_t kNumStringToClass =
+ sizeof(kStringToClass) / sizeof(kStringToClass[0]);
+ const char* pch;
+ char substring[OMX_MAX_STRINGNAME_SIZE];
+ strcpy(substring, gEnv->getRole().c_str());
+ pch = strchr(substring, '.');
+ ASSERT_NE(pch, nullptr) << "Invalid Component Role";
+ substring[pch - substring] = '\0';
+ compClass = unknown_class;
+ for (size_t i = 0; i < kNumStringToClass; ++i) {
+ if (!strcasecmp(substring, kStringToClass[i].Class)) {
+ compClass = kStringToClass[i].CompClass;
+ break;
+ }
+ }
+ ASSERT_NE(compClass, unknown_class) << "Invalid Component Class";
+
+ allocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>(
+ "ashmem");
+ ASSERT_NE(allocator, nullptr);
+ }
+
+ virtual void TearDown() override {
+ if (omxNode != nullptr) {
+ EXPECT_TRUE((omxNode->freeNode()).isOk());
+ omxNode = nullptr;
+ }
+ }
+
+ enum standardCompClass {
+ audio_decoder,
+ audio_encoder,
+ video_decoder,
+ video_encoder,
+ unknown_class,
+ };
+
+ sp<IOmx> omx;
+ sp<CodecObserver> observer;
+ sp<IOmxNode> omxNode;
+ sp<IAllocator> allocator;
+ standardCompClass compClass;
+};
+
+#define RANDOM_INDEX 1729
+
+void allocatePortBuffers(sp<IOmxNode> omxNode, sp<IAllocator> allocator,
+ android::Vector<BufferInfo>* buffArray,
+ OMX_U32 portIndex) {
+ 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);
+ 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;
+ allocator->allocate(
+ portDef.nBufferSize,
+ [&success, &buffer](bool _s,
+ ::android::hardware::hidl_memory const& mem) {
+ success = _s;
+ buffer.omxBuffer.sharedMemory = mem;
+ });
+ ASSERT_EQ(success, true);
+
+ 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);
+ }
+}
+
+Return<android::hardware::media::omx::V1_0::Status> setVideoPortFormat(
+ sp<IOmxNode> omxNode, OMX_U32 portIndex,
+ OMX_VIDEO_CODINGTYPE compressionFormat, OMX_COLOR_FORMATTYPE colorFormat,
+ OMX_U32 frameRate) {
+ OMX_U32 index = 0;
+ OMX_VIDEO_PARAM_PORTFORMATTYPE portFormat;
+ std::vector<OMX_COLOR_FORMATTYPE> eColorFormat;
+ std::vector<OMX_VIDEO_CODINGTYPE> eCompressionFormat;
+ android::hardware::media::omx::V1_0::Status status;
+
+ while (1) {
+ portFormat.nIndex = index;
+ status = getPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
+ &portFormat);
+ if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
+ if (compressionFormat == OMX_VIDEO_CodingUnused)
+ eColorFormat.push_back(portFormat.eColorFormat);
+ else
+ eCompressionFormat.push_back(portFormat.eCompressionFormat);
+ index++;
+ if (index == 512) {
+ EXPECT_LE(index, 512U)
+ << "Expecting OMX_ErrorNoMore but not received";
+ break;
+ }
+ }
+ if (!index) return status;
+ if (compressionFormat == OMX_VIDEO_CodingUnused) {
+ for (index = 0; index < eColorFormat.size(); index++) {
+ if (eColorFormat[index] == colorFormat) {
+ portFormat.eColorFormat = eColorFormat[index];
+ break;
+ }
+ }
+ if (index == eColorFormat.size()) {
+ ALOGI("setting default color format");
+ portFormat.eColorFormat = eColorFormat[0];
+ }
+ portFormat.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ } else {
+ for (index = 0; index < eCompressionFormat.size(); index++) {
+ if (eCompressionFormat[index] == compressionFormat) {
+ portFormat.eCompressionFormat = eCompressionFormat[index];
+ break;
+ }
+ }
+ if (index == eCompressionFormat.size()) {
+ ALOGI("setting default compression format");
+ portFormat.eCompressionFormat = eCompressionFormat[0];
+ }
+ portFormat.eColorFormat = OMX_COLOR_FormatUnused;
+ }
+ // In setParam call nIndex shall be ignored as per omx-il specification.
+ // see how this holds up by corrupting nIndex
+ portFormat.nIndex = RANDOM_INDEX;
+ portFormat.xFramerate = frameRate;
+ status = setPortParam(omxNode, OMX_IndexParamVideoPortFormat, portIndex,
+ &portFormat);
+ return status;
+}
+
+Return<android::hardware::media::omx::V1_0::Status> setAudioPortFormat(
+ sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE encoding) {
+ OMX_U32 index = 0;
+ OMX_AUDIO_PARAM_PORTFORMATTYPE portFormat;
+ std::vector<OMX_AUDIO_CODINGTYPE> eEncoding;
+ android::hardware::media::omx::V1_0::Status status;
+
+ while (1) {
+ portFormat.nIndex = index;
+ status = getPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
+ &portFormat);
+ if (status != ::android::hardware::media::omx::V1_0::Status::OK) break;
+ eEncoding.push_back(portFormat.eEncoding);
+ index++;
+ if (index == 512) {
+ EXPECT_LE(index, 512U)
+ << "Expecting OMX_ErrorNoMore but not received";
+ break;
+ }
+ }
+ if (!index) return status;
+ for (index = 0; index < eEncoding.size(); index++) {
+ if (eEncoding[index] == encoding) {
+ portFormat.eEncoding = eEncoding[index];
+ break;
+ }
+ }
+ if (index == eEncoding.size()) {
+ ALOGI("setting default Port format");
+ portFormat.eEncoding = eEncoding[0];
+ }
+ // In setParam call nIndex shall be ignored as per omx-il specification.
+ // see how this holds up by corrupting nIndex
+ portFormat.nIndex = RANDOM_INDEX;
+ status = setPortParam(omxNode, OMX_IndexParamAudioPortFormat, portIndex,
+ &portFormat);
+ return status;
+}
+
+Return<android::hardware::media::omx::V1_0::Status> setRole(
+ sp<IOmxNode> omxNode, const char* role) {
+ OMX_PARAM_COMPONENTROLETYPE params;
+ strcpy((char*)params.cRole, role);
+ return setParam(omxNode, OMX_IndexParamStandardComponentRole, ¶ms);
+}
+
+// Set Component Role
+TEST_F(ComponentHidlTest, SetRole) {
+ android::hardware::media::omx::V1_0::Status status;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+// Get Number of Ports and their Indices for all Domains
+// (Audio/Video/Image/Other)
+TEST_F(ComponentHidlTest, GetPortIndices) {
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_PORT_PARAM_TYPE params;
+
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ // All standard OMX components shall support following OMX Index types
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = getParam(omxNode, OMX_IndexParamImageInit, ¶ms);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = getParam(omxNode, OMX_IndexParamOtherInit, ¶ms);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+}
+
+// Enumerate Port Format
+TEST_F(ComponentHidlTest, EnumeratePortFormat) {
+ 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;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ 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;
+ }
+
+ OMX_COLOR_FORMATTYPE colorFormat = OMX_COLOR_FormatYUV420Planar;
+ OMX_U32 frameRate = 24 << 16;
+
+ if (compClass == audio_encoder) {
+ status =
+ setAudioPortFormat(omxNode, kPortIndexInput, OMX_AUDIO_CodingPCM);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = setAudioPortFormat(omxNode, kPortIndexOutput,
+ OMX_AUDIO_CodingAutoDetect);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ } else if (compClass == audio_decoder) {
+ status = setAudioPortFormat(omxNode, kPortIndexInput,
+ OMX_AUDIO_CodingAutoDetect);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status =
+ setAudioPortFormat(omxNode, kPortIndexOutput, OMX_AUDIO_CodingPCM);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ } else if (compClass == video_encoder) {
+ status =
+ setVideoPortFormat(omxNode, kPortIndexInput, OMX_VIDEO_CodingUnused,
+ colorFormat, frameRate);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = setVideoPortFormat(omxNode, kPortIndexOutput,
+ OMX_VIDEO_CodingAutoDetect,
+ OMX_COLOR_FormatUnused, 0U);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ } else {
+ status = setVideoPortFormat(omxNode, kPortIndexInput,
+ OMX_VIDEO_CodingAutoDetect,
+ OMX_COLOR_FormatUnused, 0U);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status =
+ setVideoPortFormat(omxNode, kPortIndexOutput,
+ OMX_VIDEO_CodingUnused, colorFormat, frameRate);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ }
+}
+
+// r/w default i/o port parameters
+TEST_F(ComponentHidlTest, SetDefaultPortParams) {
+ 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;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ 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;
+ }
+
+ OMX_PARAM_PORTDEFINITIONTYPE iPortDef;
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &iPortDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+
+ if (status == android::hardware::media::omx::V1_0::Status::OK) {
+ EXPECT_EQ(iPortDef.eDir, OMX_DirInput);
+ EXPECT_EQ(iPortDef.bEnabled, OMX_TRUE);
+ EXPECT_EQ(iPortDef.bPopulated, 0);
+ EXPECT_GE(iPortDef.nBufferCountMin, 1U);
+ EXPECT_GE(iPortDef.nBufferCountActual, iPortDef.nBufferCountMin);
+ if (compClass == audio_encoder || compClass == audio_decoder) {
+ EXPECT_EQ(iPortDef.eDomain, OMX_PortDomainAudio);
+ if (compClass == audio_decoder) {
+ iPortDef.format.audio.bFlagErrorConcealment = OMX_TRUE;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &iPortDef);
+ }
+ EXPECT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ } else if (compClass == video_encoder || compClass == video_decoder) {
+ EXPECT_EQ(iPortDef.eDomain, OMX_PortDomainVideo);
+ }
+ OMX_PARAM_PORTDEFINITIONTYPE dummy = iPortDef;
+ iPortDef.nBufferCountActual = iPortDef.nBufferCountMin - 1;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &iPortDef);
+ EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ // Edit Read-Only fields.
+ iPortDef.eDir = OMX_DirOutput; // Read Only field
+ iPortDef.nBufferCountActual = dummy.nBufferCountActual << 1;
+ iPortDef.nBufferCountMin = dummy.nBufferCountMin
+ << 1; // Read Only field
+ iPortDef.nBufferSize = dummy.nBufferSize << 1; // Read Only field
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &iPortDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexInput, &iPortDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ EXPECT_EQ(iPortDef.nBufferCountActual, dummy.nBufferCountActual << 1);
+ if ((iPortDef.eDir != OMX_DirInput) ||
+ (iPortDef.nBufferCountMin != dummy.nBufferCountMin) ||
+ (iPortDef.nBufferSize != dummy.nBufferSize)) {
+ ALOGI(
+ "Warning, Component does not seem to preserve Read-Only "
+ "fields");
+ printf(
+ "Warning, Component does not seem to preserve Read-Only fields "
+ "\n");
+ }
+ }
+
+ OMX_PARAM_PORTDEFINITIONTYPE oPortDef;
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexOutput, &oPortDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ EXPECT_EQ(oPortDef.eDir, OMX_DirOutput);
+ EXPECT_EQ(oPortDef.bEnabled, OMX_TRUE);
+ EXPECT_EQ(oPortDef.bPopulated, 0);
+ EXPECT_GE(oPortDef.nBufferCountMin, 1U);
+ EXPECT_GE(oPortDef.nBufferCountActual, oPortDef.nBufferCountMin);
+ if (compClass == audio_encoder || compClass == audio_decoder) {
+ EXPECT_EQ(oPortDef.eDomain, OMX_PortDomainAudio);
+ if (compClass == audio_encoder) {
+ oPortDef.format.audio.bFlagErrorConcealment = OMX_TRUE;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexOutput, &oPortDef);
+ }
+ EXPECT_EQ(status,
+ ::android::hardware::media::omx::V1_0::Status::OK);
+ } else if (compClass == video_encoder || compClass == video_decoder) {
+ EXPECT_EQ(oPortDef.eDomain, OMX_PortDomainVideo);
+ }
+ OMX_PARAM_PORTDEFINITIONTYPE dummy = oPortDef;
+ oPortDef.nBufferCountActual = oPortDef.nBufferCountMin - 1;
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexOutput, &oPortDef);
+ EXPECT_NE(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ // Edit Read-Only fields.
+ oPortDef.eDir = OMX_DirInput; // Read Only field
+ oPortDef.nBufferCountActual = dummy.nBufferCountActual << 1;
+ oPortDef.nBufferCountMin = dummy.nBufferCountMin
+ << 1; // Read Only field
+ oPortDef.nBufferSize = dummy.nBufferSize << 1; // Read Only field
+ status = setPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexOutput, &oPortDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ status = getPortParam(omxNode, OMX_IndexParamPortDefinition,
+ kPortIndexOutput, &oPortDef);
+ EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ EXPECT_EQ(oPortDef.nBufferCountActual, dummy.nBufferCountActual << 1);
+ if ((oPortDef.eDir != OMX_DirOutput) ||
+ (oPortDef.nBufferCountMin != dummy.nBufferCountMin) ||
+ (oPortDef.nBufferSize != dummy.nBufferSize)) {
+ ALOGI(
+ "Warning, Component does not seem to preserve Read-Only "
+ "fields");
+ printf(
+ "Warning, Component does not seem to preserve Read-Only fields "
+ "\n");
+ }
+ }
+}
+
+// Test State Transitions & Flush
+TEST_F(ComponentHidlTest, StateTransitions_Flush) {
+ android::hardware::media::omx::V1_0::Status status;
+ uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+ Message msg;
+
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ 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;
+ }
+
+ android::Vector<BufferInfo> iBuffer, oBuffer;
+
+ // 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 got their buffers
+ 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, allocator, &iBuffer, kPortIndexInput);
+
+ // Dont switch states until the ports got their buffers
+ 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, allocator, &oBuffer, kPortIndexOutput);
+
+ 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);
+
+ // set state to executing
+ 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, &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_StateExecuting);
+
+ 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;
+ for (size_t i = 0; i < oBuffer.size(); ++i) {
+ native_handle_t* fenceNh = native_handle_create(0, 0);
+ status = omxNode->fillBuffer(oBuffer[i].id, t, fenceNh);
+ native_handle_close(fenceNh);
+ native_handle_delete(fenceNh);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ oBuffer.editItemAt(i).owner = component;
+ }
+
+ // 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);
+ }
+
+ // set state to executing
+ 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, &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_StateExecuting);
+
+ for (size_t i = 0; i < oBuffer.size(); i += 2) {
+ native_handle_t* fenceNh = native_handle_create(0, 0);
+ status = omxNode->fillBuffer(oBuffer[i].id, t, fenceNh);
+ native_handle_close(fenceNh);
+ native_handle_delete(fenceNh);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ oBuffer.editItemAt(i).owner = component;
+ }
+
+ 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);
+ }
+
+ // 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);
+
+ // 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);
+}
+
+// Test State Transitions
+TEST_F(ComponentHidlTest, StateTransitions_M) {
+ android::hardware::media::omx::V1_0::Status status;
+ uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+ Message msg;
+
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ 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;
+ }
+
+ android::Vector<BufferInfo> iBuffer, oBuffer;
+
+ // set state to loaded ; receive error OMX_ErrorSameState
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateLoaded);
+ EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // set state to executing ; receive error OMX_ErrorIncorrectStateTransition
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateExecuting);
+ EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // set state to idle
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateIdle);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // allocate buffers on i/o port
+ allocatePortBuffers(omxNode, allocator, &iBuffer, kPortIndexInput);
+ allocatePortBuffers(omxNode, allocator, &oBuffer, kPortIndexOutput);
+
+ 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);
+
+ // set state to idle ; receive error OMX_ErrorSameState
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateIdle);
+ EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // set state to executing
+ 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, &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_StateExecuting);
+
+ // set state to executing ; receive error OMX_ErrorSameState
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateExecuting);
+ EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // set state to Loaded ; receive error OMX_ErrorIncorrectStateTransition
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateLoaded);
+ EXPECT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // 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);
+
+ // set state to Loaded
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateLoaded);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ 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);
+ }
+ 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);
+}
+
+// Enable and Disable Input and Output ports when the component is in Loaded
+// State
+TEST_F(ComponentHidlTest, PortEnableDisable_Loaded) {
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_U32 portBase = 0;
+ Message msg;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ }
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ portBase = params.nStartPortNumber;
+ }
+
+ for (size_t i = portBase; i < portBase + 2; i++) {
+ status =
+ omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i);
+ 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);
+ if (msg.data.eventData.event == OMX_EventCmdComplete) {
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortDisable);
+ ASSERT_EQ(msg.data.eventData.data2, i);
+ // If you can disable a port, then you should be able to enable it
+ // as well
+ status = omxNode->sendCommand(
+ toRawCommandType(OMX_CommandPortEnable), i);
+ 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.data1, OMX_CommandPortEnable);
+ ASSERT_EQ(msg.data.eventData.data2, i);
+ } else if (msg.data.eventData.event == OMX_EventError) {
+ ALOGI("Port %d Disabling failed with error %d", (int)i,
+ (int)msg.data.eventData.event);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ }
+}
+
+// Enable and Disable Input and Output ports when the component is in Idle State
+TEST_F(ComponentHidlTest, PortEnableDisable_Idle) {
+ android::hardware::media::omx::V1_0::Status status;
+ uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+ OMX_U32 portBase = 0;
+ Message msg;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ }
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ portBase = params.nStartPortNumber;
+ }
+ kPortIndexInput = portBase;
+ kPortIndexOutput = portBase + 1;
+
+ // Component State :: Idle
+ android::Vector<BufferInfo> pBuffer[2];
+ // set state to idle
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateIdle);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // allocate buffers on input port
+ allocatePortBuffers(omxNode, allocator, &pBuffer[0], kPortIndexInput);
+ allocatePortBuffers(omxNode, allocator, &pBuffer[1], kPortIndexOutput);
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &pBuffer[0],
+ &pBuffer[1]);
+ 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);
+
+ for (size_t i = portBase; i < portBase + 2; i++) {
+ status =
+ omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &pBuffer[0],
+ &pBuffer[1]);
+ if (status == android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ if (msg.data.eventData.event == OMX_EventCmdComplete) {
+ // do not disable the port until all the buffers are freed
+ ASSERT_TRUE(false);
+ } else if (msg.data.eventData.event == OMX_EventError) {
+ ALOGI("Port %d Disabling failed with error %d", (int)i,
+ (int)msg.data.eventData.event);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ } else if (status ==
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT) {
+ for (size_t j = 0; j < pBuffer[i - portBase].size(); ++j) {
+ status = omxNode->freeBuffer(i, pBuffer[i - portBase][j].id);
+ ASSERT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::OK);
+ }
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ &pBuffer[0], &pBuffer[1]);
+ 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_CommandPortDisable);
+ ASSERT_EQ(msg.data.eventData.data2, i);
+
+ // If you can disable a port, then you should be able to enable it
+ // as well
+ status = omxNode->sendCommand(
+ toRawCommandType(OMX_CommandPortEnable), i);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // do not enable the port until all the buffers are supplied
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ &pBuffer[0], &pBuffer[1]);
+ ASSERT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ allocatePortBuffers(omxNode, allocator, &pBuffer[i - portBase], i);
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ &pBuffer[0], &pBuffer[1]);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortEnable);
+ ASSERT_EQ(msg.data.eventData.data2, i);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ }
+}
+
+// Enable and Disable Input and Output ports when the component is in execute
+TEST_F(ComponentHidlTest, PortEnableDisable_Execute) {
+ android::hardware::media::omx::V1_0::Status status;
+ uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
+ OMX_U32 portBase = 0;
+ Message msg;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ }
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ portBase = params.nStartPortNumber;
+ }
+ kPortIndexInput = portBase;
+ kPortIndexOutput = portBase + 1;
+
+ // Component State :: Idle
+ android::Vector<BufferInfo> pBuffer[2];
+ // set state to idle
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
+ OMX_StateIdle);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // allocate buffers on input port
+ allocatePortBuffers(omxNode, allocator, &pBuffer[0], kPortIndexInput);
+ allocatePortBuffers(omxNode, allocator, &pBuffer[1], kPortIndexOutput);
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &pBuffer[0],
+ &pBuffer[1]);
+ 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);
+
+ // Component State :: 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, &pBuffer[0],
+ &pBuffer[1]);
+ 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);
+
+ 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;
+ for (size_t i = 0; i < pBuffer[1].size(); ++i) {
+ native_handle_t* fenceNh = native_handle_create(0, 0);
+ status = omxNode->fillBuffer(pBuffer[1][i].id, t, fenceNh);
+ native_handle_close(fenceNh);
+ native_handle_delete(fenceNh);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ pBuffer[1].editItemAt(i).owner = component;
+ }
+
+ for (size_t i = portBase; i < portBase + 2; i++) {
+ status =
+ omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, &pBuffer[0],
+ &pBuffer[1]);
+ if (status == android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ if (msg.data.eventData.event == OMX_EventCmdComplete) {
+ // do not disable the port until all the buffers are freed
+ ASSERT_TRUE(false);
+ } else if (msg.data.eventData.event == OMX_EventError) {
+ ALOGI("Port %d Disabling failed with error %d", (int)i,
+ (int)msg.data.eventData.event);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ } else if (status ==
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT) {
+ for (size_t j = 0; j < pBuffer[i - portBase].size(); ++j) {
+ // test if client got all its buffers back
+ EXPECT_EQ(pBuffer[i - portBase][j].owner, client);
+ // free the buffers
+ status = omxNode->freeBuffer(i, pBuffer[i - portBase][j].id);
+ ASSERT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::OK);
+ }
+
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ &pBuffer[0], &pBuffer[1]);
+ 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_CommandPortDisable);
+ ASSERT_EQ(msg.data.eventData.data2, i);
+
+ // If you can disable a port, then you should be able to enable it
+ // as well
+ status = omxNode->sendCommand(
+ toRawCommandType(OMX_CommandPortEnable), i);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // do not enable the port until all the buffers are supplied
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ &pBuffer[0], &pBuffer[1]);
+ ASSERT_EQ(status,
+ android::hardware::media::omx::V1_0::Status::TIMED_OUT);
+
+ allocatePortBuffers(omxNode, allocator, &pBuffer[i - portBase], i);
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
+ &pBuffer[0], &pBuffer[1]);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortEnable);
+ ASSERT_EQ(msg.data.eventData.data2, i);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ }
+}
+
+// Enable and Disable Input and Output ports, (in loaded state)
+TEST_F(ComponentHidlTest, PortEnableDisable_M) {
+ android::hardware::media::omx::V1_0::Status status;
+ OMX_U32 portBase = 0;
+ Message msg;
+ status = setRole(omxNode, gEnv->getRole().c_str());
+ ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
+ OMX_PORT_PARAM_TYPE params;
+ if (compClass == audio_decoder || compClass == audio_encoder) {
+ status = getParam(omxNode, OMX_IndexParamAudioInit, ¶ms);
+ } else {
+ status = getParam(omxNode, OMX_IndexParamVideoInit, ¶ms);
+ }
+ if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
+ ASSERT_EQ(params.nPorts, 2U);
+ portBase = params.nStartPortNumber;
+ }
+
+ // disable invalid port, expecting OMX_ErrorBadPortIndex
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable),
+ RANDOM_INDEX);
+ ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // enable invalid port, expecting OMX_ErrorBadPortIndex
+ status = omxNode->sendCommand(toRawCommandType(OMX_CommandPortEnable),
+ RANDOM_INDEX);
+ ASSERT_NE(status, android::hardware::media::omx::V1_0::Status::OK);
+
+ // disable all ports
+ status =
+ omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), OMX_ALL);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ for (size_t i = 0; i < 2; i++) {
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ if (msg.data.eventData.event == OMX_EventCmdComplete) {
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortDisable);
+ if (msg.data.eventData.data2 != portBase ||
+ msg.data.eventData.data2 != portBase + 1)
+ EXPECT_TRUE(false);
+ } else if (msg.data.eventData.event == OMX_EventError) {
+ ALOGI("Port %d Disabling failed with error %d", (int)i,
+ (int)msg.data.eventData.event);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ }
+
+ // enable all ports
+ status =
+ omxNode->sendCommand(toRawCommandType(OMX_CommandPortEnable), OMX_ALL);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ for (size_t i = 0; i < 2; i++) {
+ status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT);
+ ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+ ASSERT_EQ(msg.type, Message::Type::EVENT);
+ if (msg.data.eventData.event == OMX_EventCmdComplete) {
+ ASSERT_EQ(msg.data.eventData.data1, OMX_CommandPortEnable);
+ if (msg.data.eventData.data2 != portBase ||
+ msg.data.eventData.data2 != portBase + 1)
+ EXPECT_TRUE(false);
+ } else if (msg.data.eventData.event == OMX_EventError) {
+ ALOGI("Port %d Enabling failed with error %d", (int)i,
+ (int)msg.data.eventData.event);
+ } else {
+ // something unexpected happened
+ ASSERT_TRUE(false);
+ }
+ }
+}
+
+int main(int argc, char** argv) {
+ gEnv = new ComponentTestEnvironment();
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = gEnv->initFromOptions(argc, argv);
+ if (status == 0) {
+ status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ }
+ return status;
+}
diff --git a/media/omx/1.0/vts/functional/master/Android.bp b/media/omx/1.0/vts/functional/master/Android.bp
new file mode 100644
index 0000000..6edbf4a
--- /dev/null
+++ b/media/omx/1.0/vts/functional/master/Android.bp
@@ -0,0 +1,38 @@
+//
+// 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: "VtsHalMediaOmxV1_0TargetMasterTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalMediaOmxV1_0TargetMasterTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.media.omx@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
+
diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp
new file mode 100644
index 0000000..65b999e
--- /dev/null
+++ b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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_master_test"
+#include <android-base/logging.h>
+
+#include <android/hardware/media/omx/1.0/IOmx.h>
+#include <android/hardware/media/omx/1.0/types.h>
+#include <getopt.h>
+#include <log/log.h>
+#include <VtsHalHidlTargetTestBase.h>
+
+using ::android::hardware::media::omx::V1_0::IOmx;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+// A class for test environment setup
+class ComponentTestEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ ComponentTestEnvironment() : instance("default") {}
+
+ void setInstance(const char* _instance) { instance = _instance; }
+
+ const hidl_string getInstance() const { return instance; }
+
+ int initFromOptions(int argc, char** argv) {
+ static struct option options[] = {
+ {"instance", required_argument, 0, 'I'}, {0, 0, 0, 0}};
+
+ while (true) {
+ int index = 0;
+ int c = getopt_long(argc, argv, "I:", options, &index);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'I':
+ setInstance(optarg);
+ break;
+ case '?':
+ break;
+ }
+ }
+
+ if (optind < argc) {
+ fprintf(stderr,
+ "unrecognized option: %s\n\n"
+ "usage: %s <gtest options> <test options>\n\n"
+ "test options are:\n\n"
+ "-I, --instance: HAL instance to test\n",
+ argv[optind ?: 1], argv[0]);
+ return 2;
+ }
+ return 0;
+ }
+
+ private:
+ hidl_string instance;
+};
+
+static ComponentTestEnvironment* gEnv = nullptr;
+
+class MasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ omx = ::testing::VtsHalHidlTargetTestBase::getService<IOmx>(
+ gEnv->getInstance());
+ ASSERT_NE(omx, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ sp<IOmx> omx;
+};
+
+// enumerate list of components and roles
+TEST_F(MasterHidlTest, ListNodes) {
+ android::hardware::media::omx::V1_0::Status status;
+ hidl_vec<IOmx::ComponentInfo> nodeList;
+ EXPECT_TRUE(
+ omx->listNodes([&status, &nodeList](
+ android::hardware::media::omx::V1_0::Status _s,
+ hidl_vec<IOmx::ComponentInfo> const& _nl) {
+ status = _s;
+ nodeList = _nl;
+ })
+ .isOk());
+}
+
+int main(int argc, char** argv) {
+ gEnv = new ComponentTestEnvironment();
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = gEnv->initFromOptions(argc, argv);
+ if (status == 0) {
+ status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ }
+ return status;
+}
diff --git a/memtrack/1.0/Android.bp b/memtrack/1.0/Android.bp
index 4f13463..4a4e179 100644
--- a/memtrack/1.0/Android.bp
+++ b/memtrack/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.memtrack@1.0_genc++"],
generated_headers: ["android.hardware.memtrack@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.memtrack@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/memtrack/1.0/Android.mk b/memtrack/1.0/Android.mk
index 62bee97..8583b0a 100644
--- a/memtrack/1.0/Android.mk
+++ b/memtrack/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.memtrack@1.0-java
+LOCAL_MODULE := android.hardware.memtrack-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -118,7 +118,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.memtrack@1.0-java-static
+LOCAL_MODULE := android.hardware.memtrack-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -126,7 +126,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/nfc/1.0/Android.bp b/nfc/1.0/Android.bp
index 7ee3a9e..f583a42 100644
--- a/nfc/1.0/Android.bp
+++ b/nfc/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.nfc@1.0_genc++"],
generated_headers: ["android.hardware.nfc@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.nfc@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/nfc/1.0/Android.mk b/nfc/1.0/Android.mk
index 6f09764..3ea7707 100644
--- a/nfc/1.0/Android.mk
+++ b/nfc/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.nfc@1.0-java
+LOCAL_MODULE := android.hardware.nfc-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -103,7 +103,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.nfc@1.0-java-static
+LOCAL_MODULE := android.hardware.nfc-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -111,7 +111,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -201,7 +201,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.nfc@1.0-java-constants
+LOCAL_MODULE := android.hardware.nfc-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/nfc/1.0/default/Android.mk b/nfc/1.0/default/Android.mk
index 2e1f17f..4afad74 100644
--- a/nfc/1.0/default/Android.mk
+++ b/nfc/1.0/default/Android.mk
@@ -14,7 +14,6 @@
libdl \
libbase \
libutils \
- libhardware_legacy \
libhardware \
LOCAL_SHARED_LIBRARIES += \
diff --git a/power/1.0/Android.bp b/power/1.0/Android.bp
index f9d18c8..5958b12 100644
--- a/power/1.0/Android.bp
+++ b/power/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.power@1.0_genc++"],
generated_headers: ["android.hardware.power@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.power@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/power/1.0/Android.mk b/power/1.0/Android.mk
index 98d95a8..8a89a45 100644
--- a/power/1.0/Android.mk
+++ b/power/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.power@1.0-java
+LOCAL_MODULE := android.hardware.power-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -137,7 +137,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.power@1.0-java-static
+LOCAL_MODULE := android.hardware.power-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -145,7 +145,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/power/1.0/default/Power.cpp b/power/1.0/default/Power.cpp
index 6ea9167..51f87f5 100644
--- a/power/1.0/default/Power.cpp
+++ b/power/1.0/default/Power.cpp
@@ -145,25 +145,27 @@
}
IPower* HIDL_FETCH_IPower(const char* /* name */) {
- int ret = 0;
- const hw_module_t* hw_module = NULL;
- power_module_t *power_module;
- ret = hw_get_module(POWER_HARDWARE_MODULE_ID, &hw_module);
- if (ret == 0 && hw_module->methods->open) {
- ret = hw_module->methods->open(hw_module, POWER_HARDWARE_MODULE_ID,
- reinterpret_cast<hw_device_t**>(&power_module));
- if (ret == 0) {
- return new Power(power_module);
- }
- else {
- ALOGE("Passthrough failed to load legacy power HAL.");
+ const hw_module_t* hw_module = nullptr;
+ power_module_t* power_module = nullptr;
+ int err = hw_get_module(POWER_HARDWARE_MODULE_ID, &hw_module);
+ if (err) {
+ ALOGE("hw_get_module %s failed: %d", POWER_HARDWARE_MODULE_ID, err);
+ return nullptr;
+ }
+
+ 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.");
return nullptr;
}
}
- else {
- ALOGE ("hw_get_module %s failed: %d", POWER_HARDWARE_MODULE_ID, ret);
- return nullptr;
- }
+ return new Power(power_module);
}
} // namespace implementation
diff --git a/radio/1.0/Android.bp b/radio/1.0/Android.bp
index e457795..768de49 100644
--- a/radio/1.0/Android.bp
+++ b/radio/1.0/Android.bp
@@ -72,6 +72,7 @@
generated_sources: ["android.hardware.radio@1.0_genc++"],
generated_headers: ["android.hardware.radio@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.radio@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/radio/1.0/Android.mk b/radio/1.0/Android.mk
index 94072fb..a71e672 100644
--- a/radio/1.0/Android.mk
+++ b/radio/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.radio@1.0-java
+LOCAL_MODULE := android.hardware.radio-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -1841,6 +1841,25 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (P2Constant)
+#
+GEN := $(intermediates)/android/hardware/radio/V1_0/P2Constant.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.radio@1.0::types.P2Constant
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (PcoDataInfo)
#
GEN := $(intermediates)/android/hardware/radio/V1_0/PcoDataInfo.java
@@ -3039,7 +3058,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.radio@1.0-java-static
+LOCAL_MODULE := android.hardware.radio-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -3047,7 +3066,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -4875,6 +4894,25 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (P2Constant)
+#
+GEN := $(intermediates)/android/hardware/radio/V1_0/P2Constant.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.radio@1.0::types.P2Constant
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (PcoDataInfo)
#
GEN := $(intermediates)/android/hardware/radio/V1_0/PcoDataInfo.java
diff --git a/radio/1.0/IRadio.hal b/radio/1.0/IRadio.hal
index 2976290..236dbf5 100644
--- a/radio/1.0/IRadio.hal
+++ b/radio/1.0/IRadio.hal
@@ -1285,10 +1285,11 @@
*
* @param serial Serial number of request.
* @param aid AID value, See ETSI 102.221 and 101.220.
+ * @param p2 P2 value, described in ISO 7816-4. Ignore if equal to P2Constant:NO_P2
*
* Response callback is IRadioResponse.iccOpenLogicalChannelResponse()
*/
- oneway iccOpenLogicalChannel(int32_t serial, string aid);
+ oneway iccOpenLogicalChannel(int32_t serial, string aid, int32_t p2);
/**
* Close a previously opened logical channel. This command reflects TS 27.007
diff --git a/radio/1.0/types.hal b/radio/1.0/types.hal
index 2224c8b..c5d7f8a 100644
--- a/radio/1.0/types.hal
+++ b/radio/1.0/types.hal
@@ -1161,6 +1161,10 @@
// this doesn't mean no data is expected.
};
+enum P2Constant : int32_t {
+ NO_P2 = -1, // No P2 value is provided
+};
+
struct RadioResponseInfo {
RadioResponseType type; // Response type
int32_t serial; // Serial number of the request
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
index 19738d5..b759c48 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
@@ -246,12 +246,15 @@
*/
TEST_F(RadioHidlTest, iccOpenLogicalChannel) {
int serial = 1;
-
+ int p2 = 0x04;
+ // Specified in ISO 7816-4 clause 7.1.1 0x04 means that FCP template is
+ // requested.
for (int i = 0; i < (int)cardStatus.applications.size(); i++) {
- radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr);
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(serial, radioRsp->rspInfo.serial);
- EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr,
+ p2);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
}
}
@@ -317,4 +320,4 @@
if (cardStatus.cardState == CardState::ABSENT) {
ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::PASSWORD_INCORRECT);
}
-}
\ No newline at end of file
+}
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
index 9094f39..d40f15a 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -18,7 +18,7 @@
void RadioHidlTest::SetUp() {
radio = ::testing::VtsHalHidlTargetTestBase::getService<IRadio>(
- hidl_string("rild"));
+ hidl_string(RADIO_SERVICE_NAME));
ASSERT_NE(radio, nullptr);
radioRsp = new RadioResponse(*this);
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
index 6826238..51db87b 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
@@ -81,6 +81,7 @@
using ::android::sp;
#define TIMEOUT_PERIOD 40
+#define RADIO_SERVICE_NAME "slot1"
class RadioHidlTest;
extern CardStatus cardStatus;
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_test.cpp b/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
index 88274cd..02accef 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
@@ -18,7 +18,7 @@
void SapHidlTest::SetUp() {
sap = ::testing::VtsHalHidlTargetTestBase::getService<ISap>(
- hidl_string("sap_uim_socket1"));
+ hidl_string(SAP_SERVICE_NAME));
ASSERT_NE(sap, nullptr);
sapCb = new SapCallback(*this);
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_utils.h b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
index 2ee3c96..38fb003 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
@@ -34,6 +34,7 @@
using ::android::sp;
#define TIMEOUT_PERIOD 40
+#define SAP_SERVICE_NAME "slot1"
class SapHidlTest;
diff --git a/radio/deprecated/1.0/Android.bp b/radio/deprecated/1.0/Android.bp
index f8a9c64..e81186c 100644
--- a/radio/deprecated/1.0/Android.bp
+++ b/radio/deprecated/1.0/Android.bp
@@ -54,6 +54,7 @@
generated_sources: ["android.hardware.radio.deprecated@1.0_genc++"],
generated_headers: ["android.hardware.radio.deprecated@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.radio.deprecated@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/radio/deprecated/1.0/Android.mk b/radio/deprecated/1.0/Android.mk
index 4cce633..11377d8 100644
--- a/radio/deprecated/1.0/Android.mk
+++ b/radio/deprecated/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.radio.deprecated@1.0-java
+LOCAL_MODULE := android.hardware.radio.deprecated-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,8 +13,8 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hardware.radio@1.0-java \
- android.hidl.base@1.0-java \
+ android.hardware.radio-V1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -83,7 +83,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.radio.deprecated@1.0-java-static
+LOCAL_MODULE := android.hardware.radio.deprecated-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -91,8 +91,8 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hardware.radio@1.0-java-static \
- android.hidl.base@1.0-java-static \
+ android.hardware.radio-V1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/renderscript/1.0/Android.bp b/renderscript/1.0/Android.bp
index 9f2a589..b82dc4a 100644
--- a/renderscript/1.0/Android.bp
+++ b/renderscript/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.renderscript@1.0_genc++"],
generated_headers: ["android.hardware.renderscript@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.renderscript@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/renderscript/1.0/Android.mk b/renderscript/1.0/Android.mk
index 5c3a37d..cdd580a 100644
--- a/renderscript/1.0/Android.mk
+++ b/renderscript/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.renderscript@1.0-java-constants
+LOCAL_MODULE := android.hardware.renderscript-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/renderscript/1.0/vts/functional/VtsCopyTests.cpp b/renderscript/1.0/vts/functional/VtsCopyTests.cpp
index 168e681..f47253f 100644
--- a/renderscript/1.0/vts/functional/VtsCopyTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsCopyTests.cpp
@@ -30,12 +30,18 @@
TEST_F(RenderscriptHidlTest, Simple1DCopyTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x float1
Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 128 x float1
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
std::vector<float> dataIn(128), dataOut(128);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -60,12 +66,18 @@
TEST_F(RenderscriptHidlTest, Simple2DCopyTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x 128 x float1
Type type = context->typeCreate(element, 128, 128, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 128 x 128 x float1
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
std::vector<float> dataIn(128*128), dataOut(128*128);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -91,12 +103,18 @@
TEST_F(RenderscriptHidlTest, Simple3DCopyTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 32 x 32 x 32 x float1
Type type = context->typeCreate(element, 32, 32, 32, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 32 x 32 x 32 x float1
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
std::vector<float> dataIn(32*32*32), dataOut(32*32*32);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -122,8 +140,12 @@
TEST_F(RenderscriptHidlTest, SimpleBitmapTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 512 x 512 x float1
Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<float> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -133,7 +155,7 @@
AllocationMipmapControl::NONE,
_data,
(int)AllocationUsageType::SCRIPT);
- EXPECT_NE(Allocation(0), allocation);
+ ASSERT_NE(Allocation(0), allocation);
context->allocationCopyToBitmap(allocation, (Ptr)dataOut1.data(),
(Size)dataOut1.size()*sizeof(float));
@@ -158,10 +180,16 @@
TEST_F(RenderscriptHidlTest, AllocationCopy2DRangeTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 512 x 512 x float1
Type typeSrc = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), typeSrc);
+
// 256 x 256 x float1
Type typeDst = context->typeCreate(element, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), typeDst);
+
std::vector<float> dataIn(512*512), dataOut(256*256), expected(256*256);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -170,10 +198,14 @@
Allocation allocSrc = context->allocationCreateFromBitmap(typeSrc,
AllocationMipmapControl::NONE, _data,
(int)AllocationUsageType::SCRIPT);
+ ASSERT_NE(Allocation(0), allocSrc);
+
// 256 x 256 x float1
Allocation allocDst = context->allocationCreateTyped(typeDst, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocDst);
+
context->allocationCopy2DRange(allocDst, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
allocSrc, 128, 128, 0, AllocationCubemapFace::POSITIVE_X);
context->allocationRead(allocDst, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float));
@@ -200,10 +232,16 @@
TEST_F(RenderscriptHidlTest, AllocationCopy3DRangeTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x 128 x 128 x float1
Type typeSrc = context->typeCreate(element, 128, 128, 128, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), typeSrc);
+
// 64 x 64 x 64 x float1
Type typeDst = context->typeCreate(element, 64, 64, 64, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), typeDst);
+
std::vector<float> dataIn(128*128*128), dataOut(64*64*64), expected(64*64*64);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -212,10 +250,14 @@
Allocation allocSrc = context->allocationCreateTyped(typeSrc, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocSrc);
+
// 256 x 256 x float1
Allocation allocDst = context->allocationCreateTyped(typeDst, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocDst);
+
context->allocation3DWrite(allocSrc, 0, 0, 0, 0, 128, 128, 128, _data, 128*sizeof(float));
context->allocationCopy3DRange(allocDst, 0, 0, 0, 0, 64, 64, 64, allocSrc, 32, 32, 32, 0);
context->allocationRead(allocDst, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float));
@@ -243,8 +285,12 @@
TEST_F(RenderscriptHidlTest, SimpleAdapterTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 512 x 512 x float1
Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<float> dataIn(512*512), dataOut(256*256), expected;
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -254,11 +300,15 @@
AllocationMipmapControl::NONE,
_data,
(int)AllocationUsageType::SCRIPT);
+ ASSERT_NE(Allocation(0), allocation);
+
// 256 x 256 x float1
Type subType = context->typeCreate(element, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), subType);
+
// 256 x 256 x float1
AllocationAdapter allocationAdapter = context->allocationAdapterCreate(subType, allocation);
- EXPECT_NE(AllocationAdapter(0), allocationAdapter);
+ ASSERT_NE(AllocationAdapter(0), allocationAdapter);
std::vector<uint32_t> offsets(9, 0);
offsets[0] = 128;
@@ -292,8 +342,12 @@
TEST_F(RenderscriptHidlTest, SimpleMipmapTest) {
// uint8_t
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 64 x 64 x uint8_t
Type type = context->typeCreate(element, 64, 64, 0, true, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<uint8_t> dataIn(64*64), dataOut(32*32), expected(32*32);
std::generate(dataIn.begin(), dataIn.end(),
[](){ static int val = 0; return (uint8_t)(0xFF & val++); });
@@ -303,6 +357,8 @@
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::FULL,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
context->allocation2DWrite(allocation, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 64, 64,
_data, 64*sizeof(uint8_t));
context->allocationGenerateMipmaps(allocation);
@@ -333,8 +389,12 @@
TEST_F(RenderscriptHidlTest, SimpleCubemapTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x 128 x float1
Type type = context->typeCreate(element, 128, 128, 0, false, true, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<float> dataIn(128*128*6), dataOut(128*128), expected(128*128);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
hidl_vec<uint8_t> _data;
@@ -342,7 +402,7 @@
// 128 x 128 x float1 x 6
Allocation allocation = context->allocationCubeCreateFromBitmap(
type, AllocationMipmapControl::NONE, _data, (int)AllocationUsageType::SCRIPT);
- EXPECT_NE(Allocation(0), allocation);
+ ASSERT_NE(Allocation(0), allocation);
context->allocation2DRead(allocation, 0, 0, 0, AllocationCubemapFace::NEGATIVE_Z, 128,
128, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float),
@@ -367,13 +427,16 @@
*/
TEST_F(RenderscriptHidlTest, ComplexElementTest) {
Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element1);
+
Element element2 = context->elementCreate(DataType::UNSIGNED_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element2);
hidl_vec<Element> eins = {element1, element2};
hidl_vec<hidl_string> names = {hidl_string("first"), hidl_string("second")};
hidl_vec<Size> arraySizesPtr = {1, 1};
Element element3 = context->elementComplexCreate(eins, names, arraySizesPtr);
- EXPECT_NE(Element(0), element3);
+ ASSERT_NE(Element(0), element3);
std::vector<Element> ids;
std::vector<std::string> namesOut;
@@ -395,10 +458,14 @@
// 1 x (uint8_t, uint32_t)
Type type = context->typeCreate(element3, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 1 x (uint8_t, uint32_t)
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
std::vector<uint32_t> dataIn(1), dataOut(1);
std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
hidl_vec<uint8_t> _data;
diff --git a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
index 39d63ca..278dbf3 100644
--- a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
@@ -46,18 +46,18 @@
TEST_F(RenderscriptHidlTest, ElementTypeAllocationCreate) {
// Element create test
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
- EXPECT_NE(Element(0), element);
+ ASSERT_NE(Element(0), element);
// Type create test
Type type = context->typeCreate(element, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
- EXPECT_NE(Type(0), type);
+ ASSERT_NE(Type(0), type);
// Allocation create test
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)((uint32_t)AllocationUsageType::ALL
& ~(uint32_t)AllocationUsageType::OEM),
(Ptr)nullptr);
- EXPECT_NE(Allocation(0), allocation);
+ ASSERT_NE(Allocation(0), allocation);
// Allocation type test
Type type2 = context->allocationGetType(allocation);
@@ -74,8 +74,11 @@
TEST_F(RenderscriptHidlTest, MetadataTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x float1
Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
std::vector<uint32_t> elementMetadata(5);
context->elementGetNativeMetadata(element, [&](const hidl_vec<uint32_t>& _metadata){
@@ -107,24 +110,30 @@
TEST_F(RenderscriptHidlTest, ResizeTest) {
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x float1
Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 128 x float1
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
Ptr dataPtr1, dataPtr2;
Size stride;
context->allocationGetPointer(allocation, 0, AllocationCubemapFace::POSITIVE_X, 0,
[&](Ptr _dataPtr, Size _stride){
dataPtr1 = _dataPtr; stride = _stride; });
- EXPECT_EQ(0ul, stride);
+ EXPECT_EQ(Size(0), stride);
context->allocationResize1D(allocation, 1024*1024);
context->allocationGetPointer(allocation, 0, AllocationCubemapFace::POSITIVE_X, 0,
[&](Ptr _dataPtr, Size _stride){
dataPtr2 = _dataPtr; stride = _stride; });
- EXPECT_EQ(0ul, stride);
+ EXPECT_EQ(Size(0), stride);
EXPECT_NE(dataPtr1, dataPtr2);
}
@@ -139,8 +148,12 @@
TEST_F(RenderscriptHidlTest, NativeWindowIoTest) {
// uint8x4
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4);
+ ASSERT_NE(Element(0), element);
+
// 512 x 512 x uint8x4
Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<uint32_t> dataIn(512*512), dataOut(512*512);
std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
hidl_vec<uint8_t> _data;
@@ -150,14 +163,20 @@
(int)(AllocationUsageType::SCRIPT
| AllocationUsageType::IO_INPUT),
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocationRecv);
+
Allocation allocationSend = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)(AllocationUsageType::SCRIPT
| AllocationUsageType::IO_OUTPUT),
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocationSend);
+
NativeWindow nativeWindow = context->allocationGetNativeWindow(allocationRecv);
- EXPECT_NE(NativeWindow(0), nativeWindow);
+ ASSERT_NE(NativeWindow(0), nativeWindow);
((ANativeWindow *)nativeWindow)->incStrong(nullptr);
+ native_window_api_connect((ANativeWindow*)nativeWindow,
+ NATIVE_WINDOW_API_CPU);
context->allocationSetNativeWindow(allocationSend, nativeWindow);
context->allocation2DWrite(allocationSend, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
@@ -174,14 +193,20 @@
* two allocations with IO_INPUT are made to share the same BufferQueue.
*
* Calls: elementCreate, typeCreate, allocationCreateTyped,
- * allocationCreateFromBitmap, allocationSetupBufferQueue,
- * allocationShareBufferQueue
+ * allocationSetupBufferQueue, allocationShareBufferQueue,
+ * allocationGetNativeWindow, allocationSetNativeWindow,
+ * allocation2DWrite, allocation2DRead, allocationIoSend,
+ * allocationIoReceive
*/
TEST_F(RenderscriptHidlTest, BufferQueueTest) {
// uint8x4
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4);
+ ASSERT_NE(Element(0), element);
+
// 512 x 512 x uint8x4
Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<uint32_t> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
hidl_vec<uint8_t> _data;
@@ -191,23 +216,33 @@
(int)(AllocationUsageType::SCRIPT
| AllocationUsageType::IO_INPUT),
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocationRecv1);
+
Allocation allocationRecv2 = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)(AllocationUsageType::SCRIPT
| AllocationUsageType::IO_INPUT),
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocationRecv2);
+
Allocation allocationSend = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)(AllocationUsageType::SCRIPT
| AllocationUsageType::IO_INPUT),
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocationSend);
+
context->allocationSetupBufferQueue(allocationRecv1, 2);
context->allocationShareBufferQueue(allocationRecv2, allocationRecv1);
NativeWindow nativeWindow1 = context->allocationGetNativeWindow(allocationRecv1);
- EXPECT_NE(NativeWindow(0), nativeWindow1);
+ ASSERT_NE(NativeWindow(0), nativeWindow1);
+
NativeWindow nativeWindow2 = context->allocationGetNativeWindow(allocationRecv2);
+ ASSERT_NE(NativeWindow(0), nativeWindow2);
EXPECT_EQ(nativeWindow2, nativeWindow1);
((ANativeWindow *)nativeWindow1)->incStrong(nullptr);
+ native_window_api_connect((ANativeWindow*)nativeWindow1,
+ NATIVE_WINDOW_API_CPU);
context->allocationSetNativeWindow(allocationSend, nativeWindow1);
context->allocation2DWrite(allocationSend, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 512, 512,
@@ -269,6 +304,8 @@
context->contextSetCacheDir("/data/local/tmp/temp/");
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
std::string nameIn = "element_test_name";
std::string nameOut = "not_name";
hidl_string _nameIn;
diff --git a/renderscript/1.0/vts/functional/VtsScriptTests.cpp b/renderscript/1.0/vts/functional/VtsScriptTests.cpp
index 6bb375a..8268dcc 100644
--- a/renderscript/1.0/vts/functional/VtsScriptTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsScriptTests.cpp
@@ -25,6 +25,8 @@
TEST_F(RenderscriptHidlTest, IntrinsicTest) {
// uint8
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ EXPECT_NE(Element(0), element);
+
Script script = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_BLUR, element);
EXPECT_NE(Script(0), script);
@@ -43,7 +45,7 @@
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
// arg tests
context->scriptSetVarI(script, mExportVarIdx_var_int, 100);
@@ -75,12 +77,18 @@
// float1
Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 128 x float1
Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 128 x float1
Allocation allocationIn = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocationIn);
+
Allocation allocationOut = Allocation(0);
context->scriptSetVarObj(script, mExportVarIdx_var_allocation, (ObjectBase)allocationIn);
context->scriptGetVarV(script, mExportVarIdx_var_allocation, sizeof(ObjectBase),
@@ -107,6 +115,8 @@
_dimsVE.setToExternal((uint32_t*)dimsVE.data(), dimsVE.size());
// intx2 to represent point2 which is {int, int}
Element elementVE = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 2);
+ ASSERT_NE(Element(0), elementVE);
+
context->scriptSetVarVE(script, mExportVarIdx_var_point2, _dataVE, elementVE, _dimsVE);
context->scriptGetVarV(script, mExportVarIdx_var_point2, 2*sizeof(int),
[&](const hidl_vec<uint8_t>& _data){
@@ -126,7 +136,7 @@
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
// invoke test
int resultI = 0;
@@ -185,12 +195,16 @@
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
// uint8_t
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 64 x uint8_t
Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
std::vector<uint8_t> dataIn(64), dataOut(64), expected(64);
std::generate(dataIn.begin(), dataIn.end(), [](){ static uint8_t val = 0; return val++; });
std::generate(expected.begin(), expected.end(), [](){ static uint8_t val = 1; return val++; });
@@ -200,9 +214,13 @@
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
Allocation vout = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), vout);
+
context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
hidl_vec<Allocation> vains;
vains.setToExternal(&allocation, 1);
@@ -223,13 +241,19 @@
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
// uint8_t
Element element = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 64 x uint8_t
Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
Type type2 = context->typeCreate(element, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type2);
+
std::vector<int> dataIn(64), dataOut(1);
std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return val++; });
hidl_vec<uint8_t> _data;
@@ -238,9 +262,13 @@
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
Allocation vaout = context->allocationCreateTyped(type2, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), vaout);
+
context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
hidl_vec<Allocation> vains;
vains.setToExternal(&allocation, 1);
@@ -257,22 +285,29 @@
* RenderScript script, represented in the bitcode.
*
* Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
- * scriptSetVarV, scriptBindAllocation, allocationRead
+ * allocation1DWrite, scriptBindAllocation, scriptSetVarV, scriptBindAllocation,
+ * allocationRead, scriptInvokeV, allocationRead
*/
TEST_F(RenderscriptHidlTest, ScriptBindTest) {
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
// in32
Element element = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
// 64 x int32
Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
// 64 x int32
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
std::vector<int> dataIn(64), dataOut(64), expected(64, 5);
hidl_vec<uint8_t> _data;
_data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(int));
@@ -288,64 +323,82 @@
/*
* This test groups together two RenderScript intrinsic kernels to run one after
- * the other asynchronously with respect to the client. The test configures YuvToRGB(A) and Blur,
- * and links them together such that Blur will execute after YuvToRGB(A) and use its result. The
- * test checks the data returned to make sure it was changed after passing through the entire
- * ScriptGroup.
+ * the other asynchronously with respect to the client. The test configures
+ * Blend and Blur, and links them together such that Blur will execute after
+ * Blend and use its result. The test checks the data returned to make sure it
+ * was changed after passing through the entire ScriptGroup.
*
* Calls: elementCreate, typeCreate, allocationCreateTyped, allocation2DWrite,
* scriptIntrinsicCreate, scriptKernelIDCreate, scriptFieldIDCreate,
- * scriptGroupCreate, scriptGroupSetOutput, scriptGroupExecute, allocation2DRead
+ * scriptGroupCreate, scriptGroupSetInput, scriptGroupSetOutput,
+ * scriptGroupExecute, contextFinish, allocation2DRead
*/
TEST_F(RenderscriptHidlTest, ScriptGroupTest) {
- std::vector<uint8_t> dataIn(256*256*1, 128), dataOut(256*256*4, 0), zeros(256*256*4, 0);
+ std::vector<uint8_t> dataIn(256 * 256 * 4, 128), dataOut(256 * 256 * 4, 0),
+ zeros(256 * 256 * 4, 0);
hidl_vec<uint8_t> _dataIn, _dataOut;
_dataIn.setToExternal(dataIn.data(), dataIn.size());
_dataOut.setToExternal(dataOut.data(), dataOut.size());
// 256 x 256 YUV pixels
- Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_YUV, true, 1);
- Type type1 = context->typeCreate(element1, 256, 256, 0, false, false, YuvFormat::YUV_420_888);
+ Element element1 = context->elementCreate(DataType::UNSIGNED_8,
+ DataKind::PIXEL_RGBA, true, 4);
+ ASSERT_NE(Element(0), element1);
+
+ Type type1 = context->typeCreate(element1, 256, 256, 0, false, false,
+ YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type1);
+
Allocation allocation1 = context->allocationCreateTyped(type1, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation1);
+
context->allocation2DWrite(allocation1, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
_dataIn, 0);
// 256 x 256 RGBA pixels
Element element2 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_RGBA, true, 4);
+ ASSERT_NE(Element(0), element2);
+
Type type2 = context->typeCreate(element2, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type2);
+
Allocation allocation2 = context->allocationCreateTyped(type2, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation2);
+
context->allocation2DWrite(allocation2, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
_dataOut, 0);
// create scripts
- Script yuv2rgb = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_YUV_TO_RGB, element1);
- EXPECT_NE(Script(0), yuv2rgb);
+ Script blend =
+ context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_BLEND, element1);
+ ASSERT_NE(Script(0), blend);
- ScriptKernelID yuv2rgbKID = context->scriptKernelIDCreate(yuv2rgb, 0, 2);
- EXPECT_NE(ScriptKernelID(0), yuv2rgbKID);
+ ScriptKernelID blendKID = context->scriptKernelIDCreate(blend, 1, 3);
+ ASSERT_NE(ScriptKernelID(0), blendKID);
Script blur = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_BLUR, element2);
- EXPECT_NE(Script(0), blur);
+ ASSERT_NE(Script(0), blur);
ScriptKernelID blurKID = context->scriptKernelIDCreate(blur, 0, 2);
- EXPECT_NE(ScriptKernelID(0), blurKID);
+ ASSERT_NE(ScriptKernelID(0), blurKID);
+
ScriptFieldID blurFID = context->scriptFieldIDCreate(blur, 1);
- EXPECT_NE(ScriptFieldID(0), blurFID);
+ ASSERT_NE(ScriptFieldID(0), blurFID);
// ScriptGroup
- hidl_vec<ScriptKernelID> kernels = {yuv2rgbKID, blurKID};
- hidl_vec<ScriptKernelID> srcK = {yuv2rgbKID};
+ hidl_vec<ScriptKernelID> kernels = {blendKID, blurKID};
+ hidl_vec<ScriptKernelID> srcK = {blendKID};
hidl_vec<ScriptKernelID> dstK = {ScriptKernelID(0)};
hidl_vec<ScriptFieldID> dstF = {blurFID};
hidl_vec<Type> types = {type2};
ScriptGroup scriptGroup = context->scriptGroupCreate(kernels, srcK, dstK, dstF, types);
- EXPECT_NE(ScriptGroup(0), scriptGroup);
+ ASSERT_NE(ScriptGroup(0), scriptGroup);
- context->scriptSetVarObj(yuv2rgb, 0, (ObjectBase)allocation1);
+ context->scriptGroupSetInput(scriptGroup, blendKID, allocation1);
context->scriptGroupSetOutput(scriptGroup, blurKID, allocation2);
context->scriptGroupExecute(scriptGroup);
context->contextFinish();
@@ -360,14 +413,16 @@
* Similar to the ScriptGroup test, this test verifies the execution flow of
* RenderScript kernels and invokables.
*
- * Calls: scriptFieldIDCreate, closureCreate, scriptInvokeIDCreate,
- * invokeClosureCreate, closureSetGlobal, scriptGroup2Create, scriptGroupExecute
+ * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
+ * allocation1DWrite, scriptFieldIDCreate, scriptInvokeIDCreate,
+ * invokeClosureCreate, closureCreate, closureSetGlobal, scriptGroup2Create,
+ * scriptGroupExecute, allocationRead
*/
TEST_F(RenderscriptHidlTest, ScriptGroup2Test) {
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
std::vector<uint8_t> dataIn(128, 128), dataOut(128, 0), expected(128, 7+1);
hidl_vec<uint8_t> _dataIn, _dataOut;
@@ -375,19 +430,23 @@
// 256 x 256 YUV pixels
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
context->allocation1DWrite(allocation, 0, 0, (Size)_dataIn.size(), _dataIn);
ScriptFieldID fieldID = context->scriptFieldIDCreate(script, mExportVarIdx_var_allocation);
- EXPECT_NE(ScriptFieldID(0), fieldID);
ASSERT_NE(ScriptFieldID(0), fieldID);
// invoke
ScriptInvokeID invokeID = context->scriptInvokeIDCreate(script, mExportFuncIdx_setAllocation);
- EXPECT_NE(ScriptInvokeID(0), invokeID);
ASSERT_NE(ScriptInvokeID(0), invokeID);
int dim = 128;
@@ -397,12 +456,10 @@
hidl_vec<int64_t> values1 = {int64_t(0)};
hidl_vec<int32_t> sizes1 = {int32_t(0)};
Closure closure1 = context->invokeClosureCreate(invokeID, params, fieldIDS1, values1, sizes1);
- EXPECT_NE(Closure(0), closure1);
ASSERT_NE(Closure(0), closure1);
// kernel
ScriptKernelID kernelID = context->scriptKernelIDCreate(script, mExportForEachIdx_increment, 3);
- EXPECT_NE(ScriptKernelID(0), kernelID);
ASSERT_NE(ScriptKernelID(0), kernelID);
hidl_vec<ScriptFieldID> fieldIDS2 = {ScriptFieldID(0)};
@@ -412,7 +469,6 @@
hidl_vec<ScriptFieldID> depFieldIDS2 = {fieldID};
Closure closure2 = context->closureCreate(kernelID, allocation /* returnValue */, fieldIDS2,
values2, sizes2, depClosures2, depFieldIDS2);
- EXPECT_NE(Closure(0), closure2);
ASSERT_NE(Closure(0), closure2);
// set argument
@@ -424,7 +480,6 @@
hidl_string cacheDir = "/data/local/tmp";
hidl_vec<Closure> closures = {closure1, closure2};
ScriptGroup2 scriptGroup2 = context->scriptGroup2Create(name, cacheDir, closures);
- EXPECT_NE(ScriptGroup2(0), scriptGroup2);
ASSERT_NE(ScriptGroup2(0), scriptGroup2);
context->scriptGroupExecute(scriptGroup2);
@@ -436,14 +491,15 @@
* Similar to the ScriptGroup test, this test verifies a single kernel can be
* called by ScriptGroup with an unbound allocation specified before launch
*
- * Calls: scriptFieldIDCreate, closureCreate, scriptInvokeIDCreate,
- * invokeClosureCreate, closureSetArg, scriptGroup2Create, scriptGroupExecute
+ * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
+ * allocation1DWrite, scriptKernelIDCreate, closureCreate, closureSetArg,
+ * scriptGroup2Create, scriptGroupExecute, allocationRead
*/
TEST_F(RenderscriptHidlTest, ScriptGroup2KernelTest) {
hidl_vec<uint8_t> bitcode;
bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
- EXPECT_NE(Script(0), script);
+ ASSERT_NE(Script(0), script);
std::vector<uint8_t> dataIn(128, 128), dataOut(128, 0), expected(128, 128 + 1);
hidl_vec<uint8_t> _dataIn, _dataOut;
@@ -451,15 +507,20 @@
// 256 x 256 YUV pixels
Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+ ASSERT_NE(Element(0), element);
+
Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+ ASSERT_NE(Type(0), type);
+
Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
(int)AllocationUsageType::SCRIPT,
(Ptr)nullptr);
+ ASSERT_NE(Allocation(0), allocation);
+
context->allocation1DWrite(allocation, 0, 0, (Size)_dataIn.size(), _dataIn);
// kernel
ScriptKernelID kernelID = context->scriptKernelIDCreate(script, mExportForEachIdx_increment, 3);
- EXPECT_NE(ScriptKernelID(0), kernelID);
ASSERT_NE(ScriptKernelID(0), kernelID);
hidl_vec<ScriptFieldID> fieldIDS = {ScriptFieldID(0)};
@@ -469,7 +530,6 @@
hidl_vec<ScriptFieldID> depFieldIDS = {ScriptFieldID(0)};
Closure closure = context->closureCreate(kernelID, allocation /* returnValue */, fieldIDS,
values, sizes, depClosures, depFieldIDS);
- EXPECT_NE(Closure(0), closure);
ASSERT_NE(Closure(0), closure);
// set argument
@@ -480,7 +540,6 @@
hidl_string cacheDir = "/data/local/tmp";
hidl_vec<Closure> closures = {closure};
ScriptGroup2 scriptGroup2 = context->scriptGroup2Create(name, cacheDir, closures);
- EXPECT_NE(ScriptGroup2(0), scriptGroup2);
ASSERT_NE(ScriptGroup2(0), scriptGroup2);
context->scriptGroupExecute(scriptGroup2);
diff --git a/sensors/1.0/Android.bp b/sensors/1.0/Android.bp
index 9f7895d..043e139 100644
--- a/sensors/1.0/Android.bp
+++ b/sensors/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.sensors@1.0_genc++"],
generated_headers: ["android.hardware.sensors@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.sensors@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/sensors/1.0/Android.mk b/sensors/1.0/Android.mk
index 29f7c7e..18528a9 100644
--- a/sensors/1.0/Android.mk
+++ b/sensors/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.sensors@1.0-java-constants
+LOCAL_MODULE := android.hardware.sensors-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/sensors/1.0/default/Android.bp b/sensors/1.0/default/Android.bp
index 2ab1b90..8144590 100644
--- a/sensors/1.0/default/Android.bp
+++ b/sensors/1.0/default/Android.bp
@@ -23,6 +23,7 @@
cc_library_static {
name: "android.hardware.sensors@1.0-convert",
+ vendor_available: true,
defaults: ["hidl_defaults"],
srcs: ["convert.cpp"],
export_include_dirs: ["include"],
diff --git a/soundtrigger/2.0/Android.bp b/soundtrigger/2.0/Android.bp
index d2a04be..742311d 100644
--- a/soundtrigger/2.0/Android.bp
+++ b/soundtrigger/2.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.soundtrigger@2.0_genc++"],
generated_headers: ["android.hardware.soundtrigger@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.soundtrigger@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
index b0aef4b..996519b 100644
--- a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
+++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
@@ -294,8 +294,8 @@
return ret;
}
-SoundTriggerHalImpl::SoundTriggerHalImpl(const char *moduleName)
- : mModuleName(moduleName), mHwDevice(NULL), mNextModelId(1)
+SoundTriggerHalImpl::SoundTriggerHalImpl()
+ : mModuleName("primary"), mHwDevice(NULL), mNextModelId(1)
{
}
@@ -304,9 +304,6 @@
const hw_module_t *mod;
int rc;
- if (mModuleName == NULL || strlen(mModuleName) == 0) {
- mModuleName = "primary";
- }
rc = hw_get_module_by_class(SOUND_TRIGGER_HARDWARE_MODULE_ID, mModuleName, &mod);
if (rc != 0) {
ALOGE("couldn't load sound trigger module %s.%s (%s)",
@@ -570,20 +567,9 @@
delete[] levels;
}
-ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char *name)
+ISoundTriggerHw *HIDL_FETCH_ISoundTriggerHw(const char* /* name */)
{
- if (name != NULL) {
- if (strncmp(SOUND_TRIGGER_HARDWARE_MODULE_ID, name,
- strlen(SOUND_TRIGGER_HARDWARE_MODULE_ID)) != 0) {
- return NULL;
- }
- name = strchr(name, '.');
- if (name == NULL) {
- return NULL;
- }
- name++;
- }
- return new SoundTriggerHalImpl(name);
+ return new SoundTriggerHalImpl();
}
} // namespace implementation
} // namespace V2_0
diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.h b/soundtrigger/2.0/default/SoundTriggerHalImpl.h
index 8aa9285..4769590 100644
--- a/soundtrigger/2.0/default/SoundTriggerHalImpl.h
+++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.h
@@ -38,7 +38,7 @@
class SoundTriggerHalImpl : public ISoundTriggerHw {
public:
- explicit SoundTriggerHalImpl(const char *moduleName = NULL);
+ SoundTriggerHalImpl();
// Methods from ::android::hardware::soundtrigger::V2_0::ISoundTriggerHw follow.
Return<void> getProperties(getProperties_cb _hidl_cb) override;
diff --git a/soundtrigger/2.0/types.hal b/soundtrigger/2.0/types.hal
index fc7d019..99bbd56 100644
--- a/soundtrigger/2.0/types.hal
+++ b/soundtrigger/2.0/types.hal
@@ -75,8 +75,3 @@
vec<ConfidenceLevel> levels;
};
-/** TODO(elaurent) remove when Java build problem is fixed */
-union Dummy {
- uint32_t dummy1;
- int32_t dummy2;
-};
diff --git a/tests/bar/1.0/Android.bp b/tests/bar/1.0/Android.bp
index 2edde20..f7a6f75 100644
--- a/tests/bar/1.0/Android.bp
+++ b/tests/bar/1.0/Android.bp
@@ -72,6 +72,7 @@
generated_sources: ["android.hardware.tests.bar@1.0_genc++"],
generated_headers: ["android.hardware.tests.bar@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.bar@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index 1d5013b..e55a782 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -65,6 +65,7 @@
generated_sources: ["android.hardware.tests.baz@1.0_genc++"],
generated_headers: ["android.hardware.tests.baz@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.baz@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/baz/1.0/Android.mk b/tests/baz/1.0/Android.mk
index 9d4d6b6..29874da 100644
--- a/tests/baz/1.0/Android.mk
+++ b/tests/baz/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.baz@1.0-java
+LOCAL_MODULE := android.hardware.tests.baz-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -101,7 +101,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.baz@1.0-java-static
+LOCAL_MODULE := android.hardware.tests.baz-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -109,7 +109,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/expression/1.0/Android.bp b/tests/expression/1.0/Android.bp
index 5279503..6fcc0f8 100644
--- a/tests/expression/1.0/Android.bp
+++ b/tests/expression/1.0/Android.bp
@@ -47,6 +47,7 @@
generated_sources: ["android.hardware.tests.expression@1.0_genc++"],
generated_headers: ["android.hardware.tests.expression@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.expression@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/expression/1.0/Android.mk b/tests/expression/1.0/Android.mk
index 6bc9390..1a32ef5 100644
--- a/tests/expression/1.0/Android.mk
+++ b/tests/expression/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.expression@1.0-java
+LOCAL_MODULE := android.hardware.tests.expression-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -61,7 +61,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.expression@1.0-java-static
+LOCAL_MODULE := android.hardware.tests.expression-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -69,7 +69,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/extension/light/2.0/Android.bp b/tests/extension/light/2.0/Android.bp
index 93f9da1..14403b6 100644
--- a/tests/extension/light/2.0/Android.bp
+++ b/tests/extension/light/2.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.tests.extension.light@2.0_genc++"],
generated_headers: ["android.hardware.tests.extension.light@2.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.extension.light@2.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/extension/light/2.0/Android.mk b/tests/extension/light/2.0/Android.mk
index 16424a3..f1e10e4 100644
--- a/tests/extension/light/2.0/Android.mk
+++ b/tests/extension/light/2.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.extension.light@2.0-java
+LOCAL_MODULE := android.hardware.tests.extension.light-V2.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,8 +13,8 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hardware.light@2.0-java \
- android.hidl.base@1.0-java \
+ android.hardware.light-V2.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -100,7 +100,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.extension.light@2.0-java-static
+LOCAL_MODULE := android.hardware.tests.extension.light-V2.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -108,8 +108,8 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hardware.light@2.0-java-static \
- android.hidl.base@1.0-java-static \
+ android.hardware.light-V2.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index b221201..a631be8 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -72,6 +72,7 @@
generated_sources: ["android.hardware.tests.foo@1.0_genc++"],
generated_headers: ["android.hardware.tests.foo@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.foo@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp
index 895582c..b512311 100644
--- a/tests/foo/1.0/default/lib/Android.bp
+++ b/tests/foo/1.0/default/lib/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "libfootest",
+ vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"FooHelper.cpp"
diff --git a/tests/hash/1.0/Android.bp b/tests/hash/1.0/Android.bp
index c217e5c..aeefeed 100644
--- a/tests/hash/1.0/Android.bp
+++ b/tests/hash/1.0/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.tests.hash@1.0_genc++"],
generated_headers: ["android.hardware.tests.hash@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.hash@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/hash/1.0/Android.mk b/tests/hash/1.0/Android.mk
index 15428b4..586df6e 100644
--- a/tests/hash/1.0/Android.mk
+++ b/tests/hash/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.hash@1.0-java
+LOCAL_MODULE := android.hardware.tests.hash-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -40,7 +40,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.hash@1.0-java-static
+LOCAL_MODULE := android.hardware.tests.hash-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -48,7 +48,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/inheritance/1.0/Android.bp b/tests/inheritance/1.0/Android.bp
index f50aee4..11ee4f9 100644
--- a/tests/inheritance/1.0/Android.bp
+++ b/tests/inheritance/1.0/Android.bp
@@ -61,6 +61,7 @@
generated_sources: ["android.hardware.tests.inheritance@1.0_genc++"],
generated_headers: ["android.hardware.tests.inheritance@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.inheritance@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/inheritance/1.0/Android.mk b/tests/inheritance/1.0/Android.mk
index 21aac00..0ff9abc 100644
--- a/tests/inheritance/1.0/Android.mk
+++ b/tests/inheritance/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.inheritance@1.0-java
+LOCAL_MODULE := android.hardware.tests.inheritance-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -107,7 +107,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.inheritance@1.0-java-static
+LOCAL_MODULE := android.hardware.tests.inheritance-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -115,7 +115,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index 580e961..9c0fe45 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.tests.libhwbinder@1.0_genc++"],
generated_headers: ["android.hardware.tests.libhwbinder@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.libhwbinder@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/libhwbinder/1.0/Android.mk b/tests/libhwbinder/1.0/Android.mk
index 2ee26d6..4a5f779 100644
--- a/tests/libhwbinder/1.0/Android.mk
+++ b/tests/libhwbinder/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.libhwbinder@1.0-java
+LOCAL_MODULE := android.hardware.tests.libhwbinder-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -40,7 +40,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.libhwbinder@1.0-java-static
+LOCAL_MODULE := android.hardware.tests.libhwbinder-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -48,7 +48,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/memory/1.0/Android.bp b/tests/memory/1.0/Android.bp
index 49faf41..e49f436 100644
--- a/tests/memory/1.0/Android.bp
+++ b/tests/memory/1.0/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.tests.memory@1.0_genc++"],
generated_headers: ["android.hardware.tests.memory@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.memory@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index 2d42699..98bdd19 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -47,6 +47,7 @@
generated_sources: ["android.hardware.tests.msgq@1.0_genc++"],
generated_headers: ["android.hardware.tests.msgq@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.msgq@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/pointer/1.0/Android.bp b/tests/pointer/1.0/Android.bp
index 7f66e2a..48f2ec0 100644
--- a/tests/pointer/1.0/Android.bp
+++ b/tests/pointer/1.0/Android.bp
@@ -47,6 +47,7 @@
generated_sources: ["android.hardware.tests.pointer@1.0_genc++"],
generated_headers: ["android.hardware.tests.pointer@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.pointer@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp
index ae07b04..1fe0896 100644
--- a/tests/pointer/1.0/default/lib/Android.bp
+++ b/tests/pointer/1.0/default/lib/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "libpointertest",
+ vendor: true,
defaults: ["hidl_defaults"],
srcs: [
"PointerHelper.cpp"
diff --git a/tests/versioning/1.0/Android.bp b/tests/versioning/1.0/Android.bp
index fbabc10..ee41ea4 100644
--- a/tests/versioning/1.0/Android.bp
+++ b/tests/versioning/1.0/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.tests.versioning@1.0_genc++"],
generated_headers: ["android.hardware.tests.versioning@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.versioning@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/versioning/1.0/Android.mk b/tests/versioning/1.0/Android.mk
index ba18384..81ffd08 100644
--- a/tests/versioning/1.0/Android.mk
+++ b/tests/versioning/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@1.0-java
+LOCAL_MODULE := android.hardware.tests.versioning-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -40,7 +40,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@1.0-java-static
+LOCAL_MODULE := android.hardware.tests.versioning-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -48,7 +48,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/versioning/2.2/Android.bp b/tests/versioning/2.2/Android.bp
index 953b6df..bf412a6 100644
--- a/tests/versioning/2.2/Android.bp
+++ b/tests/versioning/2.2/Android.bp
@@ -47,6 +47,7 @@
generated_sources: ["android.hardware.tests.versioning@2.2_genc++"],
generated_headers: ["android.hardware.tests.versioning@2.2_genc++_headers"],
export_generated_headers: ["android.hardware.tests.versioning@2.2_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/versioning/2.2/Android.mk b/tests/versioning/2.2/Android.mk
index e2a2ff7..4fccce6 100644
--- a/tests/versioning/2.2/Android.mk
+++ b/tests/versioning/2.2/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@2.2-java
+LOCAL_MODULE := android.hardware.tests.versioning-V2.2-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -59,7 +59,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@2.2-java-static
+LOCAL_MODULE := android.hardware.tests.versioning-V2.2-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -67,7 +67,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/versioning/2.3/Android.bp b/tests/versioning/2.3/Android.bp
index 3cc2076..a8aee8e 100644
--- a/tests/versioning/2.3/Android.bp
+++ b/tests/versioning/2.3/Android.bp
@@ -54,6 +54,7 @@
generated_sources: ["android.hardware.tests.versioning@2.3_genc++"],
generated_headers: ["android.hardware.tests.versioning@2.3_genc++_headers"],
export_generated_headers: ["android.hardware.tests.versioning@2.3_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/versioning/2.3/Android.mk b/tests/versioning/2.3/Android.mk
index 68e6be4..36326d6 100644
--- a/tests/versioning/2.3/Android.mk
+++ b/tests/versioning/2.3/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@2.3-java
+LOCAL_MODULE := android.hardware.tests.versioning-V2.3-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,9 +13,9 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hardware.tests.versioning@1.0-java \
- android.hardware.tests.versioning@2.2-java \
- android.hidl.base@1.0-java \
+ android.hardware.tests.versioning-V1.0-java \
+ android.hardware.tests.versioning-V2.2-java \
+ android.hidl.base-V1.0-java \
#
@@ -80,7 +80,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@2.3-java-static
+LOCAL_MODULE := android.hardware.tests.versioning-V2.3-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -88,9 +88,9 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hardware.tests.versioning@1.0-java-static \
- android.hardware.tests.versioning@2.2-java-static \
- android.hidl.base@1.0-java-static \
+ android.hardware.tests.versioning-V1.0-java-static \
+ android.hardware.tests.versioning-V2.2-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tests/versioning/2.4/Android.bp b/tests/versioning/2.4/Android.bp
index 9d8303c..37e787f 100644
--- a/tests/versioning/2.4/Android.bp
+++ b/tests/versioning/2.4/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.tests.versioning@2.4_genc++"],
generated_headers: ["android.hardware.tests.versioning@2.4_genc++_headers"],
export_generated_headers: ["android.hardware.tests.versioning@2.4_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/versioning/2.4/Android.mk b/tests/versioning/2.4/Android.mk
index e41397f..c716172 100644
--- a/tests/versioning/2.4/Android.mk
+++ b/tests/versioning/2.4/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@2.4-java
+LOCAL_MODULE := android.hardware.tests.versioning-V2.4-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,9 +13,9 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hardware.tests.versioning@2.2-java \
- android.hardware.tests.versioning@2.3-java \
- android.hidl.base@1.0-java \
+ android.hardware.tests.versioning-V2.2-java \
+ android.hardware.tests.versioning-V2.3-java \
+ android.hidl.base-V1.0-java \
#
@@ -42,7 +42,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tests.versioning@2.4-java-static
+LOCAL_MODULE := android.hardware.tests.versioning-V2.4-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -50,9 +50,9 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hardware.tests.versioning@2.2-java-static \
- android.hardware.tests.versioning@2.3-java-static \
- android.hidl.base@1.0-java-static \
+ android.hardware.tests.versioning-V2.2-java-static \
+ android.hardware.tests.versioning-V2.3-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/thermal/1.0/Android.bp b/thermal/1.0/Android.bp
index d7d5184..41f5ab8 100644
--- a/thermal/1.0/Android.bp
+++ b/thermal/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.thermal@1.0_genc++"],
generated_headers: ["android.hardware.thermal@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.thermal@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/thermal/1.0/Android.mk b/thermal/1.0/Android.mk
index 7748b9e..5a0a9a0 100644
--- a/thermal/1.0/Android.mk
+++ b/thermal/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.thermal@1.0-java
+LOCAL_MODULE := android.hardware.thermal-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -175,7 +175,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.thermal@1.0-java-static
+LOCAL_MODULE := android.hardware.thermal-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -183,7 +183,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -345,7 +345,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.thermal@1.0-java-constants
+LOCAL_MODULE := android.hardware.thermal-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/tv/cec/1.0/Android.bp b/tv/cec/1.0/Android.bp
index a5d7b86..3f8973d 100644
--- a/tv/cec/1.0/Android.bp
+++ b/tv/cec/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.tv.cec@1.0_genc++"],
generated_headers: ["android.hardware.tv.cec@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tv.cec@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tv/cec/1.0/Android.mk b/tv/cec/1.0/Android.mk
index b08099e..1e3853d 100644
--- a/tv/cec/1.0/Android.mk
+++ b/tv/cec/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tv.cec@1.0-java
+LOCAL_MODULE := android.hardware.tv.cec-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -293,7 +293,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tv.cec@1.0-java-static
+LOCAL_MODULE := android.hardware.tv.cec-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -301,7 +301,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/tv/input/1.0/Android.bp b/tv/input/1.0/Android.bp
index e9c2d63..65a7b02 100644
--- a/tv/input/1.0/Android.bp
+++ b/tv/input/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.tv.input@1.0_genc++"],
generated_headers: ["android.hardware.tv.input@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tv.input@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tv/input/1.0/Android.mk b/tv/input/1.0/Android.mk
index 87654da..aa1cf70 100644
--- a/tv/input/1.0/Android.mk
+++ b/tv/input/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tv.input@1.0-java-constants
+LOCAL_MODULE := android.hardware.tv.input-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/usb/1.0/Android.bp b/usb/1.0/Android.bp
index f939c8b..11856a0 100644
--- a/usb/1.0/Android.bp
+++ b/usb/1.0/Android.bp
@@ -51,6 +51,7 @@
generated_sources: ["android.hardware.usb@1.0_genc++"],
generated_headers: ["android.hardware.usb@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.usb@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/usb/1.0/Android.mk b/usb/1.0/Android.mk
index 7be7147..62f6935 100644
--- a/usb/1.0/Android.mk
+++ b/usb/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.usb@1.0-java
+LOCAL_MODULE := android.hardware.usb-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -198,7 +198,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.usb@1.0-java-static
+LOCAL_MODULE := android.hardware.usb-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -206,7 +206,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -391,7 +391,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.usb@1.0-java-constants
+LOCAL_MODULE := android.hardware.usb-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
diff --git a/vibrator/1.0/Android.bp b/vibrator/1.0/Android.bp
index 11ae996..204ff50 100644
--- a/vibrator/1.0/Android.bp
+++ b/vibrator/1.0/Android.bp
@@ -44,6 +44,7 @@
generated_sources: ["android.hardware.vibrator@1.0_genc++"],
generated_headers: ["android.hardware.vibrator@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.vibrator@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/vibrator/1.0/Android.mk b/vibrator/1.0/Android.mk
index d921a7e..c54b655 100644
--- a/vibrator/1.0/Android.mk
+++ b/vibrator/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vibrator@1.0-java
+LOCAL_MODULE := android.hardware.vibrator-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -36,6 +36,25 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (EffectStrength)
+#
+GEN := $(intermediates)/android/hardware/vibrator/V1_0/EffectStrength.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.vibrator@1.0::types.EffectStrength
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (Status)
#
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Status.java
@@ -80,7 +99,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vibrator@1.0-java-static
+LOCAL_MODULE := android.hardware.vibrator-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -88,7 +107,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
@@ -111,6 +130,25 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (EffectStrength)
+#
+GEN := $(intermediates)/android/hardware/vibrator/V1_0/EffectStrength.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.vibrator@1.0::types.EffectStrength
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (Status)
#
GEN := $(intermediates)/android/hardware/vibrator/V1_0/Status.java
@@ -155,10 +193,10 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vibrator@1.0-java-constants
+LOCAL_MODULE := android.hardware.vibrator-V1.0-java-constants
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-intermediates := $(local-generated-sources-dir)
+intermediates := $(call local-generated-sources-dir, COMMON)
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
#
diff --git a/vr/1.0/Android.bp b/vr/1.0/Android.bp
index b48d010..66c346e 100644
--- a/vr/1.0/Android.bp
+++ b/vr/1.0/Android.bp
@@ -40,6 +40,7 @@
generated_sources: ["android.hardware.vr@1.0_genc++"],
generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/vr/1.0/Android.mk b/vr/1.0/Android.mk
index 0fbdaf7..fc5c675d 100644
--- a/vr/1.0/Android.mk
+++ b/vr/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vr@1.0-java
+LOCAL_MODULE := android.hardware.vr-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -40,7 +40,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vr@1.0-java-static
+LOCAL_MODULE := android.hardware.vr-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -48,7 +48,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/wifi/1.0/Android.bp b/wifi/1.0/Android.bp
index df5c9d2..9126aaf 100644
--- a/wifi/1.0/Android.bp
+++ b/wifi/1.0/Android.bp
@@ -128,6 +128,7 @@
generated_sources: ["android.hardware.wifi@1.0_genc++"],
generated_headers: ["android.hardware.wifi@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.wifi@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/wifi/1.0/Android.mk b/wifi/1.0/Android.mk
index 82409de..08cdcfa 100644
--- a/wifi/1.0/Android.mk
+++ b/wifi/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.wifi@1.0-java
+LOCAL_MODULE := android.hardware.wifi-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -1884,7 +1884,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.wifi@1.0-java-static
+LOCAL_MODULE := android.hardware.wifi-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -1892,7 +1892,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/wifi/1.0/IWifiStaIface.hal b/wifi/1.0/IWifiStaIface.hal
index 43c3126..644e78a 100644
--- a/wifi/1.0/IWifiStaIface.hal
+++ b/wifi/1.0/IWifiStaIface.hal
@@ -145,6 +145,31 @@
* program if present.
* Must fail if |StaIfaceCapabilityMask.APF| is not set.
*
+ * APF docs
+ * ==========================================================================
+ * APF functionality, instructions and bytecode/binary format is described in:
+ * http://android.googlesource.com/platform/hardware/google/apf/
+ * +/b75c9f3714cfae3dad3d976958e063150781437e/apf.h
+ *
+ * The interpreter API is described here:
+ * http://android.googlesource.com/platform/hardware/google/apf/+/
+ * b75c9f3714cfae3dad3d976958e063150781437e/apf_interpreter.h#32
+ *
+ * The assembler/generator API is described in javadocs here:
+ * http://android.googlesource.com/platform/frameworks/base/+/
+ * 4456f33a958a7f09e608399da83c4d12b2e7d191/services/net/java/android/net/
+ * apf/ApfGenerator.java
+ *
+ * Disassembler usage is described here:
+ * http://android.googlesource.com/platform/hardware/google/apf/+/
+ * b75c9f3714cfae3dad3d976958e063150781437e/apf_disassembler.c#65
+ *
+ * The BPF to APF translator usage is described here:
+ * http://android.googlesource.com/platform/frameworks/base/+/
+ * 4456f33a958a7f09e608399da83c4d12b2e7d191/tests/net/java/android/net/
+ * apf/Bpf2Apf.java
+ * ==========================================================================
+ *
* @param cmdId command Id to use for this invocation.
* @param APF Program to be set.
* @return status WifiStatus of the operation.
diff --git a/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
index 42d9a96..c0af30b 100644
--- a/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
@@ -20,9 +20,13 @@
#include <VtsHalHidlTargetTestBase.h>
+#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
+using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_0::IWifiApIface;
+using ::android::hardware::wifi::V1_0::WifiBand;
+using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::sp;
/**
@@ -30,11 +34,15 @@
*/
class WifiApIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
- virtual void SetUp() override {}
+ virtual void SetUp() override {
+ wifi_ap_iface_ = getWifiApIface();
+ ASSERT_NE(nullptr, wifi_ap_iface_.get());
+ }
virtual void TearDown() override { stopWifi(); }
protected:
+ sp<IWifiApIface> wifi_ap_iface_;
};
/*
@@ -46,3 +54,36 @@
EXPECT_NE(nullptr, getWifiApIface().get());
stopWifi();
}
+
+/*
+ * GetType:
+ * Ensures that the correct interface type is returned for AP interface.
+ */
+TEST_F(WifiApIfaceHidlTest, GetType) {
+ const auto& status_and_type = HIDL_INVOKE(wifi_ap_iface_, getType);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_type.first.code);
+ EXPECT_EQ(IfaceType::AP, status_and_type.second);
+}
+
+/*
+ * SetCountryCode:
+ * Ensures that a call to set the country code will return with a success
+ * status code.
+ */
+TEST_F(WifiApIfaceHidlTest, SetCountryCode) {
+ const android::hardware::hidl_array<int8_t, 2> kCountryCode{
+ std::array<int8_t, 2>{{0x55, 0x53}}};
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_ap_iface_, setCountryCode, kCountryCode).code);
+}
+
+/*
+ * GetValidFrequenciesForBand:
+ * Ensures that we can retrieve valid frequencies for 2.4 GHz band.
+ */
+TEST_F(WifiApIfaceHidlTest, GetValidFrequenciesForBand) {
+ const auto& status_and_freqs = HIDL_INVOKE(
+ wifi_ap_iface_, getValidFrequenciesForBand, WifiBand::BAND_24GHZ);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_freqs.first.code);
+ EXPECT_GT(status_and_freqs.second.size(), 0u);
+}
diff --git a/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
index 95add61..83f83b6 100644
--- a/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
@@ -24,7 +24,16 @@
#include "wifi_hidl_test_utils.h"
using ::android::sp;
+using ::android::hardware::wifi::V1_0::Bssid;
+using ::android::hardware::wifi::V1_0::CommandId;
+using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_0::IWifiStaIface;
+using ::android::hardware::wifi::V1_0::Rssi;
+using ::android::hardware::wifi::V1_0::Ssid;
+using ::android::hardware::wifi::V1_0::StaApfPacketFilterCapabilities;
+using ::android::hardware::wifi::V1_0::StaRoamingConfig;
+using ::android::hardware::wifi::V1_0::StaRoamingState;
+using ::android::hardware::wifi::V1_0::WifiBand;
using ::android::hardware::wifi::V1_0::WifiStatus;
using ::android::hardware::wifi::V1_0::WifiStatusCode;
@@ -41,6 +50,13 @@
virtual void TearDown() override { stopWifi(); }
protected:
+ bool isCapabilitySupported(IWifiStaIface::StaIfaceCapabilityMask cap_mask) {
+ const auto& status_and_caps =
+ HIDL_INVOKE(wifi_sta_iface_, getCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+ return (status_and_caps.second & cap_mask) != 0;
+ }
+
sp<IWifiStaIface> wifi_sta_iface_;
};
@@ -60,5 +76,190 @@
TEST_F(WifiStaIfaceHidlTest, GetCapabilities) {
const auto& status_and_caps = HIDL_INVOKE(wifi_sta_iface_, getCapabilities);
EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
- EXPECT_NE(0u, status_and_caps.second);
+ EXPECT_GT(status_and_caps.second, 0u);
+}
+
+/*
+ * GetType:
+ * Ensures that the correct interface type is returned for station interface.
+ */
+TEST_F(WifiStaIfaceHidlTest, GetType) {
+ const auto& status_and_type = HIDL_INVOKE(wifi_sta_iface_, getType);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_type.first.code);
+ EXPECT_EQ(IfaceType::STA, status_and_type.second);
+}
+
+/*
+ * GetApfPacketFilterCapabilities:
+ * Ensures that we can retrieve APF packet filter capabilites.
+ */
+TEST_F(WifiStaIfaceHidlTest, GetApfPacketFilterCapabilities) {
+ if (!isCapabilitySupported(IWifiStaIface::StaIfaceCapabilityMask::APF)) {
+ // No-op if APF packet filer is not supported.
+ return;
+ }
+
+ const auto& status_and_caps =
+ HIDL_INVOKE(wifi_sta_iface_, getApfPacketFilterCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+}
+
+/*
+ * GetBackgroundScanCapabilities:
+ * Ensures that we can retrieve background scan capabilities.
+ */
+TEST_F(WifiStaIfaceHidlTest, GetBackgroundScanCapabilities) {
+ if (!isCapabilitySupported(
+ IWifiStaIface::StaIfaceCapabilityMask::BACKGROUND_SCAN)) {
+ // No-op if background scan is not supported.
+ return;
+ }
+
+ const auto& status_and_caps =
+ HIDL_INVOKE(wifi_sta_iface_, getBackgroundScanCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+}
+
+/*
+ * GetValidFrequenciesForBand:
+ * Ensures that we can retrieve valid frequencies for 2.4 GHz band.
+ */
+TEST_F(WifiStaIfaceHidlTest, GetValidFrequenciesForBand) {
+ const auto& status_and_freqs = HIDL_INVOKE(
+ wifi_sta_iface_, getValidFrequenciesForBand, WifiBand::BAND_24GHZ);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_freqs.first.code);
+ EXPECT_GT(status_and_freqs.second.size(), 0u);
+}
+
+/*
+ * LinkLayerStatsCollection:
+ * Ensures that calls to enable, disable, and retrieve link layer stats
+ * will return a success status code.
+ */
+TEST_F(WifiStaIfaceHidlTest, LinkLayerStatsCollection) {
+ if (!isCapabilitySupported(
+ IWifiStaIface::StaIfaceCapabilityMask::LINK_LAYER_STATS)) {
+ // No-op if link layer stats is not supported.
+ return;
+ }
+
+ // Enable link layer stats collection.
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, enableLinkLayerStatsCollection, true)
+ .code);
+ // Retrieve link layer stats.
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, getLinkLayerStats).first.code);
+ // Disable link layer stats collection.
+ EXPECT_EQ(
+ WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, disableLinkLayerStatsCollection).code);
+}
+
+/*
+ * RSSIMonitoring:
+ * Ensures that calls to enable and disable RSSI monitoring will return
+ * a success status code.
+ */
+TEST_F(WifiStaIfaceHidlTest, RSSIMonitoring) {
+ if (!isCapabilitySupported(
+ IWifiStaIface::StaIfaceCapabilityMask::RSSI_MONITOR)) {
+ // No-op if RSSI monitor is not supported.
+ return;
+ }
+
+ const CommandId kCmd = 1;
+ const Rssi kMaxRssi = -50;
+ const Rssi kMinRssi = -90;
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, startRssiMonitoring, kCmd, kMaxRssi,
+ kMinRssi)
+ .code);
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, stopRssiMonitoring, kCmd).code);
+}
+
+/*
+ * RoamingControl:
+ * Ensures that calls to configure and enable roaming will return a success
+ * status code.
+ */
+TEST_F(WifiStaIfaceHidlTest, RoamingControl) {
+ if (!isCapabilitySupported(
+ IWifiStaIface::StaIfaceCapabilityMask::CONTROL_ROAMING)) {
+ // No-op if roaming control is not supported.
+ return;
+ }
+
+ // Retrieve roaming capabilities.
+ const auto& status_and_cap =
+ HIDL_INVOKE(wifi_sta_iface_, getRoamingCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_cap.first.code);
+
+ // Setup roaming configuration based on roaming capabilities.
+ const auto& cap = status_and_cap.second;
+ StaRoamingConfig roaming_config;
+ if (cap.maxBlacklistSize > 0) {
+ Bssid black_list_bssid{
+ std::array<uint8_t, 6>{{0x11, 0x22, 0x33, 0x44, 0x55, 0x66}}};
+ roaming_config.bssidBlacklist =
+ android::hardware::hidl_vec<Bssid>{black_list_bssid};
+ }
+ if (cap.maxWhitelistSize > 0) {
+ Ssid white_list_ssid{
+ std::array<uint8_t, 32>{{0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC}}};
+ roaming_config.ssidWhitelist =
+ android::hardware::hidl_vec<Ssid>{white_list_ssid};
+ }
+
+ // Configure roaming.
+ EXPECT_EQ(
+ WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, configureRoaming, roaming_config).code);
+
+ // Enable roaming.
+ EXPECT_EQ(
+ WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, setRoamingState, StaRoamingState::ENABLED)
+ .code);
+}
+
+/*
+ * EnableNDOffload:
+ * Ensures that calls to enable neighbor discovery offload will return a success
+ * status code.
+ */
+TEST_F(WifiStaIfaceHidlTest, EnableNDOffload) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, enableNdOffload, true).code);
+}
+
+/*
+ * SetScanningMacOui:
+ * Ensures that calls to set scanning MAC OUI will return a success status
+ * code.
+ */
+TEST_F(WifiStaIfaceHidlTest, SetScanningMacOui) {
+ const android::hardware::hidl_array<uint8_t, 3> kOui{
+ std::array<uint8_t, 3>{{0x10, 0x22, 0x33}}};
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, setScanningMacOui, kOui).code);
+}
+
+/*
+ * PacketFateMonitoring:
+ * Ensures that calls to start packet fate monitoring and retrieve TX/RX
+ * packets will return a success status code.
+ */
+TEST_F(WifiStaIfaceHidlTest, PacketFateMonitoring) {
+ // Start packet fate monitoring.
+ EXPECT_EQ(
+ WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, startDebugPacketFateMonitoring).code);
+
+ // Retrieve packets.
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, getDebugTxPacketFates).first.code);
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_sta_iface_, getDebugRxPacketFates).first.code);
}
diff --git a/wifi/supplicant/1.0/Android.bp b/wifi/supplicant/1.0/Android.bp
index a0adb8d..d6cb071 100644
--- a/wifi/supplicant/1.0/Android.bp
+++ b/wifi/supplicant/1.0/Android.bp
@@ -121,6 +121,7 @@
generated_sources: ["android.hardware.wifi.supplicant@1.0_genc++"],
generated_headers: ["android.hardware.wifi.supplicant@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.wifi.supplicant@1.0_genc++_headers"],
+ vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/wifi/supplicant/1.0/Android.mk b/wifi/supplicant/1.0/Android.mk
index dd210d0..18c7833 100644
--- a/wifi/supplicant/1.0/Android.mk
+++ b/wifi/supplicant/1.0/Android.mk
@@ -5,7 +5,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.wifi.supplicant@1.0-java
+LOCAL_MODULE := android.hardware.wifi.supplicant-V1.0-java
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -13,7 +13,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java \
+ android.hidl.base-V1.0-java \
#
@@ -384,7 +384,7 @@
################################################################################
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.wifi.supplicant@1.0-java-static
+LOCAL_MODULE := android.hardware.wifi.supplicant-V1.0-java-static
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
intermediates := $(call local-generated-sources-dir, COMMON)
@@ -392,7 +392,7 @@
HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
LOCAL_STATIC_JAVA_LIBRARIES := \
- android.hidl.base@1.0-java-static \
+ android.hidl.base-V1.0-java-static \
#
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_call_util.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_call_util.h
new file mode 100644
index 0000000..1c0fcec
--- /dev/null
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_call_util.h
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+// This file is copied from
+// hardware/interfaces/wifi/1.0/vts/functional/wifi_hidl_call_util.h
+// Please make sure these two file are consistent.
+
+#pragma once
+
+#include <functional>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+namespace {
+namespace detail {
+template <typename>
+struct functionArgSaver;
+
+// Provides a std::function that takes one argument, and a buffer
+// wherein the function will store its argument. The buffer has
+// the same type as the argument, but with const and reference
+// modifiers removed.
+template <typename ArgT>
+struct functionArgSaver<std::function<void(ArgT)>> final {
+ using StorageT = typename std::remove_const<
+ typename std::remove_reference<ArgT>::type>::type;
+
+ std::function<void(ArgT)> saveArgs = [this](ArgT arg) {
+ this->saved_values = arg;
+ };
+
+ StorageT saved_values;
+};
+
+// Provides a std::function that takes two arguments, and a buffer
+// wherein the function will store its arguments. The buffer is a
+// std::pair, whose elements have the same types as the arguments
+// (but with const and reference modifiers removed).
+template <typename Arg1T, typename Arg2T>
+struct functionArgSaver<std::function<void(Arg1T, Arg2T)>> final {
+ using StorageT =
+ std::pair<typename std::remove_const<
+ typename std::remove_reference<Arg1T>::type>::type,
+ typename std::remove_const<
+ typename std::remove_reference<Arg2T>::type>::type>;
+
+ std::function<void(Arg1T, Arg2T)> saveArgs = [this](Arg1T arg1,
+ Arg2T arg2) {
+ this->saved_values = {arg1, arg2};
+ };
+
+ StorageT saved_values;
+};
+
+// Provides a std::function that takes three or more arguments, and a
+// buffer wherein the function will store its arguments. The buffer is a
+// std::tuple whose elements have the same types as the arguments (but
+// with const and reference modifiers removed).
+template <typename... ArgT>
+struct functionArgSaver<std::function<void(ArgT...)>> final {
+ using StorageT = std::tuple<typename std::remove_const<
+ typename std::remove_reference<ArgT>::type>::type...>;
+
+ std::function<void(ArgT...)> saveArgs = [this](ArgT... arg) {
+ this->saved_values = {arg...};
+ };
+
+ StorageT saved_values;
+};
+
+// Invokes |method| on |object|, providing |method| a CallbackT as the
+// final argument. Returns a copy of the parameters that |method| provided
+// to CallbackT. (The parameters are returned by value.)
+template <typename CallbackT, typename MethodT, typename ObjectT,
+ typename... ArgT>
+typename functionArgSaver<CallbackT>::StorageT invokeMethod(
+ MethodT method, ObjectT object, ArgT&&... methodArg) {
+ functionArgSaver<CallbackT> result_buffer;
+ const auto& res = ((*object).*method)(std::forward<ArgT>(methodArg)...,
+ result_buffer.saveArgs);
+ EXPECT_TRUE(res.isOk());
+ return result_buffer.saved_values;
+}
+} // namespace detail
+} // namespace
+
+// Invokes |method| on |strong_pointer|, passing provided arguments through to
+// |method|.
+//
+// Returns either:
+// - A copy of the result callback parameter (for callbacks with a single
+// parameter), OR
+// - A pair containing a copy of the result callback parameters (for callbacks
+// with two parameters), OR
+// - A tuple containing a copy of the result callback paramters (for callbacks
+// with three or more parameters).
+//
+// Example usage:
+// EXPECT_EQ(WifiStatusCode::SUCCESS,
+// HIDL_INVOKE(strong_pointer, methodReturningWifiStatus).code);
+// EXPECT_EQ(WifiStatusCode::SUCCESS,
+// HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndOneMore)
+// .first.code);
+// EXPECT_EQ(WifiStatusCode::SUCCESS, std::get<0>(
+// HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndTwoMore))
+// .code);
+#define HIDL_INVOKE(strong_pointer, method, ...) \
+ (detail::invokeMethod< \
+ std::remove_reference<decltype(*strong_pointer)>::type::method##_cb>( \
+ &std::remove_reference<decltype(*strong_pointer)>::type::method, \
+ strong_pointer, ##__VA_ARGS__))
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 72a3c42..0181f7b 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -20,6 +20,7 @@
#include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
+#include "supplicant_hidl_call_util.h"
#include "supplicant_hidl_test_utils.h"
using ::android::sp;
@@ -28,6 +29,7 @@
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIfaceCallback;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantNetworkId;
@@ -38,16 +40,30 @@
constexpr uint8_t kTestSsidPostfix[] = {'t', 'e', 's', 't'};
constexpr uint8_t kTestMacAddr[] = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
constexpr uint8_t kTestPeerMacAddr[] = {0x56, 0x67, 0x55, 0xf4, 0x56, 0x92};
+constexpr uint8_t kTestBonjourServiceQuery[] = {'t', 'e', 's', 't', 'q',
+ 'u', 'e', 'r', 'y'};
+constexpr uint8_t kTestBonjourServiceResponse[] = {
+ 't', 'e', 's', 't', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e'};
+constexpr uint8_t kTestWfdDeviceInfo[] = {[0 ... 5] = 0x01};
constexpr char kTestConnectPin[] = "34556665";
constexpr char kTestGroupIfName[] = "TestGroup";
+constexpr char kTestWpsDeviceName[] = "TestWpsDeviceName";
+constexpr char kTestWpsManufacturer[] = "TestManufacturer";
+constexpr char kTestWpsModelName[] = "TestModelName";
+constexpr char kTestWpsModelNumber[] = "TestModelNumber";
+constexpr char kTestWpsSerialNumber[] = "TestSerialNumber";
+constexpr char kTestUpnpServiceName[] = "TestServiceName";
+constexpr uint8_t kTestWpsDeviceType[] = {[0 ... 7] = 0x01};
+constexpr uint16_t kTestWpsConfigMethods = 0xffff;
constexpr uint32_t kTestConnectGoIntent = 6;
constexpr uint32_t kTestFindTimeout = 5;
-constexpr SupplicantNetworkId kTestNetworkId = 5;
+constexpr uint32_t kTestSetGroupIdleTimeout = 6;
constexpr uint32_t kTestChannel = 1;
constexpr uint32_t kTestOperatingClass = 81;
constexpr uint32_t kTestFreqRange[] = {2412, 2432};
constexpr uint32_t kTestExtListenPeriod = 400;
constexpr uint32_t kTestExtListenInterval = 400;
+constexpr SupplicantNetworkId kTestNetworkId = 5;
} // namespace
class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
@@ -178,6 +194,26 @@
}
/*
+ * GetName
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetName) {
+ const auto& status_and_interface_name = HIDL_INVOKE(p2p_iface_, getName);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_interface_name.first.code);
+ EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
+}
+
+/*
+ * GetType
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetType) {
+ const auto& status_and_interface_type = HIDL_INVOKE(p2p_iface_, getType);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_interface_type.first.code);
+ EXPECT_EQ(status_and_interface_type.second, IfaceType::P2P);
+}
+
+/*
* GetDeviceAddress
*/
TEST_F(SupplicantP2pIfaceHidlTest, GetDeviceAddress) {
@@ -219,10 +255,6 @@
p2p_iface_->stopFind([](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
-
- p2p_iface_->stopFind([](const SupplicantStatus& status) {
- EXPECT_NE(SupplicantStatusCode::SUCCESS, status.code);
- });
}
/*
@@ -290,6 +322,15 @@
}
/*
+ * RemoveGroup
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, RemoveGroup) {
+ // This is not going to work with fake values.
+ EXPECT_NE(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, removeGroup, kTestGroupIfName).code);
+}
+
+/*
* Reject
*/
TEST_F(SupplicantP2pIfaceHidlTest, Reject) {
@@ -411,3 +452,170 @@
status.code);
});
}
+
+/*
+ * SetGroupIdle
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetGroupIdle) {
+ // This is not going to work with fake values.
+ EXPECT_NE(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setGroupIdle, kTestGroupIfName,
+ kTestSetGroupIdleTimeout)
+ .code);
+}
+
+/*
+ * SetPowerSave
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetPowerSave) {
+ // This is not going to work with fake values.
+ EXPECT_NE(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setPowerSave, kTestGroupIfName, true).code);
+ // This is not going to work with fake values.
+ EXPECT_NE(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setPowerSave, kTestGroupIfName, false).code);
+}
+
+/*
+ * SetWpsDeviceName
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsDeviceName) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsDeviceName, kTestWpsDeviceName).code);
+}
+
+/*
+ * SetWpsDeviceType
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsDeviceType) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsDeviceType, kTestWpsDeviceType).code);
+}
+
+/*
+ * SetWpsManufacturer
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsManufacturer) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsManufacturer, kTestWpsManufacturer).code);
+}
+
+/*
+ * SetWpsModelName
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsModelName) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsModelName, kTestWpsModelName).code);
+}
+
+/*
+ * SetWpsModelNumber
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsModelNumber) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsModelNumber, kTestWpsModelNumber).code);
+}
+
+/*
+ * SetWpsSerialNumber
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsSerialNumber) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsSerialNumber, kTestWpsSerialNumber).code);
+}
+
+/*
+ * SetWpsConfigMethods
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWpsConfigMethods) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWpsConfigMethods, kTestWpsConfigMethods)
+ .code);
+}
+
+/*
+ * AddAndRemoveBonjourService
+ * This tests that we are able to add a bonjour service, and we can remove it
+ * by using the same query data.
+ * This also tests that removeBonjourSerive() returns error when there is no
+ * existing bonjour service with the same query data.
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, AddAndRemoveBonjourService) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(
+ p2p_iface_, addBonjourService,
+ std::vector<uint8_t>(kTestBonjourServiceQuery,
+ kTestBonjourServiceQuery +
+ sizeof(kTestBonjourServiceQuery)),
+ std::vector<uint8_t>(kTestBonjourServiceResponse,
+ kTestBonjourServiceResponse +
+ sizeof(kTestBonjourServiceResponse)))
+ .code);
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, removeBonjourService,
+ std::vector<uint8_t>(kTestBonjourServiceQuery,
+ kTestBonjourServiceQuery +
+ sizeof(kTestBonjourServiceQuery)))
+ .code);
+ // This will fail because boujour service with kTestBonjourServiceQuery was
+ // already removed.
+ EXPECT_NE(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, removeBonjourService,
+ std::vector<uint8_t>(kTestBonjourServiceQuery,
+ kTestBonjourServiceQuery +
+ sizeof(kTestBonjourServiceQuery)))
+ .code);
+}
+
+/*
+ * AddAndRemoveUpnpService
+ * This tests that we are able to add a upnp service, and we can remove it
+ * by using the same service name.
+ * This also tests that removeUpnpService() returns error when there is no
+ * exsiting upnp service with the same service name.
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, AddAndRemoveUpnpService) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, addUpnpService, 0 /* version */,
+ kTestUpnpServiceName)
+ .code);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, removeUpnpService, 0 /* version */,
+ kTestUpnpServiceName)
+ .code);
+ // This will fail because Upnp service with kTestUpnpServiceName was
+ // already removed.
+ EXPECT_NE(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, removeUpnpService, 0 /* version */,
+ kTestUpnpServiceName)
+ .code);
+}
+
+/*
+ * EnableWfd
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, EnableWfd) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, enableWfd, true).code);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, enableWfd, false).code);
+}
+
+/*
+ * SetWfdDeviceInfo
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetWfdDeviceInfo) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(p2p_iface_, setWfdDeviceInfo, kTestWfdDeviceInfo).code);
+}
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
index 5abf4e0..c0e62d1 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -20,6 +20,7 @@
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
+#include "supplicant_hidl_call_util.h"
#include "supplicant_hidl_test_utils.h"
using ::android::sp;
@@ -28,6 +29,7 @@
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIfaceCallback;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
@@ -45,7 +47,18 @@
ISupplicantStaIface::Hs20AnqpSubtypes::WAN_METRICS,
ISupplicantStaIface::Hs20AnqpSubtypes::OPERATOR_FRIENDLY_NAME};
constexpr char kTestHs20IconFile[] = "TestFile";
+constexpr char kTestWpsDeviceName[] = "TestWpsDeviceName";
+constexpr char kTestWpsManufacturer[] = "TestManufacturer";
+constexpr char kTestWpsModelName[] = "TestModelName";
+constexpr char kTestWpsModelNumber[] = "TestModelNumber";
+constexpr char kTestWpsSerialNumber[] = "TestSerialNumber";
+constexpr char kTestRadioWorkName[] = "TestRadioWork";
+constexpr uint32_t kTestRadioWorkFrequency = 2412;
+constexpr uint32_t kTestRadioWorkTimeout = 8;
+constexpr uint32_t kTestRadioWorkId = 16;
constexpr int8_t kTestCountryCode[] = {'U', 'S'};
+constexpr uint8_t kTestWpsDeviceType[] = {[0 ... 7] = 0x01};
+constexpr uint16_t kTestWpsConfigMethods = 0xffff;
} // namespace
class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
@@ -163,6 +176,26 @@
}
/*
+ * GetName
+ */
+TEST_F(SupplicantStaIfaceHidlTest, GetName) {
+ const auto& status_and_interface_name = HIDL_INVOKE(sta_iface_, getName);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_interface_name.first.code);
+ EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
+}
+
+/*
+ * GetType
+ */
+TEST_F(SupplicantStaIfaceHidlTest, GetType) {
+ const auto& status_and_interface_type = HIDL_INVOKE(sta_iface_, getType);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_interface_type.first.code);
+ EXPECT_EQ(status_and_interface_type.second, IfaceType::STA);
+}
+
+/*
* listNetworks.
*/
TEST_F(SupplicantStaIfaceHidlTest, listNetworks) {
@@ -405,3 +438,101 @@
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
+
+/*
+ * SetWpsDeviceName
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsDeviceName) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsDeviceName, kTestWpsDeviceName).code);
+}
+
+/*
+ * SetWpsDeviceType
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsDeviceType) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsDeviceType, kTestWpsDeviceType).code);
+}
+
+/*
+ * SetWpsManufacturer
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsManufacturer) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsManufacturer, kTestWpsManufacturer).code);
+}
+
+/*
+ * SetWpsModelName
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsModelName) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsModelName, kTestWpsModelName).code);
+}
+
+/*
+ * SetWpsModelNumber
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsModelNumber) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsModelNumber, kTestWpsModelNumber).code);
+}
+
+/*
+ * SetWpsSerialNumber
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsSerialNumber) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsSerialNumber, kTestWpsSerialNumber).code);
+}
+
+/*
+ * SetWpsConfigMethods
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetWpsConfigMethods) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setWpsConfigMethods, kTestWpsConfigMethods)
+ .code);
+}
+
+/*
+ * SetExternalSim
+ */
+TEST_F(SupplicantStaIfaceHidlTest, SetExternalSim) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setExternalSim, true).code);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, setExternalSim, false).code);
+}
+
+/*
+ * AddExtRadioWork
+ */
+TEST_F(SupplicantStaIfaceHidlTest, AddExtRadioWork) {
+ const auto& status_and_radio_work_id =
+ HIDL_INVOKE(sta_iface_, addExtRadioWork, kTestRadioWorkName,
+ kTestRadioWorkFrequency, kTestRadioWorkTimeout);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_radio_work_id.first.code);
+ // removeExtRadio only succeeds if the added radio work hasn't started yet.
+ // So there this no guaranteed result from calling removeExtRadioWork here.
+ // That being said, currently we are not able to test addExtRadioWork and
+ // removeExtRadioWork in a row.
+}
+
+/*
+ * RemoveExtRadioWork
+ */
+TEST_F(SupplicantStaIfaceHidlTest, RemoveExtRadioWork) {
+ // This fails because there is no on going radio work with kTestRadioWorkId.
+ EXPECT_NE(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_iface_, removeExtRadioWork, kTestRadioWorkId).code);
+}
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
index aa84e9a..832dd41 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
+#include "supplicant_hidl_call_util.h"
#include "supplicant_hidl_test_utils.h"
using ::android::sp;
@@ -30,6 +31,7 @@
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
using ::android::hardware::wifi::supplicant::V1_0::
@@ -39,7 +41,7 @@
namespace {
constexpr char kTestSsidStr[] = "TestSsid1234";
-constexpr char kTestPsk[] = "TestPsk123";
+constexpr char kTestPskPassphrase[] = "TestPsk123";
constexpr char kTestIdStr[] = "TestIdstr";
constexpr char kTestEapPasswdStr[] = "TestEapPasswd1234";
constexpr char kTestEapCert[] = "keystore://CERT";
@@ -54,7 +56,10 @@
constexpr uint8_t kTestIk[] = {[0 ... 15] = 0x65};
constexpr uint8_t kTestCk[] = {[0 ... 15] = 0x45};
constexpr uint8_t kTestIdentity[] = {0x45, 0x67, 0x98, 0x67, 0x56};
+constexpr uint8_t kTestPsk[] = {[0 ... 31] = 0x12};
+constexpr uint8_t kTestAutParam[] = {[0 ... 13] = 0xe1};
constexpr uint32_t kTestWepTxKeyIdx = 2;
+constexpr uint32_t kTestUpdateIdentifier = 21;
constexpr uint32_t kTestKeyMgmt = (ISupplicantStaNetwork::KeyMgmtMask::WPA_PSK |
ISupplicantStaNetwork::KeyMgmtMask::WPA_EAP);
constexpr uint32_t kTestProto = (ISupplicantStaNetwork::ProtoMask::OSEN |
@@ -137,6 +142,27 @@
});
}
+/*
+ * GetInterfaceName
+ */
+TEST_F(SupplicantStaNetworkHidlTest, GetInterfaceName) {
+ const auto& status_and_interface_name =
+ HIDL_INVOKE(sta_network_, getInterfaceName);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_interface_name.first.code);
+ EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
+}
+
+/*
+ * GetType
+ */
+TEST_F(SupplicantStaNetworkHidlTest, GetType) {
+ const auto& status_and_interface_type = HIDL_INVOKE(sta_network_, getType);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_interface_type.first.code);
+ EXPECT_EQ(status_and_interface_type.second, IfaceType::STA);
+}
+
/* Tests out the various setter/getter methods. */
/*
* SetGetSsid
@@ -246,17 +272,29 @@
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetPskPassphrase) {
sta_network_->setPskPassphrase(
- kTestPsk, [](const SupplicantStatus& status) {
+ kTestPskPassphrase, [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
sta_network_->getPskPassphrase(
[&](const SupplicantStatus& status, const hidl_string& psk) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
- EXPECT_EQ(kTestPsk, std::string(psk.c_str()));
+ EXPECT_EQ(kTestPskPassphrase, std::string(psk.c_str()));
});
}
/*
+ * SetGetPsk
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetPsk) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setPsk, kTestPsk).code);
+ const auto& status_and_psk = HIDL_INVOKE(sta_network_, getPsk);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS, status_and_psk.first.code);
+ hidl_array<uint8_t, 32> expected_psk(kTestPsk);
+ EXPECT_EQ(expected_psk, status_and_psk.second);
+}
+
+/*
* SetGetWepKeys
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetWepTxKeyIdx) {
@@ -361,6 +399,12 @@
* SetGetEapPhase2Method
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetEapPhase2Method) {
+ ISupplicantStaNetwork::EapMethod set_eap_method =
+ ISupplicantStaNetwork::EapMethod::PEAP;
+ sta_network_->setEapMethod(
+ set_eap_method, [](const SupplicantStatus& status) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+ });
ISupplicantStaNetwork::EapPhase2Method set_eap_phase2_method =
ISupplicantStaNetwork::EapPhase2Method::NONE;
sta_network_->setEapPhase2Method(
@@ -500,6 +544,21 @@
}
/*
+ * SetGetEapSubjectMatch
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapSubjectMatch) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setEapSubjectMatch, kTestEapMatch).code);
+ const auto& status_and_subject_match =
+ HIDL_INVOKE(sta_network_, getEapSubjectMatch);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ status_and_subject_match.first.code);
+ EXPECT_EQ(kTestEapMatch,
+ std::string(status_and_subject_match.second.c_str()));
+}
+
+/*
* SetGetEapDomainSuffixMatch
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetEapDomainSuffixMatch) {
@@ -634,6 +693,14 @@
}
/*
+ * SendNetworkEapSimGsmAuthFailure
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimGsmAuthFailure) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, sendNetworkEapSimGsmAuthFailure).code);
+}
+
+/*
* SendNetworkEapSimUmtsAuthResponse
*/
TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAuthResponse) {
@@ -648,6 +715,24 @@
}
/*
+ * SendNetworkEapSimUmtsAuthFailure
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAuthFailure) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, sendNetworkEapSimUmtsAuthFailure).code);
+}
+
+/*
+ * SendNetworkEapSimUmtsAutsResponse
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAutsResponse) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, sendNetworkEapSimUmtsAutsResponse,
+ kTestAutParam)
+ .code);
+}
+
+/*
* SendNetworkEapIdentityResponse
*/
TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapIdentityResponse) {
@@ -658,3 +743,40 @@
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
+
+/*
+ * SetUpdateIdentifier
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetUpdateIdentifier) {
+ EXPECT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setUpdateIdentifier, kTestUpdateIdentifier)
+ .code);
+}
+
+/*
+ * SetProactiveKeyCaching
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetProactiveKeyCaching) {
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setProactiveKeyCaching, true).code);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setProactiveKeyCaching, false).code);
+}
+
+/*
+ * GetWpsNfcConfigurationToken
+ */
+TEST_F(SupplicantStaNetworkHidlTest, GetWpsNfcConfigurationToken) {
+ ASSERT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setSsid, ssid_).code);
+ ASSERT_EQ(SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setKeyMgmt, kTestKeyMgmt).code);
+ ASSERT_EQ(
+ SupplicantStatusCode::SUCCESS,
+ HIDL_INVOKE(sta_network_, setPskPassphrase, kTestPskPassphrase).code);
+ const auto& status_and_token =
+ HIDL_INVOKE(sta_network_, getWpsNfcConfigurationToken);
+ EXPECT_EQ(SupplicantStatusCode::SUCCESS, status_and_token.first.code);
+ EXPECT_FALSE(0 == status_and_token.second.size());
+}