Expose the window flags for lights out mode.

I hadn't wanted to do this, but it makes porting the FLAG_FULLSCREEN
stuff over to this simpler because you don't have to go find a view
to proxy through.

This change also clears the flag everywhere when the window manager
notifies the views that the change has come back.

Change-Id: I48392c7550925bcca50c5bb9e1f263e99de6c7bc
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index b0553c6..042095a 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -903,8 +903,9 @@
             attachInfo.mSystemUiVisibility = 0;
             attachInfo.mHasSystemUiListeners = false;
             host.dispatchCollectViewAttributes(0);
-            if (attachInfo.mKeepScreenOn != oldScreenOn ||
-                    attachInfo.mSystemUiVisibility != oldVis) {
+            if (attachInfo.mKeepScreenOn != oldScreenOn
+                    || attachInfo.mSystemUiVisibility != oldVis
+                    || attachInfo.mHasSystemUiListeners) {
                 params = lp;
             }
         }
@@ -987,8 +988,10 @@
                     if (attachInfo.mKeepScreenOn) {
                         params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
                     }
-                    params.systemUiVisibility = attachInfo.mSystemUiVisibility;
-                    params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
+                    params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
+                    params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners
+                            || params.subtreeSystemUiVisibility != 0
+                            || params.systemUiVisibility != 0;
                 }
                 if (DEBUG_LAYOUT) {
                     Log.i(TAG, "host=w:" + host.getMeasuredWidth() + ", h:" +
@@ -2854,6 +2857,9 @@
 
     public void handleDispatchSystemUiVisibilityChanged(int visibility) {
         if (mView == null) return;
+        if (mAttachInfo != null) {
+            mAttachInfo.mSystemUiVisibility = visibility;
+        }
         mView.dispatchSystemUiVisibilityChanged(visibility);
     }