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

Commit a1001b43 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Showing the notification icon properly now when the pulse is suppressed" into qt-r1-dev

parents c1dc1fac 65c96f2f
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -77,8 +77,10 @@ public interface DozeHost {
    interface Callback {
    interface Callback {
        /**
        /**
         * Called when a high priority notification is added.
         * 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.
         * Called when battery state or power save mode changes.
+22 −8
Original line number Original line Diff line number Diff line
@@ -106,22 +106,31 @@ public class DozeTriggers implements DozeMachine.Part {
        mDockManager = dockManager;
        mDockManager = dockManager;
    }
    }


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


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

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


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


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


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


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


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


    public boolean isPulseSuppressed() {
        return mPulseSupressed;
    }

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

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


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


    public NotificationIconAreaController(Context context, StatusBar statusBar,
    public NotificationIconAreaController(Context context, StatusBar statusBar,
            StatusBarStateController statusBarStateController,
            StatusBarStateController statusBarStateController,
@@ -265,7 +266,9 @@ public class NotificationIconAreaController implements DarkReceiver,
        if (!showAmbient && entry.shouldSuppressStatusBar()) {
        if (!showAmbient && entry.shouldSuppressStatusBar()) {
            return false;
            return false;
        }
        }
        if (hidePulsing && entry.showingPulsing()) {
        if (hidePulsing && entry.showingPulsing()
                && (!mWakeUpCoordinator.getNotificationsFullyHidden()
                        || !entry.isPulseSuppressed())) {
            return false;
            return false;
        }
        }
        return true;
        return true;
+8 −3
Original line number Original line Diff line number Diff line
@@ -1580,7 +1580,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
    public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
        mEntryManager.updateNotifications();
        mEntryManager.updateNotifications();
        if (isDozing() && isHeadsUp) {
        if (isDozing() && isHeadsUp) {
            mDozeServiceHost.fireNotificationPulse();
            entry.setPulseSuppressed(false);
            mDozeServiceHost.fireNotificationPulse(entry);
            if (mPulsing) {
            if (mPulsing) {
                mDozeScrimController.cancelPendingPulseTimeout();
                mDozeScrimController.cancelPendingPulseTimeout();
            }
            }
@@ -3931,9 +3932,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) {
            for (Callback callback : mCallbacks) {
                callback.onNotificationAlerted();
                callback.onNotificationAlerted(pulseSupressedListener);
            }
            }
        }
        }


Loading