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

Commit bd42b61f authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Merge "Showing the notification icon properly now when the pulse is...

Merge "Showing the notification icon properly now when the pulse is suppressed" into qt-r1-dev am: a1001b43 am: f50fdbbf
am: 36f25185

Change-Id: I6626296aaf04af8168530d2fd532800d82df999c
parents 5a22c8e2 36f25185
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -77,8 +77,10 @@ public interface DozeHost {
    interface Callback {
        /**
         * Called when a high priority notification is added.
         * @param onPulseSuppressedListener A listener that is invoked if the pulse is being
         *                                  supressed.
         */
        default void onNotificationAlerted() {}
        default void onNotificationAlerted(Runnable onPulseSuppressedListener) {}

        /**
         * Called when battery state or power save mode changes.
+22 −8
Original line number Diff line number Diff line
@@ -106,22 +106,31 @@ public class DozeTriggers implements DozeMachine.Part {
        mDockManager = dockManager;
    }

    private void onNotification() {
    private void onNotification(Runnable onPulseSuppressedListener) {
        if (DozeMachine.DEBUG) {
            Log.d(TAG, "requestNotificationPulse");
        }
        if (!sWakeDisplaySensorState) {
            Log.d(TAG, "Wake display false. Pulse denied.");
            runIfNotNull(onPulseSuppressedListener);
            return;
        }
        mNotificationPulseTime = SystemClock.elapsedRealtime();
        if (!mConfig.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) {
            runIfNotNull(onPulseSuppressedListener);
            return;
        }
        requestPulse(DozeLog.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */);
        requestPulse(DozeLog.PULSE_REASON_NOTIFICATION, false /* performedProxCheck */,
                onPulseSuppressedListener);
        DozeLog.traceNotificationPulse(mContext);
    }

    private static void runIfNotNull(Runnable runnable) {
        if (runnable != null) {
            runnable.run();
        }
    }

    private void proximityCheckThenCall(IntConsumer callback,
            boolean alreadyPerformedProxCheck,
            int reason) {
@@ -158,10 +167,11 @@ public class DozeTriggers implements DozeMachine.Part {
        if (isWakeDisplay) {
            onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState());
        } else if (isLongPress) {
            requestPulse(pulseReason, sensorPerformedProxCheck);
            requestPulse(pulseReason, sensorPerformedProxCheck, null /* onPulseSupressedListener */);
        } else if (isWakeLockScreen) {
            if (wakeEvent) {
                requestPulse(pulseReason, sensorPerformedProxCheck);
                requestPulse(pulseReason, sensorPerformedProxCheck,
                        null /* onPulseSupressedListener */);
            }
        } else {
            proximityCheckThenCall((result) -> {
@@ -340,7 +350,8 @@ public class DozeTriggers implements DozeMachine.Part {
        }
    }

    private void requestPulse(final int reason, boolean performedProxCheck) {
    private void requestPulse(final int reason, boolean performedProxCheck,
            Runnable onPulseSuppressedListener) {
        Assert.isMainThread();
        mDozeHost.extendPulse(reason);

@@ -357,6 +368,7 @@ public class DozeTriggers implements DozeMachine.Part {
                DozeLog.tracePulseDropped(mContext, mPulsePending, mMachine.getState(),
                        mDozeHost.isPulsingBlocked());
            }
            runIfNotNull(onPulseSuppressedListener);
            return;
        }

@@ -365,6 +377,7 @@ public class DozeTriggers implements DozeMachine.Part {
            if (result == ProximityCheck.RESULT_NEAR) {
                // in pocket, abort pulse
                mPulsePending = false;
                runIfNotNull(onPulseSuppressedListener);
            } else {
                // not in pocket, continue pulsing
                continuePulseRequest(reason);
@@ -482,7 +495,8 @@ public class DozeTriggers implements DozeMachine.Part {
        public void onReceive(Context context, Intent intent) {
            if (PULSE_ACTION.equals(intent.getAction())) {
                if (DozeMachine.DEBUG) Log.d(TAG, "Received pulse intent");
                requestPulse(DozeLog.PULSE_REASON_INTENT, false /* performedProxCheck */);
                requestPulse(DozeLog.PULSE_REASON_INTENT, false, /* performedProxCheck */
                        null /* onPulseSupressedListener */);
            }
            if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) {
                mMachine.requestState(DozeMachine.State.FINISH);
@@ -532,8 +546,8 @@ public class DozeTriggers implements DozeMachine.Part {

    private DozeHost.Callback mHostCallback = new DozeHost.Callback() {
        @Override
        public void onNotificationAlerted() {
            onNotification();
        public void onNotificationAlerted(Runnable onPulseSuppressedListener) {
            onNotification(onPulseSuppressedListener);
        }

        @Override
+9 −0
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public final class NotificationEntry {
    private boolean mSensitive = true;
    private Runnable mOnSensitiveChangedListener;
    private boolean mAutoHeadsUp;
    private boolean mPulseSupressed;

    public NotificationEntry(StatusBarNotification n) {
        this(n, null);
@@ -915,6 +916,14 @@ public final class NotificationEntry {
        mOnSensitiveChangedListener = listener;
    }

    public boolean isPulseSuppressed() {
        return mPulseSupressed;
    }

    public void setPulseSuppressed(boolean suppressed) {
        mPulseSupressed = suppressed;
    }

    /** Information about a suggestion that is being edited. */
    public static class EditedSuggestionInfo {

+4 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class NotificationIconAreaController implements DarkReceiver,
    private int mAodIconTint;
    private boolean mFullyHidden;
    private boolean mAodIconsVisible;
    private boolean mIsPulsing;

    public NotificationIconAreaController(Context context, StatusBar statusBar,
            StatusBarStateController statusBarStateController,
@@ -265,7 +266,9 @@ public class NotificationIconAreaController implements DarkReceiver,
        if (!showAmbient && entry.shouldSuppressStatusBar()) {
            return false;
        }
        if (hidePulsing && entry.showingPulsing()) {
        if (hidePulsing && entry.showingPulsing()
                && (!mWakeUpCoordinator.getNotificationsFullyHidden()
                        || !entry.isPulseSuppressed())) {
            return false;
        }
        return true;
+8 −3
Original line number Diff line number Diff line
@@ -1579,7 +1579,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
        mEntryManager.updateNotifications();
        if (isDozing() && isHeadsUp) {
            mDozeServiceHost.fireNotificationPulse();
            entry.setPulseSuppressed(false);
            mDozeServiceHost.fireNotificationPulse(entry);
            if (mPulsing) {
                mDozeScrimController.cancelPendingPulseTimeout();
            }
@@ -3930,9 +3931,13 @@ public class StatusBar extends SystemUI implements DemoMode,
            }
        }

        public void fireNotificationPulse() {
        public void fireNotificationPulse(NotificationEntry entry) {
            Runnable pulseSupressedListener = () -> {
                entry.setPulseSuppressed(true);
                mNotificationIconAreaController.updateAodNotificationIcons();
            };
            for (Callback callback : mCallbacks) {
                callback.onNotificationAlerted();
                callback.onNotificationAlerted(pulseSupressedListener);
            }
        }

Loading