diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-10-12 15:41:34 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-10-12 22:19:41 -0700 |
commit | 5e5d6d8ba04d7579df840cda055cd5dfa9d7666f (patch) | |
tree | b9c47baaa3b62795dfc12645da4bed2eb5d3ec13 | |
parent | 5b2dda3be5cc903aafb77ce7902c14d76eb26a9b (diff) | |
download | frameworks_base-5e5d6d8ba04d7579df840cda055cd5dfa9d7666f.zip frameworks_base-5e5d6d8ba04d7579df840cda055cd5dfa9d7666f.tar.gz frameworks_base-5e5d6d8ba04d7579df840cda055cd5dfa9d7666f.tar.bz2 |
Deprecate local-only CursorWindows.
There is no difference and has never really been a difference
between local-only and remotable CursorWindows. By removing the
distinction officially in the API, we will make it easier to
implement CrossProcessCursor correctly. CrossProcessCursor
is problematic currently because it's not clear whether a call
to getWindow() will return a local-only window or a remotable window.
As a result, the bulk cursor adaptor has special case handling
for AbstractWindowedCursors vs. ordinary CrossProcessCursors
so that it can set a remotable window before the cursor fills it.
All these problems go away if we just forget about local-only
windows being special in any way.
Change-Id: Ie59f517968e33d0ecb239c3c4f60206495e8f376
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | core/java/android/database/AbstractWindowedCursor.java | 7 | ||||
-rw-r--r-- | core/java/android/database/CursorToBulkCursorAdaptor.java | 4 | ||||
-rw-r--r-- | core/java/android/database/CursorWindow.java | 23 | ||||
-rw-r--r-- | core/java/android/database/sqlite/SQLiteCursor.java | 2 | ||||
-rw-r--r-- | core/jni/android_database_CursorWindow.cpp | 7 | ||||
-rw-r--r-- | include/binder/CursorWindow.h | 3 | ||||
-rw-r--r-- | libs/binder/CursorWindow.cpp | 4 |
8 files changed, 24 insertions, 29 deletions
diff --git a/api/current.txt b/api/current.txt index 662ebcd..3141947 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6851,7 +6851,8 @@ package android.database { } public class CursorWindow extends android.database.sqlite.SQLiteClosable implements android.os.Parcelable { - ctor public CursorWindow(boolean); + ctor public CursorWindow(java.lang.String); + ctor public deprecated CursorWindow(boolean); method public boolean allocRow(); method public void clear(); method public void close(); diff --git a/core/java/android/database/AbstractWindowedCursor.java b/core/java/android/database/AbstractWindowedCursor.java index d0aedd2..083485f 100644 --- a/core/java/android/database/AbstractWindowedCursor.java +++ b/core/java/android/database/AbstractWindowedCursor.java @@ -188,15 +188,14 @@ public abstract class AbstractWindowedCursor extends AbstractCursor { /** * If there is a window, clear it. - * Otherwise, creates a local window. + * Otherwise, creates a new window. * * @param name The window name. * @hide */ - protected void clearOrCreateLocalWindow(String name) { + protected void clearOrCreateWindow(String name) { if (mWindow == null) { - // If there isn't a window set already it will only be accessed locally - mWindow = new CursorWindow(name, true /* the window is local only */); + mWindow = new CursorWindow(name); } else { mWindow.clear(); } diff --git a/core/java/android/database/CursorToBulkCursorAdaptor.java b/core/java/android/database/CursorToBulkCursorAdaptor.java index dd2c9b7..bfd434b 100644 --- a/core/java/android/database/CursorToBulkCursorAdaptor.java +++ b/core/java/android/database/CursorToBulkCursorAdaptor.java @@ -144,7 +144,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor)mCursor; window = windowedCursor.getWindow(); if (window == null) { - window = new CursorWindow(mProviderName, false /*localOnly*/); + window = new CursorWindow(mProviderName); windowedCursor.setWindow(window); } @@ -152,7 +152,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative } else { window = mWindowForNonWindowedCursor; if (window == null) { - window = new CursorWindow(mProviderName, false /*localOnly*/); + window = new CursorWindow(mProviderName); mWindowForNonWindowedCursor = window; } diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java index a18a721..7ccb801 100644 --- a/core/java/android/database/CursorWindow.java +++ b/core/java/android/database/CursorWindow.java @@ -31,8 +31,8 @@ import android.util.SparseIntArray; /** * A buffer containing multiple cursor rows. * <p> - * A {@link CursorWindow} is read-write when created and used locally. When sent - * to a remote process (by writing it to a {@link Parcel}), the remote process + * A {@link CursorWindow} is read-write when initially created and used locally. + * When sent to a remote process (by writing it to a {@link Parcel}), the remote process * receives a read-only view of the cursor window. Typically the cursor window * will be allocated by the producer, filled with data, and then sent to the * consumer for reading. @@ -58,8 +58,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { private final CloseGuard mCloseGuard = CloseGuard.get(); - private static native int nativeCreate(String name, - int cursorWindowSize, boolean localOnly); + private static native int nativeCreate(String name, int cursorWindowSize); private static native int nativeCreateFromParcel(Parcel parcel); private static native void nativeDispose(int windowPtr); private static native void nativeWriteToParcel(int windowPtr, Parcel parcel); @@ -93,14 +92,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { * </p> * * @param name The name of the cursor window, or null if none. - * @param localWindow True if this window will be used in this process only, - * false if it might be sent to another processes. - * - * @hide */ - public CursorWindow(String name, boolean localWindow) { + public CursorWindow(String name) { mStartPos = 0; - mWindowPtr = nativeCreate(name, sCursorWindowSize, localWindow); + mWindowPtr = nativeCreate(name, sCursorWindowSize); if (mWindowPtr == 0) { throw new CursorWindowAllocationException("Cursor window allocation of " + (sCursorWindowSize / 1024) + " kb failed. " + printStats()); @@ -117,10 +112,14 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { * </p> * * @param localWindow True if this window will be used in this process only, - * false if it might be sent to another processes. + * false if it might be sent to another processes. This argument is ignored. + * + * @deprecated There is no longer a distinction between local and remote + * cursor windows. Use the {@link #CursorWindow(String)} constructor instead. */ + @Deprecated public CursorWindow(boolean localWindow) { - this(null, localWindow); + this((String)null); } private CursorWindow(Parcel source) { diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java index a1c36e2..9574300 100644 --- a/core/java/android/database/sqlite/SQLiteCursor.java +++ b/core/java/android/database/sqlite/SQLiteCursor.java @@ -155,7 +155,7 @@ public class SQLiteCursor extends AbstractWindowedCursor { } private void fillWindow(int startPos) { - clearOrCreateLocalWindow(getDatabase().getPath()); + clearOrCreateWindow(getDatabase().getPath()); mWindow.setStartPosition(startPos); int count = getQuery().fillWindow(mWindow); if (startPos == 0) { // fillWindow returns count(*) only for startPos = 0 diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp index 722aeea..4a9fcf2 100644 --- a/core/jni/android_database_CursorWindow.cpp +++ b/core/jni/android_database_CursorWindow.cpp @@ -57,8 +57,7 @@ static void throwUnknownTypeException(JNIEnv * env, jint type) { jniThrowException(env, "java/lang/IllegalStateException", msg.string()); } -static jint nativeCreate(JNIEnv* env, jclass clazz, - jstring nameObj, jint cursorWindowSize, jboolean localOnly) { +static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { String8 name; if (nameObj) { const char* nameStr = env->GetStringUTFChars(nameObj, NULL); @@ -70,7 +69,7 @@ static jint nativeCreate(JNIEnv* env, jclass clazz, } CursorWindow* window; - status_t status = CursorWindow::create(name, cursorWindowSize, localOnly, &window); + status_t status = CursorWindow::create(name, cursorWindowSize, &window); if (status || !window) { LOGE("Could not allocate CursorWindow '%s' of size %d due to error %d.", name.string(), cursorWindowSize, status); @@ -477,7 +476,7 @@ static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ - { "nativeCreate", "(Ljava/lang/String;IZ)I", + { "nativeCreate", "(Ljava/lang/String;I)I", (void*)nativeCreate }, { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I", (void*)nativeCreateFromParcel }, diff --git a/include/binder/CursorWindow.h b/include/binder/CursorWindow.h index 5d490ed..f0284de 100644 --- a/include/binder/CursorWindow.h +++ b/include/binder/CursorWindow.h @@ -80,8 +80,7 @@ public: ~CursorWindow(); - static status_t create(const String8& name, size_t size, bool localOnly, - CursorWindow** outCursorWindow); + static status_t create(const String8& name, size_t size, CursorWindow** outCursorWindow); static status_t createFromParcel(Parcel* parcel, CursorWindow** outCursorWindow); status_t writeToParcel(Parcel* parcel); diff --git a/libs/binder/CursorWindow.cpp b/libs/binder/CursorWindow.cpp index 1b85a71..bf8d7a6 100644 --- a/libs/binder/CursorWindow.cpp +++ b/libs/binder/CursorWindow.cpp @@ -40,11 +40,9 @@ CursorWindow::~CursorWindow() { ::close(mAshmemFd); } -status_t CursorWindow::create(const String8& name, size_t size, bool localOnly, - CursorWindow** outCursorWindow) { +status_t CursorWindow::create(const String8& name, size_t size, CursorWindow** outCursorWindow) { String8 ashmemName("CursorWindow: "); ashmemName.append(name); - ashmemName.append(localOnly ? " (local)" : " (remote)"); status_t result; int ashmemFd = ashmem_create_region(ashmemName.string(), size); |