package i.a.p;

import i.a.g;
import i.a.h;
import i.a.l.e;
import i.a.m.b;
import i.a.m.c;
import i.a.m.d;
import java.util.concurrent.Callable;

/* JADX INFO: compiled from: RxJavaPlugins.java */
/* JADX INFO: loaded from: classes.dex */
public final class a {
    static volatile c<? super Throwable> a;
    static volatile d<? super Runnable, ? extends Runnable> b;
    static volatile d<? super Callable<h>, ? extends h> c;
    static volatile d<? super Callable<h>, ? extends h> d;
    static volatile d<? super Callable<h>, ? extends h> e;
    static volatile d<? super Callable<h>, ? extends h> f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    static volatile d<? super h, ? extends h> f878g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    static volatile d<? super h, ? extends h> f879h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    static volatile d<? super h, ? extends h> f880i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    static volatile d<? super i.a.d, ? extends i.a.d> f881j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    static volatile b<? super i.a.d, ? super g, ? extends g> f882k;

    static <T, U, R> R a(b<T, U, R> bVar, T t, U u) {
        try {
            return bVar.a(t, u);
        } catch (Throwable th) {
            throw i.a.n.h.c.c(th);
        }
    }

    static <T, R> R b(d<T, R> dVar, T t) {
        try {
            return dVar.a(t);
        } catch (Throwable th) {
            throw i.a.n.h.c.c(th);
        }
    }

    static h c(d<? super Callable<h>, ? extends h> dVar, Callable<h> callable) {
        Object objB = b(dVar, callable);
        i.a.n.b.b.d(objB, "Scheduler Callable result can't be null");
        return (h) objB;
    }

    static h d(Callable<h> callable) {
        try {
            h hVarCall = callable.call();
            i.a.n.b.b.d(hVarCall, "Scheduler Callable result can't be null");
            return hVarCall;
        } catch (Throwable th) {
            throw i.a.n.h.c.c(th);
        }
    }

    public static h e(Callable<h> callable) {
        i.a.n.b.b.d(callable, "Scheduler Callable can't be null");
        d<? super Callable<h>, ? extends h> dVar = c;
        return dVar == null ? d(callable) : c(dVar, callable);
    }

    public static h f(Callable<h> callable) {
        i.a.n.b.b.d(callable, "Scheduler Callable can't be null");
        d<? super Callable<h>, ? extends h> dVar = e;
        return dVar == null ? d(callable) : c(dVar, callable);
    }

    public static h g(Callable<h> callable) {
        i.a.n.b.b.d(callable, "Scheduler Callable can't be null");
        d<? super Callable<h>, ? extends h> dVar = f;
        return dVar == null ? d(callable) : c(dVar, callable);
    }

    public static h h(Callable<h> callable) {
        i.a.n.b.b.d(callable, "Scheduler Callable can't be null");
        d<? super Callable<h>, ? extends h> dVar = d;
        return dVar == null ? d(callable) : c(dVar, callable);
    }

    static boolean i(Throwable th) {
        return (th instanceof i.a.l.c) || (th instanceof IllegalStateException) || (th instanceof NullPointerException) || (th instanceof IllegalArgumentException) || (th instanceof i.a.l.a);
    }

    public static <T> i.a.d<T> j(i.a.d<T> dVar) {
        d<? super i.a.d, ? extends i.a.d> dVar2 = f881j;
        return dVar2 != null ? (i.a.d) b(dVar2, dVar) : dVar;
    }

    public static h k(h hVar) {
        d<? super h, ? extends h> dVar = f878g;
        return dVar == null ? hVar : (h) b(dVar, hVar);
    }

    public static void l(Throwable th) {
        c<? super Throwable> cVar = a;
        if (th == null) {
            th = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources.");
        } else if (!i(th)) {
            th = new e(th);
        }
        if (cVar != null) {
            try {
                cVar.accept(th);
                return;
            } catch (Throwable th2) {
                th2.printStackTrace();
                q(th2);
            }
        }
        th.printStackTrace();
        q(th);
    }

    public static h m(h hVar) {
        d<? super h, ? extends h> dVar = f879h;
        return dVar == null ? hVar : (h) b(dVar, hVar);
    }

    public static h n(h hVar) {
        d<? super h, ? extends h> dVar = f880i;
        return dVar == null ? hVar : (h) b(dVar, hVar);
    }

    public static Runnable o(Runnable runnable) {
        i.a.n.b.b.d(runnable, "run is null");
        d<? super Runnable, ? extends Runnable> dVar = b;
        return dVar == null ? runnable : (Runnable) b(dVar, runnable);
    }

    public static <T> g<? super T> p(i.a.d<T> dVar, g<? super T> gVar) {
        b<? super i.a.d, ? super g, ? extends g> bVar = f882k;
        return bVar != null ? (g) a(bVar, dVar, gVar) : gVar;
    }

    static void q(Throwable th) {
        Thread threadCurrentThread = Thread.currentThread();
        threadCurrentThread.getUncaughtExceptionHandler().uncaughtException(threadCurrentThread, th);
    }
}
