am ebda7847
: Fix bugs related to Contacts sync behavior in Exchange
Merge commit 'ebda78473223242ae0be4508a46dc60d2632b8ea' * commit 'ebda78473223242ae0be4508a46dc60d2632b8ea': Fix bugs related to Contacts sync behavior in Exchange
This commit is contained in:
commit
3f61b5a432
@ -31,8 +31,10 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SyncResult;
|
import android.content.SyncResult;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.provider.ContactsContract.RawContacts;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class ContactsSyncAdapterService extends Service {
|
public class ContactsSyncAdapterService extends Service {
|
||||||
@ -88,10 +90,28 @@ public class ContactsSyncAdapterService extends Service {
|
|||||||
* The missing piece at this point is integration with the push/ping mechanism in EAS; this will
|
* The missing piece at this point is integration with the push/ping mechanism in EAS; this will
|
||||||
* be put in place at a later time.
|
* be put in place at a later time.
|
||||||
*/
|
*/
|
||||||
private static void performSync(Context context, Account account, Bundle extras, String authority,
|
private static void performSync(Context context, Account account, Bundle extras,
|
||||||
ContentProviderClient provider, SyncResult syncResult)
|
String authority, ContentProviderClient provider, SyncResult syncResult)
|
||||||
throws OperationCanceledException {
|
throws OperationCanceledException {
|
||||||
ContentResolver cr = context.getContentResolver();
|
ContentResolver cr = context.getContentResolver();
|
||||||
|
Log.i(TAG, "performSync");
|
||||||
|
if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD)) {
|
||||||
|
Uri uri = RawContacts.CONTENT_URI.buildUpon()
|
||||||
|
.appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
|
||||||
|
.appendQueryParameter(RawContacts.ACCOUNT_TYPE, Eas.ACCOUNT_MANAGER_TYPE)
|
||||||
|
.build();
|
||||||
|
Cursor c = cr.query(uri,
|
||||||
|
new String[] {RawContacts._ID}, RawContacts.DIRTY + "=1", null, null);
|
||||||
|
try {
|
||||||
|
if (!c.moveToFirst()) {
|
||||||
|
Log.i(TAG, "Upload sync; no changes");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
c.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find the (EmailProvider) account associated with this email address
|
// Find the (EmailProvider) account associated with this email address
|
||||||
Cursor accountCursor =
|
Cursor accountCursor =
|
||||||
cr.query(com.android.email.provider.EmailContent.Account.CONTENT_URI, ID_PROJECTION,
|
cr.query(com.android.email.provider.EmailContent.Account.CONTENT_URI, ID_PROJECTION,
|
||||||
@ -103,7 +123,7 @@ public class ContactsSyncAdapterService extends Service {
|
|||||||
Cursor mailboxCursor = cr.query(Mailbox.CONTENT_URI, ID_PROJECTION,
|
Cursor mailboxCursor = cr.query(Mailbox.CONTENT_URI, ID_PROJECTION,
|
||||||
ACCOUNT_AND_TYPE_CONTACTS, new String[] {Long.toString(accountId)}, null);
|
ACCOUNT_AND_TYPE_CONTACTS, new String[] {Long.toString(accountId)}, null);
|
||||||
try {
|
try {
|
||||||
if (mailboxCursor.moveToFirst()) {
|
if (mailboxCursor.moveToFirst()) {
|
||||||
Log.i(TAG, "Contact sync requested for " + account.name);
|
Log.i(TAG, "Contact sync requested for " + account.name);
|
||||||
// Ask for a sync from our sync manager
|
// Ask for a sync from our sync manager
|
||||||
SyncManager.serviceRequest(mailboxCursor.getLong(0),
|
SyncManager.serviceRequest(mailboxCursor.getLong(0),
|
||||||
|
Loading…
Reference in New Issue
Block a user