From 229666e10693e156ad99397f36dedf95b53f86fc Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sat, 27 Mar 2010 10:51:10 -0700 Subject: [PATCH] Check for dirty events in specified account before syncing * We were starting a sync if there was a dirty event in ANY of our Exchange accounts * Change to check for the specific account before syncing; this saves provider queries and service (i.e. thread) startups Bug: 2550620 Change-Id: I83e953f1bade9fa269b777e96121a63664e8edc8 --- .../android/exchange/CalendarSyncAdapterService.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/com/android/exchange/CalendarSyncAdapterService.java b/src/com/android/exchange/CalendarSyncAdapterService.java index d2f4ecf77..357d67f5b 100644 --- a/src/com/android/exchange/CalendarSyncAdapterService.java +++ b/src/com/android/exchange/CalendarSyncAdapterService.java @@ -43,6 +43,8 @@ public class CalendarSyncAdapterService extends Service { private static final String ACCOUNT_AND_TYPE_CALENDAR = MailboxColumns.ACCOUNT_KEY + "=? AND " + MailboxColumns.TYPE + '=' + Mailbox.TYPE_CALENDAR; + private static final String DIRTY_IN_ACCOUNT = + Events._SYNC_DIRTY + "=1 AND " + Events._SYNC_ACCOUNT + "=?"; public CalendarSyncAdapterService() { super(); @@ -93,16 +95,13 @@ public class CalendarSyncAdapterService extends Service { throws OperationCanceledException { ContentResolver cr = context.getContentResolver(); boolean logging = Eas.USER_LOG; - if (logging) { - Log.d(TAG, "performSync"); - } if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD)) { Cursor c = cr.query(Events.CONTENT_URI, - new String[] {Events._ID}, Events._SYNC_DIRTY + "=1", null, null); + new String[] {Events._ID}, DIRTY_IN_ACCOUNT, new String[] {account.name}, null); try { if (!c.moveToFirst()) { if (logging) { - Log.d(TAG, "Upload sync; no changes"); + Log.d(TAG, "No changes for " + account.name); } return; } @@ -125,7 +124,7 @@ public class CalendarSyncAdapterService extends Service { try { if (mailboxCursor.moveToFirst()) { if (logging) { - Log.d(TAG, "Calendar sync requested for " + account.name); + Log.d(TAG, "Upload sync requested for " + account.name); } // Ask for a sync from our sync manager SyncManager.serviceRequest(mailboxCursor.getLong(0),