51 lines
1.9 KiB
Java
51 lines
1.9 KiB
Java
|
package kotlinx.coroutines.android;
|
||
|
|
||
|
import android.os.Build;
|
||
|
import java.lang.Thread;
|
||
|
import java.lang.reflect.Method;
|
||
|
import java.lang.reflect.Modifier;
|
||
|
import kotlinx.coroutines.CoroutineExceptionHandler;
|
||
|
import o.AbstractC14904gbf;
|
||
|
import o.InterfaceC14912gbn;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class AndroidExceptionPreHandler extends AbstractC14904gbf implements CoroutineExceptionHandler {
|
||
|
private volatile Object _preHandler;
|
||
|
|
||
|
public AndroidExceptionPreHandler() {
|
||
|
super(CoroutineExceptionHandler.b);
|
||
|
this._preHandler = this;
|
||
|
}
|
||
|
|
||
|
private final Method preHandler() {
|
||
|
Object obj = this._preHandler;
|
||
|
if (obj != this) {
|
||
|
return (Method) obj;
|
||
|
}
|
||
|
Method method = null;
|
||
|
try {
|
||
|
Method declaredMethod = Thread.class.getDeclaredMethod("getUncaughtExceptionPreHandler", new Class[0]);
|
||
|
if (Modifier.isPublic(declaredMethod.getModifiers())) {
|
||
|
if (Modifier.isStatic(declaredMethod.getModifiers())) {
|
||
|
method = declaredMethod;
|
||
|
}
|
||
|
}
|
||
|
} catch (Throwable unused) {
|
||
|
}
|
||
|
this._preHandler = method;
|
||
|
return method;
|
||
|
}
|
||
|
|
||
|
@Override // kotlinx.coroutines.CoroutineExceptionHandler
|
||
|
public final void handleException(InterfaceC14912gbn interfaceC14912gbn, Throwable th) {
|
||
|
if (Build.VERSION.SDK_INT < 28) {
|
||
|
Method preHandler = preHandler();
|
||
|
Object invoke = preHandler != null ? preHandler.invoke(null, new Object[0]) : null;
|
||
|
Thread.UncaughtExceptionHandler uncaughtExceptionHandler = invoke instanceof Thread.UncaughtExceptionHandler ? (Thread.UncaughtExceptionHandler) invoke : null;
|
||
|
if (uncaughtExceptionHandler != null) {
|
||
|
uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), th);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|