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/api/current.txt b/api/current.txt
index 4b63c5b..24eb234 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22661,8 +22661,11 @@
field protected static final int[] SELECTED_STATE_SET;
field protected static final int[] SELECTED_WINDOW_FOCUSED_STATE_SET;
field public static final int SOUND_EFFECTS_ENABLED = 134217728; // 0x8000000
- field public static final int STATUS_BAR_HIDDEN = 1; // 0x1
- field public static final int STATUS_BAR_VISIBLE = 0; // 0x0
+ field public static final deprecated int STATUS_BAR_HIDDEN = 1; // 0x1
+ field public static final deprecated int STATUS_BAR_VISIBLE = 0; // 0x0
+ field public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2; // 0x2
+ field public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 1; // 0x1
+ field public static final int SYSTEM_UI_FLAG_VISIBLE = 0; // 0x0
field public static android.util.Property TRANSLATION_X;
field public static android.util.Property TRANSLATION_Y;
field protected static final java.lang.String VIEW_LOG_TAG = "View";
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 296e6be..e86f5d5 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1784,18 +1784,51 @@
public static final int OVER_SCROLL_NEVER = 2;
/**
- * View has requested the status bar to be visible (the default).
+ * View has requested the system UI (status bar) to be visible (the default).
*
* @see #setSystemUiVisibility(int)
*/
- public static final int STATUS_BAR_VISIBLE = 0;
+ public static final int SYSTEM_UI_FLAG_VISIBLE = 0;
/**
- * View has requested the status bar to be hidden.
+ * View has requested the system UI to enter an unobtrusive "low profile" mode.
+ *
+ * This is for use in games, book readers, video players, or any other "immersive" application
+ * where the usual system chrome is deemed too distracting.
+ *
+ * In low profile mode, the status bar and/or navigation icons may dim.
*
* @see #setSystemUiVisibility(int)
*/
- public static final int STATUS_BAR_HIDDEN = 0x00000001;
+ public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 0x00000001;
+
+ /**
+ * View has requested that the system navigation be temporarily hidden.
+ *
+ * This is an even less obtrusive state than that called for by
+ * {@link #SYSTEM_UI_FLAG_LOW_PROFILE}; on devices that draw essential navigation controls
+ * (Home, Back, and the like) on screen, <code>SYSTEM_UI_FLAG_HIDE_NAVIGATION</code> will cause
+ * those to disappear. This is useful (in conjunction with the
+ * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN FLAG_FULLSCREEN} and
+ * {@link android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN FLAG_LAYOUT_IN_SCREEN}
+ * window flags) for displaying content using every last pixel on the display.
+ *
+ * There is a limitation: because navigation controls are so important, the least user
+ * interaction will cause them to reappear immediately.
+ *
+ * @see #setSystemUiVisibility(int)
+ */
+ public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 0x00000002;
+
+ /**
+ * @deprecated Use {@link #SYSTEM_UI_FLAG_LOW_PROFILE} instead.
+ */
+ public static final int STATUS_BAR_HIDDEN = SYSTEM_UI_FLAG_LOW_PROFILE;
+
+ /**
+ * @deprecated Use {@link #SYSTEM_UI_FLAG_VISIBLE} instead.
+ */
+ public static final int STATUS_BAR_VISIBLE = SYSTEM_UI_FLAG_VISIBLE;
/**
* @hide
@@ -1889,7 +1922,7 @@
/**
* @hide
*/
- public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = STATUS_BAR_HIDDEN;
+ public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x0000FFFF;
/**
* Controls the over-scroll mode for this view.
@@ -1934,7 +1967,17 @@
* This view's request for the visibility of the status bar.
* @hide
*/
- @ViewDebug.ExportedProperty()
+ @ViewDebug.ExportedProperty(flagMapping = {
+ @ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LOW_PROFILE,
+ equals = SYSTEM_UI_FLAG_LOW_PROFILE,
+ name = "SYSTEM_UI_FLAG_LOW_PROFILE", outputIf = true),
+ @ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_HIDE_NAVIGATION,
+ equals = SYSTEM_UI_FLAG_HIDE_NAVIGATION,
+ name = "SYSTEM_UI_FLAG_HIDE_NAVIGATION", outputIf = true),
+ @ViewDebug.FlagToString(mask = PUBLIC_STATUS_BAR_VISIBILITY_MASK,
+ equals = SYSTEM_UI_FLAG_VISIBLE,
+ name = "SYSTEM_UI_FLAG_VISIBLE", outputIf = true)
+ })
int mSystemUiVisibility;
/**
@@ -12537,7 +12580,8 @@
/**
* Request that the visibility of the status bar be changed.
- * @param visibility Either {@link #STATUS_BAR_VISIBLE} or {@link #STATUS_BAR_HIDDEN}.
+ * @param visibility Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE} or
+ * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}.
*/
public void setSystemUiVisibility(int visibility) {
if (visibility != mSystemUiVisibility) {
@@ -12550,7 +12594,8 @@
/**
* Returns the status bar visibility that this view has requested.
- * @return Either {@link #STATUS_BAR_VISIBLE} or {@link #STATUS_BAR_HIDDEN}.
+ * @return Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE} or
+ * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}.
*/
public int getSystemUiVisibility() {
return mSystemUiVisibility;
@@ -13653,7 +13698,8 @@
* Called when the status bar changes visibility because of a call to
* {@link View#setSystemUiVisibility(int)}.
*
- * @param visibility {@link #STATUS_BAR_VISIBLE} or {@link #STATUS_BAR_HIDDEN}.
+ * @param visibility Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE} or
+ * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}.
*/
public void onSystemUiVisibilityChange(int visibility);
}
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index c11fc10..3916e86 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -30,7 +30,7 @@
void disable(int state);
void animateExpand();
void animateCollapse();
- void setLightsOn(boolean on);
+ void setSystemUiVisibility(int vis);
void topAppWindowChanged(boolean menuVisible);
void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
void setHardKeyboardStatus(boolean available, boolean enabled);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 62d7500..c91f513 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -54,7 +54,7 @@
private static final int OP_EXPAND = 1;
private static final int OP_COLLAPSE = 2;
- private static final int MSG_SET_LIGHTS_ON = 7 << MSG_SHIFT;
+ private static final int MSG_SET_SYSTEMUI_VISIBILITY = 7 << MSG_SHIFT;
private static final int MSG_TOP_APP_WINDOW_CHANGED = 8 << MSG_SHIFT;
private static final int MSG_SHOW_IME_BUTTON = 9 << MSG_SHIFT;
@@ -86,7 +86,7 @@
public void disable(int state);
public void animateExpand();
public void animateCollapse();
- public void setLightsOn(boolean on);
+ public void setSystemUiVisibility(int vis);
public void topAppWindowChanged(boolean visible);
public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
public void setHardKeyboardStatus(boolean available, boolean enabled);
@@ -160,10 +160,10 @@
}
}
- public void setLightsOn(boolean on) {
+ public void setSystemUiVisibility(int vis) {
synchronized (mList) {
- mHandler.removeMessages(MSG_SET_LIGHTS_ON);
- mHandler.obtainMessage(MSG_SET_LIGHTS_ON, on ? 1 : 0, 0, null).sendToTarget();
+ mHandler.removeMessages(MSG_SET_SYSTEMUI_VISIBILITY);
+ mHandler.obtainMessage(MSG_SET_SYSTEMUI_VISIBILITY, vis, 0, null).sendToTarget();
}
}
@@ -259,8 +259,8 @@
mCallbacks.animateCollapse();
}
break;
- case MSG_SET_LIGHTS_ON:
- mCallbacks.setLightsOn(msg.arg1 != 0);
+ case MSG_SET_SYSTEMUI_VISIBILITY:
+ mCallbacks.setSystemUiVisibility(msg.arg1);
break;
case MSG_TOP_APP_WINDOW_CHANGED:
mCallbacks.topAppWindowChanged(msg.arg1 != 0);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
index ca75138..918d5a3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
@@ -78,7 +78,7 @@
}
disable(switches[0]);
- setLightsOn(switches[1] != 0);
+ setSystemUiVisibility(switches[1]);
topAppWindowChanged(switches[2] != 0);
// StatusBarManagerService has a back up of IME token and it's restored here.
setImeWindowStatus(binders.get(0), switches[3], switches[4]);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 550fc57..2740898 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -17,11 +17,14 @@
package com.android.systemui.statusbar.phone;
import android.animation.Animator;
+import android.animation.AnimatorSet;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
+import android.content.res.Resources;
import android.os.ServiceManager;
import android.util.AttributeSet;
+import android.util.Slog;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -36,6 +39,9 @@
import com.android.systemui.R;
public class NavigationBarView extends LinearLayout {
+ final static boolean DEBUG = false;
+ final static String TAG = "NavigationBarView";
+
final static boolean DEBUG_DEADZONE = false;
final static boolean NAVBAR_ALWAYS_AT_RIGHT = true;
@@ -44,7 +50,12 @@
final Display mDisplay;
View mCurrentView = null;
View[] mRotatedViews = new View[4];
- Animator mLastAnimator = null;
+ AnimatorSet mLastAnimator = null;
+
+ int mBarSize;
+ boolean mVertical;
+
+ boolean mHidden;
public View getRecentsButton() {
return mCurrentView.findViewById(R.id.recent_apps);
@@ -56,37 +67,53 @@
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
+ mHidden = false;
+
mDisplay = ((WindowManager)context.getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
mBarService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
- //setLayerType(View.LAYER_TYPE_HARDWARE, null);
-
- setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
- @Override
- public void onSystemUiVisibilityChange(int visibility) {
- boolean on = (visibility == View.STATUS_BAR_VISIBLE);
- android.util.Log.d("NavigationBarView", "LIGHTS "
- + (on ? "ON" : "OUT"));
- setLights(on);
- }
- });
+ final Resources res = mContext.getResources();
+ mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
+ mVertical = false;
}
- private void setLights(final boolean on) {
+ public void setHidden(final boolean hide) {
+ if (hide == mHidden) return;
+
+ mHidden = hide;
+ Slog.d(TAG,
+ (hide ? "HIDING" : "SHOWING") + " navigation bar");
+
float oldAlpha = mCurrentView.getAlpha();
- android.util.Log.d("NavigationBarView", "animating alpha: " + oldAlpha + " -> "
- + (on ? 1f : 0f));
+ if (DEBUG) {
+ Slog.d(TAG, "animating alpha: " + oldAlpha + " -> "
+ + (!hide ? 1f : 0f));
+ }
if (mLastAnimator != null && mLastAnimator.isRunning()) mLastAnimator.cancel();
- mLastAnimator = ObjectAnimator.ofFloat(mCurrentView, "alpha", oldAlpha, on ? 1f : 0f)
- .setDuration(on ? 250 : 1500);
+ if (!hide) {
+ setVisibility(View.VISIBLE);
+ }
+
+ // play us off, animatorset
+ mLastAnimator = new AnimatorSet();
+ mLastAnimator.playTogether(
+ ObjectAnimator.ofFloat(mCurrentView, "alpha", hide ? 0f : 1f),
+ ObjectAnimator.ofFloat(mCurrentView,
+ mVertical ? "translationX" : "translationY",
+ hide ? mBarSize : 0)
+ );
+ mLastAnimator.setDuration(!hide ? 250 : 1000);
mLastAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator _a) {
mLastAnimator = null;
+ if (hide) {
+ setVisibility(View.INVISIBLE);
+ }
}
});
mLastAnimator.start();
@@ -108,7 +135,7 @@
@Override
public boolean onTouchEvent(MotionEvent ev) {
// immediately bring up the lights
- setLights(true);
+ setHidden(false);
return false; // pass it on
}
@@ -119,11 +146,14 @@
}
mCurrentView = mRotatedViews[rot];
mCurrentView.setVisibility(View.VISIBLE);
+ mVertical = (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270);
if (DEBUG_DEADZONE) {
mCurrentView.findViewById(R.id.deadzone).setBackgroundColor(0x808080FF);
}
- android.util.Log.d("NavigationBarView", "reorient(): rot=" + mDisplay.getRotation());
+ if (DEBUG) {
+ Slog.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 21b774c..f55c2bc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -198,6 +198,9 @@
// for disabling the status bar
int mDisabled = 0;
+ // tracking calls to View.setSystemUiVisibility()
+ int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
+
private class ExpandedDialog extends Dialog {
ExpandedDialog(Context context) {
super(context, com.android.internal.R.style.Theme_Light_NoTitleBar);
@@ -253,20 +256,33 @@
mIntruderAlertView.setVisibility(View.GONE);
mIntruderAlertView.setClickable(true);
+ PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context,
+ R.layout.status_bar, null);
+ sb.mService = this;
+ mStatusBarView = sb;
+
try {
boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
if (showNav) {
mNavigationBarView =
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
+
+ sb.setOnSystemUiVisibilityChangeListener(
+ new View.OnSystemUiVisibilityChangeListener() {
+ @Override
+ public void onSystemUiVisibilityChange(int visibility) {
+ if (DEBUG) {
+ Slog.d(TAG, "systemUi: " + visibility);
+ }
+ boolean hide = (0 != (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION));
+ mNavigationBarView.setHidden(hide);
+ }
+ });
}
} catch (Resources.NotFoundException ex) {
// no nav bar for you
}
- PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context,
- R.layout.status_bar, null);
- sb.mService = this;
-
// figure out which pixel-format to use for the status bar.
mPixelFormat = PixelFormat.TRANSLUCENT;
Drawable bg = sb.getBackground();
@@ -274,7 +290,6 @@
mPixelFormat = bg.getOpacity();
}
- mStatusBarView = sb;
mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons);
mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
mIcons = (LinearLayout)sb.findViewById(R.id.icons);
@@ -1275,22 +1290,31 @@
return false;
}
- public void setLightsOn(boolean on) {
- Log.v(TAG, "lights " + (on ? "on" : "off"));
- if (!on) {
- // All we do for "lights out" mode on a phone is hide the status bar,
- // which the window manager does. But we do need to hide the windowshade
- // on our own.
- animateCollapse();
+ @Override // CommandQueue
+ public void setSystemUiVisibility(int vis) {
+ if (vis != mSystemUiVisibility) {
+ mSystemUiVisibility = vis;
+
+ if (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)) {
+ animateCollapse();
+ }
+
+ notifyUiVisibilityChanged();
}
- notifyLightsChanged(on);
}
- private void notifyLightsChanged(boolean shown) {
+ public void setLightsOn(boolean on) {
+ Log.v(TAG, "setLightsOn(" + on + ")");
+ if (on) {
+ setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ } else {
+ setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ }
+ }
+
+ private void notifyUiVisibilityChanged() {
try {
- Slog.d(TAG, "lights " + (shown?"on":"out"));
- mWindowManager.statusBarVisibilityChanged(
- shown ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN);
+ mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility);
} catch (RemoteException ex) {
}
}
@@ -1715,10 +1739,10 @@
}
}
+ // The user is not allowed to get stuck without navigation UI. Upon the slightest user
+ // interaction we bring the navigation back.
public void userActivity() {
- try {
- mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
- } catch (RemoteException ex) { }
+ mNavigationBarView.setHidden(false);
}
public void toggleRecentApps() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 96f6e2f..c6e546e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -176,6 +176,8 @@
private InputMethodsPanel mInputMethodsPanel;
private CompatModePanel mCompatModePanel;
+ int mSystemUiVisibility = 0;
+
public Context getContext() { return mContext; }
protected void addPanelWindows() {
@@ -729,14 +731,16 @@
if (DEBUG) Slog.d(TAG, "hiding shadows (lights on)");
mBarContents.setVisibility(View.VISIBLE);
mShadow.setVisibility(View.GONE);
- notifyLightsChanged(true);
+ mSystemUiVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ notifyUiVisibilityChanged();
break;
case MSG_HIDE_CHROME:
if (DEBUG) Slog.d(TAG, "showing shadows (lights out)");
animateCollapse();
mBarContents.setVisibility(View.GONE);
mShadow.setVisibility(View.VISIBLE);
- notifyLightsChanged(false);
+ mSystemUiVisibility |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ notifyUiVisibilityChanged();
break;
case MSG_STOP_TICKER:
mTicker.halt();
@@ -1025,17 +1029,40 @@
mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK);
}
- // called by StatusBar
- @Override
+ private void notifyUiVisibilityChanged() {
+ try {
+ mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility);
+ } catch (RemoteException ex) {
+ }
+ }
+
+ @Override // CommandQueue
+ public void setSystemUiVisibility(int vis) {
+ if (vis != mSystemUiVisibility) {
+ mSystemUiVisibility = vis;
+
+ mHandler.removeMessages(MSG_HIDE_CHROME);
+ mHandler.removeMessages(MSG_SHOW_CHROME);
+ mHandler.sendEmptyMessage(0 == (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)
+ ? MSG_SHOW_CHROME : MSG_HIDE_CHROME);
+
+ notifyUiVisibilityChanged();
+ }
+ }
+
public void setLightsOn(boolean on) {
// Policy note: if the frontmost activity needs the menu key, we assume it is a legacy app
// that can't handle lights-out mode.
if (mMenuButton.getVisibility() == View.VISIBLE) {
on = true;
}
- mHandler.removeMessages(MSG_HIDE_CHROME);
- mHandler.removeMessages(MSG_SHOW_CHROME);
- mHandler.sendEmptyMessage(on ? MSG_SHOW_CHROME : MSG_HIDE_CHROME);
+
+ Slog.v(TAG, "setLightsOn(" + on + ")");
+ if (on) {
+ setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ } else {
+ setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ }
}
public void topAppWindowChanged(boolean showMenu) {
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;
diff --git a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
index e75a079..da5f488 100644
--- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
@@ -48,6 +48,8 @@
StatusBarManager mStatusBarManager;
NotificationManager mNotificationManager;
Handler mHandler = new Handler();
+ int mUiVisibility = 0;
+ View mListView;
View.OnSystemUiVisibilityChangeListener mOnSystemUiVisibilityChangeListener
= new View.OnSystemUiVisibilityChangeListener() {
@@ -69,32 +71,52 @@
return mTests;
}
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ mListView = findViewById(android.R.id.list);
+ mListView.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener);
+ }
+
private Test[] mTests = new Test[] {
+ new Test("toggle LOW_PROFILE (lights out)") {
+ public void run() {
+ if (0 != (mUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE)) {
+ mUiVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ } else {
+ mUiVisibility |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ }
+ mListView.setSystemUiVisibility(mUiVisibility);
+ }
+ },
+ new Test("toggle HIDE_NAVIGATION") {
+ public void run() {
+ if (0 != (mUiVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)) {
+ mUiVisibility &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ } else {
+ mUiVisibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ }
+ mListView.setSystemUiVisibility(mUiVisibility);
+
+ }
+ },
+ new Test("clear SYSTEM_UI_FLAGs") {
+ public void run() {
+ mUiVisibility = 0;
+ mListView.setSystemUiVisibility(mUiVisibility);
+ }
+ },
+// new Test("no setSystemUiVisibility") {
+// public void run() {
+// View v = findViewById(android.R.id.list);
+// v.setOnSystemUiVisibilityChangeListener(null);
+// v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
+// }
+// },
new Test("DISABLE_NAVIGATION") {
public void run() {
- View v = findViewById(android.R.id.list);
- v.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NAVIGATION);
- }
- },
- new Test("STATUS_BAR_HIDDEN") {
- public void run() {
- View v = findViewById(android.R.id.list);
- v.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener);
- v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
- }
- },
- new Test("STATUS_BAR_VISIBLE") {
- public void run() {
- View v = findViewById(android.R.id.list);
- v.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener);
- v.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
- }
- },
- new Test("no setSystemUiVisibility") {
- public void run() {
- View v = findViewById(android.R.id.list);
- v.setOnSystemUiVisibilityChangeListener(null);
- v.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
+ mListView.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NAVIGATION);
}
},
new Test("Double Remove") {