package j1;

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.fragment.app.d1;
import androidx.fragment.app.e0;
import androidx.fragment.app.strictmode.FragmentReuseViolation;
import androidx.fragment.app.strictmode.FragmentStrictMode$Flag;
import androidx.fragment.app.strictmode.Violation;
import e.t;
import java.util.Set;
import kotlin.collections.n;
import nb.g;

/* JADX INFO: loaded from: classes.dex */
public abstract class b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final a f28545a = a.f28542c;

    public static a a(e0 e0Var) {
        while (e0Var != null) {
            if (e0Var.isAdded()) {
                d1 parentFragmentManager = e0Var.getParentFragmentManager();
                g.h(parentFragmentManager, "declaringFragment.parentFragmentManager");
                if (parentFragmentManager.getStrictModePolicy() != null) {
                    a strictModePolicy = parentFragmentManager.getStrictModePolicy();
                    g.f(strictModePolicy);
                    return strictModePolicy;
                }
            }
            e0Var = e0Var.getParentFragment();
        }
        return f28545a;
    }

    public static void b(a aVar, Violation violation) {
        e0 fragment = violation.getFragment();
        String name = fragment.getClass().getName();
        FragmentStrictMode$Flag fragmentStrictMode$Flag = FragmentStrictMode$Flag.f2583a;
        Set set = aVar.f28543a;
        set.contains(fragmentStrictMode$Flag);
        if (set.contains(FragmentStrictMode$Flag.f2584b)) {
            t tVar = new t(name, violation, 4);
            if (!fragment.isAdded()) {
                tVar.run();
                return;
            }
            Handler handler = fragment.getParentFragmentManager().f2388w.f2532c;
            if (g.c(handler.getLooper(), Looper.myLooper())) {
                tVar.run();
            } else {
                handler.post(tVar);
            }
        }
    }

    public static void c(Violation violation) {
        if (Log.isLoggable("FragmentManager", 3)) {
            violation.getFragment().getClass();
        }
    }

    public static final void d(e0 e0Var, String str) {
        g.i(e0Var, "fragment");
        g.i(str, "previousFragmentId");
        FragmentReuseViolation fragmentReuseViolation = new FragmentReuseViolation(e0Var, str);
        c(fragmentReuseViolation);
        a aVarA = a(e0Var);
        if (aVarA.f28543a.contains(FragmentStrictMode$Flag.f2585c) && e(aVarA, e0Var.getClass(), FragmentReuseViolation.class)) {
            b(aVarA, fragmentReuseViolation);
        }
    }

    public static boolean e(a aVar, Class cls, Class cls2) {
        Set set = (Set) aVar.f28544b.get(cls.getName());
        if (set == null) {
            return true;
        }
        if (g.c(cls2.getSuperclass(), Violation.class) || !n.c1(set, cls2.getSuperclass())) {
            return !set.contains(cls2);
        }
        return false;
    }
}
