package com.google.firebase.sessions;

import android.content.Context;
import android.util.Log;
import com.google.firebase.sessions.SessionDatastoreImpl;
import dn.p;
import java.io.IOException;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.l;
import rm.n0;
import rm.y;
import tp.m0;

@kotlin.coroutines.jvm.internal.f(c = "com.google.firebase.sessions.SessionDatastoreImpl$updateSessionId$1", f = "SessionDatastore.kt", l = {89}, m = "invokeSuspend")
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\u008a@"}, d2 = {"Ltp/m0;", "Lrm/n0;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
/* loaded from: classes3.dex */
final class SessionDatastoreImpl$updateSessionId$1 extends l implements p {
    final /* synthetic */ String $sessionId;
    int label;
    final /* synthetic */ SessionDatastoreImpl this$0;

    /* JADX INFO: Access modifiers changed from: package-private */
    @kotlin.coroutines.jvm.internal.f(c = "com.google.firebase.sessions.SessionDatastoreImpl$updateSessionId$1$1", f = "SessionDatastore.kt", l = {}, m = "invokeSuspend")
    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\u008a@"}, d2 = {"Li4/a;", "preferences", "Lrm/n0;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
    /* renamed from: com.google.firebase.sessions.SessionDatastoreImpl$updateSessionId$1$1, reason: invalid class name */
    /* loaded from: classes3.dex */
    public static final class AnonymousClass1 extends l implements p {
        final /* synthetic */ String $sessionId;
        /* synthetic */ Object L$0;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        AnonymousClass1(String str, vm.d<? super AnonymousClass1> dVar) {
            super(2, dVar);
            this.$sessionId = str;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d<n0> create(Object obj, vm.d<?> dVar) {
            AnonymousClass1 anonymousClass1 = new AnonymousClass1(this.$sessionId, dVar);
            anonymousClass1.L$0 = obj;
            return anonymousClass1;
        }

        @Override // dn.p
        public final Object invoke(i4.a aVar, vm.d<? super n0> dVar) {
            return ((AnonymousClass1) create(aVar, dVar)).invokeSuspend(n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            wm.d.f();
            if (this.label != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            y.b(obj);
            ((i4.a) this.L$0).j(SessionDatastoreImpl.FirebaseSessionDataKeys.INSTANCE.getSESSION_ID(), this.$sessionId);
            return n0.f34904a;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public SessionDatastoreImpl$updateSessionId$1(SessionDatastoreImpl sessionDatastoreImpl, String str, vm.d<? super SessionDatastoreImpl$updateSessionId$1> dVar) {
        super(2, dVar);
        this.this$0 = sessionDatastoreImpl;
        this.$sessionId = str;
    }

    @Override // kotlin.coroutines.jvm.internal.a
    public final vm.d<n0> create(Object obj, vm.d<?> dVar) {
        return new SessionDatastoreImpl$updateSessionId$1(this.this$0, this.$sessionId, dVar);
    }

    @Override // kotlin.coroutines.jvm.internal.a
    public final Object invokeSuspend(Object obj) {
        Object f10;
        SessionDatastoreImpl.Companion companion;
        Context context;
        f10 = wm.d.f();
        int i10 = this.label;
        try {
            if (i10 == 0) {
                y.b(obj);
                companion = SessionDatastoreImpl.Companion;
                context = this.this$0.context;
                f4.f dataStore = companion.getDataStore(context);
                AnonymousClass1 anonymousClass1 = new AnonymousClass1(this.$sessionId, null);
                this.label = 1;
                if (i4.g.a(dataStore, anonymousClass1, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
        } catch (IOException e10) {
            Log.w("FirebaseSessionsRepo", "Failed to update session Id: " + e10);
        }
        return n0.f34904a;
    }

    @Override // dn.p
    public final Object invoke(m0 m0Var, vm.d<? super n0> dVar) {
        return ((SessionDatastoreImpl$updateSessionId$1) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
    }
}
