package W4;

import A4.j;
import V4.A;
import V4.C0787z;
import android.os.Build;
import java.lang.Thread;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/* JADX INFO: loaded from: classes3.dex */
public final class b extends A4.a implements A {
    private volatile Object _preHandler;

    public b() {
        super(C0787z.f8352a);
        this._preHandler = this;
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x0032  */
    @Override // V4.A
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void handleException(j jVar, Throwable th) {
        Method declaredMethod;
        int i6 = Build.VERSION.SDK_INT;
        if (26 > i6 || i6 >= 28) {
            return;
        }
        Object obj = this._preHandler;
        if (obj != this) {
            declaredMethod = (Method) obj;
        } else {
            try {
                declaredMethod = Thread.class.getDeclaredMethod("getUncaughtExceptionPreHandler", new Class[0]);
            } catch (Throwable unused) {
            }
            if (Modifier.isPublic(declaredMethod.getModifiers())) {
                if (!Modifier.isStatic(declaredMethod.getModifiers())) {
                    declaredMethod = null;
                }
                this._preHandler = declaredMethod;
            }
        }
        Object objInvoke = declaredMethod != null ? declaredMethod.invoke(null, new Object[0]) : null;
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler = objInvoke instanceof Thread.UncaughtExceptionHandler ? (Thread.UncaughtExceptionHandler) objInvoke : null;
        if (uncaughtExceptionHandler != null) {
            uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), th);
        }
    }
}
