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

Commit 79ab4d1b authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Ensure that HUN ordering is correct for Incoming CallStyle notifications

Bug: 178272497
Test: atest SystemUITests
Change-Id: I28adf676aaa58138a814c0aa21969ed20ce7e9af
parent 9b357d54
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -386,9 +386,17 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {
        return false;
    }

    private static boolean isOngoingCallNotif(NotificationEntry entry) {
        return entry.getSbn().isOngoing() && Notification.CATEGORY_CALL.equals(
                entry.getSbn().getNotification().category);
    /**
     * Determines if the notification is for a critical call that must display on top of an active
     * input notification.
     * The call isOngoing check is for a special case of incoming calls (see b/164291424).
     */
    private static boolean isCriticalCallNotif(NotificationEntry entry) {
        Notification n = entry.getSbn().getNotification();
        boolean isIncomingCall = n.isStyle(Notification.CallStyle.class) && n.extras.getInt(
                Notification.EXTRA_CALL_TYPE) == Notification.CallStyle.CALL_TYPE_INCOMING;
        return isIncomingCall || (entry.getSbn().isOngoing()
                && Notification.CATEGORY_CALL.equals(n.category));
    }

    /**
@@ -423,8 +431,8 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {
                return 1;
            }

            boolean selfCall = isOngoingCallNotif(mEntry);
            boolean otherCall = isOngoingCallNotif(headsUpEntry.mEntry);
            boolean selfCall = isCriticalCallNotif(mEntry);
            boolean otherCall = isCriticalCallNotif(headsUpEntry.mEntry);

            if (selfCall && !otherCall) {
                return -1;
+24 −0
Original line number Diff line number Diff line
@@ -24,9 +24,11 @@ import static junit.framework.Assert.assertTrue;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Person;
import android.content.Context;
import android.content.Intent;
import android.testing.AndroidTestingRunner;
@@ -116,6 +118,28 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest {
        assertThat(activeRemoteInput.compareTo(ongoingCall)).isGreaterThan(0);
    }

    @Test
    public void testAlertEntryCompareTo_incomingCallLessThanActiveRemoteInput() {
        HeadsUpManager.HeadsUpEntry incomingCall = mHeadsUpManager.new HeadsUpEntry();
        Person person = new Person.Builder().setName("person").build();
        PendingIntent intent = mock(PendingIntent.class);
        incomingCall.setEntry(new NotificationEntryBuilder()
                .setSbn(createNewSbn(0,
                        new Notification.Builder(mContext, "")
                                .setStyle(Notification.CallStyle
                                        .forIncomingCall(person, intent, intent))))
                .build());

        HeadsUpManager.HeadsUpEntry activeRemoteInput = mHeadsUpManager.new HeadsUpEntry();
        activeRemoteInput.setEntry(new NotificationEntryBuilder()
                .setSbn(createNewNotification(1))
                .build());
        activeRemoteInput.remoteInputActive = true;

        assertThat(incomingCall.compareTo(activeRemoteInput)).isLessThan(0);
        assertThat(activeRemoteInput.compareTo(incomingCall)).isGreaterThan(0);
    }

    @Test
    public void testPinEntry_logsPeek() {
        // Needs full screen intent in order to be pinned