Fix cursor-related errors:
1) Have CachedCursor implement CrossProcessCursor; still need to figure out how this ever worked 2) Close cursor used internally in findMailboxOfType Bug: 4869024 Change-Id: Id20d37b7b83e133aa4d5fe9293a42ae217024f01
This commit is contained in:
parent
0404a331ad
commit
d12f78d6ba
@ -315,12 +315,19 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
||||
Uri uri = FROM_ACCOUNT_AND_TYPE_URI.buildUpon().appendPath(Long.toString(accountId))
|
||||
.appendPath(Integer.toString(type)).build();
|
||||
Cursor c = context.getContentResolver().query(uri, ID_PROJECTION, null, null, null);
|
||||
if (c != null) {
|
||||
try {
|
||||
c.moveToFirst();
|
||||
Long mailboxId = c.getLong(ID_PROJECTION_COLUMN);
|
||||
if (mailboxId != null && mailboxId.intValue() != 0) {
|
||||
return mailboxId;
|
||||
} else {
|
||||
Log.w(Logging.LOG_TAG, "========== Mailbox of type " + type + " not found in cache??");
|
||||
Log.w(Logging.LOG_TAG, "========== Mailbox of type " + type
|
||||
+ " not found in cache");
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
String[] bindArguments = new String[] {Long.toString(type), Long.toString(accountId)};
|
||||
return Utility.getFirstRowLong(context, Mailbox.CONTENT_URI,
|
||||
|
@ -17,7 +17,9 @@
|
||||
package com.android.email.provider;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.CrossProcessCursor;
|
||||
import android.database.Cursor;
|
||||
import android.database.CursorWindow;
|
||||
import android.database.CursorWrapper;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
@ -275,7 +277,7 @@ public final class ContentCache {
|
||||
* Multiple CachedCursor's can use the same underlying cursor, so we override the various
|
||||
* moveX methods such that each CachedCursor can have its own position information
|
||||
*/
|
||||
public static final class CachedCursor extends CursorWrapper {
|
||||
public static final class CachedCursor extends CursorWrapper implements CrossProcessCursor {
|
||||
// The cursor we're wrapping
|
||||
private final Cursor mCursor;
|
||||
// The cache which generated this cursor
|
||||
@ -381,6 +383,21 @@ public final class ContentCache {
|
||||
public final boolean isAfterLast() {
|
||||
return mPosition == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CursorWindow getWindow() {
|
||||
return ((CrossProcessCursor)mCursor).getWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWindow(int pos, CursorWindow window) {
|
||||
((CrossProcessCursor)mCursor).fillWindow(pos, window);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMove(int oldPosition, int newPosition) {
|
||||
return ((CrossProcessCursor)mCursor).onMove(oldPosition, newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user