diff options
10 files changed, 242 insertions, 89 deletions
diff --git a/api/current.txt b/api/current.txt index 4b63c5bbe9ee..24eb234fa17c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -22661,8 +22661,11 @@ package android.view { 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 296e6be2f163..e86f5d5e7b15 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -1784,18 +1784,51 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit 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 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 STATUS_BAR_HIDDEN = 0x00000001; + 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 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit /** * @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 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit * 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 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit /** * 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 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit /** * 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 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit * 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 c11fc100a947..3916e865a9fc 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -30,7 +30,7 @@ oneway interface IStatusBar 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 62d75000b434..c91f513a2f1b 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 @@ public class CommandQueue extends IStatusBar.Stub { 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 class CommandQueue extends IStatusBar.Stub { 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 class CommandQueue extends IStatusBar.Stub { } } - 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 @@ public class CommandQueue extends IStatusBar.Stub { 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 ca7513839713..918d5a3ec380 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 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac } 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 550fc57e9a78..274089836a7a 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.internal.statusbar.IStatusBarService; 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 @@ public class NavigationBarView extends LinearLayout { 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 class NavigationBarView extends LinearLayout { 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 @@ public class NavigationBarView extends LinearLayout { @Override public boolean onTouchEvent(MotionEvent ev) { // immediately bring up the lights - setLights(true); + setHidden(false); return false; // pass it on } @@ -119,11 +146,14 @@ public class NavigationBarView extends LinearLayout { } 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 21b774c0127d..f55c2bcb7fbd 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 @@ public class PhoneStatusBar extends StatusBar { // 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 @@ public class PhoneStatusBar extends StatusBar { 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 @@ public class PhoneStatusBar extends StatusBar { 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 @@ public class PhoneStatusBar extends StatusBar { return false; } + @Override // CommandQueue + public void setSystemUiVisibility(int vis) { + if (vis != mSystemUiVisibility) { + mSystemUiVisibility = vis; + + if (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { + animateCollapse(); + } + + notifyUiVisibilityChanged(); + } + } + 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(); + Log.v(TAG, "setLightsOn(" + on + ")"); + if (on) { + setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE); + } else { + setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE); } - notifyLightsChanged(on); } - private void notifyLightsChanged(boolean shown) { + 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 @@ public class PhoneStatusBar extends StatusBar { } } + // 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 96f6e2f4c3a5..c6e546e875b9 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 @@ public class TabletStatusBar extends StatusBar implements private InputMethodsPanel mInputMethodsPanel; private CompatModePanel mCompatModePanel; + int mSystemUiVisibility = 0; + public Context getContext() { return mContext; } protected void addPanelWindows() { @@ -729,14 +731,16 @@ public class TabletStatusBar extends StatusBar implements 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 @@ public class TabletStatusBar extends StatusBar implements 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 4ced83c9c672..ca3b12d9cdad 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -69,8 +69,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub 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 @@ public class StatusBarManagerService extends IStatusBarService.Stub // 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 @@ public class StatusBarManagerService extends IStatusBarService.Stub } 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 e75a0797dfa7..da5f488ed19c 100644 --- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java +++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java @@ -48,6 +48,8 @@ public class StatusBarTest extends TestActivity StatusBarManager mStatusBarManager; NotificationManager mNotificationManager; Handler mHandler = new Handler(); + int mUiVisibility = 0; + View mListView; View.OnSystemUiVisibilityChangeListener mOnSystemUiVisibilityChangeListener = new View.OnSystemUiVisibilityChangeListener() { @@ -69,32 +71,52 @@ public class StatusBarTest extends TestActivity return mTests; } + @Override + public void onResume() { + super.onResume(); + + mListView = findViewById(android.R.id.list); + mListView.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener); + } + private Test[] mTests = new Test[] { - new Test("DISABLE_NAVIGATION") { + new Test("toggle LOW_PROFILE (lights out)") { public void run() { - View v = findViewById(android.R.id.list); - v.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NAVIGATION); + 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("STATUS_BAR_HIDDEN") { + new Test("toggle HIDE_NAVIGATION") { public void run() { - View v = findViewById(android.R.id.list); - v.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener); - v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); + 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("STATUS_BAR_VISIBLE") { + new Test("clear SYSTEM_UI_FLAGs") { public void run() { - View v = findViewById(android.R.id.list); - v.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener); - v.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); + mUiVisibility = 0; + mListView.setSystemUiVisibility(mUiVisibility); } }, - new Test("no setSystemUiVisibility") { +// 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.setOnSystemUiVisibilityChangeListener(null); - v.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); + mListView.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NAVIGATION); } }, new Test("Double Remove") { |