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

import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
import androidx.annotation.Nullable;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.PatternSyntaxException;
import org.json.JSONException;
import org.json.JSONObject;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final q7.a f11384b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Executor f11385c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final AtomicReference f11386d = new AtomicReference("");

    public ft0(Context context, q7.a aVar, a30 a30Var) {
        this.f11383a = context;
        this.f11384b = aVar;
        this.f11385c = a30Var;
    }

    public static final String b(String str) {
        return p7.r0.E(new String(Base64.decode(str, 0)), new String(Base64.decode((String) n7.y.f31093e.f31096c.b(ao.Bf), 10), StandardCharsets.UTF_8));
    }

    public final String a() {
        String name;
        q7.a aVar = this.f11384b;
        String strB = null;
        if (aVar.f32215d) {
            name = c60.class.getName();
        } else {
            try {
                name = (String) new JSONObject(b((String) n7.y.f31093e.f31096c.b(ao.f9191zf))).get(Integer.toString(aVar.f32214c));
            } catch (ClassCastException | IllegalArgumentException | NullPointerException | JSONException e10) {
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.yf)).booleanValue()) {
                    m7.n.C.f30469h.d("SdkIE", e10);
                }
                name = null;
            }
        }
        if (TextUtils.isEmpty(name)) {
            return "2";
        }
        try {
            strB = b((String) n7.y.f31093e.f31096c.b(ao.Af));
        } catch (IllegalArgumentException e11) {
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.yf)).booleanValue()) {
                m7.n.C.f30469h.d("SdkIE", e11);
            }
        }
        if (TextUtils.isEmpty(strB)) {
            return "3";
        }
        try {
            for (Method method : this.f11383a.getClassLoader().loadClass(name).getDeclaredMethods()) {
                if (method.getName().matches(strB)) {
                    return "1";
                }
            }
            return SessionDescription.SUPPORTED_SDP_VERSION;
        } catch (ClassNotFoundException unused) {
            return "4";
        } catch (NoClassDefFoundError unused2) {
            return "6";
        } catch (SecurityException unused3) {
            return "7";
        } catch (PatternSyntaxException unused4) {
            return "5";
        }
    }

    @Nullable
    public final String zza() {
        tn tnVar = ao.f9159xf;
        n7.y yVar = n7.y.f31093e;
        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
            tn tnVar2 = ao.f9191zf;
            yn ynVar = yVar.f31096c;
            if (!((String) ynVar.b(tnVar2)).isEmpty() && !((String) ynVar.b(ao.Af)).isEmpty() && !((String) ynVar.b(ao.Bf)).isEmpty()) {
                String str = (String) this.f11386d.get();
                if (!str.isEmpty()) {
                    return str;
                }
                this.f11385c.execute(new z80(this, 15));
                return null;
            }
        }
        return null;
    }
}
