Loading services/core/java/com/android/server/notification/PreferencesHelper.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1255,6 +1255,7 @@ public class PreferencesHelper implements RankingConfig { for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) { final NotificationChannel nc = p.channels.valueAt(i); final NotificationChannel nc = p.channels.valueAt(i); if (!TextUtils.isEmpty(nc.getConversationId()) && !nc.isDeleted() if (!TextUtils.isEmpty(nc.getConversationId()) && !nc.isDeleted() && !nc.isDemoted() && (nc.isImportantConversation() || !onlyImportant)) { && (nc.isImportantConversation() || !onlyImportant)) { ConversationChannelWrapper conversation = new ConversationChannelWrapper(); ConversationChannelWrapper conversation = new ConversationChannelWrapper(); conversation.setPkg(p.pkg); conversation.setPkg(p.pkg); Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +38 −0 Original line number Original line Diff line number Diff line Loading @@ -3141,6 +3141,44 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertTrue(conversationWrapperContainsChannel(convos, channel2)); assertTrue(conversationWrapperContainsChannel(convos, channel2)); } } @Test public void testGetConversations_notDemoted() { String convoId = "convo"; NotificationChannel messages = new NotificationChannel("messages", "Messages", IMPORTANCE_DEFAULT); mHelper.createNotificationChannel(PKG_O, UID_O, messages, true, false); NotificationChannel calls = new NotificationChannel("calls", "Calls", IMPORTANCE_DEFAULT); mHelper.createNotificationChannel(PKG_O, UID_O, calls, true, false); NotificationChannel p = new NotificationChannel("p calls", "Calls", IMPORTANCE_DEFAULT); mHelper.createNotificationChannel(PKG_P, UID_P, p, true, false); NotificationChannel channel = new NotificationChannel("A person msgs", "messages from A", IMPORTANCE_DEFAULT); channel.setConversationId(messages.getId(), convoId); mHelper.createNotificationChannel(PKG_O, UID_O, channel, true, false); NotificationChannel diffConvo = new NotificationChannel("B person msgs", "messages from B", IMPORTANCE_DEFAULT); diffConvo.setConversationId(p.getId(), "different convo"); diffConvo.setDemoted(true); mHelper.createNotificationChannel(PKG_P, UID_P, diffConvo, true, false); NotificationChannel channel2 = new NotificationChannel("A person calls", "calls from A", IMPORTANCE_DEFAULT); channel2.setConversationId(calls.getId(), convoId); channel2.setImportantConversation(true); mHelper.createNotificationChannel(PKG_O, UID_O, channel2, true, false); List<ConversationChannelWrapper> convos = mHelper.getConversations(false); assertEquals(2, convos.size()); assertTrue(conversationWrapperContainsChannel(convos, channel)); assertFalse(conversationWrapperContainsChannel(convos, diffConvo)); assertTrue(conversationWrapperContainsChannel(convos, channel2)); } @Test @Test public void testGetConversations_onlyImportant() { public void testGetConversations_onlyImportant() { String convoId = "convo"; String convoId = "convo"; Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1255,6 +1255,7 @@ public class PreferencesHelper implements RankingConfig { for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) { final NotificationChannel nc = p.channels.valueAt(i); final NotificationChannel nc = p.channels.valueAt(i); if (!TextUtils.isEmpty(nc.getConversationId()) && !nc.isDeleted() if (!TextUtils.isEmpty(nc.getConversationId()) && !nc.isDeleted() && !nc.isDemoted() && (nc.isImportantConversation() || !onlyImportant)) { && (nc.isImportantConversation() || !onlyImportant)) { ConversationChannelWrapper conversation = new ConversationChannelWrapper(); ConversationChannelWrapper conversation = new ConversationChannelWrapper(); conversation.setPkg(p.pkg); conversation.setPkg(p.pkg); Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +38 −0 Original line number Original line Diff line number Diff line Loading @@ -3141,6 +3141,44 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertTrue(conversationWrapperContainsChannel(convos, channel2)); assertTrue(conversationWrapperContainsChannel(convos, channel2)); } } @Test public void testGetConversations_notDemoted() { String convoId = "convo"; NotificationChannel messages = new NotificationChannel("messages", "Messages", IMPORTANCE_DEFAULT); mHelper.createNotificationChannel(PKG_O, UID_O, messages, true, false); NotificationChannel calls = new NotificationChannel("calls", "Calls", IMPORTANCE_DEFAULT); mHelper.createNotificationChannel(PKG_O, UID_O, calls, true, false); NotificationChannel p = new NotificationChannel("p calls", "Calls", IMPORTANCE_DEFAULT); mHelper.createNotificationChannel(PKG_P, UID_P, p, true, false); NotificationChannel channel = new NotificationChannel("A person msgs", "messages from A", IMPORTANCE_DEFAULT); channel.setConversationId(messages.getId(), convoId); mHelper.createNotificationChannel(PKG_O, UID_O, channel, true, false); NotificationChannel diffConvo = new NotificationChannel("B person msgs", "messages from B", IMPORTANCE_DEFAULT); diffConvo.setConversationId(p.getId(), "different convo"); diffConvo.setDemoted(true); mHelper.createNotificationChannel(PKG_P, UID_P, diffConvo, true, false); NotificationChannel channel2 = new NotificationChannel("A person calls", "calls from A", IMPORTANCE_DEFAULT); channel2.setConversationId(calls.getId(), convoId); channel2.setImportantConversation(true); mHelper.createNotificationChannel(PKG_O, UID_O, channel2, true, false); List<ConversationChannelWrapper> convos = mHelper.getConversations(false); assertEquals(2, convos.size()); assertTrue(conversationWrapperContainsChannel(convos, channel)); assertFalse(conversationWrapperContainsChannel(convos, diffConvo)); assertTrue(conversationWrapperContainsChannel(convos, channel2)); } @Test @Test public void testGetConversations_onlyImportant() { public void testGetConversations_onlyImportant() { String convoId = "convo"; String convoId = "convo"; Loading