The fullest of fullscreen modes.

View.setSystemUiVisibility() now properly accepts a
bitfield, including:

  * SYSTEM_UI_FLAG_LOW_PROFILE: "lights out mode"
    (previously known, erroneously, as STATUS_BAR_HIDDEN)

  * SYSTEM_UI_FLAG_HIDE_NAVIGATION: for when you need every
    single pixel on a device that also has a navigation bar

These flags are painstakingly aggregated across the entire
view hierarchy and carefully delivered to the status bar
service, which in turn gently passes them along to the bar
implementation.

To really get access to the whole screen, you need to use
HIDE_NAVIGATION in conjunction with FLAG_FULLSCREEN and
FLAG_LAYOUT_IN_SCREEN. See development/samples/Overscan for
an example of how to do this.

Change-Id: I5fbfe009d9ceebbbf71db73f14a7008ea7c1d4da
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 4ced83c..ca3b12d 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -69,8 +69,8 @@
     int mDisabled = 0;
 
     Object mLock = new Object();
-    // We usually call it lights out mode, but double negatives are annoying
-    boolean mLightsOn = true;
+    // encompasses lights-out mode and other flags defined on View
+    int mSystemUiVisibility = 0;
     boolean mMenuVisible = false;
     int mImeWindowVis = 0;
     int mImeBackDisposition;
@@ -301,22 +301,23 @@
         // also allows calls from window manager which is in this process.
         enforceStatusBarService();
 
+        if (SPEW) Slog.d(TAG, "setSystemUiVisibility(" + vis + ")");
+
         synchronized (mLock) {
-            final boolean lightsOn = (vis & View.STATUS_BAR_HIDDEN) == 0;
-            updateLightsOnLocked(lightsOn);
+            updateUiVisibilityLocked(vis);
             disableLocked(vis & StatusBarManager.DISABLE_MASK, mSysUiVisToken,
                     "WindowManager.LayoutParams");
         }
     }
 
-    private void updateLightsOnLocked(final boolean lightsOn) {
-        if (mLightsOn != lightsOn) {
-            mLightsOn = lightsOn;
+    private void updateUiVisibilityLocked(final int vis) {
+        if (mSystemUiVisibility != vis) {
+            mSystemUiVisibility = vis;
             mHandler.post(new Runnable() {
                     public void run() {
                         if (mBar != null) {
                             try {
-                                mBar.setLightsOn(lightsOn);
+                                mBar.setSystemUiVisibility(vis);
                             } catch (RemoteException ex) {
                             }
                         }
@@ -392,7 +393,7 @@
         }
         synchronized (mLock) {
             switches[0] = gatherDisableActionsLocked();
-            switches[1] = mLightsOn ? 1 : 0;
+            switches[1] = mSystemUiVisibility;
             switches[2] = mMenuVisible ? 1 : 0;
             switches[3] = mImeWindowVis;
             switches[4] = mImeBackDisposition;