mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
Sync in KeychainIntentService on delete, import, save
This commit is contained in:
parent
642a63fab6
commit
6e3af6605a
@ -21,6 +21,8 @@ import android.accounts.Account;
|
||||
import android.app.Service;
|
||||
import android.content.AbstractThreadedSyncAdapter;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SyncResult;
|
||||
import android.os.Bundle;
|
||||
@ -29,9 +31,11 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.provider.ContactsContract;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.ContactHelper;
|
||||
import org.sufficientlysecure.keychain.helper.EmailKeyHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@ -94,6 +98,15 @@ public class ContactSyncAdapterService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
public static void requestSync(Context context) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
|
||||
ContentResolver.requestSync(
|
||||
new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME),
|
||||
ContactsContract.AUTHORITY,
|
||||
extras);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new ContactSyncAdapter().getSyncAdapterBinder();
|
||||
|
@ -453,6 +453,9 @@ public class KeychainIntentService extends IntentService
|
||||
|
||||
setProgress(R.string.progress_done, 100, 100);
|
||||
|
||||
// make sure new data is synced into contacts
|
||||
ContactSyncAdapterService.requestSync(this);
|
||||
|
||||
/* Output */
|
||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, saveResult);
|
||||
} catch (Exception e) {
|
||||
@ -501,6 +504,8 @@ public class KeychainIntentService extends IntentService
|
||||
if (result.mSecret > 0) {
|
||||
providerHelper.consolidateDatabaseStep1(this);
|
||||
}
|
||||
// make sure new data is synced into contacts
|
||||
ContactSyncAdapterService.requestSync(this);
|
||||
|
||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||
} catch (Exception e) {
|
||||
@ -708,6 +713,9 @@ public class KeychainIntentService extends IntentService
|
||||
}
|
||||
|
||||
if (success) {
|
||||
// make sure new data is synced into contacts
|
||||
ContactSyncAdapterService.requestSync(this);
|
||||
|
||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user