resolved conflicts for merge of faf083ef to master

Change-Id: I316a1b4356f6dba6c3880ccb02dbb2fa00d21a85
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index e73f0dd..6bc5e8a 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -723,6 +723,7 @@
             attachInfo.mWindowVisibility = viewVisibility;
             attachInfo.mRecomputeGlobalAttributes = false;
             attachInfo.mKeepScreenOn = false;
+            attachInfo.mSystemUiVisibility = 0;
             viewVisibilityChanged = false;
             mLastConfiguration.setTo(host.getResources().getConfiguration());
             host.dispatchAttachedToWindow(attachInfo, 0);
@@ -896,14 +897,17 @@
         }
 
         if (attachInfo.mRecomputeGlobalAttributes) {
-            //Log.i(TAG, "Computing screen on!");
+            //Log.i(TAG, "Computing view hierarchy attributes!");
             attachInfo.mRecomputeGlobalAttributes = false;
-            boolean oldVal = attachInfo.mKeepScreenOn;
+            boolean oldScreenOn = attachInfo.mKeepScreenOn;
+            int oldVis = attachInfo.mSystemUiVisibility;
             attachInfo.mKeepScreenOn = false;
+            attachInfo.mSystemUiVisibility = 0;
+            attachInfo.mHasSystemUiListeners = false;
             host.dispatchCollectViewAttributes(0);
-            if (attachInfo.mKeepScreenOn != oldVal) {
+            if (attachInfo.mKeepScreenOn != oldScreenOn ||
+                    attachInfo.mSystemUiVisibility != oldVis) {
                 params = lp;
-                //Log.i(TAG, "Keep screen on changed: " + attachInfo.mKeepScreenOn);
             }
         }
 
@@ -985,6 +989,8 @@
                     if (attachInfo.mKeepScreenOn) {
                         params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
                     }
+                    params.systemUiVisibility = attachInfo.mSystemUiVisibility;
+                    params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
                 }
                 if (DEBUG_LAYOUT) {
                     Log.i(TAG, "host=w:" + host.getMeasuredWidth() + ", h:" +
@@ -1900,7 +1906,8 @@
     public final static int CLOSE_SYSTEM_DIALOGS = 1014;
     public final static int DISPATCH_DRAG_EVENT = 1015;
     public final static int DISPATCH_DRAG_LOCATION_EVENT = 1016;
-    public final static int DISPATCH_GENERIC_MOTION = 1017;
+    public final static int DISPATCH_SYSTEM_UI_VISIBILITY = 1017;
+    public final static int DISPATCH_GENERIC_MOTION = 1018;
 
     @Override
     public void handleMessage(Message msg) {
@@ -2066,6 +2073,9 @@
             event.mLocalState = mLocalDragState;    // only present when this app called startDrag()
             handleDragEvent(event);
         } break;
+        case DISPATCH_SYSTEM_UI_VISIBILITY: {
+            handleDispatchSystemUiVisibilityChanged(msg.arg1);
+        } break;
         }
     }
     
@@ -2931,6 +2941,11 @@
         event.recycle();
     }
 
+    public void handleDispatchSystemUiVisibilityChanged(int visibility) {
+        if (mView == null) return;
+        mView.dispatchSystemUiVisibilityChanged(visibility);
+    }
+
     public void getLastTouchPoint(Point outLocation) {
         outLocation.x = (int) mLastTouchPoint.x;
         outLocation.y = (int) mLastTouchPoint.y;
@@ -3249,6 +3264,10 @@
         sendMessage(msg);
     }
 
+    public void dispatchSystemUiVisibilityChanged(int visibility) {
+        sendMessage(obtainMessage(DISPATCH_SYSTEM_UI_VISIBILITY, visibility, 0));
+    }
+
     /**
      * The window is getting focus so if there is anything focused/selected
      * send an {@link AccessibilityEvent} to announce that.
@@ -3467,6 +3486,14 @@
                 viewRoot.dispatchDragEvent(event);
             }
         }
+
+        @Override
+        public void dispatchSystemUiVisibilityChanged(int visibility) {
+            final ViewRoot viewRoot = mViewRoot.get();
+            if (viewRoot != null) {
+                viewRoot.dispatchSystemUiVisibilityChanged(visibility);
+            }
+        }
     }
 
     /**