Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +12 −12 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { private final Context mContext; private final NotificationManager mNotificationManager; private final Handler mMainHandler; private final List<NotifServiceListener> mNotificationListeners = new ArrayList<>(); private final List<NotificationHandler> mNotificationHandlers = new ArrayList<>(); private final ArrayList<NotificationSettingsListener> mSettingsListeners = new ArrayList<>(); @Inject Loading @@ -65,11 +65,11 @@ public class NotificationListener extends NotificationListenerWithPlugins { } /** Registers a listener that's notified when notifications are added/removed/etc. */ public void addNotificationListener(NotifServiceListener listener) { if (mNotificationListeners.contains(listener)) { public void addNotificationHandler(NotificationHandler handler) { if (mNotificationHandlers.contains(handler)) { throw new IllegalArgumentException("Listener is already added"); } mNotificationListeners.add(listener); mNotificationHandlers.add(handler); } /** Registers a listener that's notified when any notification-related settings change. */ Loading Loading @@ -100,7 +100,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { final RankingMap completeMap = new RankingMap(newRankings.toArray(new Ranking[0])); for (StatusBarNotification sbn : notifications) { for (NotifServiceListener listener : mNotificationListeners) { for (NotificationHandler listener : mNotificationHandlers) { listener.onNotificationPosted(sbn, completeMap); } } Loading @@ -117,8 +117,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { mMainHandler.post(() -> { processForRemoteInput(sbn.getNotification(), mContext); for (NotifServiceListener listener : mNotificationListeners) { listener.onNotificationPosted(sbn, rankingMap); for (NotificationHandler handler : mNotificationHandlers) { handler.onNotificationPosted(sbn, rankingMap); } }); } Loading @@ -130,8 +130,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { if (DEBUG) Log.d(TAG, "onNotificationRemoved: " + sbn + " reason: " + reason); if (sbn != null && !onPluginNotificationRemoved(sbn, rankingMap)) { mMainHandler.post(() -> { for (NotifServiceListener listener : mNotificationListeners) { listener.onNotificationRemoved(sbn, rankingMap, reason); for (NotificationHandler handler : mNotificationHandlers) { handler.onNotificationRemoved(sbn, rankingMap, reason); } }); } Loading @@ -148,8 +148,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { if (rankingMap != null) { RankingMap r = onPluginRankingUpdate(rankingMap); mMainHandler.post(() -> { for (NotifServiceListener listener : mNotificationListeners) { listener.onNotificationRankingUpdate(r); for (NotificationHandler handler : mNotificationHandlers) { handler.onNotificationRankingUpdate(r); } }); } Loading Loading @@ -207,7 +207,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { } /** Interface for listening to add/remove events that we receive from NotificationManager. */ public interface NotifServiceListener { public interface NotificationHandler { void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap); void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap); void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap, int reason); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.statusbar.NotificationLifetimeExtender; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationRemoveInterceptor; Loading Loading @@ -179,7 +179,7 @@ public class NotificationEntryManager implements /** Once called, the NEM will start processing notification events from system server. */ public void attach(NotificationListener notificationListener) { notificationListener.addNotificationListener(mNotifListener); notificationListener.addNotificationHandler(mNotifListener); } /** Adds a {@link NotificationEntryListener}. */ Loading Loading @@ -326,7 +326,7 @@ public class NotificationEntryManager implements } } private final NotifServiceListener mNotifListener = new NotifServiceListener() { private final NotificationHandler mNotifListener = new NotificationHandler() { @Override public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { final boolean isUpdate = mActiveNotifications.containsKey(sbn.getKey()); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +3 −3 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ import android.util.Log; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.util.Assert; import java.lang.annotation.Retention; Loading Loading @@ -115,7 +115,7 @@ public class NotifCollection { } mAttached = true; listenerService.addNotificationListener(mNotifServiceListener); listenerService.addNotificationHandler(mNotificationHandler); } /** Loading Loading @@ -372,7 +372,7 @@ public class NotifCollection { mAmDispatchingToOtherCode = false; } private final NotifServiceListener mNotifServiceListener = new NotifServiceListener() { private final NotificationHandler mNotificationHandler = new NotificationHandler() { @Override public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { NotifCollection.this.onNotificationPosted(sbn, rankingMap); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import org.junit.Before; import org.junit.Test; Loading @@ -51,7 +51,7 @@ public class NotificationListenerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test"; private static final int TEST_UID = 0; @Mock private NotifServiceListener mServiceListener; @Mock private NotificationHandler mNotificationHandler; @Mock private NotificationManager mNotificationManager; private NotificationListener mListener; Loading @@ -69,21 +69,21 @@ public class NotificationListenerTest extends SysuiTestCase { mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, new Notification(), UserHandle.CURRENT, null, 0); mListener.addNotificationListener(mServiceListener); mListener.addNotificationHandler(mNotificationHandler); } @Test public void testNotificationAddCallsAddNotification() { mListener.onNotificationPosted(mSbn, mRanking); TestableLooper.get(this).processAllMessages(); verify(mServiceListener).onNotificationPosted(mSbn, mRanking); verify(mNotificationHandler).onNotificationPosted(mSbn, mRanking); } @Test public void testNotificationRemovalCallsRemoveNotification() { mListener.onNotificationRemoved(mSbn, mRanking); TestableLooper.get(this).processAllMessages(); verify(mServiceListener).onNotificationRemoved(eq(mSbn), eq(mRanking), anyInt()); verify(mNotificationHandler).onNotificationRemoved(eq(mSbn), eq(mRanking), anyInt()); } @Test Loading @@ -91,7 +91,7 @@ public class NotificationListenerTest extends SysuiTestCase { mListener.onNotificationRankingUpdate(mRanking); TestableLooper.get(this).processAllMessages(); // RankingMap may be modified by plugins. verify(mServiceListener).onNotificationRankingUpdate(any()); verify(mNotificationHandler).onNotificationRankingUpdate(any()); } @Test Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NoManSimulator.java +6 −6 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import java.util.ArrayList; import java.util.List; Loading @@ -36,13 +36,13 @@ import java.util.Map; * keep its RankingMap up to date and call appropriate event listeners. */ public class NoManSimulator { private final List<NotifServiceListener> mListeners = new ArrayList<>(); private final List<NotificationHandler> mListeners = new ArrayList<>(); private final Map<String, Ranking> mRankings = new ArrayMap<>(); public NoManSimulator() { } public void addListener(NotifServiceListener listener) { public void addListener(NotificationHandler listener) { mListeners.add(listener); } Loading @@ -50,7 +50,7 @@ public class NoManSimulator { final NotificationEntry entry = builder.build(); mRankings.put(entry.getKey(), entry.getRanking()); final RankingMap rankingMap = buildRankingMap(); for (NotifServiceListener listener : mListeners) { for (NotificationHandler listener : mListeners) { listener.onNotificationPosted(entry.getSbn(), rankingMap); } return new NotifEvent(entry.getSbn(), entry.getRanking(), rankingMap); Loading @@ -59,7 +59,7 @@ public class NoManSimulator { public NotifEvent retractNotif(StatusBarNotification sbn, int reason) { assertNotNull(mRankings.remove(sbn.getKey())); final RankingMap rankingMap = buildRankingMap(); for (NotifServiceListener listener : mListeners) { for (NotificationHandler listener : mListeners) { listener.onNotificationRemoved(sbn, rankingMap, reason); } return new NotifEvent(sbn, null, rankingMap); Loading @@ -67,7 +67,7 @@ public class NoManSimulator { public void issueRankingUpdate() { final RankingMap rankingMap = buildRankingMap(); for (NotifServiceListener listener : mListeners) { for (NotificationHandler listener : mListeners) { listener.onNotificationRankingUpdate(rankingMap); } } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +12 −12 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { private final Context mContext; private final NotificationManager mNotificationManager; private final Handler mMainHandler; private final List<NotifServiceListener> mNotificationListeners = new ArrayList<>(); private final List<NotificationHandler> mNotificationHandlers = new ArrayList<>(); private final ArrayList<NotificationSettingsListener> mSettingsListeners = new ArrayList<>(); @Inject Loading @@ -65,11 +65,11 @@ public class NotificationListener extends NotificationListenerWithPlugins { } /** Registers a listener that's notified when notifications are added/removed/etc. */ public void addNotificationListener(NotifServiceListener listener) { if (mNotificationListeners.contains(listener)) { public void addNotificationHandler(NotificationHandler handler) { if (mNotificationHandlers.contains(handler)) { throw new IllegalArgumentException("Listener is already added"); } mNotificationListeners.add(listener); mNotificationHandlers.add(handler); } /** Registers a listener that's notified when any notification-related settings change. */ Loading Loading @@ -100,7 +100,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { final RankingMap completeMap = new RankingMap(newRankings.toArray(new Ranking[0])); for (StatusBarNotification sbn : notifications) { for (NotifServiceListener listener : mNotificationListeners) { for (NotificationHandler listener : mNotificationHandlers) { listener.onNotificationPosted(sbn, completeMap); } } Loading @@ -117,8 +117,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { mMainHandler.post(() -> { processForRemoteInput(sbn.getNotification(), mContext); for (NotifServiceListener listener : mNotificationListeners) { listener.onNotificationPosted(sbn, rankingMap); for (NotificationHandler handler : mNotificationHandlers) { handler.onNotificationPosted(sbn, rankingMap); } }); } Loading @@ -130,8 +130,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { if (DEBUG) Log.d(TAG, "onNotificationRemoved: " + sbn + " reason: " + reason); if (sbn != null && !onPluginNotificationRemoved(sbn, rankingMap)) { mMainHandler.post(() -> { for (NotifServiceListener listener : mNotificationListeners) { listener.onNotificationRemoved(sbn, rankingMap, reason); for (NotificationHandler handler : mNotificationHandlers) { handler.onNotificationRemoved(sbn, rankingMap, reason); } }); } Loading @@ -148,8 +148,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { if (rankingMap != null) { RankingMap r = onPluginRankingUpdate(rankingMap); mMainHandler.post(() -> { for (NotifServiceListener listener : mNotificationListeners) { listener.onNotificationRankingUpdate(r); for (NotificationHandler handler : mNotificationHandlers) { handler.onNotificationRankingUpdate(r); } }); } Loading Loading @@ -207,7 +207,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { } /** Interface for listening to add/remove events that we receive from NotificationManager. */ public interface NotifServiceListener { public interface NotificationHandler { void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap); void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap); void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap, int reason); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ import com.android.systemui.Dependency; import com.android.systemui.Dumpable; import com.android.systemui.statusbar.NotificationLifetimeExtender; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationRemoteInputManager; import com.android.systemui.statusbar.NotificationRemoveInterceptor; Loading Loading @@ -179,7 +179,7 @@ public class NotificationEntryManager implements /** Once called, the NEM will start processing notification events from system server. */ public void attach(NotificationListener notificationListener) { notificationListener.addNotificationListener(mNotifListener); notificationListener.addNotificationHandler(mNotifListener); } /** Adds a {@link NotificationEntryListener}. */ Loading Loading @@ -326,7 +326,7 @@ public class NotificationEntryManager implements } } private final NotifServiceListener mNotifListener = new NotifServiceListener() { private final NotificationHandler mNotifListener = new NotificationHandler() { @Override public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { final boolean isUpdate = mActiveNotifications.containsKey(sbn.getKey()); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +3 −3 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ import android.util.Log; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import com.android.systemui.util.Assert; import java.lang.annotation.Retention; Loading Loading @@ -115,7 +115,7 @@ public class NotifCollection { } mAttached = true; listenerService.addNotificationListener(mNotifServiceListener); listenerService.addNotificationHandler(mNotificationHandler); } /** Loading Loading @@ -372,7 +372,7 @@ public class NotifCollection { mAmDispatchingToOtherCode = false; } private final NotifServiceListener mNotifServiceListener = new NotifServiceListener() { private final NotificationHandler mNotificationHandler = new NotificationHandler() { @Override public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { NotifCollection.this.onNotificationPosted(sbn, rankingMap); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import org.junit.Before; import org.junit.Test; Loading @@ -51,7 +51,7 @@ public class NotificationListenerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test"; private static final int TEST_UID = 0; @Mock private NotifServiceListener mServiceListener; @Mock private NotificationHandler mNotificationHandler; @Mock private NotificationManager mNotificationManager; private NotificationListener mListener; Loading @@ -69,21 +69,21 @@ public class NotificationListenerTest extends SysuiTestCase { mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, new Notification(), UserHandle.CURRENT, null, 0); mListener.addNotificationListener(mServiceListener); mListener.addNotificationHandler(mNotificationHandler); } @Test public void testNotificationAddCallsAddNotification() { mListener.onNotificationPosted(mSbn, mRanking); TestableLooper.get(this).processAllMessages(); verify(mServiceListener).onNotificationPosted(mSbn, mRanking); verify(mNotificationHandler).onNotificationPosted(mSbn, mRanking); } @Test public void testNotificationRemovalCallsRemoveNotification() { mListener.onNotificationRemoved(mSbn, mRanking); TestableLooper.get(this).processAllMessages(); verify(mServiceListener).onNotificationRemoved(eq(mSbn), eq(mRanking), anyInt()); verify(mNotificationHandler).onNotificationRemoved(eq(mSbn), eq(mRanking), anyInt()); } @Test Loading @@ -91,7 +91,7 @@ public class NotificationListenerTest extends SysuiTestCase { mListener.onNotificationRankingUpdate(mRanking); TestableLooper.get(this).processAllMessages(); // RankingMap may be modified by plugins. verify(mServiceListener).onNotificationRankingUpdate(any()); verify(mNotificationHandler).onNotificationRankingUpdate(any()); } @Test Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NoManSimulator.java +6 −6 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import com.android.systemui.statusbar.NotificationListener.NotifServiceListener; import com.android.systemui.statusbar.NotificationListener.NotificationHandler; import java.util.ArrayList; import java.util.List; Loading @@ -36,13 +36,13 @@ import java.util.Map; * keep its RankingMap up to date and call appropriate event listeners. */ public class NoManSimulator { private final List<NotifServiceListener> mListeners = new ArrayList<>(); private final List<NotificationHandler> mListeners = new ArrayList<>(); private final Map<String, Ranking> mRankings = new ArrayMap<>(); public NoManSimulator() { } public void addListener(NotifServiceListener listener) { public void addListener(NotificationHandler listener) { mListeners.add(listener); } Loading @@ -50,7 +50,7 @@ public class NoManSimulator { final NotificationEntry entry = builder.build(); mRankings.put(entry.getKey(), entry.getRanking()); final RankingMap rankingMap = buildRankingMap(); for (NotifServiceListener listener : mListeners) { for (NotificationHandler listener : mListeners) { listener.onNotificationPosted(entry.getSbn(), rankingMap); } return new NotifEvent(entry.getSbn(), entry.getRanking(), rankingMap); Loading @@ -59,7 +59,7 @@ public class NoManSimulator { public NotifEvent retractNotif(StatusBarNotification sbn, int reason) { assertNotNull(mRankings.remove(sbn.getKey())); final RankingMap rankingMap = buildRankingMap(); for (NotifServiceListener listener : mListeners) { for (NotificationHandler listener : mListeners) { listener.onNotificationRemoved(sbn, rankingMap, reason); } return new NotifEvent(sbn, null, rankingMap); Loading @@ -67,7 +67,7 @@ public class NoManSimulator { public void issueRankingUpdate() { final RankingMap rankingMap = buildRankingMap(); for (NotifServiceListener listener : mListeners) { for (NotificationHandler listener : mListeners) { listener.onNotificationRankingUpdate(rankingMap); } } Loading