Handle call log entries with a NULL value for the NEW field.
The current query causes SQLite to not return items with a NEW field set
to NULL (if they are missed calls or voicemail) neither in the NEW
query nor its negation.
This fix makes sure that each entry will match one of the two possible
queries and therefore always appear somewhere in the call log.
Bug: 5036125
Change-Id: I66e0b9ed50c9d5733e14ec8da181884a0a6f160d
diff --git a/src/com/android/contacts/calllog/CallLogQueryHandler.java b/src/com/android/contacts/calllog/CallLogQueryHandler.java
index 8ea544d..6359479 100644
--- a/src/com/android/contacts/calllog/CallLogQueryHandler.java
+++ b/src/com/android/contacts/calllog/CallLogQueryHandler.java
@@ -141,9 +141,11 @@
/** Fetches the list of calls in the call log, either the new one or the old ones. */
private void fetchCalls(int token, boolean isNew) {
+ // We need to check for NULL explicitly otherwise entries with where NEW is NULL will not
+ // match either the query or its negation.
String selection =
- String.format("%s = 1 AND (%s = ? OR %s = ?)",
- Calls.NEW, Calls.TYPE, Calls.TYPE);
+ String.format("%s IS NOT NULL AND %s = 1 AND (%s = ? OR %s = ?)",
+ Calls.NEW, Calls.NEW, Calls.TYPE, Calls.TYPE);
String[] selectionArgs = new String[]{
Integer.toString(Calls.MISSED_TYPE),
Integer.toString(Calls.VOICEMAIL_TYPE),