package io.reactivex.plugins; import io.reactivex.Completable; import io.reactivex.CompletableObserver; import io.reactivex.Flowable; import io.reactivex.Maybe; import io.reactivex.MaybeObserver; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.Scheduler; import io.reactivex.Single; import io.reactivex.SingleObserver; import io.reactivex.exceptions.CompositeException; import io.reactivex.exceptions.MissingBackpressureException; import io.reactivex.exceptions.OnErrorNotImplementedException; import io.reactivex.exceptions.UndeliverableException; import io.reactivex.functions.BiFunction; import io.reactivex.functions.BooleanSupplier; import io.reactivex.functions.Consumer; import io.reactivex.functions.Function; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.util.ExceptionHelper; import io.reactivex.observables.ConnectableObservable; import java.util.concurrent.Callable; import org.reactivestreams.Subscriber; /* loaded from: classes2.dex */ public final class RxJavaPlugins { static volatile Consumer a; static volatile Function b; static volatile Function, ? extends Scheduler> c; static volatile Function, ? extends Scheduler> d; static volatile Function, ? extends Scheduler> e; static volatile Function, ? extends Scheduler> f; static volatile Function g; static volatile Function h; static volatile Function i; static volatile Function j; static volatile Function k; static volatile Function l; static volatile Function m; static volatile Function n; static volatile Function o; static volatile BiFunction p; static volatile BiFunction q; static volatile BiFunction r; static volatile BiFunction s; static volatile BiFunction t; static volatile BooleanSupplier u; static volatile boolean v; static volatile boolean w; public static boolean a() { return w; } public static Scheduler b(Callable callable) { ObjectHelper.a(callable, "Scheduler Callable can't be null"); Function, ? extends Scheduler> function = c; return function == null ? a(callable) : a(function, callable); } public static Scheduler c(Callable callable) { ObjectHelper.a(callable, "Scheduler Callable can't be null"); Function, ? extends Scheduler> function = e; return function == null ? a(callable) : a(function, callable); } public static Scheduler d(Callable callable) { ObjectHelper.a(callable, "Scheduler Callable can't be null"); Function, ? extends Scheduler> function = f; return function == null ? a(callable) : a(function, callable); } public static Scheduler e(Callable callable) { ObjectHelper.a(callable, "Scheduler Callable can't be null"); Function, ? extends Scheduler> function = d; return function == null ? a(callable) : a(function, callable); } public static Scheduler a(Scheduler scheduler) { Function function = g; return function == null ? scheduler : (Scheduler) a((Function) function, scheduler); } static boolean a(Throwable th) { return (th instanceof OnErrorNotImplementedException) || (th instanceof MissingBackpressureException) || (th instanceof IllegalStateException) || (th instanceof NullPointerException) || (th instanceof IllegalArgumentException) || (th instanceof CompositeException); } public static void b(Throwable th) { Consumer consumer = 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 (!a(th)) { th = new UndeliverableException(th); } if (consumer != null) { try { consumer.accept(th); return; } catch (Throwable th2) { th2.printStackTrace(); c(th2); } } th.printStackTrace(); c(th); } static void c(Throwable th) { Thread currentThread = Thread.currentThread(); currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, th); } public static Scheduler c(Scheduler scheduler) { Function function = i; return function == null ? scheduler : (Scheduler) a((Function) function, scheduler); } public static Runnable a(Runnable runnable) { ObjectHelper.a(runnable, "run is null"); Function function = b; return function == null ? runnable : (Runnable) a((Function) function, runnable); } public static void a(Consumer consumer) { if (!v) { a = consumer; return; } throw new IllegalStateException("Plugins can't be changed anymore"); } public static Scheduler b(Scheduler scheduler) { Function function = h; return function == null ? scheduler : (Scheduler) a((Function) function, scheduler); } public static Subscriber a(Flowable flowable, Subscriber subscriber) { BiFunction biFunction = p; return biFunction != null ? (Subscriber) a(biFunction, flowable, subscriber) : subscriber; } public static boolean b() { BooleanSupplier booleanSupplier = u; if (booleanSupplier == null) { return false; } try { return booleanSupplier.a(); } catch (Throwable th) { throw ExceptionHelper.a(th); } } public static Observer a(Observable observable, Observer observer) { BiFunction biFunction = r; return biFunction != null ? (Observer) a(biFunction, observable, observer) : observer; } public static SingleObserver a(Single single, SingleObserver singleObserver) { BiFunction biFunction = s; return biFunction != null ? (SingleObserver) a(biFunction, single, singleObserver) : singleObserver; } public static CompletableObserver a(Completable completable, CompletableObserver completableObserver) { BiFunction biFunction = t; return biFunction != null ? (CompletableObserver) a(biFunction, completable, completableObserver) : completableObserver; } public static MaybeObserver a(Maybe maybe, MaybeObserver maybeObserver) { BiFunction biFunction = q; return biFunction != null ? (MaybeObserver) a(biFunction, maybe, maybeObserver) : maybeObserver; } public static Maybe a(Maybe maybe) { Function function = m; return function != null ? (Maybe) a((Function, R>) function, maybe) : maybe; } public static Flowable a(Flowable flowable) { Function function = j; return function != null ? (Flowable) a((Function, R>) function, flowable) : flowable; } public static Observable a(Observable observable) { Function function = k; return function != null ? (Observable) a((Function, R>) function, observable) : observable; } public static ConnectableObservable a(ConnectableObservable connectableObservable) { Function function = l; return function != null ? (ConnectableObservable) a((Function, R>) function, connectableObservable) : connectableObservable; } public static Single a(Single single) { Function function = n; return function != null ? (Single) a((Function, R>) function, single) : single; } public static Completable a(Completable completable) { Function function = o; return function != null ? (Completable) a((Function) function, completable) : completable; } static R a(Function function, T t2) { try { return function.apply(t2); } catch (Throwable th) { throw ExceptionHelper.a(th); } } static R a(BiFunction biFunction, T t2, U u2) { try { return biFunction.apply(t2, u2); } catch (Throwable th) { throw ExceptionHelper.a(th); } } static Scheduler a(Callable callable) { try { Scheduler call = callable.call(); ObjectHelper.a(call, "Scheduler Callable result can't be null"); return call; } catch (Throwable th) { throw ExceptionHelper.a(th); } } static Scheduler a(Function, ? extends Scheduler> function, Callable callable) { Object a2 = a((Function, Object>) function, callable); ObjectHelper.a(a2, "Scheduler Callable result can't be null"); return (Scheduler) a2; } }