mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 15:40:36 +00:00
Support for syncing and checking secure voice support.
// FREEBIE
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.jobqueue.JobParameters;
|
||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||
import org.whispersystems.textsecure.api.TextSecureAccountManager;
|
||||
import org.whispersystems.textsecure.api.push.exceptions.NetworkFailureException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RefreshAttributesJob extends ContextJob {
|
||||
|
||||
private static final String TAG = RefreshAttributesJob.class.getSimpleName();
|
||||
|
||||
@Inject TextSecureAccountManager accountManager;
|
||||
|
||||
public RefreshAttributesJob(Context context) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withPersistence()
|
||||
.withRequirement(new NetworkRequirement(context))
|
||||
.withWakeLock(true)
|
||||
.create());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {}
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
String signalingKey = TextSecurePreferences.getSignalingKey(context);
|
||||
int registrationId = TextSecurePreferences.getLocalRegistrationId(context);
|
||||
|
||||
accountManager.setAccountAttributes(signalingKey, registrationId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Exception e) {
|
||||
return e instanceof NetworkFailureException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
Log.w(TAG, "Failed to update account attributes!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user