package androidx.room; import java.util.concurrent.CancellationException; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; import kotlin.Metadata; import kotlin.Result; import kotlin.ResultKt; import kotlin.Unit; import kotlin.coroutines.Continuation; import kotlin.coroutines.ContinuationInterceptor; import kotlin.coroutines.CoroutineContext; import kotlin.coroutines.intrinsics.IntrinsicsKt; import kotlin.coroutines.jvm.internal.DebugMetadata; import kotlin.coroutines.jvm.internal.DebugProbesKt; import kotlin.coroutines.jvm.internal.SuspendLambda; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; import kotlin.jvm.internal.Intrinsics; import kotlinx.coroutines.BuildersKt__BuildersKt; import kotlinx.coroutines.CancellableContinuation; import kotlinx.coroutines.CancellableContinuationImpl; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.Job; /* compiled from: RoomDatabaseExt.kt */ @Metadata(d1 = {"\u00000\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\u001a\u001d\u0010\u0000\u001a\u00020\u0001*\u00020\u00022\u0006\u0010\u0003\u001a\u00020\u0004H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010\u0005\u001a\u0015\u0010\u0006\u001a\u00020\u0007*\u00020\bH\u0082@ø\u0001\u0000¢\u0006\u0002\u0010\t\u001a9\u0010\n\u001a\u0002H\u000b\"\u0004\b\u0000\u0010\u000b*\u00020\b2\u001c\u0010\f\u001a\u0018\b\u0001\u0012\n\u0012\b\u0012\u0004\u0012\u0002H\u000b0\u000e\u0012\u0006\u0012\u0004\u0018\u00010\u000f0\rH\u0086@ø\u0001\u0000¢\u0006\u0002\u0010\u0010\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u0011"}, d2 = {"acquireTransactionThread", "Lkotlin/coroutines/ContinuationInterceptor;", "Ljava/util/concurrent/Executor;", "controlJob", "Lkotlinx/coroutines/Job;", "(Ljava/util/concurrent/Executor;Lkotlinx/coroutines/Job;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "createTransactionContext", "Lkotlin/coroutines/CoroutineContext;", "Landroidx/room/RoomDatabase;", "(Landroidx/room/RoomDatabase;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "withTransaction", "R", "block", "Lkotlin/Function1;", "Lkotlin/coroutines/Continuation;", "", "(Landroidx/room/RoomDatabase;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "room-ktx_release"}, k = 2, mv = {1, 7, 1}, xi = 48) /* loaded from: classes2.dex */ public final class RoomDatabaseKt { /* JADX WARN: Removed duplicated region for block: B:11:0x0082 A[PHI: r7 0x0082: PHI (r7v12 java.lang.Object) = (r7v9 java.lang.Object), (r7v1 java.lang.Object) binds: [B:18:0x007f, B:10:0x0029] A[DONT_GENERATE, DONT_INLINE], RETURN] */ /* JADX WARN: Removed duplicated region for block: B:19:0x0081 A[RETURN] */ /* JADX WARN: Removed duplicated region for block: B:20:0x0042 */ /* JADX WARN: Removed duplicated region for block: B:8:0x0025 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static final java.lang.Object withTransaction(androidx.room.RoomDatabase r5, kotlin.jvm.functions.Function1, ? extends java.lang.Object> r6, kotlin.coroutines.Continuation r7) { /* boolean r0 = r7 instanceof androidx.room.RoomDatabaseKt$withTransaction$1 if (r0 == 0) goto L14 r0 = r7 androidx.room.RoomDatabaseKt$withTransaction$1 r0 = (androidx.room.RoomDatabaseKt$withTransaction$1) r0 int r1 = r0.label r2 = -2147483648(0xffffffff80000000, float:-0.0) r1 = r1 & r2 if (r1 == 0) goto L14 int r7 = r0.label int r7 = r7 - r2 r0.label = r7 goto L19 L14: androidx.room.RoomDatabaseKt$withTransaction$1 r0 = new androidx.room.RoomDatabaseKt$withTransaction$1 r0.(r7) L19: java.lang.Object r7 = r0.result java.lang.Object r1 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED() int r2 = r0.label r3 = 2 r4 = 1 if (r2 == 0) goto L42 if (r2 == r4) goto L35 if (r2 != r3) goto L2d kotlin.ResultKt.throwOnFailure(r7) goto L82 L2d: java.lang.IllegalStateException r5 = new java.lang.IllegalStateException java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine" r5.(r6) throw r5 L35: java.lang.Object r5 = r0.L$1 r6 = r5 kotlin.jvm.functions.Function1 r6 = (kotlin.jvm.functions.Function1) r6 java.lang.Object r5 = r0.L$0 androidx.room.RoomDatabase r5 = (androidx.room.RoomDatabase) r5 kotlin.ResultKt.throwOnFailure(r7) goto L6b L42: kotlin.ResultKt.throwOnFailure(r7) kotlin.coroutines.CoroutineContext r7 = r0.getContext() androidx.room.TransactionElement$Key r2 = androidx.room.TransactionElement.INSTANCE kotlin.coroutines.CoroutineContext$Key r2 = (kotlin.coroutines.CoroutineContext.Key) r2 kotlin.coroutines.CoroutineContext$Element r7 = r7.get(r2) androidx.room.TransactionElement r7 = (androidx.room.TransactionElement) r7 if (r7 == 0) goto L5e kotlin.coroutines.ContinuationInterceptor r7 = r7.getTransactionDispatcher() if (r7 == 0) goto L5e kotlin.coroutines.CoroutineContext r7 = (kotlin.coroutines.CoroutineContext) r7 goto L6d L5e: r0.L$0 = r5 r0.L$1 = r6 r0.label = r4 java.lang.Object r7 = createTransactionContext(r5, r0) if (r7 != r1) goto L6b return r1 L6b: kotlin.coroutines.CoroutineContext r7 = (kotlin.coroutines.CoroutineContext) r7 L6d: androidx.room.RoomDatabaseKt$withTransaction$2 r2 = new androidx.room.RoomDatabaseKt$withTransaction$2 r4 = 0 r2.(r5, r6, r4) kotlin.jvm.functions.Function2 r2 = (kotlin.jvm.functions.Function2) r2 r0.L$0 = r4 r0.L$1 = r4 r0.label = r3 java.lang.Object r7 = kotlinx.coroutines.BuildersKt.withContext(r7, r2, r0) if (r7 != r1) goto L82 return r1 L82: return r7 */ throw new UnsupportedOperationException("Method not decompiled: androidx.room.RoomDatabaseKt.withTransaction(androidx.room.RoomDatabase, kotlin.jvm.functions.Function1, kotlin.coroutines.Continuation):java.lang.Object"); } /* JADX INFO: Access modifiers changed from: private */ /* JADX WARN: Removed duplicated region for block: B:15:0x003a */ /* JADX WARN: Removed duplicated region for block: B:8:0x0024 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static final java.lang.Object createTransactionContext(androidx.room.RoomDatabase r6, kotlin.coroutines.Continuation r7) { /* boolean r0 = r7 instanceof androidx.room.RoomDatabaseKt$createTransactionContext$1 if (r0 == 0) goto L14 r0 = r7 androidx.room.RoomDatabaseKt$createTransactionContext$1 r0 = (androidx.room.RoomDatabaseKt$createTransactionContext$1) r0 int r1 = r0.label r2 = -2147483648(0xffffffff80000000, float:-0.0) r1 = r1 & r2 if (r1 == 0) goto L14 int r7 = r0.label int r7 = r7 - r2 r0.label = r7 goto L19 L14: androidx.room.RoomDatabaseKt$createTransactionContext$1 r0 = new androidx.room.RoomDatabaseKt$createTransactionContext$1 r0.(r7) L19: java.lang.Object r7 = r0.result java.lang.Object r1 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED() int r2 = r0.label r3 = 1 if (r2 == 0) goto L3a if (r2 != r3) goto L32 java.lang.Object r6 = r0.L$1 kotlinx.coroutines.CompletableJob r6 = (kotlinx.coroutines.CompletableJob) r6 java.lang.Object r0 = r0.L$0 androidx.room.RoomDatabase r0 = (androidx.room.RoomDatabase) r0 kotlin.ResultKt.throwOnFailure(r7) goto L74 L32: java.lang.IllegalStateException r6 = new java.lang.IllegalStateException java.lang.String r7 = "call to 'resume' before 'invoke' with coroutine" r6.(r7) throw r6 L3a: kotlin.ResultKt.throwOnFailure(r7) r7 = 0 kotlinx.coroutines.CompletableJob r7 = kotlinx.coroutines.JobKt.Job$default(r7, r3, r7) kotlin.coroutines.CoroutineContext r2 = r0.getContext() kotlinx.coroutines.Job$Key r4 = kotlinx.coroutines.Job.INSTANCE kotlin.coroutines.CoroutineContext$Key r4 = (kotlin.coroutines.CoroutineContext.Key) r4 kotlin.coroutines.CoroutineContext$Element r2 = r2.get(r4) kotlinx.coroutines.Job r2 = (kotlinx.coroutines.Job) r2 if (r2 == 0) goto L5c androidx.room.RoomDatabaseKt$createTransactionContext$2 r4 = new androidx.room.RoomDatabaseKt$createTransactionContext$2 r4.() kotlin.jvm.functions.Function1 r4 = (kotlin.jvm.functions.Function1) r4 r2.invokeOnCompletion(r4) L5c: java.util.concurrent.Executor r2 = r6.getTransactionExecutor() r4 = r7 kotlinx.coroutines.Job r4 = (kotlinx.coroutines.Job) r4 r0.L$0 = r6 r0.L$1 = r7 r0.label = r3 java.lang.Object r0 = acquireTransactionThread(r2, r4, r0) if (r0 != r1) goto L70 return r1 L70: r5 = r0 r0 = r6 r6 = r7 r7 = r5 L74: kotlin.coroutines.ContinuationInterceptor r7 = (kotlin.coroutines.ContinuationInterceptor) r7 androidx.room.TransactionElement r1 = new androidx.room.TransactionElement r2 = r6 kotlinx.coroutines.Job r2 = (kotlinx.coroutines.Job) r2 r1.(r2, r7) java.lang.ThreadLocal r0 = r0.getSuspendingTransactionId() int r6 = java.lang.System.identityHashCode(r6) java.lang.Integer r6 = kotlin.coroutines.jvm.internal.Boxing.boxInt(r6) kotlinx.coroutines.ThreadContextElement r6 = kotlinx.coroutines.ThreadContextElementKt.asContextElement(r0, r6) kotlin.coroutines.CoroutineContext r1 = (kotlin.coroutines.CoroutineContext) r1 kotlin.coroutines.CoroutineContext r7 = r7.plus(r1) kotlin.coroutines.CoroutineContext r6 = (kotlin.coroutines.CoroutineContext) r6 kotlin.coroutines.CoroutineContext r6 = r7.plus(r6) return r6 */ throw new UnsupportedOperationException("Method not decompiled: androidx.room.RoomDatabaseKt.createTransactionContext(androidx.room.RoomDatabase, kotlin.coroutines.Continuation):java.lang.Object"); } /* JADX INFO: Access modifiers changed from: private */ public static final Object acquireTransactionThread(Executor executor, final Job job, Continuation continuation) { CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(IntrinsicsKt.intercepted(continuation), 1); cancellableContinuationImpl.initCancellability(); final CancellableContinuationImpl cancellableContinuationImpl2 = cancellableContinuationImpl; cancellableContinuationImpl2.invokeOnCancellation(new Function1() { // from class: androidx.room.RoomDatabaseKt$acquireTransactionThread$2$1 /* JADX INFO: Access modifiers changed from: package-private */ { super(1); } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(Throwable th) { invoke2(th); return Unit.INSTANCE; } /* renamed from: invoke, reason: avoid collision after fix types in other method */ public final void invoke2(Throwable th) { Job.DefaultImpls.cancel$default(Job.this, (CancellationException) null, 1, (Object) null); } }); try { executor.execute(new Runnable() { // from class: androidx.room.RoomDatabaseKt$acquireTransactionThread$2$2 /* compiled from: RoomDatabaseExt.kt */ @Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@"}, d2 = {"", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {1, 7, 1}, xi = 48) @DebugMetadata(c = "androidx.room.RoomDatabaseKt$acquireTransactionThread$2$2$1", f = "RoomDatabaseExt.kt", i = {}, l = {125}, m = "invokeSuspend", n = {}, s = {}) /* renamed from: androidx.room.RoomDatabaseKt$acquireTransactionThread$2$2$1, reason: invalid class name */ /* loaded from: classes2.dex */ static final class AnonymousClass1 extends SuspendLambda implements Function2, Object> { final /* synthetic */ CancellableContinuation $continuation; final /* synthetic */ Job $controlJob; private /* synthetic */ Object L$0; int label; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ /* JADX WARN: Multi-variable type inference failed */ AnonymousClass1(CancellableContinuation cancellableContinuation, Job job, Continuation continuation) { super(2, continuation); this.$continuation = cancellableContinuation; this.$controlJob = job; } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Continuation create(Object obj, Continuation continuation) { AnonymousClass1 anonymousClass1 = new AnonymousClass1(this.$continuation, this.$controlJob, continuation); anonymousClass1.L$0 = obj; return anonymousClass1; } @Override // kotlin.jvm.functions.Function2 public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) { return ((AnonymousClass1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE); } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Object invokeSuspend(Object obj) { Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED(); int i = this.label; if (i == 0) { ResultKt.throwOnFailure(obj); CoroutineScope coroutineScope = (CoroutineScope) this.L$0; CancellableContinuation cancellableContinuation = this.$continuation; Result.Companion companion = Result.INSTANCE; CoroutineContext.Element element = coroutineScope.getCoroutineContext().get(ContinuationInterceptor.INSTANCE); Intrinsics.checkNotNull(element); cancellableContinuation.resumeWith(Result.m5698constructorimpl(element)); this.label = 1; if (this.$controlJob.join(this) == coroutine_suspended) { return coroutine_suspended; } } else { if (i != 1) { throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } ResultKt.throwOnFailure(obj); } return Unit.INSTANCE; } } @Override // java.lang.Runnable public final void run() { BuildersKt__BuildersKt.runBlocking$default(null, new AnonymousClass1(cancellableContinuationImpl2, job, null), 1, null); } }); } catch (RejectedExecutionException e) { cancellableContinuationImpl2.cancel(new IllegalStateException("Unable to acquire a thread to perform the database transaction.", e)); } Object result = cancellableContinuationImpl.getResult(); if (result == IntrinsicsKt.getCOROUTINE_SUSPENDED()) { DebugProbesKt.probeCoroutineSuspended(continuation); } return result; } }