Add wallpaper input consumer to WindowManagerService

This is an input consumer similar to the one used when hiding the navbar,
but placed above wallpapers. It might be useful for processing touch
events over "desktop" in freeform MW mode.

Re-landing I9d6d28a624f750ad48fc39f9b149dd1f989cceba after fixing build.

Bug:26688904
Change-Id: I89fdabd9c72cdd4a1d7ca626c33ddc99ddea97f9
diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java
index b702180..eea0e73 100644
--- a/services/core/java/com/android/server/wm/InputMonitor.java
+++ b/services/core/java/com/android/server/wm/InputMonitor.java
@@ -282,6 +282,8 @@
 
         boolean addInputConsumerHandle = mService.mInputConsumer != null;
 
+        boolean addWallpaperInputConsumerHandle = mService.mWallpaperInputConsumer != null;
+
         // Add all windows on the default display.
         final int numDisplays = mService.mDisplayContents.size();
         final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
@@ -302,6 +304,14 @@
                     addInputConsumerHandle = false;
                 }
 
+                if (addWallpaperInputConsumerHandle) {
+                    if (child.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER) {
+                        // Add the wallpaper input consumer above the first wallpaper window.
+                        addInputWindowHandleLw(mService.mWallpaperInputConsumer.mWindowHandle);
+                        addWallpaperInputConsumerHandle = false;
+                    }
+                }
+
                 final int flags = child.mAttrs.flags;
                 final int privateFlags = child.mAttrs.privateFlags;
                 final int type = child.mAttrs.type;
@@ -329,6 +339,11 @@
             }
         }
 
+        if (addWallpaperInputConsumerHandle) {
+            // No wallpaper found, add the wallpaper input consumer at the end.
+            addInputWindowHandleLw(mService.mWallpaperInputConsumer.mWindowHandle);
+        }
+
         // Send windows to native code.
         mService.mInputManager.setInputWindows(mInputWindowHandles);