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

import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Pair;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class q1 implements Runnable {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ g2 f21869b;

    public /* synthetic */ q1(g2 g2Var, int i10) {
        this.f21868a = i10;
        this.f21869b = g2Var;
    }

    @Override // java.lang.Runnable
    public final void run() {
        g2 g2Var = this.f21869b;
        switch (this.f21868a) {
            case 0:
                g2Var.X();
                break;
            case 1:
                g2Var.w();
                if (g2Var.u().f22003u.b()) {
                    g2Var.zzj().f21841m.c("Deferred Deep Link already retrieved. Not fetching again.");
                } else {
                    long jA = g2Var.u().f22004v.a();
                    g2Var.u().f22004v.b(1 + jA);
                    if (jA >= 5) {
                        g2Var.zzj().f21837i.c("Permanently failed to retrieve Deferred Deep Link. Reached maximum retries.");
                        g2Var.u().f22003u.a(true);
                    } else {
                        if (g2Var.f21634s == null) {
                            g2Var.f21634s = new m2(g2Var, (m1) g2Var.f31277a, 2);
                        }
                        g2Var.f21634s.b(0L);
                    }
                }
                break;
            case 2:
                p1 p1Var = g2Var.f21632q;
                m1 m1Var = p1Var.f21843a;
                j1 j1Var = m1Var.f21758j;
                m1.d(j1Var);
                j1Var.w();
                if (p1Var.c()) {
                    boolean zD = p1Var.d();
                    g2 g2Var2 = m1Var.f21764p;
                    y0 y0Var = m1Var.f21756h;
                    if (zD) {
                        m1.c(y0Var);
                        y0Var.f22006x.g(null);
                        Bundle bundle = new Bundle();
                        bundle.putString("source", "(not set)");
                        bundle.putString("medium", "(not set)");
                        bundle.putString("_cis", "intent");
                        bundle.putLong("_cc", 1L);
                        m1.b(g2Var2);
                        g2Var2.d0("auto", "_cmpx", bundle);
                    } else {
                        m1.c(y0Var);
                        androidx.room.x xVar = y0Var.f22006x;
                        String strF = xVar.f();
                        if (TextUtils.isEmpty(strF)) {
                            p0 p0Var = m1Var.f21757i;
                            m1.d(p0Var);
                            p0Var.f21835g.c("Cache still valid but referrer not found");
                        } else {
                            long jA2 = ((y0Var.f22007y.a() / 3600000) - 1) * 3600000;
                            Uri uri = Uri.parse(strF);
                            Bundle bundle2 = new Bundle();
                            Pair pair = new Pair(uri.getPath(), bundle2);
                            for (String str : uri.getQueryParameterNames()) {
                                bundle2.putString(str, uri.getQueryParameter(str));
                            }
                            ((Bundle) pair.second).putLong("_cc", jA2);
                            Object obj = pair.first;
                            String str2 = obj == null ? "app" : (String) obj;
                            m1.b(g2Var2);
                            g2Var2.d0(str2, "_cmp", (Bundle) pair.second);
                        }
                        xVar.g(null);
                    }
                    m1.c(y0Var);
                    y0Var.f22007y.b(0L);
                    break;
                }
                break;
            default:
                g2Var.X();
                break;
        }
    }
}
