Enable views to be placed in windowless surfaces.

For purposes of parcelling SurfaceControl to embed view hierarchies across
processes. We also want these Surfaces to receive input, but we can't
let the clients call setInputWindowInfo directly (or we could have issues
with clients stealing focus, etc...) and so we provide a method
blessInputSurface which has the WM configure a surface for input with
a minimal and safe set of parameters.

Test: WindowlessWmTests
Bug: 111373437
Bug: 134365580
Change-Id: I45fde62ba9b810e783d62c4dd5442abd038734d5
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 8d1cc71..9f8f265 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -612,4 +612,16 @@
     boolean hasAlertWindowSurfaces() {
         return !mAlertWindowSurfaces.isEmpty();
     }
+
+    public void blessInputSurface(int displayId, SurfaceControl surface,
+            InputChannel outInputChannel) {
+        final int callerUid = Binder.getCallingUid();
+        final int callerPid = Binder.getCallingPid();
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mService.blessInputSurface(callerUid, callerPid, displayId, surface, outInputChannel);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
 }