package M;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.WindowInsets;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public abstract class T extends a0 {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static boolean f4083g = false;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static Method f4084h;
    public static Class i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static Field f4085j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static Field f4086k;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public F.b f4088d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public F.b f4089e;

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

    public T(b0 b0Var, WindowInsets windowInsets) {
        super(b0Var);
        this.f4088d = null;
        this.f4087c = windowInsets;
    }

    private F.b p(View view) {
        if (Build.VERSION.SDK_INT >= 30) {
            throw new UnsupportedOperationException("getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead.");
        }
        if (!f4083g) {
            q();
        }
        Method method = f4084h;
        if (method != null && i != null && f4085j != null) {
            try {
                Object objInvoke = method.invoke(view, null);
                if (objInvoke == null) {
                    Log.w("WindowInsetsCompat", "Failed to get visible insets. getViewRootImpl() returned null from the provided view. This means that the view is either not attached or the method has been overridden", new NullPointerException());
                    return null;
                }
                Rect rect = (Rect) f4085j.get(f4086k.get(objInvoke));
                if (rect != null) {
                    return F.b.a(rect.left, rect.top, rect.right, rect.bottom);
                }
            } catch (ReflectiveOperationException e8) {
                Log.e("WindowInsetsCompat", "Failed to get visible insets. (Reflection error). " + e8.getMessage(), e8);
            }
        }
        return null;
    }

    @SuppressLint({"PrivateApi"})
    private static void q() {
        try {
            f4084h = View.class.getDeclaredMethod("getViewRootImpl", null);
            Class<?> cls = Class.forName("android.view.View$AttachInfo");
            i = cls;
            f4085j = cls.getDeclaredField("mVisibleInsets");
            f4086k = Class.forName("android.view.ViewRootImpl").getDeclaredField("mAttachInfo");
            f4085j.setAccessible(true);
            f4086k.setAccessible(true);
        } catch (ReflectiveOperationException e8) {
            Log.e("WindowInsetsCompat", "Failed to get visible insets. (Reflection error). " + e8.getMessage(), e8);
        }
        f4083g = true;
    }

    public static boolean s(int i5, int i8) {
        return (i5 & 6) == (i8 & 6);
    }

    @Override // M.a0
    public void d(View view) {
        F.b bVarP = p(view);
        if (bVarP == null) {
            bVarP = F.b.f2228e;
        }
        r(bVarP);
    }

    @Override // M.a0
    public boolean equals(Object obj) {
        if (!super.equals(obj)) {
            return false;
        }
        T t6 = (T) obj;
        return Objects.equals(this.f4089e, t6.f4089e) && s(this.f4090f, t6.f4090f);
    }

    @Override // M.a0
    public final F.b h() {
        if (this.f4088d == null) {
            WindowInsets windowInsets = this.f4087c;
            this.f4088d = F.b.a(windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(), windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
        }
        return this.f4088d;
    }

    @Override // M.a0
    public b0 i(int i5, int i8, int i9, int i10) {
        b0 b0VarD = b0.d(this.f4087c, null);
        int i11 = Build.VERSION.SDK_INT;
        S q8 = i11 >= 34 ? new Q(b0VarD) : i11 >= 30 ? new P(b0VarD) : i11 >= 29 ? new O(b0VarD) : new N(b0VarD);
        q8.d(b0.b(h(), i5, i8, i9, i10));
        q8.c(b0.b(g(), i5, i8, i9, i10));
        return q8.b();
    }

    @Override // M.a0
    public boolean k() {
        return this.f4087c.isRound();
    }

    @Override // M.a0
    public void o(int i5) {
        this.f4090f = i5;
    }

    public void r(F.b bVar) {
        this.f4089e = bVar;
    }

    @Override // M.a0
    public void l(F.b[] bVarArr) {
    }

    @Override // M.a0
    public void m(b0 b0Var) {
    }
}
