package L1;

import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import com.google.android.gms.internal.measurement.AbstractC0366e2;
import com.google.android.gms.internal.measurement.C0399l0;
import java.util.ArrayDeque;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public final class Y0 implements Application.ActivityLifecycleCallbacks {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ int f1643k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final Object f1644l;

    public Y0(C0088c1 c0088c1) {
        this.f1643k = 0;
        this.f1644l = c0088c1;
    }

    public void a(Intent intent) {
        Bundle bundle = null;
        try {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                String string = extras.getString("google.message_id");
                if (string == null) {
                    string = extras.getString("message_id");
                }
                if (!TextUtils.isEmpty(string)) {
                    ArrayDeque arrayDeque = (ArrayDeque) this.f1644l;
                    if (arrayDeque.contains(string)) {
                        return;
                    } else {
                        arrayDeque.add(string);
                    }
                }
                bundle = extras.getBundle("gcm.n.analytics_data");
            }
        } catch (RuntimeException e2) {
            Log.w("FirebaseMessaging", "Failed trying to get analytics data from Intent extras.", e2);
        }
        if (bundle == null ? false : "1".equals(bundle.getString("google.c.a.e"))) {
            if (bundle != null) {
                if ("1".equals(bundle.getString("google.c.a.tc"))) {
                    I2.g gVarD = I2.g.d();
                    gVarD.a();
                    K2.a aVar = (K2.a) gVarD.f935d.get(K2.a.class);
                    if (Log.isLoggable("FirebaseMessaging", 3)) {
                        Log.d("FirebaseMessaging", "Received event with track-conversion=true. Setting user property and reengagement event");
                    }
                    if (aVar != null) {
                        String string2 = bundle.getString("google.c.a.c_id");
                        K2.b bVar = (K2.b) aVar;
                        if (!L2.a.f2094b.contains("fcm")) {
                            C0399l0 c0399l0 = (C0399l0) bVar.f1067a.f6465l;
                            c0399l0.getClass();
                            c0399l0.a(new com.google.android.gms.internal.measurement.X(c0399l0, string2));
                        }
                        Bundle bundle2 = new Bundle();
                        bundle2.putString("source", "Firebase");
                        bundle2.putString("medium", "notification");
                        bundle2.putString("campaign", string2);
                        bVar.a(bundle2, "_cmp");
                    } else {
                        Log.w("FirebaseMessaging", "Unable to set user property for conversion tracking:  analytics library is missing");
                    }
                } else if (Log.isLoggable("FirebaseMessaging", 3)) {
                    Log.d("FirebaseMessaging", "Received event with track-conversion=false. Do not set user property");
                }
            }
            AbstractC0366e2.o(bundle, "_no");
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0049 A[Catch: all -> 0x0028, RuntimeException -> 0x002b, TryCatch #1 {RuntimeException -> 0x002b, blocks: (B:3:0x0005, B:5:0x0019, B:7:0x001f, B:22:0x0049, B:25:0x0050, B:27:0x0063, B:29:0x006b, B:35:0x007b, B:40:0x0088, B:15:0x002e, B:17:0x0035, B:19:0x0041), top: B:49:0x0005, outer: #0 }] */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0078  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0083  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0086  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public void j(com.google.android.gms.internal.measurement.W r9, android.os.Bundle r10) {
        /*
            Method dump skipped, instruction units count: 206
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: L1.Y0.j(com.google.android.gms.internal.measurement.W, android.os.Bundle):void");
    }

    public void k(com.google.android.gms.internal.measurement.W w5) {
        C0124o1 c0124o1 = ((C0146w0) ((C0088c1) this.f1644l).f29k).f2041v;
        C0146w0.k(c0124o1);
        synchronized (c0124o1.f1939v) {
            try {
                if (Objects.equals(c0124o1.q, w5)) {
                    c0124o1.q = null;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (((C0146w0) c0124o1.f29k).f2035n.y()) {
            c0124o1.p.remove(Integer.valueOf(w5.f4997k));
        }
    }

    public void l(com.google.android.gms.internal.measurement.W w5) {
        C0146w0 c0146w0 = (C0146w0) ((C0088c1) this.f1644l).f29k;
        C0124o1 c0124o1 = c0146w0.f2041v;
        C0146w0.k(c0124o1);
        synchronized (c0124o1.f1939v) {
            c0124o1.f1938u = false;
            c0124o1.f1935r = true;
        }
        C0146w0 c0146w02 = (C0146w0) c0124o1.f29k;
        c0146w02.f2040u.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        if (c0146w02.f2035n.y()) {
            C0112k1 c0112k1P = c0124o1.p(w5);
            c0124o1.f1933n = c0124o1.f1932m;
            c0124o1.f1932m = null;
            C0137t0 c0137t0 = c0146w02.q;
            C0146w0.l(c0137t0);
            c0137t0.t(new RunnableC0121n1(c0124o1, c0112k1P, jElapsedRealtime));
        } else {
            c0124o1.f1932m = null;
            C0137t0 c0137t02 = c0146w02.q;
            C0146w0.l(c0137t02);
            c0137t02.t(new RunnableC0148x(c0124o1, jElapsedRealtime));
        }
        G1 g12 = c0146w0.f2037r;
        C0146w0.k(g12);
        C0146w0 c0146w03 = (C0146w0) g12.f29k;
        c0146w03.f2040u.getClass();
        long jElapsedRealtime2 = SystemClock.elapsedRealtime();
        C0137t0 c0137t03 = c0146w03.q;
        C0146w0.l(c0137t03);
        c0137t03.t(new C1(g12, jElapsedRealtime2, 1));
    }

    public void m(com.google.android.gms.internal.measurement.W w5) {
        C0146w0 c0146w0 = (C0146w0) ((C0088c1) this.f1644l).f29k;
        G1 g12 = c0146w0.f2037r;
        C0146w0.k(g12);
        C0146w0 c0146w02 = (C0146w0) g12.f29k;
        c0146w02.f2040u.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        C0137t0 c0137t0 = c0146w02.q;
        C0146w0.l(c0137t0);
        c0137t0.t(new C1(g12, jElapsedRealtime, 0));
        C0124o1 c0124o1 = c0146w0.f2041v;
        C0146w0.k(c0124o1);
        Object obj = c0124o1.f1939v;
        synchronized (obj) {
            c0124o1.f1938u = true;
            if (!Objects.equals(w5, c0124o1.q)) {
                synchronized (obj) {
                    c0124o1.q = w5;
                    c0124o1.f1935r = false;
                    C0146w0 c0146w03 = (C0146w0) c0124o1.f29k;
                    if (c0146w03.f2035n.y()) {
                        c0124o1.f1936s = null;
                        C0137t0 c0137t02 = c0146w03.q;
                        C0146w0.l(c0137t02);
                        c0137t02.t(new RunnableC0118m1(c0124o1, 1));
                    }
                }
            }
        }
        C0146w0 c0146w04 = (C0146w0) c0124o1.f29k;
        if (!c0146w04.f2035n.y()) {
            c0124o1.f1932m = c0124o1.f1936s;
            C0137t0 c0137t03 = c0146w04.q;
            C0146w0.l(c0137t03);
            c0137t03.t(new RunnableC0118m1(c0124o1, 0));
            return;
        }
        c0124o1.t(w5.f4998l, c0124o1.p(w5), false);
        C0151y c0151y = ((C0146w0) c0124o1.f29k).f2043x;
        C0146w0.i(c0151y);
        C0146w0 c0146w05 = (C0146w0) c0151y.f29k;
        c0146w05.f2040u.getClass();
        long jElapsedRealtime2 = SystemClock.elapsedRealtime();
        C0137t0 c0137t04 = c0146w05.q;
        C0146w0.l(c0137t04);
        c0137t04.t(new RunnableC0148x(c0151y, jElapsedRealtime2));
    }

    public void n(com.google.android.gms.internal.measurement.W w5, Bundle bundle) {
        C0112k1 c0112k1;
        C0124o1 c0124o1 = ((C0146w0) ((C0088c1) this.f1644l).f29k).f2041v;
        C0146w0.k(c0124o1);
        if (!((C0146w0) c0124o1.f29k).f2035n.y() || bundle == null || (c0112k1 = (C0112k1) c0124o1.p.get(Integer.valueOf(w5.f4997k))) == null) {
            return;
        }
        Bundle bundle2 = new Bundle();
        bundle2.putLong("id", c0112k1.f1889c);
        bundle2.putString("name", c0112k1.f1887a);
        bundle2.putString("referrer_name", c0112k1.f1888b);
        bundle.putBundle("com.google.app_measurement.screen_service", bundle2);
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityCreated(Activity activity, Bundle bundle) {
        switch (this.f1643k) {
            case 0:
                j(com.google.android.gms.internal.measurement.W.a(activity), bundle);
                break;
            default:
                Intent intent = activity.getIntent();
                if (intent != null) {
                    if (Build.VERSION.SDK_INT > 25) {
                        a(intent);
                    } else {
                        new Handler(Looper.getMainLooper()).post(new F.j(7, this, intent));
                    }
                    break;
                }
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityDestroyed(Activity activity) {
        switch (this.f1643k) {
            case 0:
                k(com.google.android.gms.internal.measurement.W.a(activity));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityPaused(Activity activity) {
        switch (this.f1643k) {
            case 0:
                l(com.google.android.gms.internal.measurement.W.a(activity));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityResumed(Activity activity) {
        switch (this.f1643k) {
            case 0:
                m(com.google.android.gms.internal.measurement.W.a(activity));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
        switch (this.f1643k) {
            case 0:
                n(com.google.android.gms.internal.measurement.W.a(activity), bundle);
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityStarted(Activity activity) {
        int i = this.f1643k;
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityStopped(Activity activity) {
        int i = this.f1643k;
    }

    public Y0() {
        this.f1643k = 1;
        this.f1644l = new ArrayDeque(10);
    }

    private final void b(Activity activity) {
    }

    private final void c(Activity activity) {
    }

    private final void d(Activity activity) {
    }

    private final void f(Activity activity) {
    }

    private final void g(Activity activity) {
    }

    private final void h(Activity activity) {
    }

    private final void i(Activity activity) {
    }

    private final void e(Activity activity, Bundle bundle) {
    }
}
