diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 1b4bdf839aee9..09abb28d093c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -155,9 +155,6 @@ public abstract class BaseStatusBar extends SystemUI implements protected HeadsUpNotificationView mHeadsUpNotificationView; protected int mHeadsUpNotificationDecay; - // used to notify status bar for suppressing notification LED - protected boolean mPanelSlightlyVisible; - // Search panel protected SearchPanelView mSearchPanelView; @@ -169,6 +166,20 @@ public abstract class BaseStatusBar extends SystemUI implements // on-screen navigation buttons protected NavigationBarView mNavigationBarView = null; + + protected Boolean mScreenOn; + + // The second field is a bit different from the first one because it only listens to screen on/ + // screen of events from Keyguard. We need this so we don't have a race condition with the + // broadcast. In the future, we should remove the first field altogether and rename the second + // field. + protected boolean mScreenOnFromKeyguard; + + protected boolean mVisible; + + // mScreenOnFromKeyguard && mVisible. + private boolean mVisibleToUser; + private Locale mLocale; private float mFontScale; @@ -1589,28 +1600,41 @@ public abstract class BaseStatusBar extends SystemUI implements } } + protected void visibilityChanged(boolean visible) { + if (mVisible != visible) { + mVisible = visible; + if (!visible) { + dismissPopups(); + } + } + updateVisibleToUser(); + } + + protected void updateVisibleToUser() { + boolean oldVisibleToUser = mVisibleToUser; + mVisibleToUser = mVisible && mScreenOnFromKeyguard; + + if (oldVisibleToUser != mVisibleToUser) { + handleVisibleToUserChanged(mVisibleToUser); + } + } + /** - * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. + * The LEDs are turned off when the notification panel is shown, even just a little bit. * This was added last-minute and is inconsistent with the way the rest of the notifications * are handled, because the notification isn't really cancelled. The lights are just * turned off. If any other notifications happen, the lights will turn back on. Steve says * this is what he wants. (see bug 1131461) */ - protected void visibilityChanged(boolean visible) { - if (mPanelSlightlyVisible != visible) { - mPanelSlightlyVisible = visible; - if (!visible) { - dismissPopups(); - } - try { - if (visible) { - mBarService.onPanelRevealed(); - } else { - mBarService.onPanelHidden(); - } - } catch (RemoteException ex) { - // Won't fail unless the world has ended. + protected void handleVisibleToUserChanged(boolean visibleToUser) { + try { + if (visibleToUser) { + mBarService.onPanelRevealed(); + } else { + mBarService.onPanelHidden(); } + } catch (RemoteException ex) { + // Won't fail unless the world has ended. } } 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 9a33a3697198b..e7ce1067104c8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -55,7 +55,6 @@ import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; -import android.graphics.Xfermode; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.inputmethodservice.InputMethodService; @@ -98,7 +97,6 @@ import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; @@ -409,13 +407,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private boolean mAutohideSuspended; private int mStatusBarMode; private int mNavigationBarMode; - private Boolean mScreenOn; - - // The second field is a bit different from the first one because it only listens to screen on/ - // screen of events from Keyguard. We need this so we don't have a race condition with the - // broadcast. In the future, we should remove the first field altogether and rename the second - // field. - private boolean mScreenOnFromKeyguard; private ViewMediatorCallback mKeyguardViewMediatorCallback; private ScrimController mScrimController; @@ -429,7 +420,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } }}; - private boolean mVisible; private boolean mWaitingForKeyguardExit; private boolean mDozing; private boolean mScrimSrcModeEnabled; @@ -3077,7 +3067,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, notifyNavigationBarScreenOn(false); notifyHeadsUpScreenOn(false); finishBarAnimations(); - stopNotificationLogging(); resetUserExpandedStates(); } else if (Intent.ACTION_SCREEN_ON.equals(action)) { @@ -3085,7 +3074,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018) repositionNavigationBar(); notifyNavigationBarScreenOn(true); - startNotificationLoggingIfScreenOnAndVisible(); } else if (ACTION_DEMO.equals(action)) { Bundle bundle = intent.getExtras(); @@ -3274,14 +3262,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // Visibility reporting @Override - protected void visibilityChanged(boolean visible) { - mVisible = visible; - if (visible) { - startNotificationLoggingIfScreenOnAndVisible(); + protected void handleVisibleToUserChanged(boolean visibleToUser) { + if (visibleToUser) { + super.handleVisibleToUserChanged(visibleToUser); + startNotificationLogging(); } else { stopNotificationLogging(); + super.handleVisibleToUserChanged(visibleToUser); } - super.visibilityChanged(visible); } private void stopNotificationLogging() { @@ -3296,17 +3284,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mStackScroller.setChildLocationsChangedListener(null); } - private void startNotificationLoggingIfScreenOnAndVisible() { - if (mVisible && mScreenOn) { - mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener); - // Some transitions like mScreenOn=false -> mScreenOn=true don't - // cause the scroller to emit child location events. Hence generate - // one ourselves to guarantee that we're reporting visible - // notifications. - // (Note that in cases where the scroller does emit events, this - // additional event doesn't break anything.) - mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller); - } + private void startNotificationLogging() { + mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener); + // Some transitions like mVisibleToUser=false -> mVisibleToUser=true don't + // cause the scroller to emit child location events. Hence generate + // one ourselves to guarantee that we're reporting visible + // notifications. + // (Note that in cases where the scroller does emit events, this + // additional event doesn't break anything.) + mNotificationLocationsChangedListener.onChildLocationsChanged(mStackScroller); } private void logNotificationVisibilityChanges( @@ -3944,6 +3930,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mScreenOnFromKeyguard = false; mScreenOnComingFromTouch = false; mStackScroller.setAnimationsEnabled(false); + updateVisibleToUser(); } public void onScreenTurnedOn() { @@ -3951,6 +3938,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mStackScroller.setAnimationsEnabled(true); mNotificationPanel.onScreenTurnedOn(); mNotificationPanel.setTouchDisabled(false); + updateVisibleToUser(); } /**