InputDispatcher: Assert that all spy windows are trusted overlays

Bug: 162194035
Test: atest inputflinger_tests
Change-Id: I6491a08ff4403db685562a37694d37e0f51581f6
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 98a73d4..bd0c6b2 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4718,6 +4718,11 @@
             window->releaseChannel();
         }
 
+        // Ensure all spy windows are trusted overlays
+        LOG_ALWAYS_FATAL_IF(info.isSpy() && !info.trustedOverlay,
+                            "%s has feature SPY, but is not a trusted overlay.",
+                            window->getName().c_str());
+
         // Ensure all stylus interceptors are trusted overlays
         LOG_ALWAYS_FATAL_IF(info.interceptsStylus() && !info.trustedOverlay,
                             "%s has feature INTERCEPTS_STYLUS, but is not a trusted overlay.",