Add null check in UserPreference
The comparator can get null objects according to bug report. Fixes: 130144755 Test: manual Change-Id: Ic8a332d390f411d2eb69c944fb7fd166d9961535
This commit is contained in:
@@ -40,9 +40,14 @@ public class UserPreference extends RestrictedPreference {
|
|||||||
public static final int USERID_UNKNOWN = -10;
|
public static final int USERID_UNKNOWN = -10;
|
||||||
public static final int USERID_GUEST_DEFAULTS = -11;
|
public static final int USERID_GUEST_DEFAULTS = -11;
|
||||||
public static final Comparator<UserPreference> SERIAL_NUMBER_COMPARATOR =
|
public static final Comparator<UserPreference> SERIAL_NUMBER_COMPARATOR =
|
||||||
new Comparator<UserPreference>() {
|
(p1, p2) -> {
|
||||||
@Override
|
|
||||||
public int compare(UserPreference p1, UserPreference p2) {
|
if (p1 == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (p2 == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
int sn1 = p1.getSerialNumber();
|
int sn1 = p1.getSerialNumber();
|
||||||
int sn2 = p2.getSerialNumber();
|
int sn2 = p2.getSerialNumber();
|
||||||
if (sn1 < sn2) {
|
if (sn1 < sn2) {
|
||||||
@@ -51,7 +56,6 @@ public class UserPreference extends RestrictedPreference {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private OnClickListener mDeleteClickListener;
|
private OnClickListener mDeleteClickListener;
|
||||||
|
Reference in New Issue
Block a user