diff --git a/modules/sensors/dynamic_sensor/Android.bp b/modules/sensors/dynamic_sensor/Android.bp index bad60481..890da82d 100644 --- a/modules/sensors/dynamic_sensor/Android.bp +++ b/modules/sensors/dynamic_sensor/Android.bp @@ -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", + ], +} diff --git a/modules/sensors/dynamic_sensor/test/HidRawDeviceTest.cpp b/modules/sensors/dynamic_sensor/test/HidRawDeviceTest.cpp index 2a68e39a..7522ca75 100644 --- a/modules/sensors/dynamic_sensor/test/HidRawDeviceTest.cpp +++ b/modules/sensors/dynamic_sensor/test/HidRawDeviceTest.cpp @@ -38,8 +38,7 @@ public: std::unordered_set interestedUsage{ ACCELEROMETER_3D, GYROMETER_3D, COMPASS_3D, CUSTOM}; - SP(HidRawDevice) device = - std::make_shared(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( - 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;