diff options
| -rw-r--r-- | core/java/android/database/Cursor.java | 5 | ||||
| -rw-r--r-- | core/java/android/database/RequeryOnUiThreadException.java | 29 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteCursor.java | 32 |
3 files changed, 3 insertions, 63 deletions
diff --git a/core/java/android/database/Cursor.java b/core/java/android/database/Cursor.java index c03c586..a344272 100644 --- a/core/java/android/database/Cursor.java +++ b/core/java/android/database/Cursor.java @@ -20,8 +20,6 @@ import android.content.ContentResolver; import android.net.Uri; import android.os.Bundle; -import java.util.Map; - /** * This interface provides random read-write access to the result set returned * by a database query. @@ -344,7 +342,10 @@ public interface Cursor { * * @return true if the requery succeeded, false if not, in which case the * cursor becomes invalid. + * @deprecated Don't use this. Just request a new cursor, so you can do this + * asynchronously and update your list view once the new cursor comes back. */ + @Deprecated boolean requery(); /** diff --git a/core/java/android/database/RequeryOnUiThreadException.java b/core/java/android/database/RequeryOnUiThreadException.java deleted file mode 100644 index 97a50d8..0000000 --- a/core/java/android/database/RequeryOnUiThreadException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.database; - -/** - * An exception that indicates invoking {@link Cursor#requery()} on Main thread could cause ANR. - * This exception should encourage apps to invoke {@link Cursor#requery()} in a background thread. - * @hide - */ -public class RequeryOnUiThreadException extends RuntimeException { - public RequeryOnUiThreadException(String packageName) { - super("In " + packageName + " Requery is executing on main (UI) thread. could cause ANR. " + - "do it in background thread."); - } -} diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java index 225eaab..fc30da2 100644 --- a/core/java/android/database/sqlite/SQLiteCursor.java +++ b/core/java/android/database/sqlite/SQLiteCursor.java @@ -16,13 +16,10 @@ package android.database.sqlite; -import android.app.ActivityThread; import android.database.AbstractWindowedCursor; import android.database.CursorWindow; import android.database.DataSetObserver; -import android.database.RequeryOnUiThreadException; import android.os.Handler; -import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.StrictMode; @@ -76,11 +73,6 @@ public class SQLiteCursor extends AbstractWindowedCursor { private boolean mPendingData = false; /** - * Used by {@link #requery()} to remember for which database we've already shown the warning. - */ - private static final HashMap<String, Boolean> sAlreadyWarned = new HashMap<String, Boolean>(); - - /** * support for a cursor variant that doesn't always read all results * initialRead is the initial number of items that cursor window reads * if query contains more than this number of items, a thread will be @@ -401,35 +393,11 @@ public class SQLiteCursor extends AbstractWindowedCursor { } } - /** - * Show a warning against the use of requery() if called on the main thread. - * This warning is shown per database per process. - */ - private void warnIfUiThread() { - if (Looper.getMainLooper() == Looper.myLooper()) { - String databasePath = getQuery().mDatabase.getPath(); - // We show the warning once per database in order not to spam logcat. - if (!sAlreadyWarned.containsKey(databasePath)) { - sAlreadyWarned.put(databasePath, true); - String packageName = ActivityThread.currentPackageName(); - Throwable t = null; - // BEGIN STOPSHIP remove the following line - t = new RequeryOnUiThreadException(packageName); - // END STOPSHIP - String s = packageName == null ? "'unknown'" : packageName; - Log.w(TAG, "should not attempt requery on main (UI) thread: app = " + s + - " (database: " + mQuery.mDatabase.getPath() + - ", query: " + mQuery.mSql + ")", t); - } - } - } - @Override public boolean requery() { if (isClosed()) { return false; } - warnIfUiThread(); long timeStart = 0; if (Config.LOGV) { timeStart = System.currentTimeMillis(); |
