Skip to content

Commit

Permalink
Update WorkManager to 1.0.0-alpha11.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Nov 27, 2018
1 parent 8a1a47e commit 81055e6
Show file tree
Hide file tree
Showing 52 changed files with 184 additions and 112 deletions.
9 changes: 3 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
compile 'com.android.support:multidex:1.0.3'
compile 'android.arch.lifecycle:extensions:1.1.1'
compile 'android.arch.lifecycle:common-java8:1.1.1'
compile 'android.arch.work:work-runtime:1.0.0-alpha09'
compile 'android.arch.work:work-runtime:1.0.0-alpha11'

compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
Expand Down Expand Up @@ -149,7 +149,6 @@ dependencies {
}
}

// TODO: Update dependencies after getting final libsignal
dependencyVerification {
verify = [
'com.android.support:design:7874ad1904eedc74aa41cffffb7f759d8990056f3bbbc9264911651c67c42f5f',
Expand All @@ -167,7 +166,7 @@ dependencyVerification {
'com.android.support:gridlayout-v7:5029529f7db66f8773426bf7318645f0840fc50d74f66355cd60c5e58d2da087',
'com.android.support:exifinterface:bbf44e519edd6333a24a3285aa21fd00181b920b81ca8aa89a8899f03ab4d6b0',
'com.android.support:multidex:ecf6098572e23b5155bab3b9a82b2fd1530eda6c6c157745e0f5287c66eec60c',
'android.arch.work:work-runtime:eda29b2cad202dee05a2e5aafe0a37c93ba9cde8f7cc0d0c8926a9f1a9498a8f',
'android.arch.work:work-runtime:e2cff8a2231da07519b65af64e77e5da20b1fc5a016bb49ddade40beb44a63ff',
'android.arch.lifecycle:extensions:429426b2feec2245ffc5e75b3b5309bedb36159cf06dc71843ae43526ac289b6',
'android.arch.lifecycle:common-java8:7078b5c8ccb94203df9cc2a463c69cf0021596e6cf966d78fbfd697aaafe0630',
'com.google.android.gms:play-services-gcm:312e61253a236f2d9b750b9c04fc92fd190d23b0b2755c99de6ce4a28b259dae',
Expand Down Expand Up @@ -240,7 +239,7 @@ dependencyVerification {
'com.android.support:localbroadcastmanager:d287c823af5fdde72c099fcfc5f630efe9687af7a914343ae6fd92de32c8a806',
'com.android.support:print:4be8a812d73e4a80e35b91ceae127def3f0bb9726bf3bc439aa0cc81503f5728',
'com.android.support:support-annotations:5d5b9414f02d3fa0ee7526b8d5ddae0da67c8ecc8c4d63ffa6cf91488a93b927',
'androidx.concurrent:futures:1f63078c41efd29d20ee3444fba93c6cdfaeeb862c6d3b6166ff8debd37d471a',
'com.google.guava:listenablefuture:e4ad7607e5c0477c6f890ef26a49cb8d1bb4dffb650bab4502afee64644e3069',
'org.signal:signal-metadata-android:d9d798aab7ee7200373ecff8718baf8aaeb632c123604e8a41b7b4c0c97eeee1',
'org.whispersystems:signal-service-java:a156f4025ce59abb1b48c089719323cd0e82d6ab4bdd345c408a5e44121499b1',
'com.github.bumptech.glide:disklrucache:c1b1b6f5bbd01e2fcdc9d7f60913c8d338bdb65ed4a93bfa02b56f19daaade4b',
Expand All @@ -250,8 +249,6 @@ dependencyVerification {
'com.klinkerapps:logger:177e325259a8b111ad6745ec10db5861723c99f402222b80629f576f49408541',
'com.google.android:flexbox:a9989fd13ae2ee42765dfc515fe362edf4f326e74925d02a10369df8092a4935',
'org.jsoup:jsoup:abeaf34795a4de70f72aed6de5966d2955ec7eb348eeb813324f23c999575473',
'com.google.guava:listenablefuture:e4ad7607e5c0477c6f890ef26a49cb8d1bb4dffb650bab4502afee64644e3069',
'androidx.annotation:annotation:04f22f257944ce223701d5aa1bdc36fb7f4594e87b539044045cd161d965468e',
'org.whispersystems:signal-protocol-android:b41b7c3a47b0a4ce35802474ae7c5ddc8f033d80209e98abf7ec669543b2b3ee',
'org.signal:signal-metadata-java:af1d0dd766b1e301ed1c44e65161084cf03e2587fe97fdd29ecbea58c6aa6930',
'org.whispersystems:signal-protocol-java:b08207f7e1847228f2a1f0d49e113f93c96c6ed8490be14edddd4be55b2a4a4e',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.content.Context;
import android.support.annotation.ColorInt;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.FrameLayout;
Expand All @@ -17,9 +19,6 @@

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class AlbumThumbnailView extends FrameLayout {

private @Nullable SlideClickListener thumbnailClickListener;
Expand All @@ -38,12 +37,12 @@ public class AlbumThumbnailView extends FrameLayout {

private final OnLongClickListener defaultLongClickListener = v -> this.performLongClick();

public AlbumThumbnailView(@NonNull @android.support.annotation.NonNull Context context) {
public AlbumThumbnailView(@NonNull Context context) {
super(context);
initialize();
}

public AlbumThumbnailView(@NonNull @android.support.annotation.NonNull Context context, @Nullable @android.support.annotation.Nullable AttributeSet attrs) {
public AlbumThumbnailView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;

import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.ResUtil;

import androidx.annotation.Nullable;

public class AsciiEmojiView extends View {

private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
Expand All @@ -22,7 +21,7 @@ public AsciiEmojiView(Context context) {
super(context);
}

public AsciiEmojiView(Context context, @Nullable @android.support.annotation.Nullable AttributeSet attrs) {
public AsciiEmojiView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

Expand Down
16 changes: 8 additions & 8 deletions src/org/thoughtcrime/securesms/jobmanager/Job.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.jobmanager;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand All @@ -14,6 +15,7 @@
import org.thoughtcrime.securesms.service.GenericForegroundService;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -45,7 +47,10 @@ public Job(@NonNull Context context, @NonNull WorkerParameters workerParams) {
/**
* Invoked when a job is first created in our own codebase.
*/
protected Job(@Nullable JobParameters parameters) {
@SuppressLint("RestrictedApi")
protected Job(@NonNull Context context, @Nullable JobParameters parameters) {
//noinspection ConstantConditions
super(context, new WorkerParameters(null, null, Collections.emptySet(), null, 0, null, null, null));
this.parameters = parameters;
}

Expand Down Expand Up @@ -119,13 +124,8 @@ protected Job(@Nullable JobParameters parameters) {
}

@Override
public void onStopped(boolean cancelled) {
if (cancelled) {
warn("onStopped() with cancellation signal." + logSuffix());
onCanceled();
} else {
log("onStopped()" + logSuffix());
}
public void onStopped() {
log("onStopped()" + logSuffix());
}

final void onSubmit(@NonNull Context context, @NonNull UUID id) {
Expand Down
11 changes: 10 additions & 1 deletion src/org/thoughtcrime/securesms/jobmanager/JobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import android.content.Context;
import android.support.annotation.NonNull;

import org.thoughtcrime.securesms.logging.Log;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
Expand All @@ -17,6 +20,8 @@

public class JobManager {

private static final String TAG = JobManager.class.getSimpleName();

private static final Constraints NETWORK_CONSTRAINT = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build();
Expand All @@ -33,7 +38,11 @@ public JobManager(@NonNull Context context, @NonNull WorkManager workManager) {

public void add(Job job) {
executor.execute(() -> {
workManager.synchronous().pruneWorkSync();
try {
workManager.pruneWork().getResult().get();
} catch (ExecutionException | InterruptedException e) {
Log.w(TAG, "Failed to prune work.", e);
}

JobParameters jobParameters = job.getJobParameters();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import javax.inject.Inject;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class AttachmentDownloadJob extends ContextJob implements InjectableType {
private static final long serialVersionUID = 2L;
Expand All @@ -56,8 +57,8 @@ public class AttachmentDownloadJob extends ContextJob implements InjectableType
private long partUniqueId;
private boolean manual;

public AttachmentDownloadJob() {
super(null, null);
public AttachmentDownloadJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public AttachmentDownloadJob(Context context, long messageId, AttachmentId attachmentId, boolean manual) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/AvatarDownloadJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.inject.Inject;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class AvatarDownloadJob extends ContextJob implements InjectableType {

Expand All @@ -44,8 +45,8 @@ public class AvatarDownloadJob extends ContextJob implements InjectableType {

private byte[] groupId;

public AvatarDownloadJob() {
super(null, null);
public AvatarDownloadJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public AvatarDownloadJob(Context context, @NonNull byte[] groupId) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/CleanPreKeysJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.inject.Inject;

import androidx.work.Data;
import androidx.work.WorkerParameters;

import static org.thoughtcrime.securesms.dependencies.AxolotlStorageModule.SignedPreKeyStoreFactory;

Expand All @@ -39,8 +40,8 @@ public class CleanPreKeysJob extends ContextJob implements InjectableType {
@Inject transient SignalServiceAccountManager accountManager;
@Inject transient SignedPreKeyStoreFactory signedPreKeyStoreFactory;

public CleanPreKeysJob() {
super(null, null);
public CleanPreKeysJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public CleanPreKeysJob(Context context) {
Expand Down
11 changes: 9 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/ContextJob.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package org.thoughtcrime.securesms.jobs;

import android.content.Context;
import android.support.annotation.NonNull;

import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JobParameters;
import org.thoughtcrime.securesms.jobmanager.dependencies.ContextDependent;

import androidx.work.WorkerParameters;

public abstract class ContextJob extends Job implements ContextDependent {

protected transient Context context;

protected ContextJob(Context context, JobParameters parameters) {
super(parameters);
protected ContextJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

protected ContextJob(@NonNull Context context, @NonNull JobParameters parameters) {
super(context, parameters);
this.context = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.inject.Inject;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class CreateSignedPreKeyJob extends ContextJob implements InjectableType {

Expand All @@ -30,8 +31,8 @@ public class CreateSignedPreKeyJob extends ContextJob implements InjectableType

@Inject transient SignalServiceAccountManager accountManager;

public CreateSignedPreKeyJob() {
super(null, null);
public CreateSignedPreKeyJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public CreateSignedPreKeyJob(Context context) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/DirectoryRefreshJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.IOException;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class DirectoryRefreshJob extends ContextJob {

Expand All @@ -27,8 +28,8 @@ public class DirectoryRefreshJob extends ContextJob {
@Nullable private transient Recipient recipient;
private transient boolean notifyOfNewUsers;

public DirectoryRefreshJob() {
super(null, null);
public DirectoryRefreshJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public DirectoryRefreshJob(@NonNull Context context, boolean notifyOfNewUsers) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/GcmRefreshJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import javax.inject.Inject;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class GcmRefreshJob extends ContextJob implements InjectableType {

Expand All @@ -53,8 +54,8 @@ public class GcmRefreshJob extends ContextJob implements InjectableType {

@Inject transient SignalServiceAccountManager textSecureAccountManager;

public GcmRefreshJob() {
super(null, null);
public GcmRefreshJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public GcmRefreshJob(Context context) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/LocalBackupJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import java.util.Locale;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class LocalBackupJob extends ContextJob {

private static final String TAG = LocalBackupJob.class.getSimpleName();

public LocalBackupJob() {
super(null, null);
public LocalBackupJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public LocalBackupJob(@NonNull Context context) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.Set;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class MmsDownloadJob extends ContextJob {

Expand All @@ -63,8 +64,8 @@ public class MmsDownloadJob extends ContextJob {
private long threadId;
private boolean automatic;

public MmsDownloadJob() {
super(null, null);
public MmsDownloadJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public MmsDownloadJob(Context context, long messageId, long threadId, boolean automatic) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/MmsReceiveJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class MmsReceiveJob extends ContextJob {

Expand All @@ -38,8 +39,8 @@ public class MmsReceiveJob extends ContextJob {
private byte[] data;
private int subscriptionId;

public MmsReceiveJob() {
super(null, null);
public MmsReceiveJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public MmsReceiveJob(Context context, byte[] data, int subscriptionId) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/jobs/MmsSendJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.List;

import androidx.work.Data;
import androidx.work.WorkerParameters;

public class MmsSendJob extends SendJob {

Expand All @@ -61,8 +62,8 @@ public class MmsSendJob extends SendJob {

private long messageId;

public MmsSendJob() {
super(null, null);
public MmsSendJob(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
super(context, workerParameters);
}

public MmsSendJob(Context context, long messageId) {
Expand Down
Loading

0 comments on commit 81055e6

Please sign in to comment.