diff options
| author | 2020-09-24 16:26:03 +0000 | |
|---|---|---|
| committer | 2020-09-24 16:26:03 +0000 | |
| commit | 35f3713bc0bfad251977d4ed215c07be67960f5e (patch) | |
| tree | dbdf5e12582ae6faf7fc0ee2bfedb85edc3a10e3 | |
| parent | c231992ac3b068c3068619550bf95203e3bc2dc2 (diff) | |
| parent | 590c72f5ce8891b3c8979de4b035ec4169bdc949 (diff) | |
Merge "Uprank ongoing CATEGORY_CALL HUNs over those w/ active remote input" into rvc-qpr-dev
3 files changed, 48 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index c43ad36d4462..82ad00ad7c6d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -20,6 +20,7 @@ import static com.android.systemui.statusbar.notification.row.NotificationRowCon import android.annotation.NonNull; import android.annotation.Nullable; +import android.app.Notification; import android.content.Context; import android.content.res.Resources; import android.database.ContentObserver; @@ -359,6 +360,11 @@ 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); + } + /** * This represents a notification and how long it is in a heads up mode. It also manages its * lifecycle automatically when created. @@ -391,6 +397,15 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { 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) { return -1; } else if (!remoteInputActive && headsUpEntry.remoteInputActive) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java index 402a99d4c23d..dee6020dfd56 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java @@ -108,11 +108,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { return new TestableAlertingNotificationManager(); } - protected StatusBarNotification createNewNotification(int id) { - Notification.Builder n = new Notification.Builder(mContext, "") - .setSmallIcon(R.drawable.ic_person) - .setContentTitle("Title") - .setContentText("Text"); + protected StatusBarNotification createNewSbn(int id, Notification.Builder n) { return new StatusBarNotification( TEST_PACKAGE_NAME /* pkg */, TEST_PACKAGE_NAME, @@ -126,6 +122,14 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { 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 public void setUp() { mTestHandler = Handler.createAsync(Looper.myLooper()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java index fc7d0ce30687..0e4b053833b9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java @@ -16,12 +16,15 @@ 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.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doReturn; +import android.app.Notification; import android.content.Context; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; @@ -30,6 +33,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.statusbar.AlertingNotificationManager; import com.android.systemui.statusbar.AlertingNotificationManagerTest; +import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import org.junit.Before; import org.junit.Test; @@ -84,5 +88,25 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest { assertTrue("Heads up should live long enough", mLivesPastNormalTime); 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); + } } |