Merge "Add capability for sensor hal to use wakelock"
diff --git a/biometrics/fingerprint/2.1/vts/functional/Android.bp b/biometrics/fingerprint/2.1/vts/functional/Android.bp
index 27b7157..bee3657 100644
--- a/biometrics/fingerprint/2.1/vts/functional/Android.bp
+++ b/biometrics/fingerprint/2.1/vts/functional/Android.bp
@@ -16,21 +16,8 @@
cc_test {
name: "VtsHalBiometricsFingerprintV2_1TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalBiometricsFingerprintV2_1TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "libhidltransport",
- "libhardware",
- "libhidlbase",
- "liblog",
- "libutils",
- "android.hardware.biometrics.fingerprint@2.1",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.biometrics.fingerprint@2.1"],
}
diff --git a/bluetooth/1.0/default/async_fd_watcher.cc b/bluetooth/1.0/default/async_fd_watcher.cc
index bc0bc92..d8714f5 100644
--- a/bluetooth/1.0/default/async_fd_watcher.cc
+++ b/bluetooth/1.0/default/async_fd_watcher.cc
@@ -105,6 +105,9 @@
timeout_cb_ = nullptr;
}
+ close(notification_listen_fd_);
+ close(notification_write_fd_);
+
return 0;
}
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index fb53366..6c9aa18 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -464,8 +464,9 @@
// Return the number of completed packets reported by the controller.
int BluetoothHidlTest::wait_for_completed_packets_event(uint16_t handle) {
- EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
- .no_timeout);
+ if (!bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout) {
+ ALOGW("%s: WaitForCallback timed out.", __func__);
+ }
int packets_processed = 0;
while (event_queue.size() > 0) {
hidl_vec<uint8_t> event = event_queue.front();
@@ -604,20 +605,24 @@
// This should work, but breaks on some current platforms. Figure out how to
// grandfather older devices but test new ones.
- int sco_packets_sent = 0;
if (0 && sco_connection_handles.size() > 0) {
sendAndCheckSCO(1, max_sco_data_packet_length, sco_connection_handles[0]);
- sco_packets_sent = 1;
- EXPECT_EQ(sco_packets_sent,
- wait_for_completed_packets_event(sco_connection_handles[0]));
+ int sco_packets_sent = 1;
+ int completed_packets = wait_for_completed_packets_event(sco_connection_handles[0]);
+ if (sco_packets_sent != completed_packets) {
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, sco_packets_sent,
+ completed_packets);
+ }
}
- int acl_packets_sent = 0;
if (acl_connection_handles.size() > 0) {
sendAndCheckACL(1, max_acl_data_packet_length, acl_connection_handles[0]);
- acl_packets_sent = 1;
- EXPECT_EQ(acl_packets_sent,
- wait_for_completed_packets_event(acl_connection_handles[0]));
+ int acl_packets_sent = 1;
+ int completed_packets = wait_for_completed_packets_event(acl_connection_handles[0]);
+ if (acl_packets_sent != completed_packets) {
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, acl_packets_sent,
+ completed_packets);
+ }
}
}
@@ -633,22 +638,26 @@
// This should work, but breaks on some current platforms. Figure out how to
// grandfather older devices but test new ones.
- int sco_packets_sent = 0;
if (0 && sco_connection_handles.size() > 0) {
sendAndCheckSCO(NUM_SCO_PACKETS_BANDWIDTH, max_sco_data_packet_length,
sco_connection_handles[0]);
- sco_packets_sent = NUM_SCO_PACKETS_BANDWIDTH;
- EXPECT_EQ(sco_packets_sent,
- wait_for_completed_packets_event(sco_connection_handles[0]));
+ int sco_packets_sent = NUM_SCO_PACKETS_BANDWIDTH;
+ int completed_packets = wait_for_completed_packets_event(sco_connection_handles[0]);
+ if (sco_packets_sent != completed_packets) {
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, sco_packets_sent,
+ completed_packets);
+ }
}
- int acl_packets_sent = 0;
if (acl_connection_handles.size() > 0) {
sendAndCheckACL(NUM_ACL_PACKETS_BANDWIDTH, max_acl_data_packet_length,
acl_connection_handles[0]);
- acl_packets_sent = NUM_ACL_PACKETS_BANDWIDTH;
- EXPECT_EQ(acl_packets_sent,
- wait_for_completed_packets_event(acl_connection_handles[0]));
+ int acl_packets_sent = NUM_ACL_PACKETS_BANDWIDTH;
+ int completed_packets = wait_for_completed_packets_event(acl_connection_handles[0]);
+ if (acl_packets_sent != completed_packets) {
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, acl_packets_sent,
+ completed_packets);
+ }
}
}
diff --git a/boot/1.0/vts/functional/Android.bp b/boot/1.0/vts/functional/Android.bp
index 5b14f54..2ef89f3 100644
--- a/boot/1.0/vts/functional/Android.bp
+++ b/boot/1.0/vts/functional/Android.bp
@@ -16,20 +16,7 @@
cc_test {
name: "VtsHalBootV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalBootV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libnativehelper",
- "libutils",
- "android.hardware.boot@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.boot@1.0"],
}
diff --git a/broadcastradio/1.0/vts/functional/Android.bp b/broadcastradio/1.0/vts/functional/Android.bp
index cf52f49..f31a2dc 100644
--- a/broadcastradio/1.0/vts/functional/Android.bp
+++ b/broadcastradio/1.0/vts/functional/Android.bp
@@ -16,21 +16,7 @@
cc_test {
name: "VtsHalBroadcastradioV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalBroadcastradioV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.broadcastradio@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
+ static_libs: ["android.hardware.broadcastradio@1.0"],
}
diff --git a/camera/common/1.0/default/Android.bp b/camera/common/1.0/default/Android.bp
index 03a71fa..5461d82 100644
--- a/camera/common/1.0/default/Android.bp
+++ b/camera/common/1.0/default/Android.bp
@@ -1,6 +1,6 @@
cc_library_static {
name: "android.hardware.camera.common@1.0-helper",
- vendor: true,
+ vendor_available: true,
defaults: ["hidl_defaults"],
srcs: [
"CameraModule.cpp",
diff --git a/camera/device/1.0/default/CameraDevice.cpp b/camera/device/1.0/default/CameraDevice.cpp
index c53c0d8..a03bbc8 100644
--- a/camera/device/1.0/default/CameraDevice.cpp
+++ b/camera/device/1.0/default/CameraDevice.cpp
@@ -377,10 +377,14 @@
hidl_handle hidlHandle = mem->mHidlHandle;
MemoryId id = object->mDeviceCallback->registerMemory(hidlHandle, buf_size, num_bufs);
mem->handle.mId = id;
- if (object->mMemoryMap.count(id) != 0) {
- ALOGE("%s: duplicate MemoryId %d returned by client!", __FUNCTION__, id);
+
+ {
+ Mutex::Autolock _l(object->mMemoryMapLock);
+ if (object->mMemoryMap.count(id) != 0) {
+ ALOGE("%s: duplicate MemoryId %d returned by client!", __FUNCTION__, id);
+ }
+ object->mMemoryMap[id] = mem;
}
- object->mMemoryMap[id] = mem;
mem->handle.mDevice = object;
return &mem->handle;
}
@@ -398,7 +402,10 @@
ALOGE("%s: camera HAL return memory while camera is not opened!", __FUNCTION__);
}
device->mDeviceCallback->unregisterMemory(mem->handle.mId);
- device->mMemoryMap.erase(mem->handle.mId);
+ {
+ Mutex::Autolock _l(device->mMemoryMapLock);
+ device->mMemoryMap.erase(mem->handle.mId);
+ }
mem->decStrong(mem);
}
@@ -826,7 +833,16 @@
return;
}
if (mDevice->ops->release_recording_frame) {
- CameraHeapMemory* camMemory = mMemoryMap.at(memId);
+ CameraHeapMemory* camMemory;
+ {
+ Mutex::Autolock _l(mMemoryMapLock);
+ auto it = mMemoryMap.find(memId);
+ if (it == mMemoryMap.end() || it->second == nullptr) {
+ ALOGE("%s unknown memoryId %d", __FUNCTION__, memId);
+ return;
+ }
+ camMemory = it->second;
+ }
if (bufferIndex >= camMemory->mNumBufs) {
ALOGE("%s: bufferIndex %d exceeds number of buffers %d",
__FUNCTION__, bufferIndex, camMemory->mNumBufs);
diff --git a/camera/device/1.0/default/CameraDevice_1_0.h b/camera/device/1.0/default/CameraDevice_1_0.h
index c078596..2c980f0 100644
--- a/camera/device/1.0/default/CameraDevice_1_0.h
+++ b/camera/device/1.0/default/CameraDevice_1_0.h
@@ -165,6 +165,8 @@
sp<ICameraDeviceCallback> mDeviceCallback = nullptr;
+ mutable Mutex mMemoryMapLock; // gating access to mMemoryMap
+ // must not hold mLock after this lock is acquired
std::unordered_map<MemoryId, CameraHeapMemory*> mMemoryMap;
bool mMetadataMode = false;
diff --git a/configstore/1.0/vts/functional/Android.bp b/configstore/1.0/vts/functional/Android.bp
index 1775538..1b8a591 100644
--- a/configstore/1.0/vts/functional/Android.bp
+++ b/configstore/1.0/vts/functional/Android.bp
@@ -16,19 +16,8 @@
cc_test {
name: "VtsHalConfigstoreV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalConfigstoreV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "libhidlbase",
- "liblog",
- "libutils",
- "android.hardware.configstore@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.configstore@1.0"],
}
diff --git a/configstore/utils/Android.bp b/configstore/utils/Android.bp
index a4cad66..93e52f1 100644
--- a/configstore/utils/Android.bp
+++ b/configstore/utils/Android.bp
@@ -17,6 +17,9 @@
cc_library_shared {
name: "android.hardware.configstore-utils",
vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
defaults: ["hidl_defaults"],
srcs: [ "ConfigStoreUtils.cpp" ],
diff --git a/contexthub/1.0/vts/functional/Android.bp b/contexthub/1.0/vts/functional/Android.bp
index c35386d..7c6e8c7 100644
--- a/contexthub/1.0/vts/functional/Android.bp
+++ b/contexthub/1.0/vts/functional/Android.bp
@@ -16,19 +16,8 @@
cc_test {
name: "VtsHalContexthubV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalContexthubV1_0TargetTest.cpp"],
- shared_libs: [
- "liblog",
- "libhidlbase",
- "libhidltransport",
- "libutils",
- "android.hardware.contexthub@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.contexthub@1.0"],
}
diff --git a/current.txt b/current.txt
index c152bb1..0828c6e 100644
--- a/current.txt
+++ b/current.txt
@@ -189,4 +189,7 @@
# ABI preserving changes to HALs released in Android O
-28e929b453df3d9f5060af2764e6cdb123ddb893e3e86923c877f6ff7e5f02c9 android.hardware.wifi@1.0::types
\ No newline at end of file
+28e929b453df3d9f5060af2764e6cdb123ddb893e3e86923c877f6ff7e5f02c9 android.hardware.wifi@1.0::types
+
+# HALs released in Android O MR1 (Final Set)
+0a159f81359cd4f71bbe00972ee8403ea79351fb7c0cd48be72ebb3e424dbaef android.hardware.radio@1.0::types
diff --git a/drm/1.0/Android.bp b/drm/1.0/Android.bp
index d004b82..096aa06 100644
--- a/drm/1.0/Android.bp
+++ b/drm/1.0/Android.bp
@@ -92,3 +92,5 @@
"libutils",
],
}
+
+subdirs = ["default"]
diff --git a/drm/1.0/default/Android.bp b/drm/1.0/default/Android.bp
new file mode 100644
index 0000000..ed6bcde
--- /dev/null
+++ b/drm/1.0/default/Android.bp
@@ -0,0 +1,23 @@
+cc_library_static {
+ name: "android.hardware.drm@1.0-helper",
+ vendor_available: true,
+ defaults: ["hidl_defaults"],
+ srcs: [
+ "SharedLibrary.cpp",
+ ],
+ cflags: [
+ "-Werror",
+ "-Wextra",
+ "-Wall",
+ ],
+ shared_libs: [
+ "liblog",
+ ],
+ header_libs: [
+ "libutils_headers",
+ ],
+ export_header_lib_headers: [
+ "libutils_headers",
+ ],
+ export_include_dirs : ["include"]
+}
diff --git a/drm/1.0/default/Android.mk b/drm/1.0/default/Android.mk
index 4c05da8..0cc6e71 100644
--- a/drm/1.0/default/Android.mk
+++ b/drm/1.0/default/Android.mk
@@ -36,6 +36,9 @@
libutils \
libbinder \
+LOCAL_STATIC_LIBRARIES := \
+ android.hardware.drm@1.0-helper \
+
LOCAL_C_INCLUDES := \
hardware/interfaces/drm
@@ -71,10 +74,12 @@
libhidlmemory \
libhidltransport \
liblog \
- libmediadrm \
libstagefright_foundation \
libutils \
+LOCAL_STATIC_LIBRARIES := \
+ android.hardware.drm@1.0-helper \
+
LOCAL_C_INCLUDES := \
frameworks/native/include \
frameworks/av/include
diff --git a/drm/1.0/default/CryptoFactory.h b/drm/1.0/default/CryptoFactory.h
index 412b557..6b1d1ff 100644
--- a/drm/1.0/default/CryptoFactory.h
+++ b/drm/1.0/default/CryptoFactory.h
@@ -19,7 +19,7 @@
#include <android/hardware/drm/1.0/ICryptoFactory.h>
#include <hidl/Status.h>
#include <media/hardware/CryptoAPI.h>
-#include <media/PluginLoader.h>
+#include <PluginLoader.h>
#include <media/SharedLibrary.h>
namespace android {
@@ -28,6 +28,7 @@
namespace V1_0 {
namespace implementation {
+using ::android::hardware::drm::V1_0::helper::PluginLoader;
using ::android::hardware::drm::V1_0::ICryptoFactory;
using ::android::hardware::drm::V1_0::ICryptoPlugin;
using ::android::hardware::hidl_array;
@@ -51,7 +52,7 @@
override;
private:
- android::PluginLoader<android::CryptoFactory> loader;
+ PluginLoader<android::CryptoFactory> loader;
CryptoFactory(const CryptoFactory &) = delete;
void operator=(const CryptoFactory &) = delete;
diff --git a/drm/1.0/default/DrmFactory.h b/drm/1.0/default/DrmFactory.h
index a008844..726bf97 100644
--- a/drm/1.0/default/DrmFactory.h
+++ b/drm/1.0/default/DrmFactory.h
@@ -19,7 +19,7 @@
#include <android/hardware/drm/1.0/IDrmFactory.h>
#include <hidl/Status.h>
#include <media/drm/DrmAPI.h>
-#include <media/PluginLoader.h>
+#include <PluginLoader.h>
#include <media/SharedLibrary.h>
namespace android {
@@ -28,6 +28,7 @@
namespace V1_0 {
namespace implementation {
+using ::android::hardware::drm::V1_0::helper::PluginLoader;
using ::android::hardware::drm::V1_0::IDrmFactory;
using ::android::hardware::drm::V1_0::IDrmPlugin;
using ::android::hardware::hidl_array;
@@ -53,7 +54,7 @@
const hidl_string& appPackageName, createPlugin_cb _hidl_cb) override;
private:
- android::PluginLoader<android::DrmFactory> loader;
+ PluginLoader<android::DrmFactory> loader;
DrmFactory(const DrmFactory &) = delete;
void operator=(const DrmFactory &) = delete;
diff --git a/drm/1.0/vts/functional/shared_library.cpp b/drm/1.0/default/SharedLibrary.cpp
similarity index 82%
rename from drm/1.0/vts/functional/shared_library.cpp
rename to drm/1.0/default/SharedLibrary.cpp
index 6658150..0a942cd 100644
--- a/drm/1.0/vts/functional/shared_library.cpp
+++ b/drm/1.0/default/SharedLibrary.cpp
@@ -14,17 +14,19 @@
* limitations under the License.
*/
-#define LOG_TAG "drm-vts-shared-library"
+
+#include "SharedLibrary.h"
#include <dlfcn.h>
-#include <shared_library.h>
-using std::string;
+namespace android {
+namespace hardware {
+namespace drm {
+namespace V1_0 {
+namespace helper {
-namespace drm_vts {
-
-SharedLibrary::SharedLibrary(const string& path) {
- mLibHandle = dlopen(path.c_str(), RTLD_NOW);
+SharedLibrary::SharedLibrary(const String8& path) {
+ mLibHandle = dlopen(path.string(), RTLD_NOW);
}
SharedLibrary::~SharedLibrary() {
@@ -53,4 +55,9 @@
const char* error = dlerror();
return error ? error : "No errors or unknown error";
}
-};
+
+}
+}
+}
+}
+} // namespace android
diff --git a/drm/1.0/default/include/PluginLoader.h b/drm/1.0/default/include/PluginLoader.h
new file mode 100644
index 0000000..f387b3c
--- /dev/null
+++ b/drm/1.0/default/include/PluginLoader.h
@@ -0,0 +1,107 @@
+/**
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_LOADER_H_
+#define PLUGIN_LOADER_H_
+
+#include "SharedLibrary.h"
+#include <utils/Log.h>
+#include <utils/String8.h>
+#include <utils/Vector.h>
+
+namespace android {
+namespace hardware {
+namespace drm {
+namespace V1_0 {
+namespace helper {
+
+template <class T>
+class PluginLoader {
+
+ public:
+ PluginLoader(const char *dir, const char *entry) {
+ /**
+ * scan all plugins in the plugin directory and add them to the
+ * factories list.
+ */
+ String8 pluginDir(dir);
+
+ DIR* pDir = opendir(pluginDir.string());
+ if (pDir == NULL) {
+ ALOGE("Failed to find plugin directory %s", pluginDir.string());
+ } else {
+ struct dirent* pEntry;
+ while ((pEntry = readdir(pDir))) {
+ String8 file(pEntry->d_name);
+ if (file.getPathExtension() == ".so") {
+ String8 path = pluginDir + "/" + pEntry->d_name;
+ T *plugin = loadOne(path, entry);
+ if (plugin) {
+ factories.push(plugin);
+ }
+ }
+ }
+ closedir(pDir);
+ }
+ }
+
+ ~PluginLoader() {
+ for (size_t i = 0; i < factories.size(); i++) {
+ delete factories[i];
+ }
+ }
+
+ T *getFactory(size_t i) const {
+ return factories[i];
+ }
+
+ size_t factoryCount() const {return factories.size();}
+
+ private:
+ T* loadOne(const char *path, const char *entry) {
+ sp<SharedLibrary> library = new SharedLibrary(String8(path));
+ if (!library.get()) {
+ ALOGE("Failed to open plugin library %s: %s", path,
+ library->lastError());
+ } else {
+ typedef T *(*CreateFactoryFunc)();
+ CreateFactoryFunc createFactoryFunc =
+ (CreateFactoryFunc)library->lookup(entry);
+ if (createFactoryFunc) {
+ ALOGV("Found plugin factory entry %s in %s", entry, path);
+ libraries.push(library);
+ T* result = createFactoryFunc();
+ return result;
+ }
+ }
+ return NULL;
+ }
+
+ Vector<T *> factories;
+ Vector<sp<SharedLibrary> > libraries;
+
+ PluginLoader(const PluginLoader &) = delete;
+ void operator=(const PluginLoader &) = delete;
+};
+
+}
+}
+}
+}
+} // namespace android
+
+#endif // PLUGIN_LOADER_H_
+
diff --git a/drm/1.0/vts/functional/shared_library.h b/drm/1.0/default/include/SharedLibrary.h
similarity index 79%
rename from drm/1.0/vts/functional/shared_library.h
rename to drm/1.0/default/include/SharedLibrary.h
index 1f32243..8e174d0 100644
--- a/drm/1.0/vts/functional/shared_library.h
+++ b/drm/1.0/default/include/SharedLibrary.h
@@ -17,13 +17,18 @@
#ifndef SHARED_LIBRARY_H_
#define SHARED_LIBRARY_H_
-#include <string>
-#include <vector>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
-namespace drm_vts {
-class SharedLibrary {
+namespace android {
+namespace hardware {
+namespace drm {
+namespace V1_0 {
+namespace helper {
+
+class SharedLibrary : public RefBase {
public:
- explicit SharedLibrary(const std::string& path);
+ explicit SharedLibrary(const String8& path);
~SharedLibrary();
bool operator!() const;
@@ -36,6 +41,11 @@
SharedLibrary(const SharedLibrary&) = delete;
void operator=(const SharedLibrary&) = delete;
};
-};
+
+}
+}
+}
+}
+}
#endif // SHARED_LIBRARY_H_
diff --git a/drm/1.0/vts/functional/Android.bp b/drm/1.0/vts/functional/Android.bp
index 43ea372..b45ce84 100644
--- a/drm/1.0/vts/functional/Android.bp
+++ b/drm/1.0/vts/functional/Android.bp
@@ -19,7 +19,6 @@
srcs: [
"drm_hal_clearkey_test.cpp",
"drm_hal_vendor_test.cpp",
- "shared_library.cpp",
"vendor_modules.cpp"
],
shared_libs: [
@@ -39,7 +38,8 @@
"libutils",
],
static_libs: [
- "VtsHalHidlTargetTestBase"
+ "VtsHalHidlTargetTestBase",
+ "android.hardware.drm@1.0-helper",
],
cflags: [
"-O0",
diff --git a/drm/1.0/vts/functional/vendor_modules.cpp b/drm/1.0/vts/functional/vendor_modules.cpp
index 2bf0b28..98430f5 100644
--- a/drm/1.0/vts/functional/vendor_modules.cpp
+++ b/drm/1.0/vts/functional/vendor_modules.cpp
@@ -20,13 +20,16 @@
#include <dlfcn.h>
#include <log/log.h>
#include <memory>
+#include <utils/String8.h>
+#include <SharedLibrary.h>
-#include "shared_library.h"
#include "vendor_modules.h"
using std::string;
using std::vector;
using std::unique_ptr;
+using ::android::String8;
+using ::android::hardware::drm::V1_0::helper::SharedLibrary;
namespace drm_vts {
void VendorModules::scanModules(const std::string &directory) {
@@ -48,7 +51,7 @@
DrmHalVTSVendorModule* VendorModules::getModule(const string& path) {
if (mOpenLibraries.find(path) == mOpenLibraries.end()) {
- auto library = std::make_unique<SharedLibrary>(path);
+ auto library = std::make_unique<SharedLibrary>(String8(path.c_str()));
if (!library) {
ALOGE("failed to map shared library %s", path.c_str());
return NULL;
diff --git a/drm/1.0/vts/functional/vendor_modules.h b/drm/1.0/vts/functional/vendor_modules.h
index ca538f6..8330b0a 100644
--- a/drm/1.0/vts/functional/vendor_modules.h
+++ b/drm/1.0/vts/functional/vendor_modules.h
@@ -18,8 +18,12 @@
#define VENDOR_MODULES_H
#include <map>
+#include <vector>
+#include <string>
-#include "shared_library.h"
+#include <SharedLibrary.h>
+
+using ::android::hardware::drm::V1_0::helper::SharedLibrary;
class DrmHalVTSVendorModule;
diff --git a/gatekeeper/1.0/vts/functional/Android.bp b/gatekeeper/1.0/vts/functional/Android.bp
index 70cb615..aa1da7b 100644
--- a/gatekeeper/1.0/vts/functional/Android.bp
+++ b/gatekeeper/1.0/vts/functional/Android.bp
@@ -16,21 +16,7 @@
cc_test {
name: "VtsHalGatekeeperV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalGatekeeperV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.gatekeeper@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.gatekeeper@1.0"],
}
diff --git a/gnss/1.0/vts/functional/Android.bp b/gnss/1.0/vts/functional/Android.bp
index 6d96059..d7713db 100644
--- a/gnss/1.0/vts/functional/Android.bp
+++ b/gnss/1.0/vts/functional/Android.bp
@@ -16,21 +16,7 @@
cc_test {
name: "VtsHalGnssV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalGnssV1_0TargetTest.cpp"],
- shared_libs: [
- "android.hardware.gnss@1.0",
- "libbase",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "liblog",
- "libnativehelper",
- "libutils",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
-}
\ No newline at end of file
+ static_libs: ["android.hardware.gnss@1.0"],
+}
diff --git a/health/1.0/vts/functional/Android.bp b/health/1.0/vts/functional/Android.bp
index 1a4c8c8..8742651 100644
--- a/health/1.0/vts/functional/Android.bp
+++ b/health/1.0/vts/functional/Android.bp
@@ -16,17 +16,7 @@
cc_test {
name: "VtsHalHealthV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalHealthV1_0TargetTest.cpp"],
- shared_libs: [
- "libhidlbase",
- "liblog",
- "libutils",
- "android.hardware.health@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.health@1.0"],
}
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
index 0558ff2..e0ec4cf 100644
--- a/light/2.0/vts/functional/Android.bp
+++ b/light/2.0/vts/functional/Android.bp
@@ -16,19 +16,8 @@
cc_test {
name: "VtsHalLightV2_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalLightV2_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "libhidlbase",
- "liblog",
- "libutils",
- "android.hardware.light@2.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.light@2.0"],
}
diff --git a/memtrack/1.0/vts/functional/Android.bp b/memtrack/1.0/vts/functional/Android.bp
index 71e6111..2d833e7 100644
--- a/memtrack/1.0/vts/functional/Android.bp
+++ b/memtrack/1.0/vts/functional/Android.bp
@@ -16,20 +16,7 @@
cc_test {
name: "VtsHalMemtrackV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalMemtrackV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhardware",
- "libhidlbase",
- "libutils",
- "android.hardware.memtrack@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.memtrack@1.0"],
}
diff --git a/power/1.0/vts/functional/Android.bp b/power/1.0/vts/functional/Android.bp
index 5ab1eb4..45f74fc 100644
--- a/power/1.0/vts/functional/Android.bp
+++ b/power/1.0/vts/functional/Android.bp
@@ -16,21 +16,7 @@
cc_test {
name: "VtsHalPowerV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalPowerV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.power@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.power@1.0"],
}
diff --git a/radio/1.0/types.hal b/radio/1.0/types.hal
index c5d7f8a..4d22bc0 100644
--- a/radio/1.0/types.hal
+++ b/radio/1.0/types.hal
@@ -1507,8 +1507,8 @@
int32_t lac; // 16-bit Location Area Code, 0..65535, INT_MAX if unknown
int32_t cid; // 16-bit GSM Cell Identity described in
// TS 27.007, 0..65535, INT_MAX if unknown
- int32_t arfcn; // 16-bit GSM Absolute RF channel number, INT_MAX if
- // unknown
+ int32_t arfcn; // 16-bit GSM Absolute RF channel number; this value must
+ // be valid
uint8_t bsic; // 6-bit Base Station Identity Code, 0xFF if unknown
};
@@ -1520,9 +1520,9 @@
int32_t cid; // 28-bit UMTS Cell Identity described in
// TS 25.331, 0..268435455, INT_MAX if unknown
int32_t psc; // 9-bit UMTS Primary Scrambling Code described in
- // TS 25.331, 0..511, INT_MAX if unknown
- int32_t uarfcn; // 16-bit UMTS Absolute RF Channel Number, INT_MAX if
- // unknown
+ // TS 25.331, 0..511; this value must be valid
+ int32_t uarfcn; // 16-bit UMTS Absolute RF Channel Number; this value must
+ // be valid
};
struct CellIdentityCdma {
@@ -1547,10 +1547,10 @@
// unknown
int32_t ci; // 28-bit Cell Identity described in TS TS 27.007, INT_MAX
// if unknown
- int32_t pci; // physical cell id 0..503, INT_MAX if unknown
+ int32_t pci; // physical cell id 0..503; this value must be valid
int32_t tac; // 16-bit tracking area code, INT_MAX if unknown
- int32_t earfcn; // 18-bit LTE Absolute RC Channel Number, INT_MAX if
- // unknown
+ int32_t earfcn; // 18-bit LTE Absolute RF Channel Number; this value must
+ // be valid
};
struct CellIdentityTdscdma {
diff --git a/sensors/1.0/default/OWNERS b/sensors/1.0/default/OWNERS
new file mode 100644
index 0000000..6a38a1f
--- /dev/null
+++ b/sensors/1.0/default/OWNERS
@@ -0,0 +1,2 @@
+ashutoshj@google.com
+pengxu@google.com
diff --git a/sensors/1.0/vts/functional/Android.bp b/sensors/1.0/vts/functional/Android.bp
index af149ba..fb8d22e 100644
--- a/sensors/1.0/vts/functional/Android.bp
+++ b/sensors/1.0/vts/functional/Android.bp
@@ -16,19 +16,15 @@
cc_test {
name: "VtsHalSensorsV1_0TargetTest",
- defaults: ["hidl_defaults"],
- srcs: ["VtsHalSensorsV1_0TargetTest.cpp"],
- shared_libs: [
- "android.hardware.sensors@1.0",
- "libcutils",
- "libhidlbase",
- "liblog",
- "libutils",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: [
+ "GrallocWrapper.cpp",
+ "VtsHalSensorsV1_0TargetTest.cpp"
],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
+ static_libs: [
+ "android.hardware.graphics.allocator@2.0",
+ "android.hardware.graphics.mapper@2.0",
+ "android.hardware.sensors@1.0"
+ ]
}
diff --git a/sensors/1.0/vts/functional/GrallocWrapper.cpp b/sensors/1.0/vts/functional/GrallocWrapper.cpp
new file mode 100644
index 0000000..e422d62
--- /dev/null
+++ b/sensors/1.0/vts/functional/GrallocWrapper.cpp
@@ -0,0 +1,232 @@
+/*
+ * 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 "GrallocWrapper"
+
+#include "GrallocWrapper.h"
+
+#include <utils/Log.h>
+
+namespace android {
+
+GrallocWrapper::GrallocWrapper() { init(); }
+
+void GrallocWrapper::init() {
+ mAllocator = allocator2::IAllocator::getService();
+ if (mAllocator == nullptr) {
+ ALOGE("Failed to get allocator service");
+ }
+
+ mMapper = mapper2::IMapper::getService();
+ if (mMapper == nullptr) {
+ ALOGE("Failed to get mapper service");
+ }
+ if (mMapper->isRemote()) {
+ ALOGE("Mapper is not in passthrough mode");
+ }
+}
+
+GrallocWrapper::~GrallocWrapper() {
+ for (auto bufferHandle : mClonedBuffers) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+ native_handle_close(buffer);
+ native_handle_delete(buffer);
+ }
+ mClonedBuffers.clear();
+
+ for (auto bufferHandle : mImportedBuffers) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+ if (mMapper->freeBuffer(buffer) != mapper2::Error::NONE) {
+ ALOGE("Failed to free buffer %p", buffer);
+ }
+ }
+ mImportedBuffers.clear();
+}
+
+sp<allocator2::IAllocator> GrallocWrapper::getAllocator() const {
+ return mAllocator;
+}
+
+std::string GrallocWrapper::dumpDebugInfo() {
+ std::string debugInfo;
+ mAllocator->dumpDebugInfo(
+ [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
+
+ return debugInfo;
+}
+
+const native_handle_t* GrallocWrapper::cloneBuffer(
+ const hardware::hidl_handle& rawHandle) {
+ const native_handle_t* bufferHandle =
+ native_handle_clone(rawHandle.getNativeHandle());
+
+ if (bufferHandle) {
+ mClonedBuffers.insert(bufferHandle);
+ }
+ return bufferHandle;
+}
+
+std::vector<const native_handle_t*> GrallocWrapper::allocate(
+ const mapper2::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) {
+ if (mapper2::Error::NONE != tmpError) {
+ ALOGE("Failed to allocate buffers");
+ }
+ if (count != tmpBuffers.size()) {
+ ALOGE("Invalid buffer array");
+ }
+
+ for (uint32_t i = 0; i < count; i++) {
+ if (import) {
+ bufferHandles.push_back(importBuffer(tmpBuffers[i]));
+ } else {
+ bufferHandles.push_back(cloneBuffer(tmpBuffers[i]));
+ }
+ }
+
+ if (outStride) {
+ *outStride = tmpStride;
+ }
+ });
+
+ return bufferHandles;
+}
+
+const native_handle_t* GrallocWrapper::allocate(
+ const mapper2::IMapper::BufferDescriptorInfo& descriptorInfo, bool import,
+ uint32_t* outStride) {
+ mapper2::BufferDescriptor descriptor = createDescriptor(descriptorInfo);
+ ALOGE("QQ");
+ auto buffers = allocate(descriptor, 1, import, outStride);
+ return buffers[0];
+}
+
+sp<mapper2::IMapper> GrallocWrapper::getMapper() const { return mMapper; }
+
+mapper2::BufferDescriptor GrallocWrapper::createDescriptor(
+ const mapper2::IMapper::BufferDescriptorInfo& descriptorInfo) {
+ mapper2::BufferDescriptor descriptor;
+ mMapper->createDescriptor(
+ descriptorInfo, [&](const auto& tmpError, const auto& tmpDescriptor) {
+ if (tmpError != mapper2::Error::NONE) {
+ ALOGE("Failed to create descriptor");
+ }
+ descriptor = tmpDescriptor;
+ });
+
+ return descriptor;
+}
+
+const native_handle_t* GrallocWrapper::importBuffer(
+ const hardware::hidl_handle& rawHandle) {
+ const native_handle_t* bufferHandle = nullptr;
+ mMapper->importBuffer(
+ rawHandle, [&](const auto& tmpError, const auto& tmpBuffer) {
+ if (tmpError != mapper2::Error::NONE) {
+ ALOGE("Failed to import buffer %p", rawHandle.getNativeHandle());
+ }
+ bufferHandle = static_cast<const native_handle_t*>(tmpBuffer);
+ });
+
+ if (bufferHandle) {
+ mImportedBuffers.insert(bufferHandle);
+ }
+
+ return bufferHandle;
+}
+
+void GrallocWrapper::freeBuffer(const native_handle_t* bufferHandle) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+
+ if (mImportedBuffers.erase(bufferHandle)) {
+ mapper2::Error error = mMapper->freeBuffer(buffer);
+ if (error != mapper2::Error::NONE) {
+ ALOGE("Failed to free %p", buffer);
+ }
+ } else {
+ mClonedBuffers.erase(bufferHandle);
+ native_handle_close(buffer);
+ native_handle_delete(buffer);
+ }
+}
+
+void* GrallocWrapper::lock(const native_handle_t* bufferHandle,
+ uint64_t cpuUsage,
+ const mapper2::IMapper::Rect& accessRegion,
+ int acquireFence) {
+ auto buffer = const_cast<native_handle_t*>(bufferHandle);
+
+ NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 1, 0);
+ hardware::hidl_handle acquireFenceHandle;
+ if (acquireFence >= 0) {
+ auto h = native_handle_init(acquireFenceStorage, 1, 0);
+ h->data[0] = acquireFence;
+ acquireFenceHandle = h;
+ }
+
+ void* data = nullptr;
+ mMapper->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpData) {
+ if (tmpError != mapper2::Error::NONE) {
+ ALOGE("Failed to lock buffer %p", buffer);
+ }
+ data = tmpData;
+ });
+
+ if (acquireFence >= 0) {
+ close(acquireFence);
+ }
+
+ return data;
+}
+
+int GrallocWrapper::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) {
+ if (tmpError != mapper2::Error::NONE) {
+ ALOGE("Failed to unlock buffer %p", buffer);
+ }
+
+ auto fenceHandle = tmpReleaseFence.getNativeHandle();
+ if (fenceHandle) {
+ if (fenceHandle->numInts != 0) {
+ ALOGE("Invalid fence handle %p", fenceHandle);
+ }
+ if (fenceHandle->numFds == 1) {
+ releaseFence = dup(fenceHandle->data[0]);
+ if (releaseFence < 0){
+ ALOGE("Failed to dup fence fd");
+ }
+ } else {
+ if (fenceHandle->numFds != 0) {
+ ALOGE("Invalid fence handle %p", fenceHandle);
+ }
+ }
+ }
+ });
+
+ return releaseFence;
+}
+
+} // namespace android
diff --git a/sensors/1.0/vts/functional/GrallocWrapper.h b/sensors/1.0/vts/functional/GrallocWrapper.h
new file mode 100644
index 0000000..e506fe1
--- /dev/null
+++ b/sensors/1.0/vts/functional/GrallocWrapper.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GRALLO_WRAPPER_H_
+#define GRALLO_WRAPPER_H_
+
+#include <unordered_set>
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+
+namespace allocator2 = ::android::hardware::graphics::allocator::V2_0;
+namespace mapper2 = ::android::hardware::graphics::mapper::V2_0;
+
+namespace android {
+
+// Modified from hardware/interfaces/graphics/mapper/2.0/vts/functional/
+class GrallocWrapper {
+ public:
+ GrallocWrapper();
+ ~GrallocWrapper();
+
+ sp<allocator2::IAllocator> getAllocator() const;
+ sp<mapper2::IMapper> getMapper() const;
+
+ std::string dumpDebugInfo();
+
+ // 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 mapper2::BufferDescriptor& descriptor, uint32_t count, bool import = true,
+ uint32_t* outStride = nullptr);
+ const native_handle_t* allocate(
+ const mapper2::IMapper::BufferDescriptorInfo& descriptorInfo, bool import = true,
+ uint32_t* outStride = nullptr);
+
+ mapper2::BufferDescriptor createDescriptor(
+ const mapper2::IMapper::BufferDescriptorInfo& descriptorInfo);
+
+ const native_handle_t* importBuffer(const hardware::hidl_handle& rawHandle);
+ void freeBuffer(const native_handle_t* bufferHandle);
+
+ // We use fd instead of hardware::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 mapper2::IMapper::Rect& accessRegion, int acquireFence);
+
+ int unlock(const native_handle_t* bufferHandle);
+
+ private:
+ void init();
+ const native_handle_t* cloneBuffer(const hardware::hidl_handle& rawHandle);
+
+ sp<allocator2::IAllocator> mAllocator;
+ sp<mapper2::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 android
+#endif // GRALLO_WRAPPER_H_
diff --git a/sensors/1.0/vts/functional/OWNERS b/sensors/1.0/vts/functional/OWNERS
new file mode 100644
index 0000000..8715e5d
--- /dev/null
+++ b/sensors/1.0/vts/functional/OWNERS
@@ -0,0 +1,7 @@
+# Sensors team
+ashutoshj@google.com
+pengxu@google.com
+
+# VTS team
+trong@google.com
+yim@google.com
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
index 4842946..19265c2 100644
--- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
+++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "sensors_hidl_hal_test"
+#include "GrallocWrapper.h"
#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <android/hardware/sensors/1.0/ISensors.h>
@@ -36,6 +37,7 @@
#include <sys/mman.h>
#include <unistd.h>
+using ::android::GrallocWrapper;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_string;
@@ -230,6 +232,7 @@
native_handle_t* mNativeHandle;
size_t mSize;
char* mBuffer;
+ std::unique_ptr<GrallocWrapper> mGrallocWrapper;
DISALLOW_COPY_AND_ASSIGN(SensorsTestSharedMemory);
};
@@ -265,6 +268,7 @@
while (offset + kEventSize <= mSize) {
int64_t atomicCounter = *reinterpret_cast<uint32_t *>(mBuffer + offset + kOffsetAtomicCounter);
if (atomicCounter <= lastCounter) {
+ ALOGV("atomicCounter = %" PRId64 ", lastCounter = %" PRId64, atomicCounter, lastCounter);
break;
}
@@ -324,7 +328,34 @@
break;
}
case SharedMemType::GRALLOC: {
+ mGrallocWrapper = std::make_unique<GrallocWrapper>();
+ if (mGrallocWrapper->getAllocator() == nullptr || mGrallocWrapper->getMapper() == nullptr) {
+ break;
+ }
+ using android::hardware::graphics::common::V1_0::BufferUsage;
+ using android::hardware::graphics::common::V1_0::PixelFormat;
+ mapper2::IMapper::BufferDescriptorInfo buf_desc_info = {
+ .width = static_cast<uint32_t>(size),
+ .height = 1,
+ .layerCount = 1,
+ .usage = static_cast<uint64_t> (BufferUsage::SENSOR_DIRECT_DATA |
+ BufferUsage::CPU_READ_OFTEN),
+ .format = PixelFormat::BLOB
+ };
+ handle = const_cast<native_handle_t *>(mGrallocWrapper->allocate(buf_desc_info));
+ if (handle != nullptr) {
+ mapper2::IMapper::Rect region{0, 0,
+ static_cast<int32_t>(buf_desc_info.width),
+ static_cast<int32_t>(buf_desc_info.height)};
+ buffer = static_cast<char *>
+ (mGrallocWrapper->lock(handle, buf_desc_info.usage, region, /*fence=*/-1));
+ if (buffer != nullptr) {
+ break;
+ }
+ mGrallocWrapper->freeBuffer(handle);
+ handle = nullptr;
+ }
break;
}
default:
@@ -353,6 +384,16 @@
}
break;
}
+ case SharedMemType::GRALLOC: {
+ if (mSize != 0) {
+ mGrallocWrapper->unlock(mNativeHandle);
+ mGrallocWrapper->freeBuffer(mNativeHandle);
+
+ mNativeHandle = nullptr;
+ mSize = 0;
+ }
+ break;
+ }
default: {
if (mNativeHandle != nullptr || mSize != 0 || mBuffer != nullptr) {
ALOGE("SensorsTestSharedMemory %p not properly destructed: "
@@ -1223,7 +1264,7 @@
void SensorsHidlTest::testDirectReportOperation(
SensorType type, SharedMemType memType, RateLevel rate, const SensorEventsChecker &checker) {
constexpr size_t kEventSize = static_cast<size_t>(SensorsEventFormatOffset::TOTAL_LENGTH);
- constexpr size_t kNEvent = 500;
+ constexpr size_t kNEvent = 4096;
constexpr size_t kMemSize = kEventSize * kNEvent;
constexpr float kNormalNominal = 50;
@@ -1379,6 +1420,60 @@
SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::VERY_FAST, NullChecker());
}
+// Test sensor event direct report with gralloc for accel sensor at normal rate
+TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationNormal) {
+ testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::NORMAL,
+ sAccelNormChecker);
+}
+
+// Test sensor event direct report with gralloc for accel sensor at fast rate
+TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationFast) {
+ testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::FAST,
+ sAccelNormChecker);
+}
+
+// Test sensor event direct report with gralloc for accel sensor at very fast rate
+TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationVeryFast) {
+ testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::VERY_FAST,
+ sAccelNormChecker);
+}
+
+// Test sensor event direct report with gralloc for gyro sensor at normal rate
+TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationNormal) {
+ testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::NORMAL,
+ sGyroNormChecker);
+}
+
+// Test sensor event direct report with gralloc for gyro sensor at fast rate
+TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationFast) {
+ testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::FAST,
+ sGyroNormChecker);
+}
+
+// Test sensor event direct report with gralloc for gyro sensor at very fast rate
+TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationVeryFast) {
+ testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::VERY_FAST,
+ sGyroNormChecker);
+}
+
+// Test sensor event direct report with gralloc for mag sensor at normal rate
+TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationNormal) {
+ testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::NORMAL,
+ NullChecker());
+}
+
+// Test sensor event direct report with gralloc for mag sensor at fast rate
+TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationFast) {
+ testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::FAST,
+ NullChecker());
+}
+
+// Test sensor event direct report with gralloc for mag sensor at very fast rate
+TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) {
+ testDirectReportOperation(
+ SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::VERY_FAST, NullChecker());
+}
+
int main(int argc, char **argv) {
::testing::AddGlobalTestEnvironment(SensorsHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
diff --git a/soundtrigger/2.0/vts/functional/Android.bp b/soundtrigger/2.0/vts/functional/Android.bp
index 8f0cc4e..be6b3a8 100644
--- a/soundtrigger/2.0/vts/functional/Android.bp
+++ b/soundtrigger/2.0/vts/functional/Android.bp
@@ -16,21 +16,7 @@
cc_test {
name: "VtsHalSoundtriggerV2_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalSoundtriggerV2_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.soundtrigger@2.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
+ static_libs: ["android.hardware.soundtrigger@2.0"],
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 9583bfd..18fc473 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -25,4 +25,6 @@
"pointer/1.0",
"pointer/1.0/default",
"pointer/1.0/default/lib",
+ "trie/1.0",
+ "trie/1.0/default",
]
diff --git a/tests/bar/1.0/.hidl_for_test b/tests/bar/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/bar/1.0/.hidl_for_test
diff --git a/tests/bar/1.0/Android.bp b/tests/bar/1.0/Android.bp
index 2dbfb0f..b6ee042 100644
--- a/tests/bar/1.0/Android.bp
+++ b/tests/bar/1.0/Android.bp
@@ -74,9 +74,6 @@
generated_headers: ["android.hardware.tests.bar@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.bar@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/bar/1.0/IImportRules.hal b/tests/bar/1.0/IImportRules.hal
index db454b0..401c8ad 100644
--- a/tests/bar/1.0/IImportRules.hal
+++ b/tests/bar/1.0/IImportRules.hal
@@ -30,6 +30,7 @@
rule0a(Outer o); // should be resolved to Outer above
rule0a1(IImportRules.Outer o); // should be resolved to Outer above
rule0b(@1.0::IImportRules.Outer o);
+ rule0b1(android.hardware.tests.bar@1.0::IImportRules.Outer o);
rule0c(android.hardware.tests.foo@1.0::Outer o);
rule0d(@1.0::Outer o); // android.hardware.tests.foo@1.0::Outer
rule0e(Outer.Inner o); // should be resolved to Outer above
diff --git a/tests/baz/1.0/.hidl_for_test b/tests/baz/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/baz/1.0/.hidl_for_test
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index cec3039..ef68149 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -67,9 +67,6 @@
generated_headers: ["android.hardware.tests.baz@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.baz@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/expression/1.0/.hidl_for_test b/tests/expression/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/expression/1.0/.hidl_for_test
diff --git a/tests/expression/1.0/Android.bp b/tests/expression/1.0/Android.bp
index 093b660..bc389b0 100644
--- a/tests/expression/1.0/Android.bp
+++ b/tests/expression/1.0/Android.bp
@@ -49,9 +49,6 @@
generated_headers: ["android.hardware.tests.expression@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.expression@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/extension/light/2.0/.hidl_for_test b/tests/extension/light/2.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/extension/light/2.0/.hidl_for_test
diff --git a/tests/extension/light/2.0/Android.bp b/tests/extension/light/2.0/Android.bp
index 52117b4..c5987a7 100644
--- a/tests/extension/light/2.0/Android.bp
+++ b/tests/extension/light/2.0/Android.bp
@@ -46,9 +46,6 @@
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,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/foo/1.0/.hidl_for_test b/tests/foo/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/foo/1.0/.hidl_for_test
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index d0038ab..6387950 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -74,9 +74,6 @@
generated_headers: ["android.hardware.tests.foo@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.foo@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index a43b883..c1ce7b0 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -122,6 +122,28 @@
bitfield<BitField> bf;
};
+ typedef int32_t[5][6][7] multidimArrayOne;
+ typedef multidimArrayOne[8][9][10] multidimArrayTwo;
+ typedef multidimArrayTwo[2][3][4] multidimArrayThree;
+
+ struct InnerTestStruct {};
+ typedef InnerTestStruct InnerTestStructTypedef;
+ struct S1 {
+ struct InnerTestStruct {};
+ InnerTestStructTypedef foo;
+ };
+
+ enum InnerTestEnum : int32_t {
+ VALUE = 0
+ };
+ typedef InnerTestEnum InnerTestEnumTypedef;
+ struct S2 {
+ enum InnerTestEnum : int32_t {
+ VALUE = 1
+ };
+ InnerTestEnumTypedef foo;
+ };
+
doThis(float param);
doThatAndReturnSomething(int64_t param) generates (int32_t result);
doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
diff --git a/tests/hash/1.0/.hidl_for_test b/tests/hash/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/hash/1.0/.hidl_for_test
diff --git a/tests/hash/1.0/Android.bp b/tests/hash/1.0/Android.bp
index 336963e..505a4ad 100644
--- a/tests/hash/1.0/Android.bp
+++ b/tests/hash/1.0/Android.bp
@@ -42,9 +42,6 @@
generated_headers: ["android.hardware.tests.hash@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.hash@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/inheritance/1.0/.hidl_for_test b/tests/inheritance/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/inheritance/1.0/.hidl_for_test
diff --git a/tests/inheritance/1.0/Android.bp b/tests/inheritance/1.0/Android.bp
index a8c0e6c..5d8d53d 100644
--- a/tests/inheritance/1.0/Android.bp
+++ b/tests/inheritance/1.0/Android.bp
@@ -63,9 +63,6 @@
generated_headers: ["android.hardware.tests.inheritance@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.inheritance@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/libhwbinder/1.0/.hidl_for_test b/tests/libhwbinder/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/libhwbinder/1.0/.hidl_for_test
diff --git a/tests/libhwbinder/1.0/Android.bp b/tests/libhwbinder/1.0/Android.bp
index 6132628..338a72b 100644
--- a/tests/libhwbinder/1.0/Android.bp
+++ b/tests/libhwbinder/1.0/Android.bp
@@ -49,9 +49,6 @@
generated_headers: ["android.hardware.tests.libhwbinder@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.libhwbinder@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
index 13f9c18..f1f99a6 100644
--- a/tests/libhwbinder/1.0/default/Android.bp
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -6,9 +6,12 @@
"ScheduleTest.cpp",
],
shared_libs: [
+ "libcutils",
"libhidlbase",
"libhidltransport",
+ "libhwbinder",
+ "liblog",
"libutils",
- "android.hardware.tests.libhwbinder@1.0",
],
+ static_libs: ["android.hardware.tests.libhwbinder@1.0"],
}
diff --git a/tests/libhwbinder/aidl/.hidl_for_test b/tests/libhwbinder/aidl/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/libhwbinder/aidl/.hidl_for_test
diff --git a/tests/memory/1.0/.hidl_for_test b/tests/memory/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/memory/1.0/.hidl_for_test
diff --git a/tests/memory/1.0/Android.bp b/tests/memory/1.0/Android.bp
index c5cc4a0..a753824 100644
--- a/tests/memory/1.0/Android.bp
+++ b/tests/memory/1.0/Android.bp
@@ -42,9 +42,6 @@
generated_headers: ["android.hardware.tests.memory@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.memory@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/msgq/1.0/.hidl_for_test b/tests/msgq/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/msgq/1.0/.hidl_for_test
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index 017e0d4..0937545 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -49,9 +49,6 @@
generated_headers: ["android.hardware.tests.msgq@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.msgq@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/multithread/1.0/.hidl_for_test b/tests/multithread/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/multithread/1.0/.hidl_for_test
diff --git a/tests/multithread/1.0/Android.bp b/tests/multithread/1.0/Android.bp
index 68c19aa..5f4c44c 100644
--- a/tests/multithread/1.0/Android.bp
+++ b/tests/multithread/1.0/Android.bp
@@ -42,9 +42,6 @@
generated_headers: ["android.hardware.tests.multithread@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.multithread@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/pointer/1.0/.hidl_for_test b/tests/pointer/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/pointer/1.0/.hidl_for_test
diff --git a/tests/pointer/1.0/Android.bp b/tests/pointer/1.0/Android.bp
index 55598ca..a765ae7 100644
--- a/tests/pointer/1.0/Android.bp
+++ b/tests/pointer/1.0/Android.bp
@@ -49,9 +49,6 @@
generated_headers: ["android.hardware.tests.pointer@1.0_genc++_headers"],
export_generated_headers: ["android.hardware.tests.pointer@1.0_genc++_headers"],
vendor_available: true,
- vndk: {
- enabled: true,
- },
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/tests/trie/1.0/.hidl_for_test b/tests/trie/1.0/.hidl_for_test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/trie/1.0/.hidl_for_test
diff --git a/tests/trie/1.0/Android.bp b/tests/trie/1.0/Android.bp
new file mode 100644
index 0000000..9e11c3e
--- /dev/null
+++ b/tests/trie/1.0/Android.bp
@@ -0,0 +1,63 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.tests.trie@1.0_hal",
+ srcs: [
+ "types.hal",
+ "ITrie.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.trie@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.trie@1.0",
+ srcs: [
+ ":android.hardware.tests.trie@1.0_hal",
+ ],
+ out: [
+ "android/hardware/tests/trie/1.0/types.cpp",
+ "android/hardware/tests/trie/1.0/TrieAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.trie@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.trie@1.0",
+ srcs: [
+ ":android.hardware.tests.trie@1.0_hal",
+ ],
+ out: [
+ "android/hardware/tests/trie/1.0/types.h",
+ "android/hardware/tests/trie/1.0/hwtypes.h",
+ "android/hardware/tests/trie/1.0/ITrie.h",
+ "android/hardware/tests/trie/1.0/IHwTrie.h",
+ "android/hardware/tests/trie/1.0/BnHwTrie.h",
+ "android/hardware/tests/trie/1.0/BpHwTrie.h",
+ "android/hardware/tests/trie/1.0/BsTrie.h",
+ ],
+}
+
+cc_library {
+ name: "android.hardware.tests.trie@1.0",
+ defaults: ["hidl-module-defaults"],
+ generated_sources: ["android.hardware.tests.trie@1.0_genc++"],
+ generated_headers: ["android.hardware.tests.trie@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.tests.trie@1.0_genc++_headers"],
+ vendor_available: true,
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/tests/trie/1.0/ITrie.hal b/tests/trie/1.0/ITrie.hal
new file mode 100644
index 0000000..5d009ca
--- /dev/null
+++ b/tests/trie/1.0/ITrie.hal
@@ -0,0 +1,23 @@
+/*
+ * 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.tests.trie@1.0;
+
+interface ITrie {
+ newTrie() generates (TrieNode trie);
+ addStrings(TrieNode trie, vec<string> strings) generates (TrieNode trie);
+ containsStrings(TrieNode trie, vec<string> strings) generates (vec<bool> contains);
+};
diff --git a/tests/trie/1.0/default/Android.bp b/tests/trie/1.0/default/Android.bp
new file mode 100644
index 0000000..315c8bb
--- /dev/null
+++ b/tests/trie/1.0/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+ name: "android.hardware.tests.trie@1.0-impl",
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ srcs: [
+ "Trie.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.trie@1.0",
+ ],
+}
diff --git a/tests/trie/1.0/default/Trie.cpp b/tests/trie/1.0/default/Trie.cpp
new file mode 100644
index 0000000..c81c508
--- /dev/null
+++ b/tests/trie/1.0/default/Trie.cpp
@@ -0,0 +1,114 @@
+/*
+ * 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 "hidl_test"
+
+#include "Trie.h"
+#include <android-base/logging.h>
+#include <inttypes.h>
+#include <string>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace trie {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::trie::V1_0::ITrie follow.
+Return<void> Trie::newTrie(newTrie_cb _hidl_cb) {
+ LOG(INFO) << "SERVER(Trie) newTrie()";
+
+ TrieNode ret;
+ ret.isTerminal = false;
+ _hidl_cb(ret);
+ return Void();
+}
+
+Return<void> Trie::addStrings(const TrieNode& trie, const hidl_vec<hidl_string>& strings,
+ addStrings_cb _hidl_cb) {
+ LOG(INFO) << "SERVER(Trie) addStrings(trie, " << strings.size() << " strings)";
+
+ // Make trie modifiable.
+ TrieNode newTrie = trie;
+
+ for (const auto& str : strings) {
+ addString(&newTrie, str);
+ }
+ _hidl_cb(newTrie);
+ return Void();
+}
+
+Return<void> Trie::containsStrings(const TrieNode& trie, const hidl_vec<hidl_string>& strings,
+ containsStrings_cb _hidl_cb) {
+ LOG(INFO) << "SERVER(Trie) containsStrings(trie, " << strings.size() << " strings)";
+
+ std::vector<bool> ret(strings.size());
+ for (size_t i = 0; i != strings.size(); ++i) {
+ ret[i] = containsString(&trie, strings[i]);
+ }
+ _hidl_cb(ret);
+ return Void();
+}
+
+void Trie::addString(TrieNode* trieRoot, const std::string& str) {
+ TrieNode* currNode = trieRoot;
+
+ for (char ch : str) {
+ auto& vec = currNode->next;
+
+ auto it = std::find_if(vec.begin(), vec.end(),
+ [&](const TrieEdge& edge) { return ch == edge.character; });
+
+ if (it == vec.end()) {
+ vec.resize(vec.size() + 1);
+ it = vec.end() - 1;
+ it->character = ch;
+ it->node.isTerminal = false;
+ }
+
+ currNode = &(it->node);
+ }
+
+ currNode->isTerminal = true;
+}
+
+bool Trie::containsString(const TrieNode* trieRoot, const std::string& str) {
+ const TrieNode* currNode = trieRoot;
+
+ for (char ch : str) {
+ const auto& vec = currNode->next;
+
+ auto it = std::find_if(vec.begin(), vec.end(),
+ [&](const TrieEdge& edge) { return ch == edge.character; });
+
+ if (it == vec.end()) return false;
+ currNode = &(it->node);
+ }
+
+ return currNode->isTerminal;
+}
+
+ITrie* HIDL_FETCH_ITrie(const char* /* name */) {
+ return new Trie();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace trie
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/trie/1.0/default/Trie.h b/tests/trie/1.0/default/Trie.h
new file mode 100644
index 0000000..c2ef40b
--- /dev/null
+++ b/tests/trie/1.0/default/Trie.h
@@ -0,0 +1,61 @@
+/*
+ * 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 ANDROID_HARDWARE_TESTS_TRIE_V1_0_TRIE_H
+#define ANDROID_HARDWARE_TESTS_TRIE_V1_0_TRIE_H
+
+#include <android/hardware/tests/trie/1.0/ITrie.h>
+#include <hidl/Status.h>
+
+#include <string>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace trie {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::tests::trie::V1_0::ITrie;
+using ::android::hardware::tests::trie::V1_0::TrieNode;
+
+struct Trie : public ITrie {
+ // Methods from ::android::hardware::tests::trie::V1_0::ITrie follow.
+ virtual Return<void> newTrie(newTrie_cb _hidl_cb) override;
+ virtual Return<void> addStrings(const TrieNode& trie, const hidl_vec<hidl_string>& strings,
+ addStrings_cb _hidl_cb) override;
+ virtual Return<void> containsStrings(const TrieNode& trie, const hidl_vec<hidl_string>& strings,
+ containsStrings_cb _hidl_cb) override;
+
+ private:
+ void addString(TrieNode* trieRoot, const std::string& str);
+ bool containsString(const TrieNode* trieRoot, const std::string& str);
+};
+
+extern "C" ITrie* HIDL_FETCH_ITrie(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace trie
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_TRIE_V1_0_TRIE_H
diff --git a/tests/trie/1.0/types.hal b/tests/trie/1.0/types.hal
new file mode 100644
index 0000000..c626909
--- /dev/null
+++ b/tests/trie/1.0/types.hal
@@ -0,0 +1,51 @@
+/*
+ * 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.tests.trie@1.0;
+
+struct TrieEdge {
+ int8_t character;
+ TrieNode node; // Requires reordering.
+};
+
+struct TrieNode {
+ vec<TrieEdge> next;
+ bool isTerminal;
+};
+
+// Some forward reference tests.
+
+struct A {
+ ref<B> b;
+};
+
+struct B {
+ ref<A> a;
+};
+
+typedef ref<S> refS;
+struct S {
+ refS f;
+};
+
+enum E2 : E1 {
+ ACCEPT,
+};
+
+enum E1 : int32_t {
+ OK = E2:ACCEPT + ANOTHER,
+ ANOTHER = 100,
+};
diff --git a/thermal/1.0/vts/functional/Android.bp b/thermal/1.0/vts/functional/Android.bp
index 9046882..f661f1e 100644
--- a/thermal/1.0/vts/functional/Android.bp
+++ b/thermal/1.0/vts/functional/Android.bp
@@ -16,22 +16,8 @@
cc_test {
name: "VtsHalThermalV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalThermalV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.thermal@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
+ static_libs: ["android.hardware.thermal@1.0"],
}
diff --git a/tv/input/1.0/vts/functional/Android.bp b/tv/input/1.0/vts/functional/Android.bp
index c862429..978830c 100644
--- a/tv/input/1.0/vts/functional/Android.bp
+++ b/tv/input/1.0/vts/functional/Android.bp
@@ -16,22 +16,8 @@
cc_test {
name: "VtsHalTvInputV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalTvInputV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.tv.input@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.tv.input@1.0"],
}
diff --git a/usb/1.0/vts/functional/Android.bp b/usb/1.0/vts/functional/Android.bp
index 7438bc7..96d3c0e 100644
--- a/usb/1.0/vts/functional/Android.bp
+++ b/usb/1.0/vts/functional/Android.bp
@@ -16,21 +16,7 @@
cc_test {
name: "VtsHalUsbV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalUsbV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "android.hardware.usb@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
+ static_libs: ["android.hardware.usb@1.0"],
}
diff --git a/vibrator/1.0/vts/functional/Android.bp b/vibrator/1.0/vts/functional/Android.bp
index 9e25def..016d627 100644
--- a/vibrator/1.0/vts/functional/Android.bp
+++ b/vibrator/1.0/vts/functional/Android.bp
@@ -16,19 +16,8 @@
cc_test {
name: "VtsHalVibratorV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalVibratorV1_0TargetTest.cpp"],
- shared_libs: [
- "libbase",
- "libhidlbase",
- "liblog",
- "libutils",
- "android.hardware.vibrator@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ],
+ static_libs: ["android.hardware.vibrator@1.0"],
}
diff --git a/vr/1.0/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp
index 5d5a99a..4029137 100644
--- a/vr/1.0/vts/functional/Android.bp
+++ b/vr/1.0/vts/functional/Android.bp
@@ -16,17 +16,7 @@
cc_test {
name: "VtsHalVrV1_0TargetTest",
- defaults: ["hidl_defaults"],
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalVrV1_0TargetTest.cpp"],
- shared_libs: [
- "liblog",
- "libhidlbase",
- "libutils",
- "android.hardware.vr@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
- ]
+ static_libs: ["android.hardware.vr@1.0"],
}