package androidx.core.view;

import android.graphics.Rect;
import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

/* JADX INFO: loaded from: classes.dex */
public final class s2 extends v2 {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static Field f1821e = null;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static Constructor f1823g = null;

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public j0.d f1826d;

    public s2() {
        this.f1825c = createWindowInsetsInstance();
    }

    @Nullable
    private static WindowInsets createWindowInsetsInstance() {
        if (!f1822f) {
            try {
                f1821e = WindowInsets.class.getDeclaredField("CONSUMED");
            } catch (ReflectiveOperationException unused) {
            }
            f1822f = true;
        }
        Field field = f1821e;
        if (field != null) {
            try {
                WindowInsets windowInsets = (WindowInsets) field.get(null);
                if (windowInsets != null) {
                    return new WindowInsets(windowInsets);
                }
            } catch (ReflectiveOperationException unused2) {
            }
        }
        if (!f1824h) {
            try {
                f1823g = WindowInsets.class.getConstructor(Rect.class);
            } catch (ReflectiveOperationException unused3) {
            }
            f1824h = true;
        }
        Constructor constructor = f1823g;
        if (constructor != null) {
            try {
                return (WindowInsets) constructor.newInstance(new Rect());
            } catch (ReflectiveOperationException unused4) {
            }
        }
        return null;
    }

    @Override // androidx.core.view.v2
    @NonNull
    public f3 b() {
        a();
        f3 windowInsetsCompat = f3.toWindowInsetsCompat(this.f1825c, null);
        windowInsetsCompat.f1747a.o(this.f1841b);
        windowInsetsCompat.setStableInsets(this.f1826d);
        return windowInsetsCompat;
    }

    @Override // androidx.core.view.v2
    public void f(@NonNull j0.d dVar) {
        WindowInsets windowInsets = this.f1825c;
        if (windowInsets != null) {
            this.f1825c = windowInsets.replaceSystemWindowInsets(dVar.f28502a, dVar.f28503b, dVar.f28504c, dVar.f28505d);
        }
    }

    @Override // androidx.core.view.v2
    public void setStableInsets(@Nullable j0.d dVar) {
        this.f1826d = dVar;
    }

    public s2(@NonNull f3 f3Var) {
        super(f3Var);
        this.f1825c = f3Var.toWindowInsets();
    }
}
