-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement send support for resumable uploads behind a flag.
- Loading branch information
1 parent
7c44286
commit 2afb939
Showing
24 changed files
with
913 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/src/main/java/org/thoughtcrime/securesms/jobs/ResumableUploadSpecJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.thoughtcrime.securesms.jobs; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies; | ||
import org.thoughtcrime.securesms.jobmanager.Data; | ||
import org.thoughtcrime.securesms.jobmanager.Job; | ||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint; | ||
import org.thoughtcrime.securesms.logging.Log; | ||
import org.thoughtcrime.securesms.util.FeatureFlags; | ||
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class ResumableUploadSpecJob extends BaseJob { | ||
|
||
private static final String TAG = Log.tag(ResumableUploadSpecJob.class); | ||
|
||
static final String KEY_RESUME_SPEC = "resume_spec"; | ||
|
||
public static final String KEY = "ResumableUploadSpecJob"; | ||
|
||
public ResumableUploadSpecJob() { | ||
this(new Job.Parameters.Builder() | ||
.addConstraint(NetworkConstraint.KEY) | ||
.setLifespan(TimeUnit.DAYS.toMillis(1)) | ||
.setMaxAttempts(Parameters.UNLIMITED) | ||
.build()); | ||
} | ||
|
||
private ResumableUploadSpecJob(@NonNull Parameters parameters) { | ||
super(parameters); | ||
} | ||
|
||
@Override | ||
protected void onRun() throws Exception { | ||
if (!FeatureFlags.attachmentsV3()) { | ||
Log.i(TAG, "Attachments V3 is not enabled so there is nothing to do!"); | ||
} | ||
|
||
ResumableUploadSpec resumableUploadSpec = ApplicationDependencies.getSignalServiceMessageSender() | ||
.getResumableUploadSpec(); | ||
|
||
setOutputData(new Data.Builder() | ||
.putString(KEY_RESUME_SPEC, resumableUploadSpec.serialize()) | ||
.build()); | ||
} | ||
|
||
@Override | ||
protected boolean onShouldRetry(@NonNull Exception e) { | ||
return e instanceof IOException; | ||
} | ||
|
||
@Override | ||
public @NonNull Data serialize() { | ||
return Data.EMPTY; | ||
} | ||
|
||
@Override | ||
public @NonNull String getFactoryKey() { | ||
return KEY; | ||
} | ||
|
||
@Override | ||
public void onFailure() { | ||
|
||
} | ||
|
||
public static class Factory implements Job.Factory<ResumableUploadSpecJob> { | ||
|
||
@Override | ||
public @NonNull ResumableUploadSpecJob create(@NonNull Parameters parameters, @NonNull Data data) { | ||
return new ResumableUploadSpecJob(parameters); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.