Merge "HidRawDeviceTest: Enable for device build"

This commit is contained in:
Andy Hung 2023-02-06 20:24:33 +00:00 committed by Gerrit Code Review
commit 698fe8448b
2 changed files with 28 additions and 4 deletions

View file

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