package com.google.android.gms.measurement.internal;

import D1.RunnableC0077b;
import G3.b;
import O1.C;
import O1.C0225a;
import P2.C0253j;
import P2.w;
import V2.a;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
import android.text.TextUtils;
import com.google.android.gms.common.util.DynamiteApi;
import com.google.android.gms.internal.measurement.I;
import com.google.android.gms.internal.measurement.L;
import com.google.android.gms.internal.measurement.O;
import com.google.android.gms.internal.measurement.Q;
import com.google.android.gms.internal.measurement.T;
import com.google.android.gms.internal.measurement.U;
import com.google.android.gms.internal.measurement.W;
import com.google.android.material.datepicker.c;
import d3.C0764A;
import d3.C0774c1;
import d3.C0784g;
import d3.C0786g1;
import d3.C0795j1;
import d3.C0815q0;
import d3.C0817r0;
import d3.C0825u;
import d3.C0828v;
import d3.EnumC0780e1;
import d3.G0;
import d3.H;
import d3.H0;
import d3.H1;
import d3.J1;
import d3.K0;
import d3.L0;
import d3.M0;
import d3.P;
import d3.RunnableC0770b0;
import d3.RunnableC0832w0;
import d3.S0;
import d3.S1;
import d3.U0;
import d3.W1;
import d3.X;
import d3.X0;
import d3.Y0;
import d3.Z;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import q.e;

/* JADX INFO: loaded from: classes.dex */
@DynamiteApi
public class AppMeasurementDynamiteService extends I {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public C0817r0 f10093e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final e f10094f;

    public static void $r8$lambda$W3cgi1t5N0SU6fYxM9Fsh5qQfPc(AppMeasurementDynamiteService appMeasurementDynamiteService, O o8) {
        try {
            o8.a();
        } catch (RemoteException e8) {
            C0817r0 c0817r0 = appMeasurementDynamiteService.f10093e;
            w.f(c0817r0);
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11878y.c(e8, "Failed to call IDynamiteUploadBatchesCallback");
        }
    }

