Disable contact sync by default on Android >= 6
This commit is contained in:
@@ -17,10 +17,7 @@
|
||||
|
||||
package org.sufficientlysecure.keychain;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Application;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -28,12 +25,11 @@ import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.ContactsContract;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.ui.ConsolidateDialogActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||
@@ -93,7 +89,9 @@ public class KeychainApplication extends Application {
|
||||
brandGlowEffect(getApplicationContext(),
|
||||
FormattingUtils.getColorFromAttr(getApplicationContext(), R.attr.colorPrimary));
|
||||
|
||||
setupAccountAsNeeded(this);
|
||||
// Add OpenKeychain account to Android to link contacts with keys and keyserver sync
|
||||
KeyserverSyncAdapterService.enableKeyserverSync(this);
|
||||
ContactSyncAdapterService.initContactsSync(this);
|
||||
|
||||
// Update keyserver list as needed
|
||||
Preferences.getPreferences(this).upgradePreferences(this);
|
||||
@@ -136,31 +134,6 @@ public class KeychainApplication extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.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);
|
||||
KeyserverSyncAdapterService.enableKeyserverSync(context);
|
||||
} else {
|
||||
Log.e(Constants.TAG, "Adding account failed!");
|
||||
}
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
||||
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
static void brandGlowEffect(Context context, int brandColor) {
|
||||
// no hack on Android 5
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
|
||||
Reference in New Issue
Block a user