package j;

import android.os.Handler;
import android.os.Looper;
import j.c;
import j.j;
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 org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final y f7028a;

    public static class a extends y {

        /* JADX INFO: renamed from: j.y$a$a, reason: collision with other inner class name */
        public static class ExecutorC0094a implements Executor {

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

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

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

        @Override // j.y
        public Executor b() {
            return new ExecutorC0094a();
        }

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

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

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

    @IgnoreJRERequirement
    public static class b extends y {
        @Override // j.y
        public List<? extends c.a> a(@Nullable Executor executor) {
            ArrayList arrayList = new ArrayList(2);
            arrayList.add(g.f6908a);
            arrayList.add(new k(executor));
            return Collections.unmodifiableList(arrayList);
        }

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

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

        @Override // j.y
        public Object e(Method method, Class<?> cls, Object obj, @Nullable Object... objArr) throws NoSuchMethodException {
            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 // j.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();
        }
        f7028a = 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) {
        throw new UnsupportedOperationException();
    }

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