Uprank ongoing CATEGORY_CALL HUNs over those w/ active remote input
Fixes: 164291424 Test: manual, atest Change-Id: I43d2812eaaf0a7ba47f6d0ccc1079acf669d3094
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user