package androidx.work.impl; import androidx.work.Logger; import androidx.work.impl.WorkerWrapper; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import kotlin.NoWhenBranchMatchedException; import kotlin.ResultKt; import kotlin.Unit; import kotlin.coroutines.Continuation; import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt; import kotlin.coroutines.jvm.internal.DebugMetadata; import kotlin.coroutines.jvm.internal.SuspendLambda; import kotlin.jvm.functions.Function2; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.SourceDebugExtension; import kotlinx.coroutines.BuildersKt; import kotlinx.coroutines.CompletableJob; import kotlinx.coroutines.CoroutineScope; @DebugMetadata(c = "androidx.work.impl.WorkerWrapper$launch$1", f = "WorkerWrapper.kt", l = {98}, m = "invokeSuspend") @SourceDebugExtension({"SMAP\nWorkerWrapper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper$launch$1\n+ 2 LoggerExt.kt\nandroidx/work/LoggerExtKt\n*L\n1#1,607:1\n32#2:608\n*S KotlinDebug\n*F\n+ 1 WorkerWrapper.kt\nandroidx/work/impl/WorkerWrapper$launch$1\n*L\n105#1:608\n*E\n"}) /* loaded from: classes.dex */ public final class WorkerWrapper$launch$1 extends SuspendLambda implements Function2 { int label; final /* synthetic */ WorkerWrapper this$0; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public WorkerWrapper$launch$1(WorkerWrapper workerWrapper, Continuation continuation) { super(2, continuation); this.this$0 = workerWrapper; } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Continuation create(Object obj, Continuation continuation) { return new WorkerWrapper$launch$1(this.this$0, continuation); } @Override // kotlin.jvm.functions.Function2 public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) { return ((WorkerWrapper$launch$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE); } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Object invokeSuspend(Object obj) { Object coroutine_suspended; String str; final WorkerWrapper.Resolution failed; WorkDatabase workDatabase; CompletableJob completableJob; coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED(); int i = this.label; try { if (i == 0) { ResultKt.throwOnFailure(obj); completableJob = this.this$0.workerJob; WorkerWrapper$launch$1$resolution$1 workerWrapper$launch$1$resolution$1 = new WorkerWrapper$launch$1$resolution$1(this.this$0, null); this.label = 1; obj = BuildersKt.withContext(completableJob, workerWrapper$launch$1$resolution$1, this); if (obj == coroutine_suspended) { return coroutine_suspended; } } else { if (i != 1) { throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } ResultKt.throwOnFailure(obj); } failed = (WorkerWrapper.Resolution) obj; } catch (WorkerStoppedException e) { failed = new WorkerWrapper.Resolution.ResetWorkerStatus(e.getReason()); } catch (CancellationException unused) { failed = new WorkerWrapper.Resolution.Failed(null, 1, null); } catch (Throwable th) { str = WorkerWrapperKt.TAG; Logger.get().error(str, "Unexpected error in WorkerWrapper", th); failed = new WorkerWrapper.Resolution.Failed(null, 1, null); } workDatabase = this.this$0.workDatabase; final WorkerWrapper workerWrapper = this.this$0; Object runInTransaction = workDatabase.runInTransaction((Callable) new Callable() { // from class: androidx.work.impl.WorkerWrapper$launch$1$$ExternalSyntheticLambda0 @Override // java.util.concurrent.Callable public final Object call() { Boolean invokeSuspend$lambda$1; invokeSuspend$lambda$1 = WorkerWrapper$launch$1.invokeSuspend$lambda$1(WorkerWrapper.Resolution.this, workerWrapper); return invokeSuspend$lambda$1; } }); Intrinsics.checkNotNullExpressionValue(runInTransaction, "workDatabase.runInTransa… }\n )"); return runInTransaction; } /* JADX INFO: Access modifiers changed from: private */ public static final Boolean invokeSuspend$lambda$1(WorkerWrapper.Resolution resolution, WorkerWrapper workerWrapper) { boolean resetWorkerStatus; if (resolution instanceof WorkerWrapper.Resolution.Finished) { resetWorkerStatus = workerWrapper.onWorkFinished(((WorkerWrapper.Resolution.Finished) resolution).getResult()); } else if (resolution instanceof WorkerWrapper.Resolution.Failed) { workerWrapper.setFailed(((WorkerWrapper.Resolution.Failed) resolution).getResult()); resetWorkerStatus = false; } else { if (!(resolution instanceof WorkerWrapper.Resolution.ResetWorkerStatus)) { throw new NoWhenBranchMatchedException(); } resetWorkerStatus = workerWrapper.resetWorkerStatus(((WorkerWrapper.Resolution.ResetWorkerStatus) resolution).getReason()); } return Boolean.valueOf(resetWorkerStatus); } }