aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java22
1 files changed, 5 insertions, 17 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
index 86da33a74..387347986 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
@@ -155,22 +155,10 @@ public class ContactSyncAdapterService extends Service {
}
public static void enableContactsSync(Context context) {
- try {
- AccountManager manager = AccountManager.get(context);
- Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
-
- Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
- if (accounts.length == 0) {
- if (!manager.addAccountExplicitly(account, null, null)) {
- Log.d(Constants.TAG, "account already exists, the account is null, or another error occured");
- }
- }
-
- ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
- ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
- } catch (SecurityException e) {
- Log.e(Constants.TAG, "SecurityException when adding the account", e);
- Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
- }
+ AccountManager manager = AccountManager.get(context);
+ Account account = manager.getAccountsByType(Constants.ACCOUNT_TYPE)[0];
+
+ ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
+ ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
}
}