diff options
| author | Vasu Nori <vnori@google.com> | 2010-04-28 14:22:38 -0700 |
|---|---|---|
| committer | Vasu Nori <vnori@google.com> | 2010-04-28 15:32:54 -0700 |
| commit | 020e5345795a157d7829ebbe4d7864595dafc576 (patch) | |
| tree | 3ddeda5f1123e5168542ed42146e5ed37a4da419 /core/java/android | |
| parent | 9aaf24f2a46eacd1e342f8c0300c3093646e2814 (diff) | |
bug:2622719 move 'forcing of cursor execution' to ContentProvider
revert part of the CL: Ia561135e974a44ad3e3774ecb23c6a3d0fc38176
and add it to ContentProvider.query() to force query execution
in worker thread, instead of having the main thread incur the cost
of query execution and potentially get ANR
Change-Id: I0ea8a170bd954a421f4ad825f8090319a83a5b2b
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/content/ContentResolver.java | 2 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index d114ecce3d96..b4718ab6ef2b 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -247,6 +247,8 @@ public abstract class ContentResolver { releaseProvider(provider); return null; } + // force query execution + qCursor.getCount(); long durationMillis = SystemClock.uptimeMillis() - startTime; maybeLogQueryToEventLog(durationMillis, uri, projection, selection, sortOrder); // Wrap the cursor object into CursorWrapperInner object diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index 70f681fef6ad..fb5507dc8f83 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -1341,19 +1341,19 @@ public class SQLiteDatabase extends SQLiteClosable { SQLiteCursorDriver driver = new SQLiteDirectCursorDriver(this, sql, editTable); Cursor cursor = null; - int count = 0; try { cursor = driver.query( cursorFactory != null ? cursorFactory : mFactory, selectionArgs); - - // Force query execution - if (cursor != null) { - count = cursor.getCount(); - } } finally { if (Config.LOGV || mSlowQueryThreshold != -1) { + // Force query execution + int count = -1; + if (cursor != null) { + count = cursor.getCount(); + } + long duration = System.currentTimeMillis() - timeStart; if (Config.LOGV || duration >= mSlowQueryThreshold) { @@ -1361,7 +1361,7 @@ public class SQLiteDatabase extends SQLiteClosable { "query (" + duration + " ms): " + driver.toString() + ", args are " + (selectionArgs != null ? TextUtils.join(",", selectionArgs) - : "<null>") + ", count is " + count); + : "<null>") + ", count is " + count); } } } |
