summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFred Quintana <fredq@google.com>2009-08-20 17:18:58 -0700
committerFred Quintana <fredq@google.com>2009-08-20 17:18:58 -0700
commit77709755b74bcc852cd511ff833c2827c0f0e1aa (patch)
treed526a9851433873588bf3504b1f2baa9e9555548 /core
parent404780d62b8f6fe6787fca27cf36fe2c20b7220e (diff)
downloadframeworks_base-77709755b74bcc852cd511ff833c2827c0f0e1aa.zip
frameworks_base-77709755b74bcc852cd511ff833c2827c0f0e1aa.tar.gz
frameworks_base-77709755b74bcc852cd511ff833c2827c0f0e1aa.tar.bz2
- add a reset to EntityIterator to allow it to go back to the beginning
- clean up the debug printing of SyncResult
Diffstat (limited to 'core')
-rw-r--r--core/java/android/content/AbstractCursorEntityIterator.java8
-rw-r--r--core/java/android/content/ContentProviderNative.java8
-rw-r--r--core/java/android/content/ContentResolver.java7
-rw-r--r--core/java/android/content/EntityIterator.java2
-rw-r--r--core/java/android/content/IEntityIterator.java29
-rw-r--r--core/java/android/content/SyncResult.java21
-rw-r--r--core/java/android/content/SyncStats.java21
7 files changed, 79 insertions, 17 deletions
diff --git a/core/java/android/content/AbstractCursorEntityIterator.java b/core/java/android/content/AbstractCursorEntityIterator.java
index bf3c4de..c2b13a4 100644
--- a/core/java/android/content/AbstractCursorEntityIterator.java
+++ b/core/java/android/content/AbstractCursorEntityIterator.java
@@ -87,6 +87,14 @@ public abstract class AbstractCursorEntityIterator implements EntityIterator {
}
}
+ public void reset() throws RemoteException {
+ if (mIsClosed) {
+ throw new IllegalStateException("calling reset() when the iterator is closed");
+ }
+ mEntityCursor.moveToPosition(-1);
+ mNextEntity = null;
+ }
+
/**
* Closes this iterator making it invalid. If is invalid for the user to call any public
* method on the iterator once it has been closed.
diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java
index a4c217b..e367ceb 100644
--- a/core/java/android/content/ContentProviderNative.java
+++ b/core/java/android/content/ContentProviderNative.java
@@ -281,6 +281,10 @@ abstract public class ContentProviderNative extends Binder implements IContentPr
return mEntityIterator.next();
}
+ public void reset() throws RemoteException {
+ mEntityIterator.reset();
+ }
+
public void close() throws RemoteException {
mEntityIterator.close();
}
@@ -406,6 +410,10 @@ final class ContentProviderProxy implements IContentProvider
return mEntityIterator.next();
}
+ public void reset() throws RemoteException {
+ mEntityIterator.reset();
+ }
+
public void close() {
try {
mEntityIterator.close();
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index 239b3de..b915803 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -244,6 +244,13 @@ public abstract class ContentResolver {
return mInner.next();
}
+ public void reset() throws RemoteException {
+ if (mClientReleased) {
+ throw new IllegalStateException("this iterator is already closed");
+ }
+ mInner.reset();
+ }
+
public void close() {
mClient.release();
mInner.close();
diff --git a/core/java/android/content/EntityIterator.java b/core/java/android/content/EntityIterator.java
index 5e5f14c..3cc1040 100644
--- a/core/java/android/content/EntityIterator.java
+++ b/core/java/android/content/EntityIterator.java
@@ -41,6 +41,8 @@ public interface EntityIterator {
*/
public Entity next() throws RemoteException;
+ public void reset() throws RemoteException;
+
/**
* Indicates that this iterator is no longer needed and that any associated resources
* may be released (such as a SQLite cursor).
diff --git a/core/java/android/content/IEntityIterator.java b/core/java/android/content/IEntityIterator.java
index 1c478b3..068581e 100644
--- a/core/java/android/content/IEntityIterator.java
+++ b/core/java/android/content/IEntityIterator.java
@@ -98,6 +98,20 @@ public interface IEntityIterator extends IInterface {
return true;
}
+ case TRANSACTION_reset:
+ {
+ data.enforceInterface(DESCRIPTOR);
+ try {
+ this.reset();
+ } catch (RemoteException e) {
+ Log.e(TAG, "caught exception in next()", e);
+ reply.writeException(e);
+ return true;
+ }
+ reply.writeNoException();
+ return true;
+ }
+
case TRANSACTION_close:
{
data.enforceInterface(DESCRIPTOR);
@@ -157,6 +171,19 @@ public interface IEntityIterator extends IInterface {
}
}
+ public void reset() throws RemoteException {
+ Parcel _data = Parcel.obtain();
+ Parcel _reply = Parcel.obtain();
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ mRemote.transact(Stub.TRANSACTION_reset, _data, _reply, 0);
+ _reply.readException();
+ } finally {
+ _reply.recycle();
+ _data.recycle();
+ }
+ }
+
public void close() throws RemoteException {
Parcel _data = Parcel.obtain();
Parcel _reply = Parcel.obtain();
@@ -174,8 +201,10 @@ public interface IEntityIterator extends IInterface {
static final int TRANSACTION_hasNext = (IBinder.FIRST_CALL_TRANSACTION + 0);
static final int TRANSACTION_next = (IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_close = (IBinder.FIRST_CALL_TRANSACTION + 2);
+ static final int TRANSACTION_reset = (IBinder.FIRST_CALL_TRANSACTION + 3);
}
public boolean hasNext() throws RemoteException;
public Entity next() throws RemoteException;
+ public void reset() throws RemoteException;
public void close() throws RemoteException;
}
diff --git a/core/java/android/content/SyncResult.java b/core/java/android/content/SyncResult.java
index f3260f3..4c201e6 100644
--- a/core/java/android/content/SyncResult.java
+++ b/core/java/android/content/SyncResult.java
@@ -113,14 +113,19 @@ public final class SyncResult implements Parcelable {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append(" syncAlreadyInProgress: ").append(syncAlreadyInProgress);
- sb.append(" tooManyDeletions: ").append(tooManyDeletions);
- sb.append(" tooManyRetries: ").append(tooManyRetries);
- sb.append(" databaseError: ").append(databaseError);
- sb.append(" fullSyncRequested: ").append(fullSyncRequested);
- sb.append(" partialSyncUnavailable: ").append(partialSyncUnavailable);
- sb.append(" moreRecordsToGet: ").append(moreRecordsToGet);
- sb.append(" stats: ").append(stats);
+ sb.append("SyncResult:");
+ if (syncAlreadyInProgress) {
+ sb.append(" syncAlreadyInProgress: ").append(syncAlreadyInProgress);
+ }
+ if (tooManyDeletions) sb.append(" tooManyDeletions: ").append(tooManyDeletions);
+ if (tooManyRetries) sb.append(" tooManyRetries: ").append(tooManyRetries);
+ if (databaseError) sb.append(" databaseError: ").append(databaseError);
+ if (fullSyncRequested) sb.append(" fullSyncRequested: ").append(fullSyncRequested);
+ if (partialSyncUnavailable) {
+ sb.append(" partialSyncUnavailable: ").append(partialSyncUnavailable);
+ }
+ if (moreRecordsToGet) sb.append(" moreRecordsToGet: ").append(moreRecordsToGet);
+ sb.append(stats);
return sb.toString();
}
diff --git a/core/java/android/content/SyncStats.java b/core/java/android/content/SyncStats.java
index b561b05..cc544c0 100644
--- a/core/java/android/content/SyncStats.java
+++ b/core/java/android/content/SyncStats.java
@@ -60,15 +60,18 @@ public class SyncStats implements Parcelable {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("numAuthExceptions: ").append(numAuthExceptions);
- sb.append(" numIoExceptions: ").append(numIoExceptions);
- sb.append(" numParseExceptions: ").append(numParseExceptions);
- sb.append(" numConflictDetectedExceptions: ").append(numConflictDetectedExceptions);
- sb.append(" numInserts: ").append(numInserts);
- sb.append(" numUpdates: ").append(numUpdates);
- sb.append(" numDeletes: ").append(numDeletes);
- sb.append(" numEntries: ").append(numEntries);
- sb.append(" numSkippedEntries: ").append(numSkippedEntries);
+ sb.append(" stats [");
+ if (numAuthExceptions > 0) sb.append(" numAuthExceptions: ").append(numAuthExceptions);
+ if (numIoExceptions > 0) sb.append(" numIoExceptions: ").append(numIoExceptions);
+ if (numParseExceptions > 0) sb.append(" numParseExceptions: ").append(numParseExceptions);
+ if (numConflictDetectedExceptions > 0)
+ sb.append(" numConflictDetectedExceptions: ").append(numConflictDetectedExceptions);
+ if (numInserts > 0) sb.append(" numInserts: ").append(numInserts);
+ if (numUpdates > 0) sb.append(" numUpdates: ").append(numUpdates);
+ if (numDeletes > 0) sb.append(" numDeletes: ").append(numDeletes);
+ if (numEntries > 0) sb.append(" numEntries: ").append(numEntries);
+ if (numSkippedEntries > 0) sb.append(" numSkippedEntries: ").append(numSkippedEntries);
+ sb.append("]");
return sb.toString();
}