Sorting people by key crashes launcher

Approch: approach: filter out people with null getKey before sorting.

Bug:139436782
Change-Id: I6510a12374ff4fec02c879ff76ba42b1fcdb8281
This commit is contained in:
Samuel Fufa
2019-08-14 14:26:05 -07:00
parent 23582eb7c0
commit 8628eb9353

View File

@@ -20,16 +20,14 @@ import android.app.Notification;
import android.app.Person;
import android.service.notification.StatusBarNotification;
import com.android.launcher3.Utilities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.Utilities;
import java.util.ArrayList;
import java.util.List;
/**
* The key data associated with the notification, used to determine what to include
* in dots and dummy popup views before they are populated.
@@ -39,8 +37,9 @@ import androidx.annotation.Nullable;
public class NotificationKeyData {
public final String notificationKey;
public final String shortcutId;
@NonNull
public final String[] personKeysFromNotification;
public int count;
@NonNull public final String[] personKeysFromNotification;
private NotificationKeyData(String notificationKey, String shortcutId, int count,
String[] personKeysFromNotification) {
@@ -70,7 +69,8 @@ public class NotificationKeyData {
if (people == null || people.isEmpty()) {
return Utilities.EMPTY_STRING_ARRAY;
}
return people.stream().map(Person::getKey).sorted().toArray(String[]::new);
return people.stream().filter(person -> person.getKey() != null)
.map(Person::getKey).sorted().toArray(String[]::new);
}
@Override