Fix bug with phantom input windows.

Add dumpsys integration for the native input dispatcher.
Add some InputDevice API stubs.
Add an appendFormat helper method to String8 for printf style
string formatting mainly for debugging purposes.
Use generic ArrayList<WindowState> everywhere in WindowManagerService
to eliminate unnecessary casts all over.

Change-Id: I9d1e3bd90eb7222d10620200477f11b7bfd25e44
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java
index 3c60a98..b4f46ab 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/InputManager.java
@@ -56,8 +56,6 @@
     private final Callbacks mCallbacks;
     private final Context mContext;
     private final WindowManagerService mWindowManagerService;
-    private final PowerManager mPowerManager;
-    private final PowerManagerService mPowerManagerService;
     
     private int mTouchScreenConfig;
     private int mKeyboardConfig;
@@ -85,6 +83,7 @@
     private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen);
     private static native void nativeSetFocusedApplication(InputApplication application);
     private static native void nativePreemptInputDispatch();
+    private static native String nativeDump();
     
     // Device class as defined by EventHub.
     private static final int CLASS_KEYBOARD = 0x00000001;
@@ -100,14 +99,9 @@
     static final int INPUT_EVENT_INJECTION_FAILED = 2;
     static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3;
     
-    public InputManager(Context context,
-            WindowManagerService windowManagerService,
-            PowerManager powerManager,
-            PowerManagerService powerManagerService) {
+    public InputManager(Context context, WindowManagerService windowManagerService) {
         this.mContext = context;
         this.mWindowManagerService = windowManagerService;
-        this.mPowerManager = powerManager;
-        this.mPowerManagerService = powerManagerService;
         
         this.mCallbacks = new Callbacks();
         
@@ -297,7 +291,10 @@
     }
     
     public void dump(PrintWriter pw) {
-        // TODO
+        String dumpStr = nativeDump();
+        if (dumpStr != null) {
+            pw.println(dumpStr);
+        }
     }
     
     private static final class VirtualKeyDefinition {