re-enable contact sync by default
This commit is contained in:
@@ -91,7 +91,7 @@ public class KeychainApplication extends Application {
|
|||||||
|
|
||||||
// Add OpenKeychain account to Android to link contacts with keys and keyserver sync
|
// Add OpenKeychain account to Android to link contacts with keys and keyserver sync
|
||||||
KeyserverSyncAdapterService.enableKeyserverSync(this);
|
KeyserverSyncAdapterService.enableKeyserverSync(this);
|
||||||
ContactSyncAdapterService.initContactsSync(this);
|
ContactSyncAdapterService.enableContactsSync(this);
|
||||||
|
|
||||||
// Update keyserver list as needed
|
// Update keyserver list as needed
|
||||||
Preferences.getPreferences(this).upgradePreferences(this);
|
Preferences.getPreferences(this).upgradePreferences(this);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class ContactSyncAdapterService extends Service {
|
|||||||
extras);
|
extras);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initContactsSync(Context context) {
|
public static void enableContactsSync(Context context) {
|
||||||
try {
|
try {
|
||||||
AccountManager manager = AccountManager.get(context);
|
AccountManager manager = AccountManager.get(context);
|
||||||
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
|
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
|
||||||
@@ -165,11 +165,7 @@ public class ContactSyncAdapterService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
||||||
|
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
||||||
// Enable by default for Android < 6, on Android >= 6 runtime permissions are required
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
||||||
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
|
||||||
}
|
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
||||||
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
||||||
|
|||||||
Reference in New Issue
Block a user