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

Commit 2c275ad7 authored by Liran Binyamin's avatar Liran Binyamin Committed by Android (Google) Code Review
Browse files

Merge "Show HUN when bubbles cannot show notification" into main

parents 9df25ae5 306b56b6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2228,6 +2228,7 @@ public class BubbleController implements ConfigurationChangeListener,
        pw.print(prefix); pw.println("  currentUserId= " + mCurrentUserId);
        pw.print(prefix); pw.println("  isStatusBarShade= " + mIsStatusBarShade);
        pw.print(prefix); pw.println("  isShowingAsBubbleBar= " + isShowingAsBubbleBar());
        pw.print(prefix); pw.println("  isImeVisible= " + mBubblePositioner.isImeVisible());
        pw.println();

        mBubbleData.dump(pw);
@@ -2730,7 +2731,7 @@ public class BubbleController implements ConfigurationChangeListener,
        public boolean canShowBubbleNotification() {
            // in bubble bar mode, when the IME is visible we can't animate new bubbles.
            if (BubbleController.this.isShowingAsBubbleBar()) {
                return !BubbleController.this.mBubblePositioner.getIsImeVisible();
                return !BubbleController.this.mBubblePositioner.isImeVisible();
            }
            return true;
        }
+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ public class BubblePositioner {
    }

    /** Returns whether the IME is visible. */
    public boolean getIsImeVisible() {
    public boolean isImeVisible() {
        return mImeVisible;
    }

+12 −3
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.util.settings.GlobalSettings
import com.android.systemui.util.settings.SystemSettings
import com.android.systemui.util.time.SystemClock
import com.android.wm.shell.bubbles.Bubbles
import java.util.Optional
import kotlin.jvm.optionals.getOrElse

class PeekDisabledSuppressor(
    private val globalSettings: GlobalSettings,
@@ -119,12 +122,18 @@ class PeekPackageSnoozedSuppressor(private val headsUpManager: HeadsUpManager) :
        }
}

class PeekAlreadyBubbledSuppressor(private val statusBarStateController: StatusBarStateController) :
    VisualInterruptionFilter(types = setOf(PEEK), reason = "already bubbled") {
class PeekAlreadyBubbledSuppressor(
    private val statusBarStateController: StatusBarStateController,
    private val bubbles: Optional<Bubbles>
) : VisualInterruptionFilter(types = setOf(PEEK), reason = "already bubbled") {
    override fun shouldSuppress(entry: NotificationEntry) =
        when {
            statusBarStateController.state != SHADE -> false
            else -> entry.isBubble
            else -> {
                val bubblesCanShowNotification =
                    bubbles.map { it.canShowBubbleNotification() }.getOrElse { false }
                entry.isBubble && bubblesCanShowNotification
            }
        }
}

+9 −2
Original line number Diff line number Diff line
@@ -52,9 +52,11 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.EventLog;
import com.android.systemui.util.settings.GlobalSettings;
import com.android.systemui.util.time.SystemClock;
import com.android.wm.shell.bubbles.Bubbles;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javax.inject.Inject;

@@ -83,6 +85,7 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
    private final SystemClock mSystemClock;
    private final GlobalSettings mGlobalSettings;
    private final EventLog mEventLog;
    private final Optional<Bubbles> mBubbles;

    @VisibleForTesting
    protected boolean mUseHeadsUp = false;
@@ -132,7 +135,8 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
            DeviceProvisionedController deviceProvisionedController,
            SystemClock systemClock,
            GlobalSettings globalSettings,
            EventLog eventLog) {
            EventLog eventLog,
            Optional<Bubbles> bubbles) {
        mPowerManager = powerManager;
        mBatteryController = batteryController;
        mAmbientDisplayConfiguration = ambientDisplayConfiguration;
@@ -148,6 +152,7 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
        mSystemClock = systemClock;
        mGlobalSettings = globalSettings;
        mEventLog = eventLog;
        mBubbles = bubbles;
        ContentObserver headsUpObserver = new ContentObserver(mainHandler) {
            @Override
            public void onChange(boolean selfChange) {
@@ -440,7 +445,9 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
        }

        boolean inShade = mStatusBarStateController.getState() == SHADE;
        if (entry.isBubble() && inShade) {
        boolean bubblesCanShowNotification =
                mBubbles.isPresent() && mBubbles.get().canShowBubbleNotification();
        if (entry.isBubble() && inShade && bubblesCanShowNotification) {
            if (log) mLogger.logNoHeadsUpAlreadyBubbled(entry);
            return false;
        }
+5 −2
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ import com.android.systemui.util.EventLog
import com.android.systemui.util.settings.GlobalSettings
import com.android.systemui.util.settings.SystemSettings
import com.android.systemui.util.time.SystemClock
import com.android.wm.shell.bubbles.Bubbles
import java.util.Optional
import javax.inject.Inject

class VisualInterruptionDecisionProviderImpl
@@ -65,7 +67,8 @@ constructor(
    private val userTracker: UserTracker,
    private val avalancheProvider: AvalancheProvider,
    private val systemSettings: SystemSettings,
    private val packageManager: PackageManager
    private val packageManager: PackageManager,
    private val bubbles: Optional<Bubbles>
) : VisualInterruptionDecisionProvider {

    init {
@@ -158,7 +161,7 @@ constructor(
        addCondition(PulseDisabledSuppressor(ambientDisplayConfiguration, userTracker))
        addCondition(PulseBatterySaverSuppressor(batteryController))
        addFilter(PeekPackageSnoozedSuppressor(headsUpManager))
        addFilter(PeekAlreadyBubbledSuppressor(statusBarStateController))
        addFilter(PeekAlreadyBubbledSuppressor(statusBarStateController, bubbles))
        addFilter(PeekDndSuppressor())
        addFilter(PeekNotImportantSuppressor())
        addCondition(PeekDeviceNotInUseSuppressor(powerManager, statusBarStateController))
Loading