Merge "HidRawDeviceTest: Enable for device build" am: 698fe8448b

Original change: https://android-review.googlesource.com/c/platform/hardware/libhardware/+/2404797

Change-Id: Ie2968a66d2f4961ffd8462874710f7eb37dd99ee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Andy Hung 2023-02-06 21:01:17 +00:00 committed by Automerger Merge Worker
commit f4871891b2
2 changed files with 28 additions and 4 deletions

View file

@ -157,3 +157,28 @@ cc_binary_host {
"test/HidRawDeviceTest.cpp",
],
}
//
// Android device test for HidRawDevice and HidRawSensor
//
// Assuming lunch target 1
// $ cd test
// $ mma -j .
// $ adb push $ANDROID_BUILD_TOP/out/target/product/generic/vendor/bin/hidrawdevice_test /vendor/bin
// $ adb shell hidrawdevice_test /dev/hidraw0
//
cc_binary {
name: "hidrawdevice_test",
defaults: ["dynamic_sensor_defaults"],
srcs: [
"test/HidRawDeviceTest.cpp",
],
cflags: ["-DLOG_TO_CONSOLE=1"],
local_include_dirs: [
"test",
"HidUtils/test",
],
}

View file

@ -38,8 +38,7 @@ public:
std::unordered_set<unsigned int> interestedUsage{
ACCELEROMETER_3D, GYROMETER_3D, COMPASS_3D, CUSTOM};
SP(HidRawDevice) device =
std::make_shared<HidRawDevice>(std::string(devicePath), interestedUsage);
SP(HidRawDevice) device{new HidRawDevice(std::string(devicePath), interestedUsage)};
const HidDevice::HidDeviceInfo &info = device->getDeviceInfo();
LOG_V << "Sizeof descriptor: " << info.descriptor.size() << LOG_ENDL;
@ -69,8 +68,8 @@ public:
// use HidRawSensor to operate the device, pick first digest
//
auto &reportDigest = device->mDigestVector[0];
SP(HidRawSensor) sensor = std::make_shared<HidRawSensor>(
device, reportDigest.fullUsage, reportDigest.packets);
SP(HidRawSensor) sensor{
new HidRawSensor(device, reportDigest.fullUsage, reportDigest.packets)};
if (!sensor->isValid()) {
LOG_E << "Sensor is not valid " << LOG_ENDL;