package com.google.android.gms.internal.ads; import android.content.Context; import android.content.res.Resources; import android.graphics.Point; import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.ironsource.v8; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes3.dex */ public final class zzfmg { private static WindowManager zzb; private static final String[] zzc = {"x", "y", "width", "height"}; static float zza = Resources.getSystem().getDisplayMetrics().density; public static JSONObject zza(int i, int i2, int i3, int i4) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("x", i / zza); jSONObject.put("y", i2 / zza); jSONObject.put("width", i3 / zza); jSONObject.put("height", i4 / zza); } catch (JSONException e) { zzfmh.zza("Error with creating viewStateObject", e); } return jSONObject; } public static void zzb(JSONObject jSONObject, String str) { try { jSONObject.put("adSessionId", str); } catch (JSONException e) { zzfmh.zza("Error with setting ad session id", e); } } public static void zzc(JSONObject jSONObject, JSONObject jSONObject2) { try { JSONArray optJSONArray = jSONObject.optJSONArray("childViews"); if (optJSONArray == null) { optJSONArray = new JSONArray(); jSONObject.put("childViews", optJSONArray); } optJSONArray.put(jSONObject2); } catch (JSONException e) { e.printStackTrace(); } } public static void zzd(Context context) { if (context != null) { zza = context.getResources().getDisplayMetrics().density; zzb = (WindowManager) context.getSystemService("window"); } } public static void zze(JSONObject jSONObject, String str, Object obj) { try { jSONObject.put(str, obj); } catch (NullPointerException | JSONException e) { zzfmh.zza("JSONException during JSONObject.put for name [" + str + v8.i.e, e); } } public static void zzf(JSONObject jSONObject) { float f; float f2; if (zzb != null) { Point point = new Point(0, 0); zzb.getDefaultDisplay().getRealSize(point); float f3 = point.x; float f4 = zza; f = f3 / f4; f2 = point.y / f4; } else { f = 0.0f; f2 = 0.0f; } try { jSONObject.put("width", f); jSONObject.put("height", f2); } catch (JSONException e) { e.printStackTrace(); } } public static boolean zzg(@NonNull JSONObject jSONObject, @Nullable JSONObject jSONObject2) { if (jSONObject == null && jSONObject2 == null) { return true; } if (jSONObject != null && jSONObject2 != null) { String[] strArr = zzc; int i = 0; while (true) { if (i < 4) { String str = strArr[i]; if (jSONObject.optDouble(str) != jSONObject2.optDouble(str)) { break; } i++; } else if (jSONObject.optString("adSessionId", "").equals(jSONObject2.optString("adSessionId", "")) && Boolean.valueOf(jSONObject.optBoolean("noOutputDevice")).equals(Boolean.valueOf(jSONObject2.optBoolean("noOutputDevice"))) && Boolean.valueOf(jSONObject.optBoolean("hasWindowFocus")).equals(Boolean.valueOf(jSONObject2.optBoolean("hasWindowFocus")))) { JSONArray optJSONArray = jSONObject.optJSONArray("isFriendlyObstructionFor"); JSONArray optJSONArray2 = jSONObject2.optJSONArray("isFriendlyObstructionFor"); if (optJSONArray != null || optJSONArray2 != null) { if (zzh(optJSONArray, optJSONArray2)) { for (int i2 = 0; i2 < optJSONArray.length(); i2++) { if (!optJSONArray.optString(i2, "").equals(optJSONArray2.optString(i2, ""))) { break; } } } } JSONArray optJSONArray3 = jSONObject.optJSONArray("childViews"); JSONArray optJSONArray4 = jSONObject2.optJSONArray("childViews"); if (optJSONArray3 != null || optJSONArray4 != null) { if (zzh(optJSONArray3, optJSONArray4)) { for (int i3 = 0; i3 < optJSONArray3.length(); i3++) { if (zzg(optJSONArray3.optJSONObject(i3), optJSONArray4.optJSONObject(i3))) { } } } } return true; } } } return false; } private static boolean zzh(JSONArray jSONArray, JSONArray jSONArray2) { if (jSONArray == null && jSONArray2 == null) { return true; } return (jSONArray == null || jSONArray2 == null || jSONArray.length() != jSONArray2.length()) ? false : true; } }