package androidx.work; import android.annotation.SuppressLint; import android.content.Context; import android.net.Network; import android.net.Uri; import androidx.annotation.IntRange; import androidx.annotation.Keep; import androidx.annotation.MainThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.annotation.RestrictTo; import androidx.work.impl.utils.taskexecutor.TaskExecutor; import c.d.b.a.a; import java.util.List; import java.util.Set; import java.util.UUID; import java.util.concurrent.Executor; public abstract class ListenableWorker { @NonNull private Context mAppContext; private boolean mRunInForeground; private volatile boolean mStopped; private boolean mUsed; @NonNull private WorkerParameters mWorkerParams; public static abstract class Result { @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public static final class Failure extends Result { private final Data mOutputData; public Failure() { this(Data.EMPTY); } public Failure(@NonNull Data data) { this.mOutputData = data; } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || Failure.class != obj.getClass()) { return false; } return this.mOutputData.equals(((Failure) obj).mOutputData); } @NonNull @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public Data getOutputData() { return this.mOutputData; } public int hashCode() { return this.mOutputData.hashCode() + 846803280; } public String toString() { StringBuilder L = a.L("Failure {mOutputData="); L.append(this.mOutputData); L.append('}'); return L.toString(); } } @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public static final class Retry extends Result { public boolean equals(Object obj) { if (this == obj) { return true; } return obj != null && Retry.class == obj.getClass(); } public int hashCode() { return 25945934; } public String toString() { return "Retry"; } } @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public static final class Success extends Result { private final Data mOutputData; public Success() { this(Data.EMPTY); } public Success(@NonNull Data data) { this.mOutputData = data; } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || Success.class != obj.getClass()) { return false; } return this.mOutputData.equals(((Success) obj).mOutputData); } @NonNull @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public Data getOutputData() { return this.mOutputData; } public int hashCode() { return this.mOutputData.hashCode() - 1876823561; } public String toString() { StringBuilder L = a.L("Success {mOutputData="); L.append(this.mOutputData); L.append('}'); return L.toString(); } } @NonNull public static Result failure() { return new Failure(); } @NonNull public static Result failure(@NonNull Data data) { return new Failure(data); } @NonNull public static Result retry() { return new Retry(); } @NonNull public static Result success() { return new Success(); } @NonNull public static Result success(@NonNull Data data) { return new Success(data); } } @Keep @SuppressLint({"BanKeepAnnotation"}) public ListenableWorker(@NonNull Context context, @NonNull WorkerParameters workerParameters) { if (context == null) { throw new IllegalArgumentException("Application Context is null"); } else if (workerParameters != null) { this.mAppContext = context; this.mWorkerParams = workerParameters; } else { throw new IllegalArgumentException("WorkerParameters is null"); } } @NonNull public final Context getApplicationContext() { return this.mAppContext; } @NonNull @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public Executor getBackgroundExecutor() { return this.mWorkerParams.getBackgroundExecutor(); } @NonNull public final UUID getId() { return this.mWorkerParams.getId(); } @NonNull public final Data getInputData() { return this.mWorkerParams.getInputData(); } @Nullable @RequiresApi(28) public final Network getNetwork() { return this.mWorkerParams.getNetwork(); } @IntRange(from = 0) public final int getRunAttemptCount() { return this.mWorkerParams.getRunAttemptCount(); } @NonNull public final Set getTags() { return this.mWorkerParams.getTags(); } @NonNull @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public TaskExecutor getTaskExecutor() { return this.mWorkerParams.getTaskExecutor(); } @NonNull @RequiresApi(24) public final List getTriggeredContentAuthorities() { return this.mWorkerParams.getTriggeredContentAuthorities(); } @NonNull @RequiresApi(24) public final List getTriggeredContentUris() { return this.mWorkerParams.getTriggeredContentUris(); } @NonNull @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public WorkerFactory getWorkerFactory() { return this.mWorkerParams.getWorkerFactory(); } @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public boolean isRunInForeground() { return this.mRunInForeground; } public final boolean isStopped() { return this.mStopped; } @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public final boolean isUsed() { return this.mUsed; } public void onStopped() { } @NonNull public final c.i.b.d.a.a setForegroundAsync(@NonNull ForegroundInfo foregroundInfo) { this.mRunInForeground = true; return this.mWorkerParams.getForegroundUpdater().setForegroundAsync(getApplicationContext(), getId(), foregroundInfo); } @NonNull public final c.i.b.d.a.a setProgressAsync(@NonNull Data data) { return this.mWorkerParams.getProgressUpdater().updateProgress(getApplicationContext(), getId(), data); } @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public final void setUsed() { this.mUsed = true; } @NonNull @MainThread public abstract c.i.b.d.a.a startWork(); @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) public final void stop() { this.mStopped = true; onStopped(); } }