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

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public final class yx extends zv1 implements ys {
    public int Q;
    public int R;
    public int S;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final x50 f18995d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final WindowManager f18997f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final qn f18998g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public DisplayMetrics f18999h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public float f19000i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f19001j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f19002k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f19003l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f19004m;

    public yx(x50 x50Var, Context context, qn qnVar) {
        super(x50Var, "", 11);
        this.f19001j = -1;
        this.f19002k = -1;
        this.f19004m = -1;
        this.Q = -1;
        this.R = -1;
        this.S = -1;
        this.f18995d = x50Var;
        this.f18996e = context;
        this.f18998g = qnVar;
        this.f18997f = (WindowManager) context.getSystemService("window");
    }

    @Override // com.google.android.gms.internal.ads.ys
    public final void a(Object obj, Map map) {
        JSONObject jSONObjectPut;
        this.f18999h = new DisplayMetrics();
        Display defaultDisplay = this.f18997f.getDefaultDisplay();
        defaultDisplay.getMetrics(this.f18999h);
        this.f19000i = this.f18999h.density;
        this.f19003l = defaultDisplay.getRotation();
        q7.e eVar = n7.x.f31085g.f31086a;
        this.f19001j = Math.round(r10.widthPixels / this.f18999h.density);
        this.f19002k = Math.round(r10.heightPixels / this.f18999h.density);
        x50 x50Var = this.f18995d;
        Activity activityZzj = x50Var.zzj();
        if (activityZzj == null || activityZzj.getWindow() == null) {
            this.f19004m = this.f19001j;
            this.Q = this.f19002k;
        } else {
            p7.r0 r0Var = m7.n.C.f30464c;
            int[] iArrM = p7.r0.m(activityZzj);
            this.f19004m = Math.round(iArrM[0] / this.f18999h.density);
            this.Q = Math.round(iArrM[1] / this.f18999h.density);
        }
        if (x50Var.zzN().b()) {
            this.R = this.f19001j;
            this.S = this.f19002k;
        } else {
            x50Var.measure(0, 0);
        }
        i(this.f19001j, this.f19002k, this.f19004m, this.Q, this.f19003l, this.f19000i);
        xx xxVar = new xx();
        Intent intent = new Intent("android.intent.action.DIAL");
        intent.setData(Uri.parse("tel:"));
        qn qnVar = this.f18998g;
        xxVar.f18604b = qnVar.b(intent);
        Intent intent2 = new Intent("android.intent.action.VIEW");
        intent2.setData(Uri.parse("sms:"));
        xxVar.f18603a = qnVar.b(intent2);
        xxVar.f18605c = qnVar.b(new Intent("android.intent.action.INSERT").setType("vnd.android.cursor.dir/event"));
        boolean zA = qnVar.a();
        boolean z10 = xxVar.f18603a;
        try {
            jSONObjectPut = new JSONObject().put("sms", z10).put("tel", xxVar.f18604b).put("calendar", xxVar.f18605c).put("storePicture", zA).put("inlineVideo", true);
        } catch (JSONException unused) {
            jSONObjectPut = null;
        }
        x50Var.e("onDeviceFeaturesReceived", jSONObjectPut);
        int[] iArr = new int[2];
        x50Var.getLocationOnScreen(iArr);
        n7.x xVar = n7.x.f31085g;
        q7.e eVar2 = xVar.f31086a;
        int i10 = iArr[0];
        Context context = this.f18996e;
        j(eVar2.b(context, i10), xVar.f31086a.b(context, iArr[1]));
        if (q7.j.f(2)) {
            q7.j.c("Dispatching Ready Event.");
        }
        try {
            ((x50) this.f19404b).e("onReadyEventReceived", new JSONObject().put("js", x50Var.zzs().f32212a));
        } catch (JSONException unused2) {
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0061 A[PHI: r4
      0x0061: PHI (r4v2 int) = (r4v1 int), (r4v6 int) binds: [B:11:0x0040, B:17:0x0052] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void j(int i10, int i11) {
        int i12;
        Context context = this.f18996e;
        int i13 = 0;
        if (context instanceof Activity) {
            p7.r0 r0Var = m7.n.C.f30464c;
            i12 = p7.r0.n((Activity) context)[0];
        } else {
            i12 = 0;
        }
        x50 x50Var = this.f18995d;
        if (x50Var.zzN() == null || !x50Var.zzN().b()) {
            int width = x50Var.getWidth();
            int height = x50Var.getHeight();
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.f9045r0)).booleanValue()) {
                if (width == 0) {
                    width = x50Var.zzN() != null ? x50Var.zzN().f10257c : 0;
                }
                if (height == 0) {
                    if (x50Var.zzN() != null) {
                        i13 = x50Var.zzN().f10256b;
                    }
                }
                n7.x xVar = n7.x.f31085g;
                this.R = xVar.f31086a.b(context, width);
                this.S = xVar.f31086a.b(context, i13);
            } else {
                i13 = height;
                n7.x xVar2 = n7.x.f31085g;
                this.R = xVar2.f31086a.b(context, width);
                this.S = xVar2.f31086a.b(context, i13);
            }
        }
        try {
            ((x50) this.f19404b).e("onDefaultPositionReceived", new JSONObject().put("x", i10).put("y", i11 - i12).put("width", this.R).put("height", this.S));
        } catch (JSONException unused) {
        }
        ux uxVar = x50Var.zzP().Y;
        if (uxVar != null) {
            uxVar.f17412f = i10;
            uxVar.f17413g = i11;
        }
    }
}
