Run some inputflinger_tests on host

Sometimes, it's convenient to execute the input tests without having a
connected device. This is especially useful when doing cherry-picks of
patch on a cloud device.

Allow input code to build for host, and enable the tests for running on
host.

Bug: 249591924
Test: atest --host --no-bazel-mode -c -m inputflinger_tests
Change-Id: Ib9be6a5fb6c35ffc450e41cb2a5688bfb2c8d01a
diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp
index ddcd51f..4dcbba2 100644
--- a/services/inputflinger/Android.bp
+++ b/services/inputflinger/Android.bp
@@ -41,7 +41,9 @@
         "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
     ],
     sanitize: {
-        misc_undefined: ["bounds"],
+        misc_undefined: [
+            "bounds",
+        ],
     },
     tidy: true,
     tidy_checks: [
@@ -57,11 +59,11 @@
 filegroup {
     name: "libinputflinger_sources",
     srcs: [
-        "InputProcessor.cpp",
         "InputCommonConverter.cpp",
+        "InputManager.cpp",
+        "InputProcessor.cpp",
         "PreferStylusOverTouchBlocker.cpp",
         "UnwantedInteractionBlocker.cpp",
-        "InputManager.cpp",
     ],
 }
 
@@ -77,13 +79,10 @@
         "libcrypto",
         "libcutils",
         "libhidlbase",
-        "libinput",
         "libkll",
         "liblog",
         "libprotobuf-cpp-lite",
         "libstatslog",
-        "libstatspull",
-        "libstatssocket",
         "libutils",
         "server_configurable_flags",
     ],
@@ -92,6 +91,23 @@
         "libpalmrejection",
         "libui-types",
     ],
+    target: {
+        android: {
+            shared_libs: [
+                "libgui",
+                "libinput",
+                "libstatspull",
+                "libstatssocket",
+            ],
+        },
+        host: {
+            static_libs: [
+                "libinput",
+                "libstatspull",
+                "libstatssocket",
+            ],
+        },
+    },
 }
 
 cc_library_shared {
@@ -108,9 +124,8 @@
         // This should consist only of dependencies from inputflinger. Other dependencies should be
         // in cc_defaults so that they are included in the tests.
         "libinputflinger_base",
-        "libinputreporter",
         "libinputreader",
-        "libgui",
+        "libinputreporter",
     ],
     static_libs: [
         "libinputdispatcher",
@@ -130,6 +145,7 @@
 
 cc_library_headers {
     name: "libinputflinger_headers",
+    host_supported: true,
     export_include_dirs: ["include"],
 }
 
@@ -151,17 +167,29 @@
         "libbase",
         "libbinder",
         "libcutils",
-        "libinput",
         "liblog",
         "libutils",
     ],
     header_libs: [
         "libinputflinger_headers",
     ],
+    target: {
+        android: {
+            shared_libs: [
+                "libinput",
+            ],
+        },
+        host: {
+            static_libs: [
+                "libinput",
+            ],
+        },
+    },
 }
 
 cc_library_shared {
     name: "libinputflinger_base",
+    host_supported: true,
     defaults: [
         "inputflinger_defaults",
         "libinputflinger_base_defaults",