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

Commit ebb1c643 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Uprank ongoing CATEGORY_CALL HUNs over those w/ active remote input"...

Merge "Uprank ongoing CATEGORY_CALL HUNs over those w/ active remote input" into rvc-qpr-dev am: 35f3713b am: 7999d971

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12675708

Change-Id: If5274a96970f63d165938eeea2b084a32221318a
parents eb74d9ac 7999d971
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.systemui.statusbar.notification.row.NotificationRowCon


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.database.ContentObserver;
@@ -359,6 +360,11 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {
        return false;
        return false;
    }
    }


    private static boolean isOngoingCallNotif(NotificationEntry entry) {
        return entry.getSbn().isOngoing() && Notification.CATEGORY_CALL.equals(
                entry.getSbn().getNotification().category);
    }

    /**
    /**
     * This represents a notification and how long it is in a heads up mode. It also manages its
     * This represents a notification and how long it is in a heads up mode. It also manages its
     * lifecycle automatically when created.
     * lifecycle automatically when created.
@@ -391,6 +397,15 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {
                return 1;
                return 1;
            }
            }


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

            if (selfCall && !otherCall) {
                return -1;
            } else if (!selfCall && otherCall) {
                return 1;
            }

            if (remoteInputActive && !headsUpEntry.remoteInputActive) {
            if (remoteInputActive && !headsUpEntry.remoteInputActive) {
                return -1;
                return -1;
            } else if (!remoteInputActive && headsUpEntry.remoteInputActive) {
            } else if (!remoteInputActive && headsUpEntry.remoteInputActive) {
+9 −5
Original line number Original line Diff line number Diff line
@@ -108,11 +108,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase {
        return new TestableAlertingNotificationManager();
        return new TestableAlertingNotificationManager();
    }
    }


    protected StatusBarNotification createNewNotification(int id) {
    protected StatusBarNotification createNewSbn(int id, Notification.Builder n) {
        Notification.Builder n = new Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .setContentTitle("Title")
                .setContentText("Text");
        return new StatusBarNotification(
        return new StatusBarNotification(
                TEST_PACKAGE_NAME /* pkg */,
                TEST_PACKAGE_NAME /* pkg */,
                TEST_PACKAGE_NAME,
                TEST_PACKAGE_NAME,
@@ -126,6 +122,14 @@ public class AlertingNotificationManagerTest extends SysuiTestCase {
                0 /* postTime */);
                0 /* postTime */);
    }
    }


    protected StatusBarNotification createNewNotification(int id) {
        Notification.Builder n = new Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .setContentTitle("Title")
                .setContentText("Text");
        return createNewSbn(id, n);
    }

    @Before
    @Before
    public void setUp() {
    public void setUp() {
        mTestHandler = Handler.createAsync(Looper.myLooper());
        mTestHandler = Handler.createAsync(Looper.myLooper());
+24 −0
Original line number Original line Diff line number Diff line
@@ -16,12 +16,15 @@


package com.android.systemui.statusbar.policy;
package com.android.systemui.statusbar.policy;


import static com.google.common.truth.Truth.assertThat;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.assertTrue;


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


import android.app.Notification;
import android.content.Context;
import android.content.Context;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper;
@@ -30,6 +33,7 @@ import androidx.test.filters.SmallTest;


import com.android.systemui.statusbar.AlertingNotificationManager;
import com.android.systemui.statusbar.AlertingNotificationManager;
import com.android.systemui.statusbar.AlertingNotificationManagerTest;
import com.android.systemui.statusbar.AlertingNotificationManagerTest;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;


import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
@@ -84,5 +88,25 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest {
        assertTrue("Heads up should live long enough", mLivesPastNormalTime);
        assertTrue("Heads up should live long enough", mLivesPastNormalTime);
        assertFalse(mHeadsUpManager.isAlerting(mEntry.getKey()));
        assertFalse(mHeadsUpManager.isAlerting(mEntry.getKey()));
    }
    }

    @Test
    public void testAlertEntryCompareTo_ongoingCallLessThanActiveRemoteInput() {
        HeadsUpManager.HeadsUpEntry ongoingCall = mHeadsUpManager.new HeadsUpEntry();
        ongoingCall.setEntry(new NotificationEntryBuilder()
                .setSbn(createNewSbn(0,
                        new Notification.Builder(mContext, "")
                                .setCategory(Notification.CATEGORY_CALL)
                                .setOngoing(true)))
                .build());

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

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