package f;

import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import f.e;
import f.h;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
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: compiled from: Platform.java */
/* JADX INFO: loaded from: classes.dex */
class q {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static final q f1721c = e();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final boolean f1722a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    @Nullable
    private final Constructor<MethodHandles.Lookup> f1723b;

    /* JADX INFO: compiled from: Platform.java */
    static final class a extends q {

        /* JADX INFO: renamed from: f.q$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: Platform.java */
        static final class ExecutorC0039a implements Executor {

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

            ExecutorC0039a() {
            }

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

        a() {
            super(Build.VERSION.SDK_INT >= 24);
        }

        @Override // f.q
        public Executor b() {
            return new ExecutorC0039a();
        }

        @Override // f.q
        @Nullable
        Object g(Method method, Class<?> cls, Object obj, Object... objArr) throws Throwable {
            if (Build.VERSION.SDK_INT >= 26) {
                return super.g(method, cls, obj, objArr);
            }
            throw new UnsupportedOperationException("Calling default methods on API 24 and 25 is not supported");
        }
    }

    q(boolean z) {
        this.f1722a = z;
        Constructor<MethodHandles.Lookup> declaredConstructor = null;
        if (z) {
            try {
                declaredConstructor = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, Integer.TYPE);
                declaredConstructor.setAccessible(true);
            } catch (NoClassDefFoundError | NoSuchMethodException unused) {
            }
        }
        this.f1723b = declaredConstructor;
    }

    private static q e() {
        return "Dalvik".equals(System.getProperty("java.vm.name")) ? new a() : new q(true);
    }

    static q f() {
        return f1721c;
    }

    List<? extends e.a> a(@Nullable Executor executor) {
        i iVar = new i(executor);
        return this.f1722a ? Arrays.asList(g.f1637a, iVar) : Collections.singletonList(iVar);
    }

    @Nullable
    Executor b() {
        return null;
    }

    List<? extends h.a> c() {
        return this.f1722a ? Collections.singletonList(o.f1682a) : Collections.emptyList();
    }

    int d() {
        return this.f1722a ? 1 : 0;
    }

    @Nullable
    @IgnoreJRERequirement
    Object g(Method method, Class<?> cls, Object obj, Object... objArr) throws Throwable {
        Constructor<MethodHandles.Lookup> constructor = this.f1723b;
        return (constructor != null ? constructor.newInstance(cls, -1) : MethodHandles.lookup()).unreflectSpecial(method, cls).bindTo(obj).invokeWithArguments(objArr);
    }

    @IgnoreJRERequirement
    boolean h(Method method) {
        return this.f1722a && method.isDefault();
    }
}
