summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2015-12-02 17:06:19 -0800
committerBrandon Maxwell <maxwelb@google.com>2015-12-03 11:54:18 -0800
commit5069efed6b85eea5cdccced366334e139b6b5360 (patch)
tree15baf0d04283f5af4640ce9ed02afbbe71ad2c08
parentda8da31ec024b7e9b7fb264bc776112513a9edbe (diff)
Fixing where clause issue with call log query
Change-Id: Ib4baa544925f8bcc6b8f4df8989927ebb3635ce3
-rw-r--r--src/com/android/dialer/calllog/CallLogQueryHandler.java31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java
index d99284698..559cf97b2 100644
--- a/src/com/android/dialer/calllog/CallLogQueryHandler.java
+++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java
@@ -50,8 +50,6 @@ import java.util.List;
/** Handles asynchronous queries to the call log. */
public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
private static final String TAG = "CallLogQueryHandler";
private static final int NUM_LOGS_TO_DISPLAY = 1000;
@@ -162,27 +160,25 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
/** Fetches the list of calls in the call log. */
private void fetchCalls(int token, int callType, boolean newOnly, long newerThan) {
- // We need to check for NULL explicitly otherwise entries with where READ is NULL
- // may not match either the query or its negation.
- // We consider the calls that are not yet consumed (i.e. IS_READ = 0) as "new".
StringBuilder where = new StringBuilder();
List<String> selectionArgs = Lists.newArrayList();
+ // Always hide blocked calls.
+ where.append("(").append(Calls.TYPE).append(" != ?)");
+ selectionArgs.add(Integer.toString(AppCompatConstants.CALLS_BLOCKED_TYPE));
+
// Ignore voicemails marked as deleted
if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M)
>= Build.VERSION_CODES.M) {
- where.append(Voicemails.DELETED).append(" = 0");
+ where.append(" AND (").append(Voicemails.DELETED).append(" = 0)");
}
if (newOnly) {
- where.append(" AND ");
- where.append(Calls.NEW);
- where.append(" = 1");
+ where.append(" AND (").append(Calls.NEW).append(" = 1)");
}
if (callType > CALL_TYPE_ALL) {
- where.append(" AND ");
- where.append("(" + Calls.TYPE + " = ?)");
+ where.append(" AND (").append(Calls.TYPE).append(" = ?)");
selectionArgs.add(Integer.toString(callType));
} else {
where.append(" AND NOT ");
@@ -190,24 +186,17 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
}
if (newerThan > 0) {
- where.append(" AND ");
- where.append("(" + Calls.DATE + " > ?)");
+ where.append(" AND (").append(Calls.DATE).append(" > ?)");
selectionArgs.add(Long.toString(newerThan));
}
- // Always hide blocked calls.
- where.append(" AND ");
- where.append("(" + Calls.TYPE + " != ?)");
- selectionArgs.add(Integer.toString(AppCompatConstants.CALLS_BLOCKED_TYPE));
-
final int limit = (mLogLimit == -1) ? NUM_LOGS_TO_DISPLAY : mLogLimit;
final String selection = where.length() > 0 ? where.toString() : null;
Uri uri = TelecomUtil.getCallLogUri(mContext).buildUpon()
.appendQueryParameter(Calls.LIMIT_PARAM_KEY, Integer.toString(limit))
.build();
- startQuery(token, null, uri,
- CallLogQuery._PROJECTION, selection, selectionArgs.toArray(EMPTY_STRING_ARRAY),
- Calls.DEFAULT_SORT_ORDER);
+ startQuery(token, null, uri, CallLogQuery._PROJECTION, selection, selectionArgs.toArray(
+ new String[selectionArgs.size()]), Calls.DEFAULT_SORT_ORDER);
}
/** Cancel any pending fetch request. */