discord-jadx/app/src/main/java/androidx/work/CoroutineWorker.java

137 lines
5.2 KiB
Java

package androidx.work;
import android.content.Context;
import androidx.work.ListenableWorker;
import androidx.work.impl.utils.futures.SettableFuture;
import androidx.work.impl.utils.taskexecutor.TaskExecutor;
import c.q.a.k.a;
import d0.w.g.b;
import d0.w.g.c;
import d0.w.h.a.g;
import d0.z.d.m;
import java.util.concurrent.ExecutionException;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlinx.coroutines.CoroutineDispatcher;
import s.a.e1;
import s.a.j0;
import s.a.k;
import s.a.t;
/* compiled from: CoroutineWorker.kt */
public abstract class CoroutineWorker extends ListenableWorker {
private final CoroutineDispatcher coroutineContext;
private final SettableFuture<ListenableWorker.Result> future;
private final t job = new e1(null);
/* compiled from: CoroutineWorker.kt */
/* renamed from: androidx.work.CoroutineWorker$1 reason: invalid class name */
public static final class AnonymousClass1 implements Runnable {
public final /* synthetic */ CoroutineWorker this$0;
public AnonymousClass1(CoroutineWorker coroutineWorker) {
this.this$0 = coroutineWorker;
}
@Override // java.lang.Runnable
public final void run() {
if (this.this$0.getFuture$work_runtime_ktx_release().isCancelled()) {
a.k(this.this$0.getJob$work_runtime_ktx_release(), null, 1, null);
}
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public CoroutineWorker(Context context, WorkerParameters workerParameters) {
super(context, workerParameters);
m.checkParameterIsNotNull(context, "appContext");
m.checkParameterIsNotNull(workerParameters, "params");
SettableFuture<ListenableWorker.Result> create = SettableFuture.create();
m.checkExpressionValueIsNotNull(create, "SettableFuture.create()");
this.future = create;
AnonymousClass1 r4 = new AnonymousClass1(this);
TaskExecutor taskExecutor = getTaskExecutor();
m.checkExpressionValueIsNotNull(taskExecutor, "taskExecutor");
create.addListener(r4, taskExecutor.getBackgroundExecutor());
this.coroutineContext = j0.a;
}
public static /* synthetic */ void coroutineContext$annotations() {
}
public abstract Object doWork(Continuation<? super ListenableWorker.Result> continuation);
public CoroutineDispatcher getCoroutineContext() {
return this.coroutineContext;
}
public final SettableFuture<ListenableWorker.Result> getFuture$work_runtime_ktx_release() {
return this.future;
}
public final t getJob$work_runtime_ktx_release() {
return this.job;
}
@Override // androidx.work.ListenableWorker
public final void onStopped() {
super.onStopped();
this.future.cancel(false);
}
public final Object setForeground(ForegroundInfo foregroundInfo, Continuation<? super Unit> continuation) {
Object obj;
c.i.b.d.a.a<Void> foregroundAsync = setForegroundAsync(foregroundInfo);
m.checkExpressionValueIsNotNull(foregroundAsync, "setForegroundAsync(foregroundInfo)");
if (foregroundAsync.isDone()) {
try {
obj = foregroundAsync.get();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause != null) {
throw cause;
}
throw e;
}
} else {
k kVar = new k(b.intercepted(continuation), 1);
foregroundAsync.addListener(new CoroutineWorker$await$$inlined$suspendCancellableCoroutine$lambda$2(kVar, foregroundAsync), DirectExecutor.INSTANCE);
obj = kVar.u();
if (obj == c.getCOROUTINE_SUSPENDED()) {
g.probeCoroutineSuspended(continuation);
}
}
return obj == c.getCOROUTINE_SUSPENDED() ? obj : Unit.a;
}
public final Object setProgress(Data data, Continuation<? super Unit> continuation) {
Object obj;
c.i.b.d.a.a<Void> progressAsync = setProgressAsync(data);
m.checkExpressionValueIsNotNull(progressAsync, "setProgressAsync(data)");
if (progressAsync.isDone()) {
try {
obj = progressAsync.get();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause != null) {
throw cause;
}
throw e;
}
} else {
k kVar = new k(b.intercepted(continuation), 1);
progressAsync.addListener(new CoroutineWorker$await$$inlined$suspendCancellableCoroutine$lambda$1(kVar, progressAsync), DirectExecutor.INSTANCE);
obj = kVar.u();
if (obj == c.getCOROUTINE_SUSPENDED()) {
g.probeCoroutineSuspended(continuation);
}
}
return obj == c.getCOROUTINE_SUSPENDED() ? obj : Unit.a;
}
@Override // androidx.work.ListenableWorker
public final c.i.b.d.a.a<ListenableWorker.Result> startWork() {
a.G(a.a(getCoroutineContext().plus(this.job)), null, null, new CoroutineWorker$startWork$1(this, null), 3, null);
return this.future;
}
}