Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e5d6d8b authored by Jeff Brown's avatar Jeff Brown
Browse files

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
parent 5b2dda3b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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();
+3 −4
Original line number Diff line number Diff line
@@ -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();
        }
+2 −2
Original line number Diff line number Diff line
@@ -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;
                }

+11 −12
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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
Loading