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

Commit a97ea059 authored by Kevin's avatar Kevin
Browse files

Split ambient pulse notif logic from heads up.

This CL aims to split the ambient pulse logic from the heads up logic as
a lot of the logic is specific to one or the other.  This CL introduces
the following major changes.

1. Introduces AmbientPulseManager which manages notifications that pulse
while the screen is dozing or on AOD and manages their lifetime.

2. Ties pulse duration for notifications more tightly with the lifetime.
This means DozeScrimController does not control the pulse time but
instead AmbientPulseManager.  This is because previously, having two
separate lifetimes (one for the pulse, one for the notification) caused
some strange issues to occur if one ended before the other.

3. Divide out logic for heads up and ambient pulse, so they are no
longer both tied to shouldPeek in NotificationEntryManager.

4. Multiple naming refactors for readability (e.g. contains ->
isAlerting, mShowAmbient -> mOnAmbient, etc.).

Although this is a refactor, some of the behavior does change in some
places where I thought the current behavior was not intended.  In
particular:

* Ambient notifications are no longer marked as seen immediately on
pulsing.  We should reserve this for when we are confident the user has
seen the notification.
* Ambient notifications are no longer disabled or snoozed when heads up
notifications are disabled or snoozed respectively.
* Removing/cancelling a notification that is pulsing no longer keeps
the pulse going awkwardly with no notification in the middle.  Instead,
the pulse ends (provided it was shown for a minimum amount of time).

Change-Id: I26af6f7e7ad7fa71d2d43f7c4d86fb34551151b0
Test: manual, runtest systemui
parent a01a1809
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -146,19 +146,29 @@
    <!-- Should "LTE"/"4G" be shown instead of "LTE+"/"4G+" when on NETWORK_TYPE_LTE_CA? -->
    <bool name="config_hideLtePlus">false</bool>

    <!-- milliseconds before the heads up notification auto-dismisses. -->
    <!-- The number of milliseconds before the heads up notification auto-dismisses. -->
    <integer name="heads_up_notification_decay">5000</integer>

    <!-- milliseconds after a heads up notification is pushed back
    <!-- The number of milliseconds after a heads up notification is pushed back
     before the app can interrupt again. -->
    <integer name="heads_up_default_snooze_length_ms">60000</integer>

    <!-- Minimum display time for a heads up notification, in milliseconds. -->
    <integer name="heads_up_notification_minimum_time">2000</integer>

    <!-- milliseconds before the heads up notification accepts touches. -->
    <!-- The number of milliseconds before the heads up notification accepts touches. -->
    <integer name="touch_acceptance_delay">700</integer>

    <!-- The number of milliseconds before the ambient notification auto-dismisses. This will
         override the default pulse length. -->
    <integer name="ambient_notification_decay">6000</integer>

    <!-- Minimum display time for a heads up notification, in milliseconds. -->
    <integer name="ambient_notification_minimum_time">2000</integer>

    <!-- The number of milliseconds to extend ambient pulse by when prompted (e.g. on touch) -->
    <integer name="ambient_notification_extension_time">6000</integer>

    <!-- The duration in seconds to wait before the dismiss buttons are shown. -->
    <integer name="recents_task_bar_dismiss_delay_seconds">1000</integer>

+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.Dependency.DependencyProvider;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.qs.QSTileHost;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
@@ -137,6 +138,7 @@ public class SystemUIFactory {
        providers.put(NotificationGroupManager.class, NotificationGroupManager::new);
        providers.put(NotificationMediaManager.class, () -> new NotificationMediaManager(context));
        providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager(context));
        providers.put(AmbientPulseManager.class, () -> new AmbientPulseManager(context));
        providers.put(NotificationBlockingHelperManager.class,
                () -> new NotificationBlockingHelperManager(context));
        providers.put(NotificationRemoteInputManager.class,
+2 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.systemui.car;

import android.content.Context;
import android.service.notification.StatusBarNotification;

import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.NotificationData;
@@ -41,7 +40,7 @@ public class CarNotificationEntryManager extends NotificationEntryManager {
    }

    @Override
    public boolean shouldPeek(NotificationData.Entry entry, StatusBarNotification sbn) {
    public boolean shouldHeadsUp(NotificationData.Entry entry) {
        // Because space is usually constrained in the auto use-case, there should not be a
        // pinned notification when the shade has been expanded. Ensure this by not pinning any
        // notification if the shade is already opened.
@@ -49,6 +48,6 @@ public class CarNotificationEntryManager extends NotificationEntryManager {
            return false;
        }

        return super.shouldPeek(entry, sbn);
        return super.shouldHeadsUp(entry);
    }
}
+9 −1
Original line number Diff line number Diff line
@@ -48,7 +48,15 @@ public interface DozeHost {
    void onIgnoreTouchWhilePulsing(boolean ignore);

    interface Callback {
        default void onNotificationHeadsUp() {}
        /**
         * Called when a high priority notification is added.
         */
        default void onNotificationAlerted() {}

        /**
         * Called when battery state or power save mode changes.
         * @param active whether power save is active or not
         */
        default void onPowerSaveChanged(boolean active) {}
    }

+1 −1
Original line number Diff line number Diff line
@@ -409,7 +409,7 @@ public class DozeTriggers implements DozeMachine.Part {

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

Loading