    public AppMeasurementDynamiteService() {
        super("com.google.android.gms.measurement.api.internal.IAppMeasurementDynamiteService");
        this.f10093e = null;
        this.f10094f = new e(0);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void beginAdUnitExposure(String str, long j8) {
        d();
        C0764A c0764a = this.f10093e.f12126G;
        C0817r0.h(c0764a);
        c0764a.F(j8, str);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void clearConditionalUserProperty(String str, String str2, Bundle bundle) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.K(str, str2, bundle);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void clearMeasurementEnabled(long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.F();
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new b(y02, null, 14, false));
    }

    public final void d() {
        if (this.f10093e == null) {
            throw new IllegalStateException("Attempting to perform action before initialize.");
        }
    }

    public final void e(String str, L l8) {
        d();
        W1 w12 = this.f10093e.f12122B;
        C0817r0.i(w12);
        w12.g0(str, l8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void endAdUnitExposure(String str, long j8) {
        d();
        C0764A c0764a = this.f10093e.f12126G;
        C0817r0.h(c0764a);
        c0764a.G(j8, str);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void generateEventId(L l8) {
        d();
        W1 w12 = this.f10093e.f12122B;
        C0817r0.i(w12);
        long jP0 = w12.P0();
        d();
        W1 w13 = this.f10093e.f12122B;
        C0817r0.i(w13);
        w13.f0(l8, jP0);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getAppInstanceId(L l8) {
        d();
        C0815q0 c0815q0 = this.f10093e.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new RunnableC0832w0(this, l8, 0));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getCachedAppInstanceId(L l8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        e((String) y02.f11857w.get(), l8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getConditionalUserProperties(String str, String str2, L l8) {
        d();
        C0815q0 c0815q0 = this.f10093e.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new C(this, l8, str, str2, 7, false));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getCurrentScreenClass(L l8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0795j1 c0795j1 = ((C0817r0) y02.f5146q).f12124E;
        C0817r0.j(c0795j1);
        C0786g1 c0786g1 = c0795j1.f12020s;
        e(c0786g1 != null ? c0786g1.f11980b : null, l8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getCurrentScreenName(L l8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0795j1 c0795j1 = ((C0817r0) y02.f5146q).f12124E;
        C0817r0.j(c0795j1);
        C0786g1 c0786g1 = c0795j1.f12020s;
        e(c0786g1 != null ? c0786g1.f11979a : null, l8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getGmpAppId(L l8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0817r0 c0817r0 = (C0817r0) y02.f5146q;
        String strG = null;
        if (c0817r0.f12148w.R(null, d3.I.f11580q1) || c0817r0.s() == null) {
            try {
                strG = G0.g(c0817r0.f12142q, c0817r0.f12127I);
            } catch (IllegalStateException e8) {
                Z z8 = c0817r0.f12150y;
                C0817r0.k(z8);
                z8.f11875v.c(e8, "getGoogleAppId failed with exception");
            }
        } else {
            strG = c0817r0.s();
        }
        e(strG, l8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getMaxUserProperties(String str, L l8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        w.c(str);
        ((C0817r0) y02.f5146q).getClass();
        d();
        W1 w12 = this.f10093e.f12122B;
        C0817r0.i(w12);
        w12.e0(l8, 25);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getSessionId(L l8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new b(y02, l8, 13, false));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getTestFlag(L l8, int i) {
        d();
        if (i == 0) {
            W1 w12 = this.f10093e.f12122B;
            C0817r0.i(w12);
            Y0 y02 = this.f10093e.f12125F;
            C0817r0.j(y02);
            AtomicReference atomicReference = new AtomicReference();
            C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
            C0817r0.k(c0815q0);
            w12.g0((String) c0815q0.J(atomicReference, 15000L, "String test flag value", new K0(y02, atomicReference, 3)), l8);
            return;
        }
        if (i == 1) {
            W1 w13 = this.f10093e.f12122B;
            C0817r0.i(w13);
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            AtomicReference atomicReference2 = new AtomicReference();
            C0815q0 c0815q02 = ((C0817r0) y03.f5146q).f12151z;
            C0817r0.k(c0815q02);
            w13.f0(l8, ((Long) c0815q02.J(atomicReference2, 15000L, "long test flag value", new K0(y03, atomicReference2, 4))).longValue());
            return;
        }
        if (i == 2) {
            W1 w14 = this.f10093e.f12122B;
            C0817r0.i(w14);
            Y0 y04 = this.f10093e.f12125F;
            C0817r0.j(y04);
            AtomicReference atomicReference3 = new AtomicReference();
            C0815q0 c0815q03 = ((C0817r0) y04.f5146q).f12151z;
            C0817r0.k(c0815q03);
            double dDoubleValue = ((Double) c0815q03.J(atomicReference3, 15000L, "double test flag value", new K0(y04, atomicReference3, 6))).doubleValue();
            Bundle bundle = new Bundle();
            bundle.putDouble("r", dDoubleValue);
            try {
                l8.m(bundle);
                return;
            } catch (RemoteException e8) {
                Z z8 = ((C0817r0) w14.f5146q).f12150y;
                C0817r0.k(z8);
                z8.f11878y.c(e8, "Error returning double value to wrapper");
                return;
            }
        }
        if (i == 3) {
            W1 w15 = this.f10093e.f12122B;
            C0817r0.i(w15);
            Y0 y05 = this.f10093e.f12125F;
            C0817r0.j(y05);
            AtomicReference atomicReference4 = new AtomicReference();
            C0815q0 c0815q04 = ((C0817r0) y05.f5146q).f12151z;
            C0817r0.k(c0815q04);
            w15.e0(l8, ((Integer) c0815q04.J(atomicReference4, 15000L, "int test flag value", new K0(y05, atomicReference4, 5))).intValue());
            return;
        }
        if (i != 4) {
            return;
        }
        W1 w16 = this.f10093e.f12122B;
        C0817r0.i(w16);
        Y0 y06 = this.f10093e.f12125F;
        C0817r0.j(y06);
        AtomicReference atomicReference5 = new AtomicReference();
        C0815q0 c0815q05 = ((C0817r0) y06.f5146q).f12151z;
        C0817r0.k(c0815q05);
        w16.a0(l8, ((Boolean) c0815q05.J(atomicReference5, 15000L, "boolean test flag value", new K0(y06, atomicReference5, 2))).booleanValue());
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void getUserProperties(String str, String str2, boolean z8, L l8) {
        d();
        C0815q0 c0815q0 = this.f10093e.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new U0(this, l8, str, str2, z8, 0));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void initForTests(Map map) {
        d();
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void initialize(a aVar, U u8, long j8) {
        C0817r0 c0817r0 = this.f10093e;
        if (c0817r0 == null) {
            Context context = (Context) V2.b.M(aVar);
            w.f(context);
            this.f10093e = C0817r0.q(context, u8, Long.valueOf(j8));
        } else {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11878y.b("Attempting to initialize multiple times");
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void isDataCollectionEnabled(L l8) {
        d();
        C0815q0 c0815q0 = this.f10093e.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new RunnableC0832w0(this, l8, 1));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void logEvent(String str, String str2, Bundle bundle, boolean z8, boolean z9, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.O(str, str2, bundle, z8, z9, j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void logEventAndBundle(String str, String str2, Bundle bundle, L l8, long j8) {
        d();
        w.c(str2);
        (bundle != null ? new Bundle(bundle) : new Bundle()).putString("_o", "app");
        C0828v c0828v = new C0828v(str2, new C0825u(bundle), "app", j8);
        C0815q0 c0815q0 = this.f10093e.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new C(this, l8, c0828v, str, 3, false));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void logHealthData(int i, String str, a aVar, a aVar2, a aVar3) {
        d();
        Object objM = aVar == null ? null : V2.b.M(aVar);
        Object objM2 = aVar2 == null ? null : V2.b.M(aVar2);
        Object objM3 = aVar3 != null ? V2.b.M(aVar3) : null;
        Z z8 = this.f10093e.f12150y;
        C0817r0.k(z8);
        z8.Q(i, true, false, str, objM, objM2, objM3);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityCreated(a aVar, Bundle bundle, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivityCreatedByScionActivityInfo(W.a(activity), bundle, j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityCreatedByScionActivityInfo(W w4, Bundle bundle, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        X0 x02 = y02.f11853s;
        if (x02 != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
            x02.a(w4, bundle);
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityDestroyed(a aVar, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivityDestroyedByScionActivityInfo(W.a(activity), j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityDestroyedByScionActivityInfo(W w4, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        X0 x02 = y02.f11853s;
        if (x02 != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
            x02.b(w4);
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityPaused(a aVar, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivityPausedByScionActivityInfo(W.a(activity), j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityPausedByScionActivityInfo(W w4, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        X0 x02 = y02.f11853s;
        if (x02 != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
            x02.c(w4);
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityResumed(a aVar, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivityResumedByScionActivityInfo(W.a(activity), j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityResumedByScionActivityInfo(W w4, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        X0 x02 = y02.f11853s;
        if (x02 != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
            x02.d(w4);
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivitySaveInstanceState(a aVar, L l8, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivitySaveInstanceStateByScionActivityInfo(W.a(activity), l8, j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivitySaveInstanceStateByScionActivityInfo(W w4, L l8, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        X0 x02 = y02.f11853s;
        Bundle bundle = new Bundle();
        if (x02 != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
            x02.e(w4, bundle);
        }
        try {
            l8.m(bundle);
        } catch (RemoteException e8) {
            Z z8 = this.f10093e.f12150y;
            C0817r0.k(z8);
            z8.f11878y.c(e8, "Error returning bundle value to wrapper");
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityStarted(a aVar, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivityStartedByScionActivityInfo(W.a(activity), j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityStartedByScionActivityInfo(W w4, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        if (y02.f11853s != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityStopped(a aVar, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        onActivityStoppedByScionActivityInfo(W.a(activity), j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void onActivityStoppedByScionActivityInfo(W w4, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        if (y02.f11853s != null) {
            Y0 y03 = this.f10093e.f12125F;
            C0817r0.j(y03);
            y03.L();
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void performAction(Bundle bundle, L l8, long j8) {
        d();
        l8.m(null);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void registerOnMeasurementEventListener(Q q8) {
        Object s12;
        d();
        e eVar = this.f10094f;
        synchronized (eVar) {
            try {
                s12 = (H0) eVar.get(Integer.valueOf(q8.a()));
                if (s12 == null) {
                    s12 = new S1(this, q8);
                    eVar.put(Integer.valueOf(q8.a()), s12);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.F();
        if (y02.f11855u.add(s12)) {
            return;
        }
        Z z8 = ((C0817r0) y02.f5146q).f12150y;
        C0817r0.k(z8);
        z8.f11878y.b("OnEventListener already registered");
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void resetAnalyticsData(long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.f11857w.set(null);
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new S0(y02, j8, 1));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void retrieveAndUploadBatches(O o8) {
        EnumC0780e1 enumC0780e1;
        d();
        C0784g c0784g = this.f10093e.f12148w;
        H h8 = d3.I.f11521S0;
        if (c0784g.R(null, h8)) {
            Y0 y02 = this.f10093e.f12125F;
            C0817r0.j(y02);
            C0817r0 c0817r0 = (C0817r0) y02.f5146q;
            if (c0817r0.f12148w.R(null, h8)) {
                y02.F();
                C0815q0 c0815q0 = c0817r0.f12151z;
                C0817r0.k(c0815q0);
                if (c0815q0.Q()) {
                    Z z8 = c0817r0.f12150y;
                    C0817r0.k(z8);
                    z8.f11875v.b("Cannot retrieve and upload batches from analytics worker thread");
                    return;
                }
                C0815q0 c0815q02 = c0817r0.f12151z;
                C0817r0.k(c0815q02);
                if (Thread.currentThread() == c0815q02.f12106t) {
                    Z z9 = c0817r0.f12150y;
                    C0817r0.k(z9);
                    z9.f11875v.b("Cannot retrieve and upload batches from analytics network thread");
                    return;
                }
                if (C0253j.s()) {
                    Z z10 = c0817r0.f12150y;
                    C0817r0.k(z10);
                    z10.f11875v.b("Cannot retrieve and upload batches from main thread");
                    return;
                }
                Z z11 = c0817r0.f12150y;
                C0817r0.k(z11);
                z11.D.b("[sgtm] Started client-side batch upload work.");
                boolean z12 = false;
                int size = 0;
                int i = 0;
                while (!z12) {
                    Z z13 = c0817r0.f12150y;
                    C0817r0.k(z13);
                    z13.D.b("[sgtm] Getting upload batches from service (FE)");
                    AtomicReference atomicReference = new AtomicReference();
                    C0815q0 c0815q03 = c0817r0.f12151z;
                    C0817r0.k(c0815q03);
                    c0815q03.J(atomicReference, 10000L, "[sgtm] Getting upload batches", new K0(y02, atomicReference, 1));
                    J1 j12 = (J1) atomicReference.get();
                    if (j12 == null) {
                        break;
                    }
                    List list = j12.f11611q;
                    if (list.isEmpty()) {
                        break;
                    }
                    Z z14 = c0817r0.f12150y;
                    C0817r0.k(z14);
                    z14.D.c(Integer.valueOf(list.size()), "[sgtm] Retrieved upload batches. count");
                    size += list.size();
                    Iterator it = list.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            z12 = false;
                            break;
                        }
                        H1 h12 = (H1) it.next();
                        try {
                            URL url = new URI(h12.f11482s).toURL();
                            AtomicReference atomicReference2 = new AtomicReference();
                            P pN = ((C0817r0) y02.f5146q).n();
                            pN.F();
                            w.f(pN.f11643w);
                            String str = pN.f11643w;
                            C0817r0 c0817r02 = (C0817r0) y02.f5146q;
                            Z z15 = c0817r02.f12150y;
                            C0817r0.k(z15);
                            X x8 = z15.D;
                            Long lValueOf = Long.valueOf(h12.f11480q);
                            x8.e("[sgtm] Uploading data from app. row_id, url, uncompressed size", lValueOf, h12.f11482s, Integer.valueOf(h12.f11481r.length));
                            if (!TextUtils.isEmpty(h12.f11486w)) {
                                Z z16 = c0817r02.f12150y;
                                C0817r0.k(z16);
                                z16.D.d("[sgtm] Uploading data from app. row_id", lValueOf, h12.f11486w);
                            }
                            HashMap map = new HashMap();
                            Bundle bundle = h12.f11483t;
                            for (String str2 : bundle.keySet()) {
                                String string = bundle.getString(str2);
                                if (!TextUtils.isEmpty(string)) {
                                    map.put(str2, string);
                                }
                            }
                            C0774c1 c0774c1 = c0817r02.H;
                            C0817r0.k(c0774c1);
                            byte[] bArr = h12.f11481r;
                            c cVar = new c(y02, atomicReference2, h12, 3);
                            c0774c1.G();
                            w.f(url);
                            w.f(bArr);
                            C0815q0 c0815q04 = ((C0817r0) c0774c1.f5146q).f12151z;
                            C0817r0.k(c0815q04);
                            c0815q04.N(new RunnableC0770b0(c0774c1, str, url, bArr, map, cVar));
                            try {
                                W1 w12 = c0817r02.f12122B;
                                C0817r0.i(w12);
                                C0817r0 c0817r03 = (C0817r0) w12.f5146q;
                                c0817r03.D.getClass();
                                long jCurrentTimeMillis = System.currentTimeMillis() + 60000;
                                synchronized (atomicReference2) {
                                    for (long jCurrentTimeMillis2 = 60000; atomicReference2.get() == null && jCurrentTimeMillis2 > 0; jCurrentTimeMillis2 = jCurrentTimeMillis - System.currentTimeMillis()) {
                                        try {
                                            atomicReference2.wait(jCurrentTimeMillis2);
                                            c0817r03.D.getClass();
                                        } catch (Throwable th) {
                                            throw th;
                                        }
                                    }
                                }
                            } catch (InterruptedException unused) {
                                Z z17 = ((C0817r0) y02.f5146q).f12150y;
                                C0817r0.k(z17);
                                z17.f11878y.b("[sgtm] Interrupted waiting for uploading batch");
                            }
                            enumC0780e1 = atomicReference2.get() == null ? EnumC0780e1.f11933r : (EnumC0780e1) atomicReference2.get();
                        } catch (MalformedURLException | URISyntaxException e8) {
                            Z z18 = ((C0817r0) y02.f5146q).f12150y;
                            C0817r0.k(z18);
                            z18.f11875v.e("[sgtm] Bad upload url for row_id", h12.f11482s, Long.valueOf(h12.f11480q), e8);
                            enumC0780e1 = EnumC0780e1.f11935t;
                        }
                        if (enumC0780e1 != EnumC0780e1.f11934s) {
                            if (enumC0780e1 == EnumC0780e1.f11936u) {
                                z12 = true;
                                break;
                            }
                        } else {
                            i++;
                        }
                    }
                }
                Z z19 = c0817r0.f12150y;
                C0817r0.k(z19);
                z19.D.d("[sgtm] Completed client-side batch upload work. total, success", Integer.valueOf(size), Integer.valueOf(i));
                $r8$lambda$W3cgi1t5N0SU6fYxM9Fsh5qQfPc(this, o8);
            }
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setConditionalUserProperty(Bundle bundle, long j8) {
        d();
        if (bundle == null) {
            Z z8 = this.f10093e.f12150y;
            C0817r0.k(z8);
            z8.f11875v.b("Conditional user property must not be null");
        } else {
            Y0 y02 = this.f10093e.f12125F;
            C0817r0.j(y02);
            y02.T(bundle, j8);
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setConsent(Bundle bundle, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.P(new M0(y02, bundle, j8));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setConsentThirdParty(Bundle bundle, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.U(bundle, -20, j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setCurrentScreen(a aVar, String str, String str2, long j8) {
        d();
        Activity activity = (Activity) V2.b.M(aVar);
        w.f(activity);
        setCurrentScreenByScionActivityInfo(W.a(activity), str, str2, j8);
    }

    /* JADX WARN: Code restructure failed: missing block: B:27:0x0088, code lost:
    
        if (r3 <= 500) goto L31;
     */
    /* JADX WARN: Code restructure failed: missing block: B:35:0x00b1, code lost:
    
        if (r3 <= 500) goto L39;
     */
    @Override // com.google.android.gms.internal.measurement.J
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void setCurrentScreenByScionActivityInfo(W w4, String str, String str2, long j8) {
        d();
        C0795j1 c0795j1 = this.f10093e.f12124E;
        C0817r0.j(c0795j1);
        C0817r0 c0817r0 = (C0817r0) c0795j1.f5146q;
        if (!c0817r0.f12148w.S()) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11869A.b("setCurrentScreen cannot be called while screen reporting is disabled.");
            return;
        }
        C0786g1 c0786g1 = c0795j1.f12020s;
        if (c0786g1 == null) {
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.f11869A.b("setCurrentScreen cannot be called while no activity active");
            return;
        }
        ConcurrentHashMap concurrentHashMap = c0795j1.f12023v;
        Integer numValueOf = Integer.valueOf(w4.f9767q);
        if (concurrentHashMap.get(numValueOf) == null) {
            Z z10 = c0817r0.f12150y;
            C0817r0.k(z10);
            z10.f11869A.b("setCurrentScreen must be called with an activity in the activity lifecycle");
            return;
        }
        if (str2 == null) {
            str2 = c0795j1.M(w4.f9768r);
        }
        String str3 = c0786g1.f11980b;
        String str4 = c0786g1.f11979a;
        boolean zEquals = Objects.equals(str3, str2);
        boolean zEquals2 = Objects.equals(str4, str);
        if (zEquals && zEquals2) {
            Z z11 = c0817r0.f12150y;
            C0817r0.k(z11);
            z11.f11869A.b("setCurrentScreen cannot be called with the same class and name");
            return;
        }
        if (str != null) {
            if (str.length() > 0) {
                int length = str.length();
                c0817r0.f12148w.getClass();
            }
            Z z12 = c0817r0.f12150y;
            C0817r0.k(z12);
            z12.f11869A.c(Integer.valueOf(str.length()), "Invalid screen name length in setCurrentScreen. Length");
            return;
        }
        if (str2 != null) {
            if (str2.length() > 0) {
                int length2 = str2.length();
                c0817r0.f12148w.getClass();
            }
            Z z13 = c0817r0.f12150y;
            C0817r0.k(z13);
            z13.f11869A.c(Integer.valueOf(str2.length()), "Invalid class name length in setCurrentScreen. Length");
            return;
        }
        Z z14 = c0817r0.f12150y;
        C0817r0.k(z14);
        z14.D.d("Setting current screen to name, class", str == null ? "null" : str, str2);
        W1 w12 = c0817r0.f12122B;
        C0817r0.i(w12);
        C0786g1 c0786g12 = new C0786g1(w12.P0(), str, str2);
        concurrentHashMap.put(numValueOf, c0786g12);
        c0795j1.I(w4.f9768r, c0786g12, true);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setDataCollectionEnabled(boolean z8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.F();
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new RunnableC0077b(y02, z8, 2));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setDefaultEventParameters(Bundle bundle) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        Bundle bundle2 = bundle == null ? new Bundle() : new Bundle(bundle);
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new L0(y02, bundle2, 0));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setEventInterceptor(Q q8) {
        d();
        C0225a c0225a = new C0225a(this, 29, q8);
        C0815q0 c0815q0 = this.f10093e.f12151z;
        C0817r0.k(c0815q0);
        if (!c0815q0.Q()) {
            C0815q0 c0815q02 = this.f10093e.f12151z;
            C0817r0.k(c0815q02);
            c0815q02.O(new b(this, c0225a, 16, false));
            return;
        }
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.E();
        y02.F();
        C0225a c0225a2 = y02.f11854t;
        if (c0225a != c0225a2) {
            w.h("EventInterceptor already set.", c0225a2 == null);
        }
        y02.f11854t = c0225a;
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setInstanceIdProvider(T t6) {
        d();
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setMeasurementEnabled(boolean z8, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        Boolean boolValueOf = Boolean.valueOf(z8);
        y02.F();
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new b(y02, boolValueOf, 14, false));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setMinimumSessionDuration(long j8) {
        d();
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setSessionTimeoutDuration(long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0815q0 c0815q0 = ((C0817r0) y02.f5146q).f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new S0(y02, j8, 0));
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setSgtmDebugInfo(Intent intent) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        Uri data = intent.getData();
        C0817r0 c0817r0 = (C0817r0) y02.f5146q;
        if (data == null) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11870B.b("Activity intent has no data. Preview Mode was not enabled.");
            return;
        }
        String queryParameter = data.getQueryParameter("sgtm_debug_enable");
        if (queryParameter == null || !queryParameter.equals("1")) {
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.f11870B.b("[sgtm] Preview Mode was not enabled.");
            c0817r0.f12148w.f11953s = null;
            return;
        }
        String queryParameter2 = data.getQueryParameter("sgtm_preview_key");
        if (TextUtils.isEmpty(queryParameter2)) {
            return;
        }
        Z z10 = c0817r0.f12150y;
        C0817r0.k(z10);
        z10.f11870B.c(queryParameter2, "[sgtm] Preview Mode was enabled. Using the sgtmPreviewKey: ");
        c0817r0.f12148w.f11953s = queryParameter2;
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setUserId(String str, long j8) {
        d();
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        C0817r0 c0817r0 = (C0817r0) y02.f5146q;
        if (str != null && TextUtils.isEmpty(str)) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11878y.b("User ID must be non-empty or null");
        } else {
            C0815q0 c0815q0 = c0817r0.f12151z;
            C0817r0.k(c0815q0);
            c0815q0.O(new b(y02, 11, str));
            y02.Y(null, "_id", str, true, j8);
        }
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void setUserProperty(String str, String str2, a aVar, boolean z8, long j8) {
        d();
        Object objM = V2.b.M(aVar);
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.Y(str, str2, objM, z8, j8);
    }

    @Override // com.google.android.gms.internal.measurement.J
    public void unregisterOnMeasurementEventListener(Q q8) {
        Object s12;
        d();
        e eVar = this.f10094f;
        synchronized (eVar) {
            s12 = (H0) eVar.remove(Integer.valueOf(q8.a()));
        }
        if (s12 == null) {
            s12 = new S1(this, q8);
        }
        Y0 y02 = this.f10093e.f12125F;
        C0817r0.j(y02);
        y02.F();
        if (y02.f11855u.remove(s12)) {
            return;
        }
        Z z8 = ((C0817r0) y02.f5146q).f12150y;
        C0817r0.k(z8);
        z8.f11878y.b("OnEventListener had not been registered");
    }
}
