Don't try to delete contacts if we don't have permission anymore

This commit is contained in:
Vincent Breitmoser
2018-07-18 13:38:04 +02:00
parent 22f4eb3e44
commit f9557cca37
3 changed files with 1 additions and 31 deletions

View File

@@ -135,23 +135,6 @@ public class ContactSyncAdapterService extends Service {
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
}
public static void deleteIfSyncDisabled(Context context) {
if (!(ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
== PackageManager.PERMISSION_GRANTED)) {
return;
}
Account account = KeychainApplication.createAccountIfNecessary(context);
if (account == null) {
return;
}
// if user has disabled automatic sync, delete linked OpenKeychain contacts
if (!ContentResolver.getSyncAutomatically(account, ContactsContract.AUTHORITY)) {
new ContactHelper(context).deleteAllContacts();
}
}
// TODO: Import is currently disabled, until we implement proper origin management
// private static void importKeys() {
// importDone.set(false);