Merge change 21756 into eclair

* changes:
  Add "num new messages" field to Account
This commit is contained in:
Android (Google) Code Review 2009-08-18 13:44:53 -07:00
commit 5ecdc1b635
5 changed files with 45 additions and 16 deletions

View File

@ -790,6 +790,8 @@ public abstract class EmailContent {
public static final String RINGTONE_URI = "ringtoneUri";
// Protocol version (arbitrary string, used by EAS currently)
public static final String PROTOCOL_VERSION = "protocolVersion";
// The number of new messages (reported by the sync/download engines
public static final String NEW_MESSAGE_COUNT = "newMessageCount";
}
public static final class Account extends EmailContent implements AccountColumns, Parcelable {
@ -825,6 +827,7 @@ public abstract class EmailContent {
public String mSenderName;
public String mRingtoneUri;
public String mProtocolVersion;
public int mNewMessageCount;
// Convenience for creating an account
public transient HostAuth mHostAuthRecv;
@ -844,6 +847,7 @@ public abstract class EmailContent {
public static final int CONTENT_SENDER_NAME_COLUMN = 11;
public static final int CONTENT_RINGTONE_URI_COLUMN = 12;
public static final int CONTENT_PROTOCOL_VERSION_COLUMN = 13;
public static final int CONTENT_NEW_MESSAGE_COUNT_COLUMN = 14;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, AccountColumns.DISPLAY_NAME,
@ -851,7 +855,8 @@ public abstract class EmailContent {
AccountColumns.SYNC_INTERVAL, AccountColumns.HOST_AUTH_KEY_RECV,
AccountColumns.HOST_AUTH_KEY_SEND, AccountColumns.FLAGS, AccountColumns.IS_DEFAULT,
AccountColumns.COMPATIBILITY_UUID, AccountColumns.SENDER_NAME,
AccountColumns.RINGTONE_URI, AccountColumns.PROTOCOL_VERSION
AccountColumns.RINGTONE_URI, AccountColumns.PROTOCOL_VERSION,
AccountColumns.NEW_MESSAGE_COUNT
};
public static final int CONTENT_MAILBOX_TYPE_COLUMN = 1;
@ -941,6 +946,7 @@ public abstract class EmailContent {
mSenderName = cursor.getString(CONTENT_SENDER_NAME_COLUMN);
mRingtoneUri = cursor.getString(CONTENT_RINGTONE_URI_COLUMN);
mProtocolVersion = cursor.getString(CONTENT_PROTOCOL_VERSION_COLUMN);
mNewMessageCount = cursor.getInt(CONTENT_NEW_MESSAGE_COUNT_COLUMN);
return this;
}
@ -1357,6 +1363,7 @@ public abstract class EmailContent {
values.put(AccountColumns.SENDER_NAME, mSenderName);
values.put(AccountColumns.RINGTONE_URI, mRingtoneUri);
values.put(AccountColumns.PROTOCOL_VERSION, mProtocolVersion);
values.put(AccountColumns.NEW_MESSAGE_COUNT, mNewMessageCount);
return values;
}
@ -1428,6 +1435,8 @@ public abstract class EmailContent {
dest.writeString(mCompatibilityUuid);
dest.writeString(mSenderName);
dest.writeString(mRingtoneUri);
dest.writeString(mProtocolVersion);
dest.writeInt(mNewMessageCount);
if (mHostAuthRecv != null) {
dest.writeByte((byte)1);
@ -1462,6 +1471,8 @@ public abstract class EmailContent {
mCompatibilityUuid = in.readString();
mSenderName = in.readString();
mRingtoneUri = in.readString();
mProtocolVersion = in.readString();
mNewMessageCount = in.readInt();
mHostAuthRecv = null;
if (in.readByte() == 1) {

View File

@ -55,18 +55,9 @@ public class EmailProvider extends ContentProvider {
static final String DATABASE_NAME = "EmailProvider.db";
static final String BODY_DATABASE_NAME = "EmailProviderBody.db";
// In these early versions, updating the database version will cause all tables to be deleted
// Obviously, we'll handle upgrades differently once things are a bit stable
// version 15: changed Address.pack() format.
// version 16: added protocolVersion column to Account
// version 17: prevent duplication of mailboxes with the same serverId
// version 18: renamed syncFrequency to syncInterval for Account and Mailbox
// version 19: added triggers to keep track of unreadCount by Mailbox
// version 20: changed type of EAS account mailbox, making old databases invalid for EAS
// version 21: fixed broken trigger linking account deletion to the deletion of its HostAuth's
// version 22: added syncStatus column to Mailbox
// Any changes to the database format *must* include update-in-place code.
public static final int DATABASE_VERSION = 22;
public static final int DATABASE_VERSION = 1;
public static final int BODY_DATABASE_VERSION = 1;
public static final String EMAIL_AUTHORITY = "com.android.email.provider";
@ -383,7 +374,8 @@ public class EmailProvider extends ContentProvider {
+ AccountColumns.COMPATIBILITY_UUID + " text, "
+ AccountColumns.SENDER_NAME + " text, "
+ AccountColumns.RINGTONE_URI + " text, "
+ AccountColumns.PROTOCOL_VERSION + " text"
+ AccountColumns.PROTOCOL_VERSION + " text, "
+ AccountColumns.NEW_MESSAGE_COUNT + " integer"
+ ");";
db.execSQL("create table " + Account.TABLE_NAME + s);
// Deleting an account deletes associated Mailboxes and HostAuth's

View File

@ -665,9 +665,11 @@ public class SyncManager extends Service implements Runnable {
clearAlarms();
// Release our wake lock, if we have one
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
synchronized (mWakeLocks) {
if (mWakeLock != null) {
mWakeLock.release();
mWakeLock = null;
}
}
sPendingIntents.clear();

View File

@ -52,6 +52,7 @@ public class ProviderTestUtils extends Assert {
account.mSenderName = name;
account.mRingtoneUri = "content://ringtone-" + name;
account.mProtocolVersion = "2.5" + name;
account.mNewMessageCount = 5 + name.length();
if (saveIt) {
account.save(context);
@ -207,6 +208,8 @@ public class ProviderTestUtils extends Assert {
assertEquals(caller + " mRingtoneUri", expect.mRingtoneUri, actual.mRingtoneUri);
assertEquals(caller + " mProtocolVersion", expect.mProtocolVersion,
actual.mProtocolVersion);
assertEquals(caller + " mNewMessageCount", expect.mNewMessageCount,
actual.mNewMessageCount);
}
/**

View File

@ -32,7 +32,9 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Parcel;
import android.test.ProviderTestCase2;
import java.io.File;
@ -77,6 +79,25 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
ProviderTestUtils.assertAccountEqual("testAccountSave", account1, account2);
}
/**
* Simple test of account parceling. The rather tortuous path is to ensure that the
* account is really flattened all the way down to a parcel and back.
*/
public void testAccountParcel() {
Account account1 = ProviderTestUtils.setupAccount("parcel", false, mMockContext);
Bundle b = new Bundle();
b.putParcelable("account", account1);
Parcel p = Parcel.obtain();
b.writeToParcel(p, 0);
p.setDataPosition(0); // rewind it for reading
Bundle b2 = new Bundle(Account.class.getClassLoader());
b2.readFromParcel(p);
Account account2 = (Account) b2.getParcelable("account");
p.recycle();
ProviderTestUtils.assertAccountEqual("testAccountParcel", account1, account2);
}
private final static String[] MAILBOX_UNREAD_COUNT_PROJECTION = new String [] {
MailboxColumns.UNREAD_COUNT
};