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

Commit 7cd51efc authored by Jeff Hamilton's avatar Jeff Hamilton
Browse files

Remove the deprecated cursor methods.

Change-Id: Ie3571fea9f36996c31c327240b11086f8cc487f0
parent 93f8547d
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -1579,40 +1579,6 @@ public class Activity extends ContextThemeWrapper
        return c;
    }

    /**
     * Wrapper around {@link Cursor#commitUpdates()} that takes care of noting
     * that the Cursor needs to be requeried.  You can call this method in
     * {@link #onPause} or {@link #onStop} to have the system call
     * {@link Cursor#requery} for you if the activity is later resumed.  This
     * allows you to avoid determing when to do the requery yourself (which is
     * required for the Cursor to see any data changes that were committed with
     * it).
     * 
     * @param c The Cursor whose changes are to be committed.
     * 
     * @see #managedQuery(android.net.Uri , String[], String, String[], String)
     * @see #startManagingCursor
     * @see Cursor#commitUpdates()
     * @see Cursor#requery
     * @hide
     */
    @Deprecated
    public void managedCommitUpdates(Cursor c) {
        synchronized (mManagedCursors) {
            final int N = mManagedCursors.size();
            for (int i=0; i<N; i++) {
                ManagedCursor mc = mManagedCursors.get(i);
                if (mc.mCursor == c) {
                    c.commitUpdates();
                    mc.mUpdated = true;
                    return;
                }
            }
            throw new RuntimeException(
                "Cursor " + c + " is not currently managed");
        }
    }

    /**
     * This method allows the activity to take care of managing the given
     * {@link Cursor}'s lifecycle for you based on the activity's lifecycle.
+0 −147
Original line number Diff line number Diff line
@@ -103,22 +103,6 @@ public abstract class AbstractCursor implements CrossProcessCursor {
        deactivateInternal();
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean commitUpdates(Map<? extends Long,? extends Map<String,Object>> values) {
        return false;
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean deleteRow() {
        return false;
    }

    /**
     * This function is called every time the cursor is successfully scrolled
     * to a new position, giving the subclass a chance to update any state it
@@ -315,137 +299,6 @@ public abstract class AbstractCursor implements CrossProcessCursor {
        return getColumnNames()[columnIndex];
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateBlob(int columnIndex, byte[] value) {
        return update(columnIndex, value);
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateString(int columnIndex, String value) {
        return update(columnIndex, value);
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateShort(int columnIndex, short value) {
        return update(columnIndex, Short.valueOf(value));
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateInt(int columnIndex, int value) {
        return update(columnIndex, Integer.valueOf(value));
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateLong(int columnIndex, long value) {
        return update(columnIndex, Long.valueOf(value));
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateFloat(int columnIndex, float value) {
        return update(columnIndex, Float.valueOf(value));
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateDouble(int columnIndex, double value) {
        return update(columnIndex, Double.valueOf(value));
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean updateToNull(int columnIndex) {
        return update(columnIndex, null);
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean update(int columnIndex, Object obj) {
        if (!supportsUpdates()) {
            return false;
        }

        // Long.valueOf() returns null sometimes!
//        Long rowid = Long.valueOf(getLong(mRowIdColumnIndex));
        Long rowid = new Long(getLong(mRowIdColumnIndex));
        if (rowid == null) {
            throw new IllegalStateException("null rowid. mRowIdColumnIndex = " + mRowIdColumnIndex);
        }

        synchronized(mUpdatedRows) {
            Map<String, Object> row = mUpdatedRows.get(rowid);
            if (row == null) {
                row = new HashMap<String, Object>();
                mUpdatedRows.put(rowid, row);
            }
            row.put(getColumnNames()[columnIndex], obj);
        }

        return true;
    }

    /**
     * Returns <code>true</code> if there are pending updates that have not yet been committed.
     * 
     * @return <code>true</code> if there are pending updates that have not yet been committed.
     * @hide
     * @deprecated
     */
    public boolean hasUpdates() {
        synchronized(mUpdatedRows) {
            return mUpdatedRows.size() > 0;
        }
    }

    /**
     * @hide
     * @deprecated
     */
    public void abortUpdates() {
        synchronized(mUpdatedRows) {
            mUpdatedRows.clear();
        }
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean commitUpdates() {
        return commitUpdates(null);
    }

    /**
     * @hide
     * @deprecated
     */
    public boolean supportsUpdates() {
        return mRowIdColumnIndex != -1;
    }

    public void registerContentObserver(ContentObserver observer) {
        mContentObservable.registerObserver(observer);
    }
+2 −67
Original line number Diff line number Diff line
@@ -17,13 +17,10 @@
package android.database;

import android.os.Binder;
import android.os.RemoteException;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Bundle;

import java.util.HashMap;
import java.util.Map;
import android.os.RemoteException;

/**
 * Native implementation of the bulk cursor. This is only for use in implementing
@@ -120,26 +117,6 @@ public abstract class BulkCursorNative extends Binder implements IBulkCursor
                    return true;
                }

                case UPDATE_ROWS_TRANSACTION: {
                    data.enforceInterface(IBulkCursor.descriptor);
                    // TODO - what ClassLoader should be passed to readHashMap?
                    // TODO - switch to Bundle
                    HashMap<Long, Map<String, Object>> values = data.readHashMap(null);
                    boolean result = updateRows(values);
                    reply.writeNoException();
                    reply.writeInt((result == true ? 1 : 0));
                    return true;
                }

                case DELETE_ROW_TRANSACTION: {
                    data.enforceInterface(IBulkCursor.descriptor);
                    int position = data.readInt();
                    boolean result = deleteRow(position);
                    reply.writeNoException();
                    reply.writeInt((result == true ? 1 : 0));
                    return true;
                }

                case ON_MOVE_TRANSACTION: {
                    data.enforceInterface(IBulkCursor.descriptor);
                    int position = data.readInt();
@@ -343,48 +320,6 @@ final class BulkCursorProxy implements IBulkCursor {
        return count;
    }

    public boolean updateRows(Map values) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();

        data.writeInterfaceToken(IBulkCursor.descriptor);

        data.writeMap(values);

        mRemote.transact(UPDATE_ROWS_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        
        boolean result = (reply.readInt() == 1 ? true : false);

        data.recycle();
        reply.recycle();

        return result;
    }

    public boolean deleteRow(int position) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();

        data.writeInterfaceToken(IBulkCursor.descriptor);

        data.writeInt(position);

        mRemote.transact(DELETE_ROW_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        
        boolean result = (reply.readInt() == 1 ? true : false);

        data.recycle();
        reply.recycle();

        return result;
    }

    public boolean getWantsAllOnMoveCalls() throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
+1 −73
Original line number Diff line number Diff line
@@ -16,12 +16,10 @@

package android.database;

import android.os.RemoteException;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;

import java.util.Map;

/**
 * Adapts an {@link IBulkCursor} to a {@link Cursor} for use in the local
 * process.
@@ -174,38 +172,6 @@ public final class BulkCursorToCursorAdaptor extends AbstractWindowedCursor {
        }
    }

    /**
     * @hide
     * @deprecated
     */
    @Override
    public boolean deleteRow() {
        try {
            boolean result = mBulkCursor.deleteRow(mPos);
            if (result != false) {
                // The window contains the old value, discard it
                mWindow = null;
    
                // Fix up the position
                mCount = mBulkCursor.count();
                if (mPos < mCount) {
                    int oldPos = mPos;
                    mPos = -1;
                    moveToPosition(oldPos);
                } else {
                    mPos = mCount;
                }

                // Send the change notification
                onChange(true);
            }
            return result;
        } catch (RemoteException ex) {
            Log.e(TAG, "Unable to delete row because the remote process is dead");
            return false;
        }
    }

    @Override
    public String[] getColumnNames() {
        if (mColumns == null) {
@@ -219,44 +185,6 @@ public final class BulkCursorToCursorAdaptor extends AbstractWindowedCursor {
        return mColumns;
    }

    /**
     * @hide
     * @deprecated
     */
    @Override
    public boolean commitUpdates(Map<? extends Long,
            ? extends Map<String,Object>> additionalValues) {
        if (!supportsUpdates()) {
            Log.e(TAG, "commitUpdates not supported on this cursor, did you include the _id column?");
            return false;
        }

        synchronized(mUpdatedRows) {
            if (additionalValues != null) {
                mUpdatedRows.putAll(additionalValues);
            }

            if (mUpdatedRows.size() <= 0) {
                return false;
            }

            try {
                boolean result = mBulkCursor.updateRows(mUpdatedRows);
    
                if (result == true) {
                    mUpdatedRows.clear();

                    // Send the change notification
                    onChange(true);
                }
                return result;
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to commit updates because the remote process is dead");
                return false;
            }
        }
    }

    @Override
    public Bundle getExtras() {
        try {
+0 −198
Original line number Diff line number Diff line
@@ -145,22 +145,6 @@ public interface Cursor {
     */
    boolean isAfterLast();

    /**
     * Removes the row at the current cursor position from the underlying data
     * store. After this method returns the cursor will be pointing to the row
     * after the row that is deleted. This has the side effect of decrementing
     * the result of count() by one.
     * <p>
     * The query must have the row ID column in its selection, otherwise this
     * call will fail.
     * 
     * @hide
     * @return whether the record was successfully deleted.
     * @deprecated use {@link ContentResolver#delete(Uri, String, String[])}
     */
    @Deprecated
    boolean deleteRow();

    /**
     * Returns the zero-based index for the given column name, or -1 if the column doesn't exist.
     * If you expect the column to exist use {@link #getColumnIndexOrThrow(String)} instead, which
@@ -302,188 +286,6 @@ public interface Cursor {
     */
    boolean isNull(int columnIndex);

    /**
     * Returns <code>true</code> if the cursor supports updates.
     *
     * @return whether the cursor supports updates.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean supportsUpdates();

    /**
     * Returns <code>true</code> if there are pending updates that have not yet been committed.
     * 
     * @return <code>true</code> if there are pending updates that have not yet been committed.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean hasUpdates();

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateBlob(int columnIndex, byte[] value);

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateString(int columnIndex, String value);

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateShort(int columnIndex, short value);

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateInt(int columnIndex, int value);

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateLong(int columnIndex, long value);

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateFloat(int columnIndex, float value);

    /**
     * Updates the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @param value the new value.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateDouble(int columnIndex, double value);

    /**
     * Removes the value for the given column in the row the cursor is
     * currently pointing at. Updates are not committed to the backing store
     * until {@link #commitUpdates()} is called.
     *
     * @param columnIndex the zero-based index of the target column.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean updateToNull(int columnIndex);

    /**
     * Atomically commits all updates to the backing store. After completion,
     * this method leaves the data in an inconsistent state and you should call
     * {@link #requery} before reading data from the cursor again.
     *
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean commitUpdates();

    /**
     * Atomically commits all updates to the backing store, as well as the
     * updates included in values. After completion,
     * this method leaves the data in an inconsistent state and you should call
     * {@link #requery} before reading data from the cursor again.
     *
     * @param values A map from row IDs to Maps associating column names with
     *               updated values. A null value indicates the field should be
                     removed.
     * @return whether the operation succeeded.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    boolean commitUpdates(Map<? extends Long,
            ? extends Map<String,Object>> values);

    /**
     * Reverts all updates made to the cursor since the last call to
     * commitUpdates.
     * @hide
     * @deprecated use the {@link ContentResolver} update methods instead of the Cursor
     * update methods
     */
    @Deprecated
    void abortUpdates();

    /**
     * Deactivates the Cursor, making all calls on it fail until {@link #requery} is called.
     * Inactive Cursors use fewer resources than active Cursors.
Loading