Loading src/com/android/settings/notification/app/RecentConversationsPreferenceController.java +7 −2 Original line number Diff line number Diff line Loading @@ -233,8 +233,13 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC private final Collator sCollator = Collator.getInstance(); @Override public int compare(ConversationChannel o1, ConversationChannel o2) { int labelComparison = sCollator.compare(o1.getShortcutInfo().getLabel(), o2.getShortcutInfo().getLabel()); int labelComparison = 0; if (o1.getShortcutInfo().getLabel() != null && o2.getShortcutInfo().getLabel() != null) { labelComparison = sCollator.compare( o1.getShortcutInfo().getLabel().toString(), o2.getShortcutInfo().getLabel().toString()); } if (labelComparison == 0) { return o1.getNotificationChannel().getId().compareTo( Loading tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java +33 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.pm.ShortcutInfo; import android.os.Bundle; import android.os.UserHandle; import android.provider.Settings; import android.text.SpannedString; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; Loading Loading @@ -338,4 +339,36 @@ public class RecentConversationsPreferenceControllerTest { // one for the preference, none for 'clear all' verify(outerContainer, times(1)).addPreference(any()); } @Test public void testSpans() { ShortcutInfo si = mock(ShortcutInfo.class); when(si.getLabel()).thenReturn(new SpannedString("hello")); ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "hi", 4), null, 7, true /* hasactivenotifs */); ShortcutInfo si2 = mock(ShortcutInfo.class); when(si2.getLabel()).thenReturn("hello"); ConversationChannel ccw2 = new ConversationChannel(si2, 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true /* hasactivenotifs */); // no crash mController.mConversationComparator.compare(ccw, ccw2); } @Test public void testNullSpans() { ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), null, 7, true /* hasactivenotifs */); ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true /* hasactivenotifs */); // no crash mController.mConversationComparator.compare(ccw, ccw2); } } Loading
src/com/android/settings/notification/app/RecentConversationsPreferenceController.java +7 −2 Original line number Diff line number Diff line Loading @@ -233,8 +233,13 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC private final Collator sCollator = Collator.getInstance(); @Override public int compare(ConversationChannel o1, ConversationChannel o2) { int labelComparison = sCollator.compare(o1.getShortcutInfo().getLabel(), o2.getShortcutInfo().getLabel()); int labelComparison = 0; if (o1.getShortcutInfo().getLabel() != null && o2.getShortcutInfo().getLabel() != null) { labelComparison = sCollator.compare( o1.getShortcutInfo().getLabel().toString(), o2.getShortcutInfo().getLabel().toString()); } if (labelComparison == 0) { return o1.getNotificationChannel().getId().compareTo( Loading
tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java +33 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.pm.ShortcutInfo; import android.os.Bundle; import android.os.UserHandle; import android.provider.Settings; import android.text.SpannedString; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; Loading Loading @@ -338,4 +339,36 @@ public class RecentConversationsPreferenceControllerTest { // one for the preference, none for 'clear all' verify(outerContainer, times(1)).addPreference(any()); } @Test public void testSpans() { ShortcutInfo si = mock(ShortcutInfo.class); when(si.getLabel()).thenReturn(new SpannedString("hello")); ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "hi", 4), null, 7, true /* hasactivenotifs */); ShortcutInfo si2 = mock(ShortcutInfo.class); when(si2.getLabel()).thenReturn("hello"); ConversationChannel ccw2 = new ConversationChannel(si2, 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true /* hasactivenotifs */); // no crash mController.mConversationComparator.compare(ccw, ccw2); } @Test public void testNullSpans() { ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), null, 7, true /* hasactivenotifs */); ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi2", "hi2", 4), null, 7, true /* hasactivenotifs */); // no crash mController.mConversationComparator.compare(ccw, ccw2); } }