2015-07-14 23:31:03 +02:00
|
|
|
package org.thoughtcrime.securesms.contacts;
|
|
|
|
|
|
|
|
import android.accounts.Account;
|
|
|
|
import android.content.AbstractThreadedSyncAdapter;
|
|
|
|
import android.content.ContentProviderClient;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SyncResult;
|
|
|
|
import android.os.Bundle;
|
2018-08-01 17:09:24 +02:00
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
2015-07-14 23:31:03 +02:00
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
2015-11-16 21:03:47 +01:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2015-07-14 23:31:03 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
public class ContactsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|
|
|
|
|
|
|
private static final String TAG = ContactsSyncAdapter.class.getSimpleName();
|
|
|
|
|
|
|
|
public ContactsSyncAdapter(Context context, boolean autoInitialize) {
|
|
|
|
super(context, autoInitialize);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPerformSync(Account account, Bundle extras, String authority,
|
|
|
|
ContentProviderClient provider, SyncResult syncResult)
|
|
|
|
{
|
2015-11-06 19:50:47 +01:00
|
|
|
Log.w(TAG, "onPerformSync(" + authority +")");
|
|
|
|
|
2015-11-16 21:03:47 +01:00
|
|
|
if (TextSecurePreferences.isPushRegistered(getContext())) {
|
|
|
|
try {
|
2018-01-25 04:17:44 +01:00
|
|
|
DirectoryHelper.refreshDirectory(getContext(), true);
|
2015-11-16 21:03:47 +01:00
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
}
|
2015-07-14 23:31:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-08 20:48:44 +02:00
|
|
|
@Override
|
|
|
|
public void onSyncCanceled() {
|
|
|
|
Log.w(TAG, "onSyncCanceled()");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSyncCanceled(Thread thread) {
|
|
|
|
Log.w(TAG, "onSyncCanceled(" + thread + ")");
|
|
|
|
}
|
|
|
|
|
2015-07-14 23:31:03 +02:00
|
|
|
}
|