package o;

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.text.TextUtils;
import android.util.Log;
import java.util.ArrayDeque;
import java.util.Objects;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Lx, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0308Lx implements Application.ActivityLifecycleCallbacks {
    public final /* synthetic */ int l;
    public final Object m;

    public /* synthetic */ C0308Lx(int i, Object obj) {
        this.l = i;
        this.m = obj;
    }

    public void a(Intent intent) {
        ArrayDeque arrayDeque = (ArrayDeque) this.m;
        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)) {
                    if (arrayDeque.contains(string)) {
                        return;
                    } else {
                        arrayDeque.add(string);
                    }
                }
                bundle = extras.getBundle("gcm.n.analytics_data");
            }
        } catch (RuntimeException unused) {
        }
        if (bundle == null ? false : "1".equals(bundle.getString("google.c.a.e"))) {
            if (bundle != null) {
                if ("1".equals(bundle.getString("google.c.a.tc"))) {
                    A2 a2 = (A2) C0076Cy.c().b(A2.class);
                    Log.isLoggable("FirebaseMessaging", 3);
                    if (a2 != null) {
                        String string2 = bundle.getString("google.c.a.c_id");
                        B2 b2 = (B2) a2;
                        if (!AbstractC1327gp0.c.contains("fcm")) {
                            Wp0 wp0 = (Wp0) b2.a.m;
                            wp0.a(new Fp0(wp0, string2, 0));
                        }
                        Bundle bundle2 = new Bundle();
                        bundle2.putString("source", "Firebase");
                        bundle2.putString("medium", "notification");
                        bundle2.putString("campaign", string2);
                        b2.a("fcm", "_cmp", bundle2);
                    }
                } else {
                    Log.isLoggable("FirebaseMessaging", 3);
                }
            }
            As0.L("_no", bundle);
        }
    }

    /* 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 add '--show-bad-code' argument
    */
    public void j(o.Ep0 r9, android.os.Bundle r10) {
        /*
            r8 = this;
            java.lang.Object r0 = r8.m
            r1 = r0
            o.Xs0 r1 = (o.Xs0) r1
            java.lang.Object r0 = r1.a     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.Kr0 r0 = (o.Kr0) r0     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.Nq0 r2 = r0.f     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.Kr0.l(r2)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.nl r2 = r2.n     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            java.lang.String r3 = "onActivityCreated"
            r2.b(r3)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            android.content.Intent r2 = r9.n     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r2 == 0) goto L97
            android.net.Uri r3 = r2.getData()     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r3 == 0) goto L2e
            boolean r4 = r3.isHierarchical()     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r4 != 0) goto L26
            goto L2e
        L26:
            r5 = r3
            goto L47
        L28:
            r0 = move-exception
            goto Lb9
        L2b:
            r0 = move-exception
            goto La4
        L2e:
            android.os.Bundle r3 = r2.getExtras()     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            r4 = 0
            if (r3 == 0) goto L46
            java.lang.String r5 = "com.android.vending.referral_url"
            java.lang.String r3 = r3.getString(r5)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            boolean r5 = android.text.TextUtils.isEmpty(r3)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r5 != 0) goto L46
            android.net.Uri r3 = android.net.Uri.parse(r3)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            goto L26
        L46:
            r5 = r4
        L47:
            if (r5 == 0) goto L97
            boolean r3 = r5.isHierarchical()     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r3 != 0) goto L50
            goto L97
        L50:
            o.tv0 r3 = r0.i     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.Kr0.j(r3)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            java.lang.String r3 = "android.intent.extra.REFERRER_NAME"
            java.lang.String r2 = r2.getStringExtra(r3)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            java.lang.String r3 = "android-app://com.google.android.googlequicksearchbox/https/www.google.com"
            boolean r3 = r3.equals(r2)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r3 != 0) goto L78
            java.lang.String r3 = "https://www.google.com"
            boolean r3 = r3.equals(r2)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r3 != 0) goto L78
            java.lang.String r3 = "android-app://com.google.appcrawler"
            boolean r2 = r3.equals(r2)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r2 == 0) goto L74
            goto L78
        L74:
            java.lang.String r2 = "auto"
        L76:
            r6 = r2
            goto L7b
        L78:
            java.lang.String r2 = "gs"
            goto L76
        L7b:
            java.lang.String r2 = "referrer"
            java.lang.String r7 = r5.getQueryParameter(r2)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            if (r10 != 0) goto L86
            r2 = 1
        L84:
            r4 = r2
            goto L88
        L86:
            r2 = 0
            goto L84
        L88:
            o.Fr0 r0 = r0.g     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.Kr0.l(r0)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            o.Zq0 r2 = new o.Zq0     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            r3 = r8
            r2.<init>(r3, r4, r5, r6, r7)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            r0.B(r2)     // Catch: java.lang.Throwable -> L28 java.lang.RuntimeException -> L2b
            goto Lb4
        L97:
            java.lang.Object r0 = r1.a
            o.Kr0 r0 = (o.Kr0) r0
        L9b:
            o.pt0 r0 = r0.l
            o.Kr0.k(r0)
            r0.A(r9, r10)
            return
        La4:
            java.lang.Object r2 = r1.a     // Catch: java.lang.Throwable -> L28
            o.Kr0 r2 = (o.Kr0) r2     // Catch: java.lang.Throwable -> L28
            o.Nq0 r2 = r2.f     // Catch: java.lang.Throwable -> L28
            o.Kr0.l(r2)     // Catch: java.lang.Throwable -> L28
            o.nl r2 = r2.f     // Catch: java.lang.Throwable -> L28
            java.lang.String r3 = "Throwable caught in onActivityCreated"
            r2.c(r0, r3)     // Catch: java.lang.Throwable -> L28
        Lb4:
            java.lang.Object r0 = r1.a
            o.Kr0 r0 = (o.Kr0) r0
            goto L9b
        Lb9:
            java.lang.Object r1 = r1.a
            o.Kr0 r1 = (o.Kr0) r1
            o.pt0 r1 = r1.l
            o.Kr0.k(r1)
            r1.A(r9, r10)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0308Lx.j(o.Ep0, android.os.Bundle):void");
    }

    public void k(Ep0 ep0) {
        C2191pt0 c2191pt0 = ((Kr0) ((Xs0) this.m).a).l;
        Kr0.k(c2191pt0);
        synchronized (c2191pt0.l) {
            try {
                if (Objects.equals(c2191pt0.g, ep0)) {
                    c2191pt0.g = null;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (((Kr0) c2191pt0.a).d.G()) {
            c2191pt0.f.remove(Integer.valueOf(ep0.l));
        }
    }

    public void l(Ep0 ep0) {
        Kr0 kr0 = (Kr0) ((Xs0) this.m).a;
        C2191pt0 c2191pt0 = kr0.l;
        Kr0.k(c2191pt0);
        synchronized (c2191pt0.l) {
            c2191pt0.k = false;
            c2191pt0.h = true;
        }
        Kr0 kr02 = (Kr0) c2191pt0.a;
        long jElapsedRealtime = kr02.k.elapsedRealtime();
        if (kr02.d.G()) {
            C1431ht0 c1431ht0X = c2191pt0.x(ep0);
            c2191pt0.d = c2191pt0.c;
            c2191pt0.c = null;
            Fr0 fr0 = kr02.g;
            Kr0.l(fr0);
            fr0.B(new Zb0(c2191pt0, c1431ht0X, jElapsedRealtime));
        } else {
            c2191pt0.c = null;
            Fr0 fr02 = kr02.g;
            Kr0.l(fr02);
            fr02.B(new RunnableC1135ep0(c2191pt0, jElapsedRealtime));
        }
        C2382ru0 c2382ru0 = kr0.h;
        Kr0.k(c2382ru0);
        Kr0 kr03 = (Kr0) c2382ru0.a;
        long jElapsedRealtime2 = kr03.k.elapsedRealtime();
        Fr0 fr03 = kr03.g;
        Kr0.l(fr03);
        fr03.B(new RunnableC1145eu0(c2382ru0, jElapsedRealtime2, 1));
    }

    public void m(Ep0 ep0) {
        Kr0 kr0 = (Kr0) ((Xs0) this.m).a;
        C2382ru0 c2382ru0 = kr0.h;
        Kr0.k(c2382ru0);
        Kr0 kr02 = (Kr0) c2382ru0.a;
        long jElapsedRealtime = kr02.k.elapsedRealtime();
        Fr0 fr0 = kr02.g;
        Kr0.l(fr0);
        fr0.B(new RunnableC1145eu0(c2382ru0, jElapsedRealtime, 0));
        C2191pt0 c2191pt0 = kr0.l;
        Kr0.k(c2191pt0);
        Object obj = c2191pt0.l;
        synchronized (obj) {
            c2191pt0.k = true;
            if (!Objects.equals(ep0, c2191pt0.g)) {
                synchronized (obj) {
                    c2191pt0.g = ep0;
                    c2191pt0.h = false;
                    Kr0 kr03 = (Kr0) c2191pt0.a;
                    if (kr03.d.G()) {
                        c2191pt0.i = null;
                        Fr0 fr02 = kr03.g;
                        Kr0.l(fr02);
                        fr02.B(new RunnableC1811lt0(c2191pt0, 1));
                    }
                }
            }
        }
        Kr0 kr04 = (Kr0) c2191pt0.a;
        if (!kr04.d.G()) {
            c2191pt0.c = c2191pt0.i;
            Fr0 fr03 = kr04.g;
            Kr0.l(fr03);
            fr03.B(new RunnableC1811lt0(c2191pt0, 0));
            return;
        }
        c2191pt0.B(ep0.m, c2191pt0.x(ep0), false);
        C2752vp0 c2752vp0 = ((Kr0) c2191pt0.a).n;
        Kr0.i(c2752vp0);
        Kr0 kr05 = (Kr0) c2752vp0.a;
        long jElapsedRealtime2 = kr05.k.elapsedRealtime();
        Fr0 fr04 = kr05.g;
        Kr0.l(fr04);
        fr04.B(new RunnableC1135ep0(c2752vp0, jElapsedRealtime2));
    }

    public void n(Ep0 ep0, Bundle bundle) {
        C1431ht0 c1431ht0;
        C2191pt0 c2191pt0 = ((Kr0) ((Xs0) this.m).a).l;
        Kr0.k(c2191pt0);
        if (!((Kr0) c2191pt0.a).d.G() || bundle == null || (c1431ht0 = (C1431ht0) c2191pt0.f.get(Integer.valueOf(ep0.l))) == null) {
            return;
        }
        Bundle bundle2 = new Bundle();
        bundle2.putLong("id", c1431ht0.c);
        bundle2.putString("name", c1431ht0.a);
        bundle2.putString("referrer_name", c1431ht0.b);
        bundle.putBundle("com.google.app_measurement.screen_service", bundle2);
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityCreated(Activity activity, Bundle bundle) {
        switch (this.l) {
            case 0:
                Intent intent = activity.getIntent();
                if (intent != null) {
                    if (Build.VERSION.SDK_INT > 25) {
                        a(intent);
                        break;
                    } else {
                        new Handler(Looper.getMainLooper()).post(new O3(11, this, intent));
                        break;
                    }
                }
                break;
            case 1:
                ((Wp0) this.m).a(new Ip0(this, bundle, activity));
                break;
            default:
                j(Ep0.b(activity), bundle);
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityDestroyed(Activity activity) {
        switch (this.l) {
            case 0:
                break;
            case 1:
                ((Wp0) this.m).a(new Tp0(this, activity, 4));
                break;
            default:
                k(Ep0.b(activity));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityPaused(Activity activity) {
        switch (this.l) {
            case 0:
                break;
            case 1:
                ((Wp0) this.m).a(new Tp0(this, activity, 2));
                break;
            default:
                l(Ep0.b(activity));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityResumed(Activity activity) {
        switch (this.l) {
            case 0:
                break;
            case 1:
                ((Wp0) this.m).a(new Tp0(this, activity, 1));
                break;
            default:
                m(Ep0.b(activity));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
        switch (this.l) {
            case 0:
                break;
            case 1:
                BinderC1708kp0 binderC1708kp0 = new BinderC1708kp0();
                ((Wp0) this.m).a(new Ip0(this, activity, binderC1708kp0));
                Bundle bundleC = binderC1708kp0.C(50L);
                if (bundleC != null) {
                    bundle.putAll(bundleC);
                    break;
                }
                break;
            default:
                n(Ep0.b(activity), bundle);
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityStarted(Activity activity) {
        switch (this.l) {
            case 1:
                ((Wp0) this.m).a(new Tp0(this, activity, 0));
                break;
        }
    }

    @Override // android.app.Application.ActivityLifecycleCallbacks
    public final void onActivityStopped(Activity activity) {
        switch (this.l) {
            case 1:
                ((Wp0) this.m).a(new Tp0(this, activity, 3));
                break;
        }
    }

    public C0308Lx() {
        this.l = 0;
        this.m = 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) {
    }
}
