package com.google.android.gms.ads; import android.os.Bundle; import android.os.RemoteException; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.google.android.gms.ads.internal.client.zzbc; import com.google.android.gms.ads.internal.client.zzdy; import com.google.android.gms.ads.internal.client.zzw; import com.google.android.gms.ads.internal.util.client.zzo; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class ResponseInfo { @Nullable private final zzdy zza; private final List zzb = new ArrayList(); @Nullable private AdapterResponseInfo zzc; private ResponseInfo(@Nullable zzdy zzdyVar) { this.zza = zzdyVar; if (zzdyVar != null) { try { List zzj = zzdyVar.zzj(); if (zzj != null) { Iterator it = zzj.iterator(); while (it.hasNext()) { AdapterResponseInfo zza = AdapterResponseInfo.zza((zzw) it.next()); if (zza != null) { this.zzb.add(zza); } } } } catch (RemoteException e) { zzo.zzh("Could not forward getAdapterResponseInfo to ResponseInfo.", e); } } zzdy zzdyVar2 = this.zza; if (zzdyVar2 == null) { return; } try { zzw zzf = zzdyVar2.zzf(); if (zzf != null) { this.zzc = AdapterResponseInfo.zza(zzf); } } catch (RemoteException e2) { zzo.zzh("Could not forward getLoadedAdapterResponse to ResponseInfo.", e2); } } @Nullable public static ResponseInfo zza(@Nullable zzdy zzdyVar) { if (zzdyVar != null) { return new ResponseInfo(zzdyVar); } return null; } @NonNull public static ResponseInfo zzb(@Nullable zzdy zzdyVar) { return new ResponseInfo(zzdyVar); } @NonNull public List getAdapterResponses() { return this.zzb; } @Nullable public AdapterResponseInfo getLoadedAdapterResponseInfo() { return this.zzc; } @Nullable public String getMediationAdapterClassName() { try { zzdy zzdyVar = this.zza; if (zzdyVar != null) { return zzdyVar.zzg(); } return null; } catch (RemoteException e) { zzo.zzh("Could not forward getMediationAdapterClassName to ResponseInfo.", e); return null; } } @NonNull public Bundle getResponseExtras() { try { zzdy zzdyVar = this.zza; if (zzdyVar != null) { return zzdyVar.zze(); } } catch (RemoteException e) { zzo.zzh("Could not forward getResponseExtras to ResponseInfo.", e); } return new Bundle(); } @Nullable public String getResponseId() { try { zzdy zzdyVar = this.zza; if (zzdyVar != null) { return zzdyVar.zzi(); } return null; } catch (RemoteException e) { zzo.zzh("Could not forward getResponseId to ResponseInfo.", e); return null; } } @NonNull public String toString() { try { return zzd().toString(2); } catch (JSONException unused) { return "Error forming toString output."; } } @Nullable @VisibleForTesting public final zzdy zzc() { return this.zza; } @NonNull public final JSONObject zzd() throws JSONException { JSONObject jSONObject = new JSONObject(); String responseId = getResponseId(); if (responseId == null) { jSONObject.put("Response ID", "null"); } else { jSONObject.put("Response ID", responseId); } String mediationAdapterClassName = getMediationAdapterClassName(); if (mediationAdapterClassName == null) { jSONObject.put("Mediation Adapter Class Name", "null"); } else { jSONObject.put("Mediation Adapter Class Name", mediationAdapterClassName); } JSONArray jSONArray = new JSONArray(); Iterator it = this.zzb.iterator(); while (it.hasNext()) { jSONArray.put(((AdapterResponseInfo) it.next()).zzb()); } jSONObject.put("Adapter Responses", jSONArray); AdapterResponseInfo adapterResponseInfo = this.zzc; if (adapterResponseInfo != null) { jSONObject.put("Loaded Adapter Response", adapterResponseInfo.zzb()); } Bundle responseExtras = getResponseExtras(); if (responseExtras != null) { jSONObject.put("Response Extras", zzbc.zzb().zzi(responseExtras)); } return jSONObject; } }