package kotlinx.coroutines.android; import android.os.Build; import java.lang.Thread; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import p012d1.AbstractC0625a; import p012d1.InterfaceC0633f; import p060t1.InterfaceC1721v; /* loaded from: classes.dex */ public final class AndroidExceptionPreHandler extends AbstractC0625a implements InterfaceC1721v { private volatile Object _preHandler; public AndroidExceptionPreHandler() { super(InterfaceC1721v.f3951b); this._preHandler = this; } private final Method preHandler() { Object obj = this._preHandler; if (obj != this) { return (Method) obj; } Method method = null; try { boolean z = false; Method declaredMethod = Thread.class.getDeclaredMethod("getUncaughtExceptionPreHandler", new Class[0]); if (Modifier.isPublic(declaredMethod.getModifiers())) { if (Modifier.isStatic(declaredMethod.getModifiers())) { z = true; } } if (z) { method = declaredMethod; } } catch (Throwable unused) { } this._preHandler = method; return method; } @Override // p060t1.InterfaceC1721v public void handleException(InterfaceC0633f interfaceC0633f, Throwable th) { int i = Build.VERSION.SDK_INT; if (26 <= i && i < 28) { Method preHandler = preHandler(); Object invoke = preHandler == null ? null : preHandler.invoke(null, new Object[0]); Thread.UncaughtExceptionHandler uncaughtExceptionHandler = invoke instanceof Thread.UncaughtExceptionHandler ? (Thread.UncaughtExceptionHandler) invoke : null; if (uncaughtExceptionHandler == null) { return; } uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), th); } } }