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

Commit f78da994 authored by The Android Automerger's avatar The Android Automerger
Browse files

Revert "Clean up CursorWindow lifetime."

This reverts commit 7ce74524.
parent 8f2eb43b
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -64,10 +64,7 @@ public abstract class AbstractCursor implements CrossProcessCursor {
    /* Methods that may optionally be implemented by subclasses */

    /**
     * If the cursor is backed by a {@link CursorWindow}, returns a pre-filled
     * window with the contents of the cursor, otherwise null.
     *
     * @return The pre-filled window that backs this cursor, or null if none.
     * returns a pre-filled window, return NULL if no such window
     */
    public CursorWindow getWindow() {
        return null;
+10 −43
Original line number Diff line number Diff line
@@ -18,22 +18,8 @@ package android.database;

/**
 * A base class for Cursors that store their data in {@link CursorWindow}s.
 * <p>
 * Subclasses are responsible for filling the cursor window with data during
 * {@link #onMove(int, int)}, allocating a new cursor window if necessary.
 * During {@link #requery()}, the existing cursor window should be cleared and
 * filled with new data.
 * </p><p>
 * If the contents of the cursor change or become invalid, the old window must be closed
 * (because it is owned by the cursor) and set to null.
 * </p>
 */
public abstract class AbstractWindowedCursor extends AbstractCursor {
    /**
     * The cursor window owned by this cursor.
     */
    protected CursorWindow mWindow;

    @Override
    public byte[] getBlob(int columnIndex) {
        checkPosition();
@@ -142,42 +128,23 @@ public abstract class AbstractWindowedCursor extends AbstractCursor {
    }
    
    /**
     * Sets a new cursor window for the cursor to use.
     * <p>
     * The cursor takes ownership of the provided cursor window; the cursor window
     * will be closed when the cursor is closed or when the cursor adopts a new
     * cursor window.
     * </p><p>
     * If the cursor previously had a cursor window, then it is closed when the
     * new cursor window is assigned.
     * </p>
     *
     * @param window The new cursor window, typically a remote cursor window.
     * Set a new cursor window to cursor, usually set a remote cursor window
     * @param window cursor window
     */
    public void setWindow(CursorWindow window) {
        if (window != mWindow) {
            closeWindow();
            mWindow = window;
        if (mWindow != null) {
            mWindow.close();
        }
        mWindow = window;
    }
    
    /**
     * Returns true if the cursor has an associated cursor window.
     *
     * @return True if the cursor has an associated cursor window.
     */
    public boolean hasWindow() {
        return mWindow != null;
    }

    /**
     * Closes the cursor window and sets {@link #mWindow} to null.
     * @hide
     * This needs be updated in {@link #onMove} by subclasses, and
     * needs to be set to NULL when the contents of the cursor change.
     */
    protected void closeWindow() {
        if (mWindow != null) {
            mWindow.close();
            mWindow = null;
        }
    }
    protected CursorWindow mWindow;
}
+4 −1
Original line number Diff line number Diff line
@@ -154,7 +154,10 @@ public final class BulkCursorToCursorAdaptor extends AbstractWindowedCursor {
                    false /* the window will be accessed across processes */));
            if (mCount != -1) {
                mPos = -1;
                closeWindow();
                if (mWindow != null) {
                    mWindow.close();
                    mWindow = null;
                }

                // super.requery() will call onChanged. Do it here instead of relying on the
                // observer from the far side so that observers can see a correct value for mCount
+6 −14
Original line number Diff line number Diff line
@@ -105,12 +105,8 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
    }

    @Override
    protected void finalize() throws Throwable {
        try {
    protected void finalize() {
        dispose();
        } finally {
            super.finalize();
        }
    }

    private void dispose() {
@@ -149,12 +145,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {

    /**
     * Gets the start position of this cursor window.
     * <p>
     * The start position is the zero-based index of the first row that this window contains
     * The start position is the index of the first row that this window contains
     * relative to the entire result set of the {@link Cursor}.
     * </p>
     *
     * @return The zero-based start position.
     * @return The start position.
     */
    public int getStartPosition() {
        return mStartPos;
@@ -162,12 +156,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {

    /**
     * Sets the start position of this cursor window.
     * <p>
     * The start position is the zero-based index of the first row that this window contains
     * The start position is the index of the first row that this window contains
     * relative to the entire result set of the {@link Cursor}.
     * </p>
     *
     * @param pos The new zero-based start position.
     * @param pos The new start position.
     */
    public void setStartPosition(int pos) {
        mStartPos = pos;
+1 −3
Original line number Diff line number Diff line
@@ -33,9 +33,7 @@ public class CursorWrapper implements Cursor {
    }

    /**
     * Gets the underlying cursor that is wrapped by this instance.
     *
     * @return The wrapped cursor.
     * @return the wrapped cursor
     */
    public Cursor getWrappedCursor() {
        return mCursor;
Loading