Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +1 −2 Original line number Diff line number Diff line Loading @@ -103,7 +103,6 @@ import java.lang.annotation.Target; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.function.Consumer; import javax.inject.Inject; Loading Loading @@ -735,7 +734,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @SuppressWarnings("FieldCanBeLocal") private final NotificationEntryListener mEntryListener = new NotificationEntryListener() { @Override public void onPendingEntryAdded(NotificationEntry entry) { public void onNotificationAdded(NotificationEntry entry) { boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey()); boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey()); boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments( Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java +25 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ import android.content.Context; import android.content.Intent; import android.content.pm.LauncherApps; import android.content.pm.ShortcutInfo; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Parcelable; Loading @@ -39,8 +42,11 @@ import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import com.android.internal.graphics.ColorUtils; import com.android.internal.util.ArrayUtils; import com.android.internal.util.ContrastColorUtil; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.people.PeopleHubNotificationListenerKt; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -227,15 +233,29 @@ public class BubbleExperimentConfig { List<Person> personList = getPeopleFromNotification(entry); if (personList.size() > 0) { final Person person = personList.get(0); if (person != null) { icon = person.getIcon(); if (icon == null) { // Lets try and grab the icon constructed by the layout Drawable d = PeopleHubNotificationListenerKt.extractAvatarFromRow(entry); if (d instanceof BitmapDrawable) { icon = Icon.createWithBitmap(((BitmapDrawable) d).getBitmap()); } } } } if (icon == null) { icon = notification.getLargeIcon() != null ? notification.getLargeIcon() : notification.getSmallIcon(); boolean shouldTint = notification.getLargeIcon() == null; icon = shouldTint ? notification.getSmallIcon() : notification.getLargeIcon(); if (shouldTint) { int notifColor = entry.getSbn().getNotification().color; notifColor = ColorUtils.setAlphaComponent(notifColor, 255); notifColor = ContrastColorUtil.findContrastColor(notifColor, Color.WHITE, true /* findFg */, 3f); icon.setTint(notifColor); } } if (intent != null) { return new Notification.BubbleMetadata.Builder() Loading Loading @@ -285,7 +305,7 @@ public class BubbleExperimentConfig { } static boolean isShortcutIntent(PendingIntent intent) { return intent.equals(sDummyShortcutIntent); return intent != null && intent.equals(sDummyShortcutIntent); } static List<Person> getPeopleFromNotification(NotificationEntry entry) { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt +1 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ private fun addBadgeToDrawable( } } private fun extractAvatarFromRow(entry: NotificationEntry): Drawable? = fun extractAvatarFromRow(entry: NotificationEntry): Drawable? = entry.row ?.childrenWithId(R.id.expanded) ?.mapNotNull { it as? ViewGroup } Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +18 −18 Original line number Diff line number Diff line Loading @@ -261,7 +261,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveBubble_withDismissedNotif() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading Loading @@ -304,7 +304,7 @@ public class BubbleControllerTest extends SysuiTestCase { assertFalse(mBubbleController.isStackExpanded()); // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // We should have bubbles & their notifs should not be suppressed Loading Loading @@ -334,8 +334,8 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testCollapseAfterChangingExpandedBubble() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); mBubbleController.updateBubble(mRow2.getEntry()); Loading Loading @@ -377,7 +377,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testExpansionRemovesShowInShadeAndDot() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // We should have bubbles & their notifs should not be suppressed Loading @@ -403,7 +403,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testUpdateWhileExpanded_DoesntChangeShowInShadeAndDot() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // We should have bubbles & their notifs should not be suppressed Loading Loading @@ -439,8 +439,8 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveLastExpandedCollapses() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); mBubbleController.updateBubble(mRow2.getEntry()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); Loading Loading @@ -483,7 +483,7 @@ public class BubbleControllerTest extends SysuiTestCase { Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */); // Add the auto expand bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Expansion shouldn't change Loading @@ -501,7 +501,7 @@ public class BubbleControllerTest extends SysuiTestCase { Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */); // Add the auto expand bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Expansion should change Loading @@ -519,7 +519,7 @@ public class BubbleControllerTest extends SysuiTestCase { Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */); // Add the suppress notif bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Notif should be suppressed because we were foreground Loading Loading @@ -564,7 +564,7 @@ public class BubbleControllerTest extends SysuiTestCase { public void testExpandStackAndSelectBubble_removedFirst() { final String key = mRow.getEntry().getKey(); mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Simulate notification cancellation. Loading @@ -576,7 +576,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testMarkNewNotificationAsShowInShade() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); Loading @@ -586,7 +586,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testAddNotif_notBubble() { mEntryListener.onPendingEntryAdded(mNonBubbleNotifRow.getEntry()); mEntryListener.onNotificationAdded(mNonBubbleNotifRow.getEntry()); mEntryListener.onPreEntryUpdated(mNonBubbleNotifRow.getEntry()); verify(mBubbleStateChangeListener, never()).onHasBubblesChanged(anyBoolean()); Loading Loading @@ -631,7 +631,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveBubble_succeeds_appCancel() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading @@ -646,7 +646,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void removeBubble_fails_clearAll() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading @@ -669,7 +669,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void removeBubble_fails_userDismissNotif() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading @@ -692,7 +692,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void removeBubble_succeeds_userDismissBubble_userDimissNotif() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +1 −2 Original line number Diff line number Diff line Loading @@ -103,7 +103,6 @@ import java.lang.annotation.Target; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.function.Consumer; import javax.inject.Inject; Loading Loading @@ -735,7 +734,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @SuppressWarnings("FieldCanBeLocal") private final NotificationEntryListener mEntryListener = new NotificationEntryListener() { @Override public void onPendingEntryAdded(NotificationEntry entry) { public void onNotificationAdded(NotificationEntry entry) { boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey()); boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey()); boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments( Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java +25 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ import android.content.Context; import android.content.Intent; import android.content.pm.LauncherApps; import android.content.pm.ShortcutInfo; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Parcelable; Loading @@ -39,8 +42,11 @@ import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import com.android.internal.graphics.ColorUtils; import com.android.internal.util.ArrayUtils; import com.android.internal.util.ContrastColorUtil; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.people.PeopleHubNotificationListenerKt; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -227,15 +233,29 @@ public class BubbleExperimentConfig { List<Person> personList = getPeopleFromNotification(entry); if (personList.size() > 0) { final Person person = personList.get(0); if (person != null) { icon = person.getIcon(); if (icon == null) { // Lets try and grab the icon constructed by the layout Drawable d = PeopleHubNotificationListenerKt.extractAvatarFromRow(entry); if (d instanceof BitmapDrawable) { icon = Icon.createWithBitmap(((BitmapDrawable) d).getBitmap()); } } } } if (icon == null) { icon = notification.getLargeIcon() != null ? notification.getLargeIcon() : notification.getSmallIcon(); boolean shouldTint = notification.getLargeIcon() == null; icon = shouldTint ? notification.getSmallIcon() : notification.getLargeIcon(); if (shouldTint) { int notifColor = entry.getSbn().getNotification().color; notifColor = ColorUtils.setAlphaComponent(notifColor, 255); notifColor = ContrastColorUtil.findContrastColor(notifColor, Color.WHITE, true /* findFg */, 3f); icon.setTint(notifColor); } } if (intent != null) { return new Notification.BubbleMetadata.Builder() Loading Loading @@ -285,7 +305,7 @@ public class BubbleExperimentConfig { } static boolean isShortcutIntent(PendingIntent intent) { return intent.equals(sDummyShortcutIntent); return intent != null && intent.equals(sDummyShortcutIntent); } static List<Person> getPeopleFromNotification(NotificationEntry entry) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt +1 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ private fun addBadgeToDrawable( } } private fun extractAvatarFromRow(entry: NotificationEntry): Drawable? = fun extractAvatarFromRow(entry: NotificationEntry): Drawable? = entry.row ?.childrenWithId(R.id.expanded) ?.mapNotNull { it as? ViewGroup } Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +18 −18 Original line number Diff line number Diff line Loading @@ -261,7 +261,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveBubble_withDismissedNotif() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading Loading @@ -304,7 +304,7 @@ public class BubbleControllerTest extends SysuiTestCase { assertFalse(mBubbleController.isStackExpanded()); // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // We should have bubbles & their notifs should not be suppressed Loading Loading @@ -334,8 +334,8 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testCollapseAfterChangingExpandedBubble() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); mBubbleController.updateBubble(mRow2.getEntry()); Loading Loading @@ -377,7 +377,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testExpansionRemovesShowInShadeAndDot() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // We should have bubbles & their notifs should not be suppressed Loading @@ -403,7 +403,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testUpdateWhileExpanded_DoesntChangeShowInShadeAndDot() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // We should have bubbles & their notifs should not be suppressed Loading Loading @@ -439,8 +439,8 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveLastExpandedCollapses() { // Mark it as a bubble and add it explicitly mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onPendingEntryAdded(mRow2.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow2.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); mBubbleController.updateBubble(mRow2.getEntry()); verify(mBubbleStateChangeListener).onHasBubblesChanged(true); Loading Loading @@ -483,7 +483,7 @@ public class BubbleControllerTest extends SysuiTestCase { Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */); // Add the auto expand bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Expansion shouldn't change Loading @@ -501,7 +501,7 @@ public class BubbleControllerTest extends SysuiTestCase { Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */); // Add the auto expand bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Expansion should change Loading @@ -519,7 +519,7 @@ public class BubbleControllerTest extends SysuiTestCase { Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */); // Add the suppress notif bubble mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Notif should be suppressed because we were foreground Loading Loading @@ -564,7 +564,7 @@ public class BubbleControllerTest extends SysuiTestCase { public void testExpandStackAndSelectBubble_removedFirst() { final String key = mRow.getEntry().getKey(); mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); // Simulate notification cancellation. Loading @@ -576,7 +576,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testMarkNewNotificationAsShowInShade() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade( mRow.getEntry().getKey())); Loading @@ -586,7 +586,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testAddNotif_notBubble() { mEntryListener.onPendingEntryAdded(mNonBubbleNotifRow.getEntry()); mEntryListener.onNotificationAdded(mNonBubbleNotifRow.getEntry()); mEntryListener.onPreEntryUpdated(mNonBubbleNotifRow.getEntry()); verify(mBubbleStateChangeListener, never()).onHasBubblesChanged(anyBoolean()); Loading Loading @@ -631,7 +631,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void testRemoveBubble_succeeds_appCancel() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading @@ -646,7 +646,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void removeBubble_fails_clearAll() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading @@ -669,7 +669,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void removeBubble_fails_userDismissNotif() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading @@ -692,7 +692,7 @@ public class BubbleControllerTest extends SysuiTestCase { @Test public void removeBubble_succeeds_userDismissBubble_userDimissNotif() { mEntryListener.onPendingEntryAdded(mRow.getEntry()); mEntryListener.onNotificationAdded(mRow.getEntry()); mBubbleController.updateBubble(mRow.getEntry()); assertTrue(mBubbleController.hasBubbles()); Loading