Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 037e34c8 authored by Christoph Studer's avatar Christoph Studer
Browse files

Fix notification visibility reporting

Require the screen to be on for visibility reporting.

Change-Id: I600e2fa2861bddd41ab9f9f0f381d8b1c4946afa
parent 36c492cf
Loading
Loading
Loading
Loading
+31 −13
Original line number Diff line number Diff line
@@ -379,7 +379,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
    private boolean mSettingsStarted;
    private boolean mSettingsCancelled;
    private boolean mSettingsClosing;
    private int mNotificationPadding;
    private boolean mVisible;

    private final OnChildLocationsChangedListener mOnChildLocationsChangedListener =
            new OnChildLocationsChangedListener() {
@@ -719,8 +719,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        }

        // Quick Settings (where available, some restrictions apply)
        mNotificationPadding = mContext.getResources()
                .getDimensionPixelSize(R.dimen.notification_side_padding);
        if (mHasQuickSettings) {
            // Quick Settings needs a container to survive
            mSettingsContainer = (QuickSettingsContainerView)
@@ -2551,12 +2549,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
                notifyNavigationBarScreenOn(false);
                notifyHeadsUpScreenOn(false);
                finishBarAnimations();
                stopNotificationLogging();
            }
            else if (Intent.ACTION_SCREEN_ON.equals(action)) {
                mScreenOn = true;
                // 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();
@@ -2730,9 +2730,16 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {

    @Override
    protected void visibilityChanged(boolean visible) {
        mVisible = visible;
        if (visible) {
            mStackScroller.setChildLocationsChangedListener(mNotificationLocationsChangedListener);
            startNotificationLoggingIfScreenOnAndVisible();
        } else {
            stopNotificationLogging();
        }
        super.visibilityChanged(visible);
    }

    private void stopNotificationLogging() {
        // Report all notifications as invisible and turn down the
        // reporter.
        if (!mCurrentlyVisibleNotifications.isEmpty()) {
@@ -2743,7 +2750,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        mHandler.removeCallbacks(mVisibilityReporter);
        mStackScroller.setChildLocationsChangedListener(null);
    }
        super.visibilityChanged(visible);

    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 logNotificationVisibilityChanges(