summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/exchange/service/ContactsSyncAdapterService.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/com/android/exchange/service/ContactsSyncAdapterService.java b/src/com/android/exchange/service/ContactsSyncAdapterService.java
index 0be647e0..3e699b3e 100644
--- a/src/com/android/exchange/service/ContactsSyncAdapterService.java
+++ b/src/com/android/exchange/service/ContactsSyncAdapterService.java
@@ -20,6 +20,7 @@ import android.accounts.Account;
import android.content.AbstractThreadedSyncAdapter;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
+import android.content.ContentValues;
import android.content.Context;
import android.content.SyncResult;
import android.database.Cursor;
@@ -27,6 +28,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.Settings;
import android.util.Log;
import com.android.emailcommon.provider.EmailContent;
@@ -72,10 +74,44 @@ public class ContactsSyncAdapterService extends AbstractSyncAdapterService {
LogUtils.i(TAG, "onPerformSync Contacts starting %s", extras.toString());
}
ContactsSyncAdapterService.performSync(getContext(), account, extras);
+ ContactsSyncAdapterService.maybeSetAccountContactsVisibility(getContext(), account);
LogUtils.d(TAG, "onPerformSync Contacts finished");
}
}
+ private static void maybeSetAccountContactsVisibility(Context context, Account account) {
+ String[] projection = new String[]{
+ Settings.ACCOUNT_NAME,
+ Settings.ACCOUNT_TYPE
+ };
+ String selection = Settings.ACCOUNT_NAME + "=? AND " +
+ Settings.ACCOUNT_TYPE + "=?";
+ String[] selectionArgs = new String[]{
+ account.name,
+ account.type
+ };
+ ContentResolver resolver = context.getContentResolver();
+ Cursor c = resolver.query(Settings.CONTENT_URI,
+ projection, selection, selectionArgs, null);
+ if (c != null) {
+ if (c.getCount() == 0) {
+ LogUtils.d(TAG, "setting account visibility true for account: " + account.name);
+ setAccountContactsVisibility(context, account, true);
+ }
+ c.close();
+ }
+ }
+
+ private static void setAccountContactsVisibility(Context context, Account account,
+ boolean visible) {
+ ContentValues values = new ContentValues();
+ values.put(RawContacts.ACCOUNT_NAME, account.name);
+ values.put(RawContacts.ACCOUNT_TYPE, account.type);
+ values.put(Settings.UNGROUPED_VISIBLE, visible ? 1 : 0);
+
+ context.getContentResolver().insert(Settings.CONTENT_URI, values);
+ }
+
private static boolean hasDirtyRows(ContentResolver resolver, Uri uri, String dirtyColumn) {
Cursor c = resolver.query(uri, EmailContent.ID_PROJECTION, dirtyColumn + "=1", null, null);
try {