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

import android.content.Context;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.google.ads.mediation.AbstractAdViewAdapter;
import com.google.android.gms.ads.mediation.rtb.RtbAdapter;
import java.util.ArrayList;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public final class ox extends zi implements ex {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final /* synthetic */ int f15189c = 0;

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public String f15191b;

    public ox(RtbAdapter rtbAdapter) {
        super("com.google.android.gms.ads.internal.mediation.client.rtb.IRtbAdapter");
        this.f15191b = "";
        this.f15190a = rtbAdapter;
    }

    public static final Bundle S2(String str) throws RemoteException {
        q7.j.d("Server parameters: ".concat(String.valueOf(str)));
        try {
            Bundle bundle = new Bundle();
            if (str == null) {
                return bundle;
            }
            JSONObject jSONObject = new JSONObject(str);
            Bundle bundle2 = new Bundle();
            Iterator<String> itKeys = jSONObject.keys();
            while (itKeys.hasNext()) {
                String next = itKeys.next();
                bundle2.putString(next, jSONObject.getString(next));
            }
            return bundle2;
        } catch (JSONException unused) {
            throw new RemoteException();
        }
    }

    public static final boolean T2(n7.a4 a4Var) {
        if (a4Var.f30898f) {
            return true;
        }
        q7.e eVar = n7.x.f31085g.f31086a;
        return q7.e.h();
    }

    @Nullable
    private static final String zzy(String str, n7.a4 a4Var) {
        String str2 = a4Var.zzu;
        try {
            return new JSONObject(str).getString("max_ad_content_rating");
        } catch (JSONException unused) {
            return str2;
        }
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0057  */
    @Override // com.google.android.gms.internal.ads.ex
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void A1(k8.a aVar, String str, Bundle bundle, Bundle bundle2, n7.f4 f4Var, gx gxVar) throws RemoteException {
        ru ruVar;
        RtbAdapter rtbAdapter;
        try {
            ruVar = new ru(this, gxVar);
            rtbAdapter = this.f15190a;
            switch (str) {
                case "banner":
                case "interstitial":
                case "rewarded":
                case "rewarded_interstitial":
                case "native":
                case "app_open":
                    s7.j jVar = new s7.j();
                    ArrayList arrayList = new ArrayList();
                    arrayList.add(jVar);
                    rtbAdapter.collectSignals(new t7.a((Context) k8.b.O(aVar), arrayList, bundle, new g7.g(f4Var.f30950e, f4Var.f30947b, f4Var.f30946a)), ruVar);
                    return;
                case "app_open_ad":
                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8792bd)).booleanValue()) {
                        s7.j jVar2 = new s7.j();
                        ArrayList arrayList2 = new ArrayList();
                        arrayList2.add(jVar2);
                        rtbAdapter.collectSignals(new t7.a((Context) k8.b.O(aVar), arrayList2, bundle, new g7.g(f4Var.f30950e, f4Var.f30947b, f4Var.f30946a)), ruVar);
                        return;
                    }
                    throw new IllegalArgumentException("Internal Error");
                default:
                    throw new IllegalArgumentException("Internal Error");
            }
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.collectSignals");
            throw new RemoteException();
        }
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final boolean H0(k8.b bVar) {
        return false;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void L2(String str, String str2, n7.a4 a4Var, k8.a aVar, ww wwVar, cw cwVar, n7.f4 f4Var) throws RemoteException {
        try {
            this.f15190a.loadRtbBannerAd(new s7.h((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), new g7.g(f4Var.f30950e, f4Var.f30947b, f4Var.f30946a), this.f15191b), new hx(this, wwVar, cwVar));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbBannerAd");
            throw new RemoteException();
        }
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void N1(String str, String str2, n7.a4 a4Var, k8.a aVar, cx cxVar, cw cwVar) throws RemoteException {
        try {
            this.f15190a.loadRtbRewardedInterstitialAd(new s7.o((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), this.f15191b), new nx(this, cxVar, cwVar));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbRewardedInterstitialAd");
            throw new RemoteException();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r10v11 */
    /* JADX WARN: Type inference failed for: r10v2, types: [com.google.android.gms.internal.ads.ww] */
    /* JADX WARN: Type inference failed for: r10v5, types: [com.google.android.gms.internal.ads.yw] */
    /* JADX WARN: Type inference failed for: r10v6 */
    /* JADX WARN: Type inference failed for: r10v7, types: [com.google.android.gms.internal.ads.cx] */
    /* JADX WARN: Type inference failed for: r10v8, types: [com.google.android.gms.internal.ads.ax] */
    /* JADX WARN: Type inference failed for: r10v9, types: [com.google.android.gms.internal.ads.ww] */
    /* JADX WARN: Type inference failed for: r11v11 */
    /* JADX WARN: Type inference failed for: r11v12, types: [com.google.android.gms.internal.ads.uw] */
    /* JADX WARN: Type inference failed for: r11v13 */
    /* JADX WARN: Type inference failed for: r11v14 */
    /* JADX WARN: Type inference failed for: r11v2, types: [com.google.android.gms.internal.ads.gx] */
    /* JADX WARN: Type inference failed for: r11v3 */
    /* JADX WARN: Type inference failed for: r18v0, types: [com.google.android.gms.internal.ads.cx] */
    /* JADX WARN: Type inference failed for: r18v1, types: [com.google.android.gms.internal.ads.ax] */
    /* JADX WARN: Type inference failed for: r21v0, types: [com.google.android.gms.internal.ads.ex, com.google.android.gms.internal.ads.ox] */
    @Override // com.google.android.gms.internal.ads.zi
    public final boolean Q2(int i10, Parcel parcel, Parcel parcel2) throws RemoteException {
        ?? fxVar;
        ?? xwVar;
        ?? twVar;
        Object vwVar = null;
        if (i10 == 1) {
            k8.a aVarM = k8.b.M(parcel.readStrongBinder());
            String string = parcel.readString();
            Parcelable.Creator creator = Bundle.CREATOR;
            Bundle bundle = (Bundle) aj.a(parcel, creator);
            Bundle bundle2 = (Bundle) aj.a(parcel, creator);
            n7.f4 f4Var = (n7.f4) aj.a(parcel, n7.f4.CREATOR);
            IBinder strongBinder = parcel.readStrongBinder();
            if (strongBinder == null) {
                fxVar = vwVar;
            } else {
                Object objQueryLocalInterface = strongBinder.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.ISignalsCallback");
                if (objQueryLocalInterface instanceof gx) {
                    vwVar = (gx) objQueryLocalInterface;
                    fxVar = vwVar;
                } else {
                    fxVar = new fx(strongBinder, "com.google.android.gms.ads.internal.mediation.client.rtb.ISignalsCallback", 0);
                }
            }
            aj.e(parcel);
            A1(aVarM, string, bundle, bundle2, f4Var, fxVar);
            parcel2.writeNoException();
            return true;
        }
        if (i10 == 2) {
            zzf();
            throw null;
        }
        if (i10 == 3) {
            zzg();
            throw null;
        }
        if (i10 == 5) {
            n7.p2 p2VarZzh = zzh();
            parcel2.writeNoException();
            aj.d(parcel2, p2VarZzh);
            return true;
        }
        if (i10 == 10) {
            k8.b.M(parcel.readStrongBinder());
            aj.e(parcel);
            parcel2.writeNoException();
            return true;
        }
        if (i10 == 11) {
            parcel.createStringArray();
            aj.e(parcel);
            parcel2.writeNoException();
            return true;
        }
        switch (i10) {
            case 13:
                String string2 = parcel.readString();
                String string3 = parcel.readString();
                n7.a4 a4Var = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM2 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder2 = parcel.readStrongBinder();
                if (strongBinder2 != null) {
                    Object objQueryLocalInterface2 = strongBinder2.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.IBannerCallback");
                    vwVar = objQueryLocalInterface2 instanceof ww ? (ww) objQueryLocalInterface2 : new vw(strongBinder2);
                }
                ?? r10 = vwVar;
                cw cwVarR2 = bw.R2(parcel.readStrongBinder());
                n7.f4 f4Var2 = (n7.f4) aj.a(parcel, n7.f4.CREATOR);
                aj.e(parcel);
                L2(string2, string3, a4Var, aVarM2, r10, cwVarR2, f4Var2);
                parcel2.writeNoException();
                return true;
            case 14:
                String string4 = parcel.readString();
                String string5 = parcel.readString();
                n7.a4 a4Var2 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM3 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder3 = parcel.readStrongBinder();
                if (strongBinder3 == null) {
                    xwVar = vwVar;
                } else {
                    Object objQueryLocalInterface3 = strongBinder3.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.IInterstitialCallback");
                    if (objQueryLocalInterface3 instanceof yw) {
                        vwVar = (yw) objQueryLocalInterface3;
                        xwVar = vwVar;
                    } else {
                        xwVar = new xw(strongBinder3, "com.google.android.gms.ads.internal.mediation.client.rtb.IInterstitialCallback", 0);
                    }
                }
                cw cwVarR22 = bw.R2(parcel.readStrongBinder());
                aj.e(parcel);
                Y(string4, string5, a4Var2, aVarM3, xwVar, cwVarR22);
                parcel2.writeNoException();
                return true;
            case 15:
                k8.b.M(parcel.readStrongBinder());
                aj.e(parcel);
                parcel2.writeNoException();
                parcel2.writeInt(0);
                return true;
            case 16:
                String string6 = parcel.readString();
                String string7 = parcel.readString();
                n7.a4 a4Var3 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM4 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder4 = parcel.readStrongBinder();
                if (strongBinder4 != null) {
                    Object objQueryLocalInterface4 = strongBinder4.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.IRewardedCallback");
                    vwVar = objQueryLocalInterface4 instanceof cx ? (cx) objQueryLocalInterface4 : new bx(strongBinder4);
                }
                ?? r102 = vwVar;
                cw cwVarR23 = bw.R2(parcel.readStrongBinder());
                aj.e(parcel);
                g0(string6, string7, a4Var3, aVarM4, r102, cwVarR23);
                parcel2.writeNoException();
                return true;
            case 17:
                k8.b.M(parcel.readStrongBinder());
                aj.e(parcel);
                parcel2.writeNoException();
                parcel2.writeInt(0);
                return true;
            case 18:
                String string8 = parcel.readString();
                String string9 = parcel.readString();
                n7.a4 a4Var4 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM5 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder5 = parcel.readStrongBinder();
                if (strongBinder5 != null) {
                    Object objQueryLocalInterface5 = strongBinder5.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.INativeCallback");
                    vwVar = objQueryLocalInterface5 instanceof ax ? (ax) objQueryLocalInterface5 : new zw(strongBinder5);
                }
                ?? r103 = vwVar;
                cw cwVarR24 = bw.R2(parcel.readStrongBinder());
                aj.e(parcel);
                v0(string8, string9, a4Var4, aVarM5, r103, cwVarR24, null);
                parcel2.writeNoException();
                return true;
            case 19:
                String string10 = parcel.readString();
                aj.e(parcel);
                this.f15191b = string10;
                parcel2.writeNoException();
                return true;
            case 20:
                String string11 = parcel.readString();
                String string12 = parcel.readString();
                n7.a4 a4Var5 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM6 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder6 = parcel.readStrongBinder();
                if (strongBinder6 != null) {
                    Object objQueryLocalInterface6 = strongBinder6.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.IRewardedCallback");
                    vwVar = objQueryLocalInterface6 instanceof cx ? (cx) objQueryLocalInterface6 : new bx(strongBinder6);
                }
                ?? r18 = vwVar;
                cw cwVarR25 = bw.R2(parcel.readStrongBinder());
                aj.e(parcel);
                N1(string11, string12, a4Var5, aVarM6, r18, cwVarR25);
                parcel2.writeNoException();
                return true;
            case 21:
                String string13 = parcel.readString();
                String string14 = parcel.readString();
                n7.a4 a4Var6 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM7 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder7 = parcel.readStrongBinder();
                if (strongBinder7 != null) {
                    Object objQueryLocalInterface7 = strongBinder7.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.IBannerCallback");
                    vwVar = objQueryLocalInterface7 instanceof ww ? (ww) objQueryLocalInterface7 : new vw(strongBinder7);
                }
                ?? r104 = vwVar;
                cw cwVarR26 = bw.R2(parcel.readStrongBinder());
                n7.f4 f4Var3 = (n7.f4) aj.a(parcel, n7.f4.CREATOR);
                aj.e(parcel);
                g2(string13, string14, a4Var6, aVarM7, r104, cwVarR26, f4Var3);
                parcel2.writeNoException();
                break;
            case 22:
                String string15 = parcel.readString();
                String string16 = parcel.readString();
                n7.a4 a4Var7 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM8 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder8 = parcel.readStrongBinder();
                if (strongBinder8 != null) {
                    Object objQueryLocalInterface8 = strongBinder8.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.INativeCallback");
                    vwVar = objQueryLocalInterface8 instanceof ax ? (ax) objQueryLocalInterface8 : new zw(strongBinder8);
                }
                ?? r182 = vwVar;
                cw cwVarR27 = bw.R2(parcel.readStrongBinder());
                kq kqVar = (kq) aj.a(parcel, kq.CREATOR);
                aj.e(parcel);
                v0(string15, string16, a4Var7, aVarM8, r182, cwVarR27, kqVar);
                parcel2.writeNoException();
                return true;
            case 23:
                String string17 = parcel.readString();
                String string18 = parcel.readString();
                n7.a4 a4Var8 = (n7.a4) aj.a(parcel, n7.a4.CREATOR);
                k8.a aVarM9 = k8.b.M(parcel.readStrongBinder());
                IBinder strongBinder9 = parcel.readStrongBinder();
                if (strongBinder9 != null) {
                    Object objQueryLocalInterface9 = strongBinder9.queryLocalInterface("com.google.android.gms.ads.internal.mediation.client.rtb.IAppOpenCallback");
                    if (!(objQueryLocalInterface9 instanceof uw)) {
                        twVar = new tw(strongBinder9, "com.google.android.gms.ads.internal.mediation.client.rtb.IAppOpenCallback", 0);
                        cw cwVarR28 = bw.R2(parcel.readStrongBinder());
                        aj.e(parcel);
                        R0(string17, string18, a4Var8, aVarM9, twVar, cwVarR28);
                        parcel2.writeNoException();
                    } else {
                        vwVar = (uw) objQueryLocalInterface9;
                        twVar = vwVar;
                        cw cwVarR282 = bw.R2(parcel.readStrongBinder());
                        aj.e(parcel);
                        R0(string17, string18, a4Var8, aVarM9, twVar, cwVarR282);
                        parcel2.writeNoException();
                    }
                } else {
                    twVar = vwVar;
                    cw cwVarR2822 = bw.R2(parcel.readStrongBinder());
                    aj.e(parcel);
                    R0(string17, string18, a4Var8, aVarM9, twVar, cwVarR2822);
                    parcel2.writeNoException();
                }
                break;
            case 24:
                k8.b.M(parcel.readStrongBinder());
                aj.e(parcel);
                parcel2.writeNoException();
                parcel2.writeInt(0);
                break;
            default:
                return false;
        }
        return true;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void R0(String str, String str2, n7.a4 a4Var, k8.a aVar, uw uwVar, cw cwVar) throws RemoteException {
        try {
            this.f15190a.loadRtbAppOpenAd(new s7.g((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), this.f15191b), new mx(this, uwVar, cwVar));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbAppOpenAd");
            throw new RemoteException();
        }
    }

    public final Bundle R2(n7.a4 a4Var) {
        Bundle bundle;
        Bundle bundle2 = a4Var.f30905m;
        return (bundle2 == null || (bundle = bundle2.getBundle(this.f15190a.getClass().getName())) == null) ? new Bundle() : bundle;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void Y(String str, String str2, n7.a4 a4Var, k8.a aVar, yw ywVar, cw cwVar) throws RemoteException {
        try {
            this.f15190a.loadRtbInterstitialAd(new s7.k((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), this.f15191b), new jx(this, ywVar, cwVar));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbInterstitialAd");
            throw new RemoteException();
        }
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void g0(String str, String str2, n7.a4 a4Var, k8.a aVar, cx cxVar, cw cwVar) throws RemoteException {
        try {
            this.f15190a.loadRtbRewardedAd(new s7.o((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), this.f15191b), new nx(this, cxVar, cwVar));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbRewardedAd");
            throw new RemoteException();
        }
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void g2(String str, String str2, n7.a4 a4Var, k8.a aVar, ww wwVar, cw cwVar, n7.f4 f4Var) throws RemoteException {
        try {
            ix ixVar = new ix(this, wwVar, cwVar);
            RtbAdapter rtbAdapter = this.f15190a;
            S2(str2);
            R2(a4Var);
            T2(a4Var);
            zzy(str2, a4Var);
            new g7.g(f4Var.f30950e, f4Var.f30947b, f4Var.f30946a);
            ixVar.b(new g7.a(7, rtbAdapter.getClass().getSimpleName().concat(" does not support interscroller ads."), "com.google.android.gms.ads", null));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbInterscrollerAd");
            throw new RemoteException();
        }
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void p1(String str, String str2, n7.a4 a4Var, k8.b bVar, fy0 fy0Var, cw cwVar) throws RemoteException {
        v0(str, str2, a4Var, bVar, fy0Var, cwVar, null);
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final boolean r(k8.a aVar) {
        return false;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void v0(String str, String str2, n7.a4 a4Var, k8.a aVar, ax axVar, cw cwVar, kq kqVar) throws RemoteException {
        RtbAdapter rtbAdapter = this.f15190a;
        try {
            rtbAdapter.loadRtbNativeAdMapper(new s7.m((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), this.f15191b, kqVar), new kx(this, axVar, cwVar));
        } catch (Throwable th) {
            ni.n(aVar, th, "adapter.loadRtbNativeAdMapper");
            String message = th.getMessage();
            if (TextUtils.isEmpty(message) || !message.equals("Method is not found")) {
                throw new RemoteException();
            }
            try {
                rtbAdapter.loadRtbNativeAd(new s7.m((Context) k8.b.O(aVar), str, S2(str2), R2(a4Var), T2(a4Var), a4Var.f30903k, a4Var.f30899g, a4Var.V, zzy(str2, a4Var), this.f15191b, kqVar), new lx(this, axVar, cwVar));
            } catch (Throwable th2) {
                ni.n(aVar, th2, "adapter.loadRtbNativeAd");
                throw new RemoteException();
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final boolean v1(k8.b bVar) {
        return false;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final px zzf() {
        this.f15190a.getVersionInfo();
        throw null;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final px zzg() {
        this.f15190a.getSDKVersionInfo();
        throw null;
    }

    @Override // com.google.android.gms.internal.ads.ex
    @Nullable
    public final n7.p2 zzh() {
        Object obj = this.f15190a;
        if (obj instanceof AbstractAdViewAdapter) {
            try {
                return ((AbstractAdViewAdapter) obj).getVideoController();
            } catch (Throwable unused) {
            }
        }
        return null;
    }

    @Override // com.google.android.gms.internal.ads.ex
    public final void zzo(String str) {
        this.f15191b = str;
    }
}
