summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiarhei Vishniakou <svv@google.com>2022-07-19 22:12:05 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-07-19 22:12:05 +0000
commitc86fa0e7cca3a6901b98674d4644720e9d652b74 (patch)
treecba35c3c6ab9d65dd7cc6b45eedbf9d5d2d05ea3
parent6d2a2555af19fa548744462624db938c36756d75 (diff)
parent5c279324d6f4f6d1b66abfe63ae4d1a9ab7b9035 (diff)
downloadlibpalmrejection-c86fa0e7cca3a6901b98674d4644720e9d652b74.tar.gz
Compile libpalmrejection and tests for the host am: 5c279324d6
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/libpalmrejection/+/19221361 Change-Id: I79a0c37d4990bed18109751431d957d717ecc6a6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--Android.bp26
-rw-r--r--ui/events/ozone/evdev/touch_evdev_types.h4
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc12
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h6
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h2
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc8
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.cc2
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h8
-rw-r--r--ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util_unittest.cc20
-rw-r--r--ui/events/ozone/evdev/touch_filter/palm_detection_filter.h2
10 files changed, 57 insertions, 33 deletions
diff --git a/Android.bp b/Android.bp
index 73c6a92..9d4abd8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -47,6 +47,17 @@ cc_library_static {
sanitize: {
misc_undefined: ["bounds"],
},
+ host_supported: true,
+ target: {
+ host: {
+ include_dirs: [
+ "bionic/libc/kernel/uapi",
+ ],
+ cflags: [
+ "-D__ANDROID_HOST__",
+ ],
+ },
+ },
}
cc_test {
@@ -60,7 +71,6 @@ cc_test {
"libbase",
"libchrome",
],
-
static_libs: [
"libc++fs",
"libgmock",
@@ -80,5 +90,19 @@ cc_test {
sanitize: {
misc_undefined: ["bounds"],
},
+ host_supported: true,
+ target: {
+ host: {
+ include_dirs: [
+ "bionic/libc/kernel/uapi",
+ ],
+ cflags: [
+ "-D__ANDROID_HOST__",
+ ],
+ },
+ },
+ test_options: {
+ unit_test: true,
+ },
test_suites: ["device-tests"],
}
diff --git a/ui/events/ozone/evdev/touch_evdev_types.h b/ui/events/ozone/evdev/touch_evdev_types.h
index 26106bb..9ad9a29 100644
--- a/ui/events/ozone/evdev/touch_evdev_types.h
+++ b/ui/events/ozone/evdev/touch_evdev_types.h
@@ -5,7 +5,7 @@
#ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_EVDEV_TYPES_H_
#define UI_EVENTS_OZONE_EVDEV_TOUCH_EVDEV_TYPES_H_
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
#include <compare>
#endif
#include <stddef.h>
@@ -25,7 +25,7 @@ struct COMPONENT_EXPORT(EVDEV) InProgressTouchEvdev {
InProgressTouchEvdev(const InProgressTouchEvdev& other);
~InProgressTouchEvdev();
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
auto operator<=>(const InProgressTouchEvdev&) const = default;
#endif
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc
index 9896280..c1d8b28 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc
@@ -18,12 +18,12 @@
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/values.h"
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
#include "ui/events/ozone/evdev/event_device_info.h"
#endif
#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h"
#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h"
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
#include "ui/events/ozone/features.h"
#else
#include <linux/input-event-codes.h>
@@ -39,7 +39,7 @@ float EuclideanDistance(const gfx::PointF& a, const gfx::PointF& b) {
} // namespace
NeuralStylusPalmDetectionFilter::NeuralStylusPalmDetectionFilter(
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
const EventDeviceInfo& devinfo,
#else
PalmFilterDeviceInfo palm_filter_device_info,
@@ -48,13 +48,13 @@ NeuralStylusPalmDetectionFilter::NeuralStylusPalmDetectionFilter(
SharedPalmDetectionFilterState* shared_palm_state)
: PalmDetectionFilter(shared_palm_state),
tracking_ids_count_within_session_(0),
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
palm_filter_dev_info_(CreatePalmFilterDeviceInfo(devinfo)),
#else
palm_filter_dev_info_(palm_filter_device_info),
#endif
model_(std::move(palm_model)) {
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
DCHECK(CompatibleWithNeuralStylusPalmDetectionFilter(devinfo))
<< "One should run compatible check before instantiation.";
#endif
@@ -419,7 +419,7 @@ std::string NeuralStylusPalmDetectionFilter::FilterNameForTesting() const {
return kFilterName;
}
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
bool NeuralStylusPalmDetectionFilter::
CompatibleWithNeuralStylusPalmDetectionFilter(
const EventDeviceInfo& devinfo) {
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h
index 87c2bf4..4dbec0b 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h
@@ -15,7 +15,7 @@
#include <vector>
#include "base/time/time.h"
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
#include "ui/events/ozone/evdev/event_device_info.h"
#endif
#include "ui/events/ozone/evdev/touch_evdev_types.h"
@@ -35,7 +35,7 @@ class COMPONENT_EXPORT(EVDEV) NeuralStylusPalmDetectionFilter
public:
// Takes ownership of the model.
NeuralStylusPalmDetectionFilter(
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
const EventDeviceInfo& devinfo,
#else
PalmFilterDeviceInfo palm_filter_device_info,
@@ -53,7 +53,7 @@ class COMPONENT_EXPORT(EVDEV) NeuralStylusPalmDetectionFilter
base::TimeTicks time,
std::bitset<kNumTouchEvdevSlots>* slots_to_hold,
std::bitset<kNumTouchEvdevSlots>* slots_to_suppress) override;
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
static bool CompatibleWithNeuralStylusPalmDetectionFilter(
const EventDeviceInfo& devinfo);
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h
index bc01005..30a35ad 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h
@@ -5,7 +5,7 @@
#ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_NEURAL_STYLUS_PALM_DETECTION_FILTER_MODEL_H_
#define UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_NEURAL_STYLUS_PALM_DETECTION_FILTER_MODEL_H_
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
#include "chrome_to_android_compatibility.h"
#endif
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc
index f3e834d..a3e7c7d 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc
@@ -11,7 +11,7 @@
#include "base/test/gtest_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
#include "ui/events/ozone/evdev/event_device_test_util.h"
#else
#include "chrome_to_android_compatibility_test_support.h"
@@ -51,7 +51,7 @@ class NeuralStylusPalmDetectionFilterTest : public testing::Test {
EXPECT_CALL(*model_, config())
.Times(testing::AnyNumber())
.WillRepeatedly(testing::ReturnRef(model_config_));
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
EXPECT_TRUE(
CapabilitiesToDeviceInfo(kNocturneTouchScreen, &nocturne_touchscreen_));
palm_detection_filter_ = std::make_unique<NeuralStylusPalmDetectionFilter>(
@@ -80,7 +80,7 @@ class NeuralStylusPalmDetectionFilterTest : public testing::Test {
protected:
std::vector<InProgressTouchEvdev> touch_;
std::unique_ptr<SharedPalmDetectionFilterState> shared_palm_state;
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
EventDeviceInfo nocturne_touchscreen_;
#endif
// Owned by the filter.
@@ -92,7 +92,7 @@ class NeuralStylusPalmDetectionFilterTest : public testing::Test {
class NeuralStylusPalmDetectionFilterDeathTest
: public NeuralStylusPalmDetectionFilterTest {};
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
TEST_F(NeuralStylusPalmDetectionFilterTest, EventDeviceSimpleTest) {
EventDeviceInfo devinfo;
std::vector<std::pair<DeviceCapabilities, bool>> devices = {
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.cc b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.cc
index 978bb63..b369ece 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.cc
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.cc
@@ -8,7 +8,7 @@
namespace ui {
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
PalmFilterDeviceInfo CreatePalmFilterDeviceInfo(
const EventDeviceInfo& devinfo) {
PalmFilterDeviceInfo info;
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h
index 51fee54..0052364 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h
@@ -9,12 +9,12 @@
#include <deque>
#include <vector>
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
#undef LOG_INFO
#undef LOG_WARNING
#endif
#include "base/time/time.h"
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
#include "ui/events/ozone/evdev/event_device_info.h"
#endif
#include "ui/events/ozone/evdev/touch_evdev_types.h"
@@ -31,12 +31,12 @@ struct COMPONENT_EXPORT(EVDEV) PalmFilterDeviceInfo {
float major_radius_res = 1.f;
float minor_radius_res = 1.f;
bool minor_radius_supported = false;
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
auto operator<=>(const PalmFilterDeviceInfo&) const = default;
#endif
};
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
COMPONENT_EXPORT(EVDEV)
PalmFilterDeviceInfo CreatePalmFilterDeviceInfo(const EventDeviceInfo& devinfo);
#endif
diff --git a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util_unittest.cc b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util_unittest.cc
index cc95f7c..18b4d15 100644
--- a/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util_unittest.cc
+++ b/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util_unittest.cc
@@ -10,7 +10,7 @@
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
#include <linux/input-event-codes.h>
#include "chrome_to_android_compatibility_test_support.h"
#else
@@ -22,7 +22,7 @@
namespace ui {
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
/**
* The tests that require an actual device (something that responds to ioctls)
* have been removed. The rest of the tests were simplified by modifying the
@@ -157,7 +157,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, DistillerKohakuTest) {
ASSERT_TRUE(
CapabilitiesToDeviceInfo(kKohakuTouchscreen, &kohaku_touchscreen));
const PalmFilterDeviceInfo kohaku_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(kohaku_touchscreen);
#else
CreatePalmFilterDeviceInfo(kKohakuTouchscreen);
@@ -171,7 +171,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, DistilledLinkTest) {
EventDeviceInfo link_touchscreen;
ASSERT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen, &link_touchscreen));
const PalmFilterDeviceInfo link_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(link_touchscreen);
#else
CreatePalmFilterDeviceInfo(kLinkTouchscreen);
@@ -185,7 +185,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, DistilledLinkTest) {
TEST_P(NeuralStylusPalmDetectionFilterUtilTest, PalmFilterSampleTest) {
base::TimeTicks time = base::TimeTicks() + base::Seconds(30);
const PalmFilterDeviceInfo nocturne_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(nocturne_touchscreen_);
#else
CreatePalmFilterDeviceInfo(kNocturneTouchScreen);
@@ -206,7 +206,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, LinkTouchscreenSampleTest) {
base::TimeTicks time = base::TimeTicks() + base::Seconds(30);
ASSERT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen, &link_touchscreen));
const PalmFilterDeviceInfo link_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(link_touchscreen);
#else
CreatePalmFilterDeviceInfo(kLinkTouchscreen);
@@ -229,7 +229,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, PalmFilterStrokeTest) {
base::TimeTicks time = base::TimeTicks() + base::Seconds(30);
const PalmFilterDeviceInfo nocturne_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(nocturne_touchscreen_);
#else
CreatePalmFilterDeviceInfo(kNocturneTouchScreen);
@@ -272,7 +272,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest,
base::TimeTicks time = base::TimeTicks() + base::Seconds(30);
const PalmFilterDeviceInfo nocturne_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(nocturne_touchscreen_);
#else
CreatePalmFilterDeviceInfo(kNocturneTouchScreen);
@@ -319,7 +319,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, StrokeGetMaxMajorTest) {
EXPECT_FLOAT_EQ(0, stroke.MaxMajorRadius());
base::TimeTicks time = base::TimeTicks::UnixEpoch() + base::Seconds(30);
const PalmFilterDeviceInfo nocturne_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(nocturne_touchscreen_);
#else
CreatePalmFilterDeviceInfo(kNocturneTouchScreen);
@@ -341,7 +341,7 @@ TEST_P(NeuralStylusPalmDetectionFilterUtilTest, SampleRadiusConversion) {
model_config_.radius_polynomial_resize = {71.3};
base::TimeTicks time = base::TimeTicks::UnixEpoch() + base::Seconds(30);
const PalmFilterDeviceInfo nocturne_distilled =
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
CreatePalmFilterDeviceInfo(nocturne_touchscreen_);
#else
CreatePalmFilterDeviceInfo(kNocturneTouchScreen);
diff --git a/ui/events/ozone/evdev/touch_filter/palm_detection_filter.h b/ui/events/ozone/evdev/touch_filter/palm_detection_filter.h
index 6e72dc1..5cf07e0 100644
--- a/ui/events/ozone/evdev/touch_filter/palm_detection_filter.h
+++ b/ui/events/ozone/evdev/touch_filter/palm_detection_filter.h
@@ -5,7 +5,7 @@
#ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_PALM_DETECTION_FILTER_H_
#define UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_PALM_DETECTION_FILTER_H_
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__ANDROID_HOST__)
#include "chrome_to_android_compatibility.h"
#endif