diff options
author | Megha Joshi <mjoshi@google.com> | 2009-09-30 17:47:14 -0700 |
---|---|---|
committer | Megha Joshi <mjoshi@google.com> | 2009-10-02 13:55:22 -0700 |
commit | 6ce24dc1d53f1ed2760a06cd60c705ebdf666f43 (patch) | |
tree | c583f2d60b1b6e8aa602f2b266614b381e354e80 | |
parent | 3296d3469bce0041a6cefc44d0486a2a7d0c9f82 (diff) | |
download | ContactsProvider-6ce24dc1d53f1ed2760a06cd60c705ebdf666f43.tar.gz |
Force sync to happen if Groups.SHOULD_SYNC is set.
Bug # 2093578
Dr. NO: TS
-rw-r--r-- | src/com/android/providers/contacts/ContactsProvider2.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java index 8a5c99d0..1eef5264 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -47,6 +47,7 @@ import android.accounts.OnAccountsUpdatedListener; import android.app.SearchManager; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; +import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; @@ -66,6 +67,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.database.sqlite.SQLiteStatement; import android.net.Uri; +import android.os.Bundle; import android.os.MemoryFile; import android.os.RemoteException; import android.os.SystemProperties; @@ -2870,6 +2872,29 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun if (updatedValues.containsKey(Groups.GROUP_VISIBLE)) { mVisibleTouched = true; } + if (updatedValues.containsKey(Groups.SHOULD_SYNC) + && updatedValues.getAsInteger(Groups.SHOULD_SYNC) != 0) { + final long groupId = ContentUris.parseId(uri); + Cursor c = mDb.query(Tables.GROUPS, new String[]{Groups.ACCOUNT_NAME, + Groups.ACCOUNT_TYPE}, Groups._ID + "=" + groupId, null, null, + null, null); + String accountName; + String accountType; + try { + while (c.moveToNext()) { + accountName = c.getString(0); + accountType = c.getString(1); + if(!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) { + Account account = new Account(accountName, accountType); + ContentResolver.requestSync(account, ContactsContract.AUTHORITY, + new Bundle()); + break; + } + } + } finally { + c.close(); + } + } return count; } |