Protecting against the correct flag for the input consumer

Also allow hiding the navbar if immersive or immersivesticky.

Bug: 21089476
Change-Id: I540e668746056a0e4bb077898792afd225e4e19e
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 9bb5e40..7d14d47 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -6320,11 +6320,6 @@
             }
             vis = (vis & ~flags) | (oldVis & flags);
         }
-        if (windowTypeToLayerLw(type) > windowTypeToLayerLw(TYPE_INPUT_CONSUMER)) {
-            // We can't get into fullscreen from this window otherwise the consumer would not get
-            // the input events.
-            vis = (vis & ~View.SYSTEM_UI_FLAG_FULLSCREEN);
-        }
 
         if (!areTranslucentBarsAllowed() && transWin != mStatusBar) {
             vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT
@@ -6363,6 +6358,17 @@
             vis &= ~View.SYSTEM_UI_CLEARABLE_FLAGS;
         }
 
+        final boolean immersive = (vis & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0;
+        immersiveSticky = (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0;
+        final boolean navAllowedHidden = immersive || immersiveSticky;
+
+        if (!navAllowedHidden
+                && windowTypeToLayerLw(type) > windowTypeToLayerLw(TYPE_INPUT_CONSUMER)) {
+            // We can't hide the navbar from this window otherwise the input consumer would not get
+            // the input events.
+            vis = (vis & ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+        }
+
         vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis);
 
         // update navigation bar