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

import android.content.Context;
import android.view.InputEvent;
import android.view.View;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/* JADX INFO: loaded from: classes2.dex */
public final class zj1 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Object f19289b = new Object();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static zj1 f19290c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final xj1 f19291a;

    public zj1(Context context, a30 a30Var, bk1 bk1Var) {
        vu0 vu0Var = new vu0(14, 0);
        context.getClass();
        vu0Var.f17779c = context;
        a30Var.getClass();
        vu0Var.f17778b = a30Var;
        vu0Var.f17780d = bk1Var;
        vj1.k(Context.class, (Context) vu0Var.f17779c);
        vj1.k(bk1.class, (bk1) vu0Var.f17780d);
        this.f19291a = (xj1) new ek1((ExecutorService) vu0Var.f17778b, (Context) vu0Var.f17779c, (bk1) vu0Var.f17780d).f10828m.zzb();
    }

    public final String a(Context context) {
        String string;
        ku1 ku1Var;
        xj1 xj1Var = this.f19291a;
        tk1 tk1Var = xj1Var.f18455e;
        boolean z10 = xj1Var.f18460j;
        long j10 = xj1Var.f18459i;
        boolean z11 = false;
        if (z10 && System.currentTimeMillis() - j10 <= xj1Var.f18461k) {
            z11 = true;
        }
        jp1 jp1Var = xj1Var.f18454d;
        ip1 ip1VarA = jp1Var.a(3);
        try {
            try {
                try {
                    try {
                        try {
                            ip1VarA.a();
                            el1 el1Var = xj1Var.f18451a;
                            synchronized (el1Var) {
                                ku1Var = el1Var.f10849e;
                                ku1Var.getClass();
                            }
                            string = (String) ih1.e1(ku1Var, new nv(xj1Var, context, 16), zzgzd.f19813a).get(z11 ? xj1Var.f18458h : xj1Var.f18456f, TimeUnit.MILLISECONDS);
                        } catch (TimeoutException unused) {
                            if (z11) {
                                string = ((an1) xj1Var.f18457g.zzb()).a(j10);
                            } else {
                                jp1Var.b(56);
                                string = Integer.toString(17);
                            }
                        }
                    } catch (InterruptedException e10) {
                        Thread.currentThread().interrupt();
                        ip1VarA.b(e10);
                        string = "";
                    }
                } catch (Throwable th) {
                    ip1VarA.b(th);
                    throw th;
                }
            } catch (ExecutionException e11) {
                e = e11;
                Throwable cause = e.getCause();
                if (cause != null) {
                    e = cause;
                }
                ip1VarA.b(e);
                string = Integer.toString(3);
            }
            ip1VarA.c();
            tk1Var.zzb();
            return string;
        } catch (Throwable th2) {
            ip1VarA.c();
            tk1Var.zzb();
            throw th2;
        }
    }

    public final String b(Context context, String str, View view) {
        String string;
        ku1 ku1Var;
        xj1 xj1Var = this.f19291a;
        tk1 tk1Var = xj1Var.f18455e;
        jp1 jp1Var = xj1Var.f18454d;
        ip1 ip1VarA = jp1Var.a(5);
        try {
            try {
                try {
                    try {
                        ip1VarA.a();
                        el1 el1Var = xj1Var.f18451a;
                        synchronized (el1Var) {
                            ku1Var = el1Var.f10849e;
                            ku1Var.getClass();
                        }
                        string = (String) ih1.e1(ku1Var, new w90(xj1Var, context, str, view, null, 9), zzgzd.f19813a).get(xj1Var.f18456f, TimeUnit.MILLISECONDS);
                    } catch (ExecutionException e10) {
                        e = e10;
                        Throwable cause = e.getCause();
                        if (cause != null) {
                            e = cause;
                        }
                        ip1VarA.b(e);
                        string = Integer.toString(3);
                    }
                } catch (InterruptedException e11) {
                    Thread.currentThread().interrupt();
                    ip1VarA.b(e11);
                    string = "";
                }
            } catch (TimeoutException unused) {
                jp1Var.b(58);
                string = Integer.toString(17);
            } catch (Throwable th) {
                ip1VarA.b(th);
                throw th;
            }
            ip1VarA.c();
            tk1Var.zzb();
            return string;
        } catch (Throwable th2) {
            ip1VarA.c();
            tk1Var.zzb();
            throw th2;
        }
    }

    public final void c(InputEvent inputEvent) {
        yl1 yl1Var = this.f19291a.f18452b;
        rl1 rl1Var = (rl1) yl1Var.f18884f.get();
        if (rl1Var == null) {
            yl1Var.f18883e.b(54);
        } else {
            rl1Var.b(inputEvent);
        }
    }
}
