package androidx.core.view;

import android.graphics.Path;
import android.graphics.Rect;
import android.os.Build;
import android.view.DisplayCutout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class r {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final DisplayCutout f1808a;

    public r(@Nullable Rect rect, @Nullable List<Rect> list) {
        this(Build.VERSION.SDK_INT >= 28 ? m.d.d(rect, list) : null);
    }

    private static DisplayCutout constructDisplayCutout(@NonNull j0.d dVar, @Nullable Rect rect, @Nullable Rect rect2, @Nullable Rect rect3, @Nullable Rect rect4, @NonNull j0.d dVar2, @Nullable Path path) {
        int i10 = Build.VERSION.SDK_INT;
        if (i10 >= 33) {
            return q.a(dVar.d(), rect, rect2, rect3, rect4, dVar2.d(), path);
        }
        if (i10 >= 30) {
            return androidx.core.app.c0.a(dVar.d(), rect, rect2, rect3, rect4, dVar2.d());
        }
        if (i10 >= 29) {
            return androidx.core.app.b0.c(dVar.d(), rect, rect2, rect3, rect4);
        }
        if (i10 < 28) {
            return null;
        }
        Rect rect5 = new Rect(dVar.f28502a, dVar.f28503b, dVar.f28504c, dVar.f28505d);
        ArrayList arrayList = new ArrayList();
        if (rect != null) {
            arrayList.add(rect);
        }
        if (rect2 != null) {
            arrayList.add(rect2);
        }
        if (rect3 != null) {
            arrayList.add(rect3);
        }
        if (rect4 != null) {
            arrayList.add(rect4);
        }
        return m.d.d(rect5, arrayList);
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || r.class != obj.getClass()) {
            return false;
        }
        return p0.c.equals(this.f1808a, ((r) obj).f1808a);
    }

    @Nullable
    public Path getCutoutPath() {
        if (Build.VERSION.SDK_INT >= 31) {
            return p.getCutoutPath(this.f1808a);
        }
        return null;
    }

    public final int hashCode() {
        DisplayCutout displayCutout = this.f1808a;
        if (displayCutout == null) {
            return 0;
        }
        return displayCutout.hashCode();
    }

    public final String toString() {
        return "DisplayCutoutCompat{" + this.f1808a + "}";
    }

    public r(@NonNull j0.d dVar, @Nullable Rect rect, @Nullable Rect rect2, @Nullable Rect rect3, @Nullable Rect rect4, @NonNull j0.d dVar2) {
        this(constructDisplayCutout(dVar, rect, rect2, rect3, rect4, dVar2, null));
    }

    public r(@NonNull j0.d dVar, @Nullable Rect rect, @Nullable Rect rect2, @Nullable Rect rect3, @Nullable Rect rect4, @NonNull j0.d dVar2, @Nullable Path path) {
        this(constructDisplayCutout(dVar, rect, rect2, rect3, rect4, dVar2, path));
    }

    public r(DisplayCutout displayCutout) {
        this.f1808a = displayCutout;
    }
}
