Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. Loading Loading @@ -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) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +9 −5 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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()); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. Loading Loading @@ -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) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +9 −5 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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()); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } }