Fix for Account.isValidId() crash when getting -1.
Bug 2493026
This commit is contained in:
parent
41815958dc
commit
c133e6f185
@ -74,6 +74,8 @@ public abstract class EmailContent {
|
||||
};
|
||||
public static final int ID_PROJECTION_COLUMN = 0;
|
||||
|
||||
private static final String ID_SELECTION = RECORD_ID + " =?";
|
||||
|
||||
public static final String FIELD_COLUMN_NAME = "field";
|
||||
public static final String ADD_COLUMN_NAME = "add";
|
||||
|
||||
@ -1342,9 +1344,8 @@ public abstract class EmailContent {
|
||||
* @return true if an {@code accountId} is assigned to any existing account.
|
||||
*/
|
||||
public static boolean isValidId(Context context, long accountId) {
|
||||
Cursor cursor = context.getContentResolver().query(
|
||||
ContentUris.withAppendedId(CONTENT_URI, accountId), ID_PROJECTION,
|
||||
null, null, null);
|
||||
Cursor cursor = context.getContentResolver().query(CONTENT_URI, ID_PROJECTION,
|
||||
ID_SELECTION, new String[] {"" + accountId}, null);
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
return true;
|
||||
|
@ -175,6 +175,8 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
assertTrue(Account.isValidId(mMockContext, account2.mId));
|
||||
|
||||
assertFalse(Account.isValidId(mMockContext, 1234567)); // Some random ID
|
||||
assertFalse(Account.isValidId(mMockContext, -1));
|
||||
assertFalse(Account.isValidId(mMockContext, -500));
|
||||
}
|
||||
|
||||
private final static String[] MAILBOX_UNREAD_COUNT_PROJECTION = new String [] {
|
||||
|
Loading…
Reference in New Issue
Block a user