visibility ("lights out") API.

1. Views may setSystemUiVisibility() to recommend that
the system chrome (status bar or other UI) show or hide
itself.  (This functionality was previously available only
via the FLAG_FULLSCREEN window flag for some SystemUI
implementations.)

2. Views may register a OnSystemUiVisibilityChangedListener
on a view, and find out when the system UI actually
appears or disappears, allowing apps to coordinate the
appearance of their own UI if desired.

Bug: 3241144
Change-Id: Ia1758d94099182d49a1e3688ea2738ae4995b829
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index ac3b96b..8a353ce 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -8891,6 +8891,8 @@
                                 // Ignore if process has died.
                             }
                         }
+
+                        mPolicy.focusChanged(lastFocus, newFocus);
                     }
                 } break;
 
@@ -11434,6 +11436,23 @@
     }
 
     @Override
+    public void statusBarVisibilityChanged(int visibility) {
+        synchronized (mWindowMap) {
+            final int N = mWindows.size();
+            for (int i = 0; i < N; i++) {
+                WindowState ws = mWindows.get(i);
+                try {
+                    if (ws.getAttrs().hasSystemUiListeners) {
+                        ws.mClient.dispatchSystemUiVisibilityChanged(visibility);
+                    }
+                } catch (RemoteException e) {
+                    // so sorry
+                }
+            }
+        }
+    }
+
+    @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         if (mContext.checkCallingOrSelfPermission("android.permission.DUMP")
                 != PackageManager.PERMISSION_GRANTED) {