From 256c414bbbecab8f0c013ed7562a75236ded3b70 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Mon, 27 Jan 2020 15:23:25 -0800 Subject: [PATCH] Allow empty tokens in strict grammar Allow empty tokens in SQLiteQueryBuilder's strict grammar enforcement Bug: 143230980 Test: atest SQLiteQueryBuilderTest, manual Change-Id: Ie82dded77a3eaa75095333b0e77f10e21c9f7caf Merged-In: Ie82dded77a3eaa75095333b0e77f10e21c9f7caf --- core/java/android/provider/CallLog.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index a0e92b398c4e9..276f16216b4de 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -98,6 +98,13 @@ public class CallLog { */ public static final String LIMIT_PARAM_KEY = "limit"; + /** + * Form of {@link #CONTENT_URI} which limits the query results to a single result. + */ + private static final Uri CONTENT_URI_LIMIT_1 = CONTENT_URI.buildUpon() + .appendQueryParameter(LIMIT_PARAM_KEY, "1") + .build(); + /** * Query parameter used to specify the starting record to return. *

@@ -932,11 +939,11 @@ public class CallLog { Cursor c = null; try { c = resolver.query( - CONTENT_URI, + CONTENT_URI_LIMIT_1, new String[] {NUMBER}, TYPE + " = " + OUTGOING_TYPE, null, - DEFAULT_SORT_ORDER + " LIMIT 1"); + DEFAULT_SORT_ORDER); if (c == null || !c.moveToFirst()) { return ""; }