Loading packages/SystemUI/src/com/android/systemui/people/NotificationHelper.java +10 −0 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.wm.shell.bubbles.Bubbles; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; /** Helper functions to handle notifications in People Tiles. */ Loading Loading @@ -234,5 +236,13 @@ public class NotificationHelper { if (DEBUG) Log.d(TAG, "Returning sender from group conversation notification."); return person.getName(); } /** Returns whether {@code entry} is suppressed from shade, meaning we should not show it. */ public static boolean shouldFilterOut( Optional<Bubbles> bubblesOptional, NotificationEntry entry) { return bubblesOptional.isPresent() && bubblesOptional.get().isBubbleNotificationSuppressedFromShade( entry.getKey(), entry.getSbn().getGroupKey()); } } packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +13 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE import static com.android.systemui.people.NotificationHelper.getContactUri; import static com.android.systemui.people.NotificationHelper.getHighestPriorityNotification; import static com.android.systemui.people.NotificationHelper.shouldFilterOut; import static com.android.systemui.people.NotificationHelper.shouldMatchNotificationByUri; import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_STRING; import static com.android.systemui.people.PeopleSpaceUtils.INVALID_USER_ID; Loading Loading @@ -87,6 +88,7 @@ import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.wm.shell.bubbles.Bubbles; import java.util.ArrayList; import java.util.Collections; Loading Loading @@ -119,6 +121,7 @@ public class PeopleSpaceWidgetManager { private NotificationEntryManager mNotificationEntryManager; private PackageManager mPackageManager; private INotificationManager mINotificationManager; private Optional<Bubbles> mBubblesOptional; private UserManager mUserManager; private PeopleSpaceWidgetManager mManager; public UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); Loading @@ -142,9 +145,9 @@ public class PeopleSpaceWidgetManager { @Inject public PeopleSpaceWidgetManager(Context context, LauncherApps launcherApps, NotificationEntryManager notificationEntryManager, PackageManager packageManager, UserManager userManager, NotificationManager notificationManager, BroadcastDispatcher broadcastDispatcher, @Background Executor bgExecutor) { PackageManager packageManager, Optional<Bubbles> bubblesOptional, UserManager userManager, NotificationManager notificationManager, BroadcastDispatcher broadcastDispatcher, @Background Executor bgExecutor) { if (DEBUG) Log.d(TAG, "constructor"); mContext = context; mAppWidgetManager = AppWidgetManager.getInstance(context); Loading @@ -157,6 +160,7 @@ public class PeopleSpaceWidgetManager { mPackageManager = packageManager; mINotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); mBubblesOptional = bubblesOptional; mUserManager = userManager; mNotificationManager = notificationManager; mManager = this; Loading Loading @@ -207,8 +211,9 @@ public class PeopleSpaceWidgetManager { AppWidgetManager appWidgetManager, IPeopleManager iPeopleManager, PeopleManager peopleManager, LauncherApps launcherApps, NotificationEntryManager notificationEntryManager, PackageManager packageManager, UserManager userManager, INotificationManager iNotificationManager, NotificationManager notificationManager, @Background Executor executor) { Optional<Bubbles> bubblesOptional, UserManager userManager, INotificationManager iNotificationManager, NotificationManager notificationManager, @Background Executor executor) { mContext = context; mAppWidgetManager = appWidgetManager; mIPeopleManager = iPeopleManager; Loading @@ -216,6 +221,7 @@ public class PeopleSpaceWidgetManager { mLauncherApps = launcherApps; mNotificationEntryManager = notificationEntryManager; mPackageManager = packageManager; mBubblesOptional = bubblesOptional; mUserManager = userManager; mINotificationManager = iNotificationManager; mNotificationManager = notificationManager; Loading Loading @@ -483,7 +489,8 @@ public class PeopleSpaceWidgetManager { notifications .stream() .filter(entry -> NotificationHelper.isValid(entry) && NotificationHelper.isMissedCallOrHasContent(entry)) && NotificationHelper.isMissedCallOrHasContent(entry) && !shouldFilterOut(mBubblesOptional, entry)) .collect(Collectors.groupingBy( PeopleTileKey::new, Collectors.mapping(Function.identity(), Collectors.toSet()))); Loading packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java +29 −1 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ import android.service.notification.ConversationChannelWrapper; import android.service.notification.StatusBarNotification; import android.service.notification.ZenModeConfig; import android.testing.AndroidTestingRunner; import android.text.TextUtils; import androidx.preference.PreferenceManager; import androidx.test.filters.SmallTest; Loading @@ -112,6 +113,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; import com.android.wm.shell.bubbles.Bubbles; import org.junit.Before; import org.junit.Test; Loading Loading @@ -224,6 +226,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { private NotificationManager mNotificationManager; @Mock private NotificationManager.Policy mNotificationPolicy; @Mock private Bubbles mBubbles; @Captor private ArgumentCaptor<NotificationHandler> mListenerCaptor; Loading @@ -242,7 +246,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { mDependency.injectTestDependency(NotificationEntryManager.class, mNotificationEntryManager); mManager = new PeopleSpaceWidgetManager(mContext, mAppWidgetManager, mIPeopleManager, mPeopleManager, mLauncherApps, mNotificationEntryManager, mPackageManager, mUserManager, mINotificationManager, mNotificationManager, mFakeExecutor); Optional.of(mBubbles), mUserManager, mINotificationManager, mNotificationManager, mFakeExecutor); mManager.attach(mListenerService); verify(mListenerService).addNotificationHandler(mListenerCaptor.capture()); Loading @@ -267,6 +272,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { INTERRUPTION_FILTER_ALL); int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT}; when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray); when(mBubbles.isBubbleNotificationSuppressedFromShade(any(), any())).thenReturn(false); when(mMockContext.getPackageName()).thenReturn(TEST_PACKAGE_A); when(mMockContext.getUserId()).thenReturn(0); Loading Loading @@ -1192,6 +1198,28 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { .getVisibleNotifications(); } @Test public void testAugmentTileFromNotificationEntryManager_notificationHidden() { when(mBubbles.isBubbleNotificationSuppressedFromShade(any(), any())).thenReturn(true); PeopleSpaceTile tile = new PeopleSpaceTile .Builder(SHORTCUT_ID, "userName", ICON, new Intent()) .setPackageName(TEST_PACKAGE_A) .setUserHandle(new UserHandle(0)) .build(); when(mNotificationEntryManager.getVisibleNotifications()) .thenReturn(List.of(mNotificationEntry)); PeopleSpaceTile actual = mManager.augmentTileFromNotificationEntryManager(tile, Optional.of(WIDGET_ID_WITH_SHORTCUT)); assertThat(TextUtils.isEmpty(actual.getNotificationContent())).isTrue(); verify(mNotificationEntryManager, times(1)) .getVisibleNotifications(); } @Test public void testUpdateWidgetsOnStateChange() { mManager.updateWidgetsOnStateChange(ACTION_BOOT_COMPLETED); Loading Loading
packages/SystemUI/src/com/android/systemui/people/NotificationHelper.java +10 −0 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.wm.shell.bubbles.Bubbles; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; /** Helper functions to handle notifications in People Tiles. */ Loading Loading @@ -234,5 +236,13 @@ public class NotificationHelper { if (DEBUG) Log.d(TAG, "Returning sender from group conversation notification."); return person.getName(); } /** Returns whether {@code entry} is suppressed from shade, meaning we should not show it. */ public static boolean shouldFilterOut( Optional<Bubbles> bubblesOptional, NotificationEntry entry) { return bubblesOptional.isPresent() && bubblesOptional.get().isBubbleNotificationSuppressedFromShade( entry.getKey(), entry.getSbn().getGroupKey()); } }
packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +13 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE import static com.android.systemui.people.NotificationHelper.getContactUri; import static com.android.systemui.people.NotificationHelper.getHighestPriorityNotification; import static com.android.systemui.people.NotificationHelper.shouldFilterOut; import static com.android.systemui.people.NotificationHelper.shouldMatchNotificationByUri; import static com.android.systemui.people.PeopleSpaceUtils.EMPTY_STRING; import static com.android.systemui.people.PeopleSpaceUtils.INVALID_USER_ID; Loading Loading @@ -87,6 +88,7 @@ import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.wm.shell.bubbles.Bubbles; import java.util.ArrayList; import java.util.Collections; Loading Loading @@ -119,6 +121,7 @@ public class PeopleSpaceWidgetManager { private NotificationEntryManager mNotificationEntryManager; private PackageManager mPackageManager; private INotificationManager mINotificationManager; private Optional<Bubbles> mBubblesOptional; private UserManager mUserManager; private PeopleSpaceWidgetManager mManager; public UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); Loading @@ -142,9 +145,9 @@ public class PeopleSpaceWidgetManager { @Inject public PeopleSpaceWidgetManager(Context context, LauncherApps launcherApps, NotificationEntryManager notificationEntryManager, PackageManager packageManager, UserManager userManager, NotificationManager notificationManager, BroadcastDispatcher broadcastDispatcher, @Background Executor bgExecutor) { PackageManager packageManager, Optional<Bubbles> bubblesOptional, UserManager userManager, NotificationManager notificationManager, BroadcastDispatcher broadcastDispatcher, @Background Executor bgExecutor) { if (DEBUG) Log.d(TAG, "constructor"); mContext = context; mAppWidgetManager = AppWidgetManager.getInstance(context); Loading @@ -157,6 +160,7 @@ public class PeopleSpaceWidgetManager { mPackageManager = packageManager; mINotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); mBubblesOptional = bubblesOptional; mUserManager = userManager; mNotificationManager = notificationManager; mManager = this; Loading Loading @@ -207,8 +211,9 @@ public class PeopleSpaceWidgetManager { AppWidgetManager appWidgetManager, IPeopleManager iPeopleManager, PeopleManager peopleManager, LauncherApps launcherApps, NotificationEntryManager notificationEntryManager, PackageManager packageManager, UserManager userManager, INotificationManager iNotificationManager, NotificationManager notificationManager, @Background Executor executor) { Optional<Bubbles> bubblesOptional, UserManager userManager, INotificationManager iNotificationManager, NotificationManager notificationManager, @Background Executor executor) { mContext = context; mAppWidgetManager = appWidgetManager; mIPeopleManager = iPeopleManager; Loading @@ -216,6 +221,7 @@ public class PeopleSpaceWidgetManager { mLauncherApps = launcherApps; mNotificationEntryManager = notificationEntryManager; mPackageManager = packageManager; mBubblesOptional = bubblesOptional; mUserManager = userManager; mINotificationManager = iNotificationManager; mNotificationManager = notificationManager; Loading Loading @@ -483,7 +489,8 @@ public class PeopleSpaceWidgetManager { notifications .stream() .filter(entry -> NotificationHelper.isValid(entry) && NotificationHelper.isMissedCallOrHasContent(entry)) && NotificationHelper.isMissedCallOrHasContent(entry) && !shouldFilterOut(mBubblesOptional, entry)) .collect(Collectors.groupingBy( PeopleTileKey::new, Collectors.mapping(Function.identity(), Collectors.toSet()))); Loading
packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java +29 −1 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ import android.service.notification.ConversationChannelWrapper; import android.service.notification.StatusBarNotification; import android.service.notification.ZenModeConfig; import android.testing.AndroidTestingRunner; import android.text.TextUtils; import androidx.preference.PreferenceManager; import androidx.test.filters.SmallTest; Loading @@ -112,6 +113,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; import com.android.wm.shell.bubbles.Bubbles; import org.junit.Before; import org.junit.Test; Loading Loading @@ -224,6 +226,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { private NotificationManager mNotificationManager; @Mock private NotificationManager.Policy mNotificationPolicy; @Mock private Bubbles mBubbles; @Captor private ArgumentCaptor<NotificationHandler> mListenerCaptor; Loading @@ -242,7 +246,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { mDependency.injectTestDependency(NotificationEntryManager.class, mNotificationEntryManager); mManager = new PeopleSpaceWidgetManager(mContext, mAppWidgetManager, mIPeopleManager, mPeopleManager, mLauncherApps, mNotificationEntryManager, mPackageManager, mUserManager, mINotificationManager, mNotificationManager, mFakeExecutor); Optional.of(mBubbles), mUserManager, mINotificationManager, mNotificationManager, mFakeExecutor); mManager.attach(mListenerService); verify(mListenerService).addNotificationHandler(mListenerCaptor.capture()); Loading @@ -267,6 +272,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { INTERRUPTION_FILTER_ALL); int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT}; when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray); when(mBubbles.isBubbleNotificationSuppressedFromShade(any(), any())).thenReturn(false); when(mMockContext.getPackageName()).thenReturn(TEST_PACKAGE_A); when(mMockContext.getUserId()).thenReturn(0); Loading Loading @@ -1192,6 +1198,28 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { .getVisibleNotifications(); } @Test public void testAugmentTileFromNotificationEntryManager_notificationHidden() { when(mBubbles.isBubbleNotificationSuppressedFromShade(any(), any())).thenReturn(true); PeopleSpaceTile tile = new PeopleSpaceTile .Builder(SHORTCUT_ID, "userName", ICON, new Intent()) .setPackageName(TEST_PACKAGE_A) .setUserHandle(new UserHandle(0)) .build(); when(mNotificationEntryManager.getVisibleNotifications()) .thenReturn(List.of(mNotificationEntry)); PeopleSpaceTile actual = mManager.augmentTileFromNotificationEntryManager(tile, Optional.of(WIDGET_ID_WITH_SHORTCUT)); assertThat(TextUtils.isEmpty(actual.getNotificationContent())).isTrue(); verify(mNotificationEntryManager, times(1)) .getVisibleNotifications(); } @Test public void testUpdateWidgetsOnStateChange() { mManager.updateWidgetsOnStateChange(ACTION_BOOT_COMPLETED); Loading