Use Long.compare to compare longs
Fix potential int overflow in comparator.
Bug:24117229
Change-Id: I8095e19ff9b853dcf3530e1cabd8dc9d8e326b0a
diff --git a/src/com/android/contacts/editor/RawContactDeltaComparator.java b/src/com/android/contacts/editor/RawContactDeltaComparator.java
index 17a4dda..1a00c9d 100644
--- a/src/com/android/contacts/editor/RawContactDeltaComparator.java
+++ b/src/com/android/contacts/editor/RawContactDeltaComparator.java
@@ -120,12 +120,14 @@
// Both are in the same account, fall back to contact ID
Long oneId = one.getRawContactId();
Long twoId = two.getRawContactId();
- if (oneId == null) {
+ if (oneId == null && twoId == null) {
+ return 0;
+ } else if (oneId == null) {
return -1;
} else if (twoId == null) {
return 1;
}
- return (int) (oneId - twoId);
+ return Long.compare(oneId, twoId);
}
-}
\ No newline at end of file
+}