mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-01 05:55:18 +00:00
42f1baaf61
We have to make some changes, and it's gotten to the point where maintaining it as a separate library is more hassle than it's worth, especially with Google releasing WorkManager as the preferred job scheduling library.
59 lines
2.0 KiB
Java
59 lines
2.0 KiB
Java
package org.thoughtcrime.securesms.jobs;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.util.Log;
|
|
|
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
|
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
|
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkRequirement;
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
|
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
|
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
|
import org.whispersystems.signalservice.api.messages.multidevice.ConfigurationMessage;
|
|
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
|
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
public class MultiDeviceReadReceiptUpdateJob extends ContextJob implements InjectableType {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private static final String TAG = MultiDeviceReadReceiptUpdateJob.class.getSimpleName();
|
|
|
|
@Inject transient SignalServiceMessageSender messageSender;
|
|
|
|
private final boolean enabled;
|
|
|
|
public MultiDeviceReadReceiptUpdateJob(Context context, boolean enabled) {
|
|
super(context, JobParameters.newBuilder()
|
|
.withPersistence()
|
|
.withGroupId("__MULTI_DEVICE_READ_RECEIPT_UPDATE_JOB__")
|
|
.withRequirement(new NetworkRequirement(context))
|
|
.create());
|
|
|
|
this.enabled = enabled;
|
|
}
|
|
|
|
@Override
|
|
public void onAdded() {}
|
|
|
|
@Override
|
|
public void onRun() throws IOException, UntrustedIdentityException {
|
|
messageSender.sendMessage(SignalServiceSyncMessage.forConfiguration(new ConfigurationMessage(Optional.of(enabled))));
|
|
}
|
|
|
|
@Override
|
|
public boolean onShouldRetry(Exception e) {
|
|
return e instanceof PushNetworkException;
|
|
}
|
|
|
|
@Override
|
|
public void onCanceled() {
|
|
Log.w(TAG, "**** Failed to synchronize read receipts state!");
|
|
}
|
|
}
|