Clean up AbstractCursor API.
Deprecated three protected fields that should not have been
exposed in the API.
Bug: 6353797
Change-Id: Ic6710f880a452dd1508abf0613907a1d2b1fb557
diff --git a/api/current.txt b/api/current.txt
index 7e24003..46e3be1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9743,12 +9743,9 @@
method public void setNotificationUri(android.content.ContentResolver, android.net.Uri);
method public void unregisterContentObserver(android.database.ContentObserver);
method public void unregisterDataSetObserver(android.database.DataSetObserver);
- field protected boolean mClosed;
- field protected android.content.ContentResolver mContentResolver;
- field protected deprecated java.lang.Long mCurrentRowID;
- field protected int mPos;
- field protected deprecated int mRowIdColumnIndex;
- field protected deprecated java.util.HashMap<java.lang.Long, java.util.Map<java.lang.String, java.lang.Object>> mUpdatedRows;
+ field protected deprecated boolean mClosed;
+ field protected deprecated android.content.ContentResolver mContentResolver;
+ field protected deprecated int mPos;
}
protected static class AbstractCursor.SelfContentObserver extends android.database.ContentObserver {
@@ -30582,7 +30579,7 @@
ctor public MockCursor();
method public void close();
method public void copyStringToBuffer(int, android.database.CharArrayBuffer);
- method public void deactivate();
+ method public deprecated void deactivate();
method public byte[] getBlob(int);
method public int getColumnCount();
method public int getColumnIndex(java.lang.String);
@@ -30615,8 +30612,9 @@
method public boolean moveToPrevious();
method public void registerContentObserver(android.database.ContentObserver);
method public void registerDataSetObserver(android.database.DataSetObserver);
- method public boolean requery();
+ method public deprecated boolean requery();
method public android.os.Bundle respond(android.os.Bundle);
+ method public void setExtras(android.os.Bundle);
method public void setNotificationUri(android.content.ContentResolver, android.net.Uri);
method public void unregisterContentObserver(android.database.ContentObserver);
method public void unregisterDataSetObserver(android.database.DataSetObserver);
diff --git a/api/removed.txt b/api/removed.txt
index c2b9d3e..0c433c3 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -6,6 +6,16 @@
}
+package android.database {
+
+ public abstract class AbstractCursor implements android.database.CrossProcessCursor {
+ field protected java.lang.Long mCurrentRowID;
+ field protected int mRowIdColumnIndex;
+ field protected java.util.HashMap<java.lang.Long, java.util.Map<java.lang.String, java.lang.Object>> mUpdatedRows;
+ }
+
+}
+
package android.media {
public class AudioFormat {
diff --git a/api/system-current.txt b/api/system-current.txt
index 3f2e19b..80c00ca 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -10033,12 +10033,9 @@
method public void setNotificationUri(android.content.ContentResolver, android.net.Uri);
method public void unregisterContentObserver(android.database.ContentObserver);
method public void unregisterDataSetObserver(android.database.DataSetObserver);
- field protected boolean mClosed;
- field protected android.content.ContentResolver mContentResolver;
- field protected deprecated java.lang.Long mCurrentRowID;
- field protected int mPos;
- field protected deprecated int mRowIdColumnIndex;
- field protected deprecated java.util.HashMap<java.lang.Long, java.util.Map<java.lang.String, java.lang.Object>> mUpdatedRows;
+ field protected deprecated boolean mClosed;
+ field protected deprecated android.content.ContentResolver mContentResolver;
+ field protected deprecated int mPos;
}
protected static class AbstractCursor.SelfContentObserver extends android.database.ContentObserver {
@@ -33129,7 +33126,7 @@
ctor public MockCursor();
method public void close();
method public void copyStringToBuffer(int, android.database.CharArrayBuffer);
- method public void deactivate();
+ method public deprecated void deactivate();
method public byte[] getBlob(int);
method public int getColumnCount();
method public int getColumnIndex(java.lang.String);
@@ -33162,8 +33159,9 @@
method public boolean moveToPrevious();
method public void registerContentObserver(android.database.ContentObserver);
method public void registerDataSetObserver(android.database.DataSetObserver);
- method public boolean requery();
+ method public deprecated boolean requery();
method public android.os.Bundle respond(android.os.Bundle);
+ method public void setExtras(android.os.Bundle);
method public void setNotificationUri(android.content.ContentResolver, android.net.Uri);
method public void unregisterContentObserver(android.database.ContentObserver);
method public void unregisterDataSetObserver(android.database.DataSetObserver);
diff --git a/api/system-removed.txt b/api/system-removed.txt
index c2b9d3e..0c433c3 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -6,6 +6,16 @@
}
+package android.database {
+
+ public abstract class AbstractCursor implements android.database.CrossProcessCursor {
+ field protected java.lang.Long mCurrentRowID;
+ field protected int mRowIdColumnIndex;
+ field protected java.util.HashMap<java.lang.Long, java.util.Map<java.lang.String, java.lang.Object>> mUpdatedRows;
+ }
+
+}
+
package android.media {
public class AudioFormat {
diff --git a/core/java/android/database/AbstractCursor.java b/core/java/android/database/AbstractCursor.java
index fcfcbb5..5762c1d 100644
--- a/core/java/android/database/AbstractCursor.java
+++ b/core/java/android/database/AbstractCursor.java
@@ -49,9 +49,24 @@
*/
protected Long mCurrentRowID;
+ /**
+ * @deprecated Use {@link #getPosition()} instead.
+ */
+ @Deprecated
protected int mPos;
+
+ /**
+ * @deprecated Use {@link #isClosed()} instead.
+ */
+ @Deprecated
protected boolean mClosed;
+
+ /**
+ * @deprecated Do not use.
+ */
+ @Deprecated
protected ContentResolver mContentResolver;
+
private Uri mNotifyUri;
private final Object mSelfObserverLock = new Object();
@@ -65,18 +80,28 @@
/* -------------------------------------------------------- */
/* These need to be implemented by subclasses */
+ @Override
abstract public int getCount();
+ @Override
abstract public String[] getColumnNames();
+ @Override
abstract public String getString(int column);
+ @Override
abstract public short getShort(int column);
+ @Override
abstract public int getInt(int column);
+ @Override
abstract public long getLong(int column);
+ @Override
abstract public float getFloat(int column);
+ @Override
abstract public double getDouble(int column);
+ @Override
abstract public boolean isNull(int column);
+ @Override
public int getType(int column) {
// Reflects the assumption that all commonly used field types (meaning everything
// but blobs) are convertible to strings so it should be safe to call
@@ -85,6 +110,7 @@
}
// TODO implement getBlob in all cursor types
+ @Override
public byte[] getBlob(int column) {
throw new UnsupportedOperationException("getBlob is not supported");
}
@@ -97,14 +123,17 @@
*
* @return The pre-filled window that backs this cursor, or null if none.
*/
+ @Override
public CursorWindow getWindow() {
return null;
}
+ @Override
public int getColumnCount() {
return getColumnNames().length;
}
+ @Override
public void deactivate() {
onDeactivateOrClose();
}
@@ -118,6 +147,7 @@
mDataSetObservable.notifyInvalidated();
}
+ @Override
public boolean requery() {
if (mSelfObserver != null && mSelfObserverRegistered == false) {
mContentResolver.registerContentObserver(mNotifyUri, true, mSelfObserver);
@@ -127,10 +157,12 @@
return true;
}
+ @Override
public boolean isClosed() {
return mClosed;
}
+ @Override
public void close() {
mClosed = true;
mContentObservable.unregisterAll();
@@ -147,11 +179,13 @@
* @param newPosition the position that we're moving to
* @return true if the move is successful, false otherwise
*/
+ @Override
public boolean onMove(int oldPosition, int newPosition) {
return true;
}
+ @Override
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
// Default implementation, uses getString
String result = getString(columnIndex);
@@ -174,10 +208,12 @@
mPos = -1;
}
+ @Override
public final int getPosition() {
return mPos;
}
+ @Override
public final boolean moveToPosition(int position) {
// Make sure position isn't past the end of the cursor
final int count = getCount();
@@ -212,35 +248,43 @@
DatabaseUtils.cursorFillWindow(this, position, window);
}
+ @Override
public final boolean move(int offset) {
return moveToPosition(mPos + offset);
}
+ @Override
public final boolean moveToFirst() {
return moveToPosition(0);
}
+ @Override
public final boolean moveToLast() {
return moveToPosition(getCount() - 1);
}
+ @Override
public final boolean moveToNext() {
return moveToPosition(mPos + 1);
}
+ @Override
public final boolean moveToPrevious() {
return moveToPosition(mPos - 1);
}
+ @Override
public final boolean isFirst() {
return mPos == 0 && getCount() != 0;
}
+ @Override
public final boolean isLast() {
int cnt = getCount();
return mPos == (cnt - 1) && cnt != 0;
}
+ @Override
public final boolean isBeforeFirst() {
if (getCount() == 0) {
return true;
@@ -248,6 +292,7 @@
return mPos == -1;
}
+ @Override
public final boolean isAfterLast() {
if (getCount() == 0) {
return true;
@@ -255,6 +300,7 @@
return mPos == getCount();
}
+ @Override
public int getColumnIndex(String columnName) {
// Hack according to bug 903852
final int periodIndex = columnName.lastIndexOf('.');
@@ -280,6 +326,7 @@
return -1;
}
+ @Override
public int getColumnIndexOrThrow(String columnName) {
final int index = getColumnIndex(columnName);
if (index < 0) {
@@ -288,14 +335,17 @@
return index;
}
+ @Override
public String getColumnName(int columnIndex) {
return getColumnNames()[columnIndex];
}
+ @Override
public void registerContentObserver(ContentObserver observer) {
mContentObservable.registerObserver(observer);
}
+ @Override
public void unregisterContentObserver(ContentObserver observer) {
// cursor will unregister all observers when it close
if (!mClosed) {
@@ -303,10 +353,12 @@
}
}
+ @Override
public void registerDataSetObserver(DataSetObserver observer) {
mDataSetObservable.registerObserver(observer);
}
+ @Override
public void unregisterDataSetObserver(DataSetObserver observer) {
mDataSetObservable.unregisterObserver(observer);
}
@@ -333,6 +385,7 @@
* @param notifyUri The URI to watch for changes. This can be a
* specific row URI, or a base URI for a whole class of content.
*/
+ @Override
public void setNotificationUri(ContentResolver cr, Uri notifyUri) {
setNotificationUri(cr, notifyUri, UserHandle.myUserId());
}