diff options
author | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-08-10 06:17:29 +0530 |
---|---|---|
committer | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-08-20 21:02:29 +0530 |
commit | 65a993446c8905ca5e77fefe4b7f1c4d0aee74d8 (patch) | |
tree | 537883b8c00119af5ee248079ce5d80f88ea1c2e /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java | |
parent | 448657602ce5baa5b2a99e26ab2eb2fb8061778f (diff) | |
download | open-keychain-65a993446c8905ca5e77fefe4b7f1c4d0aee74d8.tar.gz open-keychain-65a993446c8905ca5e77fefe4b7f1c4d0aee74d8.tar.bz2 open-keychain-65a993446c8905ca5e77fefe4b7f1c4d0aee74d8.zip |
reworked keyserversyncadapterservice flow
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java index cd24394d7..1d6de260d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java @@ -28,6 +28,7 @@ import android.graphics.Bitmap; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; +import android.os.Bundle; import android.os.Environment; import android.provider.ContactsContract; import android.widget.Toast; @@ -44,6 +45,7 @@ import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.TlsHelper; import java.security.Security; +import java.util.Arrays; import java.util.HashMap; @@ -136,17 +138,31 @@ public class KeychainApplication extends Application { } /** - * Add OpenKeychain account to Android to link contacts with keys + * Add OpenKeychain account to Android to link contacts with keys and keyserver sync */ public static void setupAccountAsNeeded(Context context) { try { AccountManager manager = AccountManager.get(context); Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE); - if (accounts == null || accounts.length == 0) { + + if (accounts.length == 0) { Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE); if (manager.addAccountExplicitly(account, null, null)) { + // for contact sync ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true); + // for keyserver sync + ContentResolver.setIsSyncable(account, Constants.PROVIDER_AUTHORITY, 1); + ContentResolver.setSyncAutomatically(account, Constants.PROVIDER_AUTHORITY, + true); + // TODO: Increase periodic update time after testing + Log.e("PHILIP", "enabled periodic keyserversync"); + ContentResolver.addPeriodicSync( + new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE), + Constants.PROVIDER_AUTHORITY, + new Bundle(), + 60 + ); } else { Log.e(Constants.TAG, "Adding account failed!"); } |