package androidx.window.layout;

import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import androidx.window.extensions.WindowExtensionsProvider;
import androidx.window.extensions.core.util.function.Consumer;
import androidx.window.extensions.layout.WindowLayoutComponent;
import e.y;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final y f4479b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final androidx.window.a f4480c;

    public i(ClassLoader classLoader, y yVar) {
        this.f4478a = classLoader;
        this.f4479b = yVar;
        this.f4480c = new androidx.window.a(classLoader);
    }

    public final WindowLayoutComponent a() {
        if (!this.f4480c.a() || !com.bumptech.glide.i.f(new sd.a() { // from class: androidx.window.layout.SafeWindowLayoutComponentProvider$isWindowLayoutProviderValid$1
            {
                super(0);
            }

            @Override // sd.a
            public final Object invoke() throws NoSuchMethodException, ClassNotFoundException {
                Class<?> clsLoadClass = this.this$0.f4480c.f4410a.loadClass("androidx.window.extensions.WindowExtensions");
                nb.g.h(clsLoadClass, "loader.loadClass(WindowE….WINDOW_EXTENSIONS_CLASS)");
                boolean z10 = false;
                Method method = clsLoadClass.getMethod("getWindowLayoutComponent", new Class[0]);
                Class<?> clsLoadClass2 = this.this$0.f4478a.loadClass("androidx.window.extensions.layout.WindowLayoutComponent");
                nb.g.h(clsLoadClass2, "loader.loadClass(WINDOW_LAYOUT_COMPONENT_CLASS)");
                nb.g.h(method, "getWindowLayoutComponentMethod");
                if (Modifier.isPublic(method.getModifiers()) && method.getReturnType().equals(clsLoadClass2)) {
                    z10 = true;
                }
                return Boolean.valueOf(z10);
            }
        }) || !com.bumptech.glide.i.f(new sd.a() { // from class: androidx.window.layout.SafeWindowLayoutComponentProvider$isFoldingFeatureValid$1
            {
                super(0);
            }

            @Override // sd.a
            public final Object invoke() throws NoSuchMethodException, ClassNotFoundException {
                Class<?> clsLoadClass = this.this$0.f4478a.loadClass("androidx.window.extensions.layout.FoldingFeature");
                nb.g.h(clsLoadClass, "loader.loadClass(FOLDING_FEATURE_CLASS)");
                boolean z10 = false;
                Method method = clsLoadClass.getMethod("getBounds", new Class[0]);
                Method method2 = clsLoadClass.getMethod("getType", new Class[0]);
                Method method3 = clsLoadClass.getMethod("getState", new Class[0]);
                nb.g.h(method, "getBoundsMethod");
                if (method.getReturnType().equals(nb.g.B(kotlin.jvm.internal.g.a(Rect.class))) && Modifier.isPublic(method.getModifiers())) {
                    nb.g.h(method2, "getTypeMethod");
                    Class cls = Integer.TYPE;
                    if (method2.getReturnType().equals(nb.g.B(kotlin.jvm.internal.g.a(cls))) && Modifier.isPublic(method2.getModifiers())) {
                        nb.g.h(method3, "getStateMethod");
                        if (method3.getReturnType().equals(nb.g.B(kotlin.jvm.internal.g.a(cls))) && Modifier.isPublic(method3.getModifiers())) {
                            z10 = true;
                        }
                    }
                }
                return Boolean.valueOf(z10);
            }
        })) {
            return null;
        }
        int iA = androidx.window.core.e.a();
        if (iA == 1) {
            if (!b()) {
                return null;
            }
        } else if (2 > iA || iA > Integer.MAX_VALUE || !b() || !com.bumptech.glide.i.f(new sd.a() { // from class: androidx.window.layout.SafeWindowLayoutComponentProvider$isMethodWindowLayoutInfoListenerWindowConsumerValid$1
            {
                super(0);
            }

            @Override // sd.a
            public final Object invoke() throws NoSuchMethodException, ClassNotFoundException {
                Class<?> clsLoadClass = this.this$0.f4478a.loadClass("androidx.window.extensions.layout.WindowLayoutComponent");
                nb.g.h(clsLoadClass, "loader.loadClass(WINDOW_LAYOUT_COMPONENT_CLASS)");
                boolean z10 = false;
                Method method = clsLoadClass.getMethod("addWindowLayoutInfoListener", Context.class, Consumer.class);
                Method method2 = clsLoadClass.getMethod("removeWindowLayoutInfoListener", Consumer.class);
                nb.g.h(method, "addListenerMethod");
                if (Modifier.isPublic(method.getModifiers())) {
                    nb.g.h(method2, "removeListenerMethod");
                    if (Modifier.isPublic(method2.getModifiers())) {
                        z10 = true;
                    }
                }
                return Boolean.valueOf(z10);
            }
        })) {
            return null;
        }
        try {
            return WindowExtensionsProvider.getWindowExtensions().getWindowLayoutComponent();
        } catch (UnsupportedOperationException unused) {
            return null;
        }
    }

    public final boolean b() {
        return com.bumptech.glide.i.f(new sd.a() { // from class: androidx.window.layout.SafeWindowLayoutComponentProvider$isMethodWindowLayoutInfoListenerJavaConsumerValid$1
            {
                super(0);
            }

            @Override // sd.a
            public final Object invoke() throws NoSuchMethodException, ClassNotFoundException {
                Class<?> clsM;
                y yVar = this.this$0.f4479b;
                yVar.getClass();
                try {
                    clsM = yVar.m();
                } catch (ClassNotFoundException unused) {
                    clsM = null;
                }
                if (clsM == null) {
                    return Boolean.FALSE;
                }
                Class<?> clsLoadClass = this.this$0.f4478a.loadClass("androidx.window.extensions.layout.WindowLayoutComponent");
                nb.g.h(clsLoadClass, "loader.loadClass(WINDOW_LAYOUT_COMPONENT_CLASS)");
                boolean z10 = false;
                Method method = clsLoadClass.getMethod("addWindowLayoutInfoListener", Activity.class, clsM);
                Method method2 = clsLoadClass.getMethod("removeWindowLayoutInfoListener", clsM);
                nb.g.h(method, "addListenerMethod");
                if (Modifier.isPublic(method.getModifiers())) {
                    nb.g.h(method2, "removeListenerMethod");
                    if (Modifier.isPublic(method2.getModifiers())) {
                        z10 = true;
                    }
                }
                return Boolean.valueOf(z10);
            }
        });
    }
}
