2015-04-15 10:58:29 -07:00
|
|
|
package org.thoughtcrime.securesms.jobs;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.util.Log;
|
|
|
|
|
2018-06-18 12:27:04 -07:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
2015-04-15 10:58:29 -07:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2016-03-23 10:34:41 -07:00
|
|
|
import org.whispersystems.libsignal.InvalidVersionException;
|
|
|
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
2015-04-15 10:58:29 -07:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
public class PushContentReceiveJob extends PushReceivedJob {
|
|
|
|
|
|
|
|
private static final String TAG = PushContentReceiveJob.class.getSimpleName();
|
|
|
|
|
|
|
|
private final String data;
|
|
|
|
|
|
|
|
public PushContentReceiveJob(Context context) {
|
|
|
|
super(context, JobParameters.newBuilder().create());
|
|
|
|
this.data = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PushContentReceiveJob(Context context, String data) {
|
|
|
|
super(context, JobParameters.newBuilder()
|
|
|
|
.withPersistence()
|
|
|
|
.withWakeLock(true)
|
|
|
|
.create());
|
|
|
|
|
|
|
|
this.data = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAdded() {}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRun() {
|
|
|
|
try {
|
2016-03-23 10:34:41 -07:00
|
|
|
String sessionKey = TextSecurePreferences.getSignalingKey(context);
|
|
|
|
SignalServiceEnvelope envelope = new SignalServiceEnvelope(data, sessionKey);
|
2015-04-15 10:58:29 -07:00
|
|
|
|
2017-09-15 22:38:53 -07:00
|
|
|
handle(envelope);
|
2015-04-15 10:58:29 -07:00
|
|
|
} catch (IOException | InvalidVersionException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCanceled() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onShouldRetry(Exception exception) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|