package l;

import android.os.Handler;
import android.os.Looper;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
import l.c;
import l.j;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

/* JADX INFO: compiled from: Platform.java */
/* JADX INFO: loaded from: classes.dex */
public class y {
    public static final y a;

    /* JADX INFO: compiled from: Platform.java */
    public static class a extends y {

        /* JADX INFO: renamed from: l.y$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: Platform.java */
        public static class ExecutorC0092a implements Executor {

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final Handler f5096b = new Handler(Looper.getMainLooper());

            @Override // java.util.concurrent.Executor
            public void execute(Runnable runnable) {
                this.f5096b.post(runnable);
            }
        }

        @Override // l.y
        public List<? extends c.a> a(@Nullable Executor executor) {
            if (executor != null) {
                return Arrays.asList(g.a, new k(executor));
            }
            throw new AssertionError();
        }

        @Override // l.y
        public Executor b() {
            return new ExecutorC0092a();
        }

        @Override // l.y
        public List<? extends j.a> c() {
            return Collections.singletonList(u.a);
        }

        @Override // l.y
        public int d() {
            return 1;
        }

        @Override // l.y
        @IgnoreJRERequirement
        public boolean f(Method method) {
            return method.isDefault();
        }
    }

    /* JADX INFO: compiled from: Platform.java */
    @IgnoreJRERequirement
    public static class b extends y {
        @Override // l.y
        public List<? extends c.a> a(@Nullable Executor executor) {
            ArrayList arrayList = new ArrayList(2);
            arrayList.add(g.a);
            arrayList.add(new k(executor));
            return Collections.unmodifiableList(arrayList);
        }

        @Override // l.y
        public List<? extends j.a> c() {
            return Collections.singletonList(u.a);
        }

        @Override // l.y
        public int d() {
            return 1;
        }

        @Override // l.y
        public Object e(Method method, Class<?> cls, Object obj, @Nullable Object... objArr) throws Throwable {
            Constructor declaredConstructor = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, Integer.TYPE);
            declaredConstructor.setAccessible(true);
            return ((MethodHandles.Lookup) declaredConstructor.newInstance(cls, -1)).unreflectSpecial(method, cls).bindTo(obj).invokeWithArguments(objArr);
        }

        @Override // l.y
        public boolean f(Method method) {
            return method.isDefault();
        }
    }

    static {
        y yVar;
        try {
            try {
                Class.forName("android.os.Build");
                yVar = new a();
            } catch (ClassNotFoundException unused) {
                yVar = new y();
            }
        } catch (ClassNotFoundException unused2) {
            Class.forName("java.util.Optional");
            yVar = new b();
        }
        a = yVar;
    }

    public List<? extends c.a> a(@Nullable Executor executor) {
        return Collections.singletonList(new k(executor));
    }

    @Nullable
    public Executor b() {
        return null;
    }

    public List<? extends j.a> c() {
        return Collections.emptyList();
    }

    public int d() {
        return 0;
    }

    @Nullable
    public Object e(Method method, Class<?> cls, Object obj, @Nullable Object... objArr) throws Throwable {
        throw new UnsupportedOperationException();
    }

    public boolean f(Method method) {
        return false;
    }
}
