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

Commit dae3445c authored by Lyn's avatar Lyn
Browse files

Show HUN layout on lockscreen when FSI permission is denied

Bug: 271358296
Test: visual
  deny FSI permission, send HUN on lockscreen
  => show heads up layout

  send multiple HUNs on lockscreen
  => all HUNS show heads up layout

  send HUN with UMO at default display size, font size
  => show as icon in shelf when there's not enough space

  press HUN's expand button to go to full shade
  => show expanded layout with emphasized buttons (no regression)

  send HUN while pulsing/unlocked
  => show HUN layout with emphasized buttons (no regression)

Test: ExpandableNotificationRowTest
Test: NotificationStackSizeCalculatorTest
Change-Id: I2394fad0b7cd78c2f38be26d90e61152385dd63c
parent 7f886bf4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2644,7 +2644,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * except for legacy use cases.
     */
    public boolean canShowHeadsUp() {
        if (mOnKeyguard && !isDozing() && !isBypassEnabled()) {
        if (mOnKeyguard && !isDozing() && !isBypassEnabled() && !mEntry.isStickyAndNotDemoted()) {
            return false;
        }
        return true;
+7 −1
Original line number Diff line number Diff line
@@ -264,12 +264,18 @@ constructor(
        onLockscreen: Boolean
    ): Float {
        assert(view.isShowable(onLockscreen))

        var size =
            if (onLockscreen) {
                if (view is ExpandableNotificationRow && view.entry.isStickyAndNotDemoted) {
                    view.intrinsicHeight.toFloat()
                } else {
                    view.getMinHeight(/* ignoreTemporaryStates= */ true).toFloat()
                }
            } else {
                view.intrinsicHeight.toFloat()
            }

        size += calculateGapAndDividerHeight(stack, previousView, current = view, visibleIndex)
        return size
    }
+1 −1
Original line number Diff line number Diff line
@@ -734,7 +734,7 @@ public class StackScrollAlgorithm {
            float unmodifiedEndLocation = childState.getYTranslation() + childState.height;
            if (mIsExpanded) {
                if (row.mustStayOnScreen() && !childState.headsUpIsVisible
                        && !row.showingPulsing()) {
                        && !row.showingPulsing() && !ambientState.isOnKeyguard()) {
                    // Ensure that the heads up is always visible even when scrolled off
                    clampHunToTop(mQuickQsOffsetHeight, ambientState.getStackTranslation(),
                            row.getCollapsedHeight(), childState);
+56 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableView.OnHeightChangedListener;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer;
import com.android.systemui.statusbar.phone.KeyguardBypassController;

import org.junit.Assert;
import org.junit.Before;
@@ -103,6 +104,61 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
        mNotificationTestHelper.setFeatureFlags(fakeFeatureFlags);
    }

    @Test
    public void testCanShowHeadsUp_notOnKeyguard_true() throws Exception {
        ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        row.setOnKeyguard(false);

        assertTrue(row.canShowHeadsUp());
    }

    @Test
    public void testCanShowHeadsUp_dozing_true() throws Exception {
        ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        StatusBarStateController statusBarStateControllerMock =
                mNotificationTestHelper.getStatusBarStateController();
        when(statusBarStateControllerMock.isDozing()).thenReturn(true);

        assertTrue(row.canShowHeadsUp());
    }

    @Test
    public void testCanShowHeadsUp_bypassEnabled_true() throws Exception {
        ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        KeyguardBypassController keyguardBypassControllerMock =
                mNotificationTestHelper.getKeyguardBypassController();
        when(keyguardBypassControllerMock.getBypassEnabled()).thenReturn(true);

        assertTrue(row.canShowHeadsUp());
    }

    @Test
    public void testCanShowHeadsUp_stickyAndNotDemoted_true() throws Exception {
        ExpandableNotificationRow row = mNotificationTestHelper.createStickyRow();

        assertTrue(row.canShowHeadsUp());
    }

    @Test
    public void testCanShowHeadsUp_false() throws Exception {
        ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        row.setOnKeyguard(true);

        StatusBarStateController statusBarStateControllerMock =
                mNotificationTestHelper.getStatusBarStateController();
        when(statusBarStateControllerMock.isDozing()).thenReturn(false);

        KeyguardBypassController keyguardBypassControllerMock =
                mNotificationTestHelper.getKeyguardBypassController();
        when(keyguardBypassControllerMock.getBypassEnabled()).thenReturn(false);

        assertFalse(row.canShowHeadsUp());
    }

    @Test
    public void testUpdateBackgroundColors_isRecursive() throws Exception {
        ExpandableNotificationRow group = mNotificationTestHelper.createGroup();
+24 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.row;

import static android.app.Notification.FLAG_BUBBLE;
import static android.app.Notification.FLAG_FSI_REQUESTED_BUT_DENIED;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;

@@ -74,6 +75,7 @@ import com.android.systemui.statusbar.notification.people.PeopleNotificationIden
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow.ExpandableNotificationRowLogger;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow.OnExpandClickListener;
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag;
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.InflatedSmartReplyState;
@@ -121,6 +123,7 @@ public class NotificationTestHelper {
    private final RowContentBindStage mBindStage;
    private final IconManager mIconManager;
    private final StatusBarStateController mStatusBarStateController;
    private final KeyguardBypassController mKeyguardBypassController;
    private final PeopleNotificationIdentifier mPeopleNotificationIdentifier;
    private final OnUserInteractionCallback mOnUserInteractionCallback;
    private final NotificationDismissibilityProvider mDismissibilityProvider;
@@ -139,6 +142,7 @@ public class NotificationTestHelper {
        dependency.injectMockDependency(MediaOutputDialogFactory.class);
        mMockLogger = mock(ExpandableNotificationRowLogger.class);
        mStatusBarStateController = mock(StatusBarStateController.class);
        mKeyguardBypassController = mock(KeyguardBypassController.class);
        mGroupMembershipManager = mock(GroupMembershipManager.class);
        mGroupExpansionManager = mock(GroupExpansionManager.class);
        mHeadsUpManager = mock(HeadsUpManagerPhone.class);
@@ -308,6 +312,21 @@ public class NotificationTestHelper {
        return row;
    }

    /**
     * Returns an {@link ExpandableNotificationRow} that shows as a sticky FSI HUN.
     */
    public ExpandableNotificationRow createStickyRow()
            throws Exception {
        Notification n = createNotification(false /* isGroupSummary */,
                null /* groupKey */,
                makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */));
        n.flags |= FLAG_FSI_REQUESTED_BUT_DENIED;
        ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE,
                mDefaultInflationFlags, IMPORTANCE_HIGH);
        return row;
    }


    /**
     * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble.
     */
@@ -483,6 +502,10 @@ public class NotificationTestHelper {
        return mStatusBarStateController;
    }

    public KeyguardBypassController getKeyguardBypassController() {
        return mKeyguardBypassController;
    }

    private ExpandableNotificationRow generateRow(
            Notification notification,
            String pkg,
@@ -541,7 +564,7 @@ public class NotificationTestHelper {
                APP_NAME,
                entry.getKey(),
                mMockLogger,
                mock(KeyguardBypassController.class),
                mKeyguardBypassController,
                mGroupMembershipManager,
                mGroupExpansionManager,
                mHeadsUpManager,
Loading