package X6FRs_4.IMuAHx_6.IFxWkV_5;

import X6FRs_4.IMuAHx_6.X6FRs_4.PGPF6hQ_2.PGPF6hQ_2;
import X6FRs_4.IMuAHx_6.XnFJ5_9.QxJ9d_1;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.CancellationSignal;
import android.util.Log;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.List;
/* compiled from: TypefaceCompatApi24Impl.java */
/* loaded from: classes.dex */
public class X6FRs_4 extends FSaI4_7 {
    public static final Class KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final Constructor f403KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final Method f404KQgRr5e_0;
    public static final Method QxJ9d_1;

    static {
        Class<?> cls;
        Method method;
        Method method2;
        Constructor<?> constructor = null;
        try {
            cls = Class.forName("android.graphics.FontFamily");
            Constructor<?> constructor2 = cls.getConstructor(new Class[0]);
            method2 = cls.getMethod("addFontWeightStyle", ByteBuffer.class, Integer.TYPE, List.class, Integer.TYPE, Boolean.TYPE);
            method = Typeface.class.getMethod("createFromFamiliesWithDefault", Array.newInstance(cls, 1).getClass());
            constructor = constructor2;
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            Log.e("TypefaceCompatApi24Impl", e.getClass().getName(), e);
            cls = null;
            method = null;
            method2 = null;
        }
        f403KQgRr5e_0 = constructor;
        KQgRr5e_0 = cls;
        f404KQgRr5e_0 = method2;
        QxJ9d_1 = method;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static boolean m289KQgRr5e_0() {
        if (f404KQgRr5e_0 == null) {
            Log.w("TypefaceCompatApi24Impl", "Unable to collect necessary private methods.Fallback to legacy implementation.");
        }
        return f404KQgRr5e_0 != null;
    }

    public static Object KQgRr5e_0() {
        try {
            return f403KQgRr5e_0.newInstance(new Object[0]);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException unused) {
            return null;
        }
    }

    public static boolean KQgRr5e_0(Object obj, ByteBuffer byteBuffer, int i, int i2, boolean z) {
        try {
            return ((Boolean) f404KQgRr5e_0.invoke(obj, byteBuffer, Integer.valueOf(i), null, Integer.valueOf(i2), Boolean.valueOf(z))).booleanValue();
        } catch (IllegalAccessException | InvocationTargetException unused) {
            return false;
        }
    }

    public static Typeface KQgRr5e_0(Object obj) {
        try {
            Object newInstance = Array.newInstance(KQgRr5e_0, 1);
            Array.set(newInstance, 0, obj);
            return (Typeface) QxJ9d_1.invoke(null, newInstance);
        } catch (IllegalAccessException | InvocationTargetException unused) {
            return null;
        }
    }

    @Override // X6FRs_4.IMuAHx_6.IFxWkV_5.FSaI4_7
    public Typeface KQgRr5e_0(Context context, CancellationSignal cancellationSignal, QxJ9d_1.IFxWkV_5[] iFxWkV_5Arr, int i) {
        Object KQgRr5e_02 = KQgRr5e_0();
        if (KQgRr5e_02 == null) {
            return null;
        }
        X6FRs_4.Mqv2r_3.IMuAHx_6 iMuAHx_6 = new X6FRs_4.Mqv2r_3.IMuAHx_6();
        for (QxJ9d_1.IFxWkV_5 iFxWkV_5 : iFxWkV_5Arr) {
            Uri m346KQgRr5e_0 = iFxWkV_5.m346KQgRr5e_0();
            ByteBuffer byteBuffer = (ByteBuffer) iMuAHx_6.get(m346KQgRr5e_0);
            if (byteBuffer == null) {
                byteBuffer = Xgtqvk_8.KQgRr5e_0(context, cancellationSignal, m346KQgRr5e_0);
                iMuAHx_6.put(m346KQgRr5e_0, byteBuffer);
            }
            if (byteBuffer == null || !KQgRr5e_0(KQgRr5e_02, byteBuffer, iFxWkV_5.QxJ9d_1(), iFxWkV_5.PGPF6hQ_2(), iFxWkV_5.m347KQgRr5e_0())) {
                return null;
            }
        }
        Typeface KQgRr5e_03 = KQgRr5e_0(KQgRr5e_02);
        if (KQgRr5e_03 == null) {
            return null;
        }
        return Typeface.create(KQgRr5e_03, i);
    }

    @Override // X6FRs_4.IMuAHx_6.IFxWkV_5.FSaI4_7
    public Typeface KQgRr5e_0(Context context, PGPF6hQ_2.QxJ9d_1 qxJ9d_1, Resources resources, int i) {
        PGPF6hQ_2.C0046PGPF6hQ_2[] KQgRr5e_02;
        Object KQgRr5e_03 = KQgRr5e_0();
        if (KQgRr5e_03 == null) {
            return null;
        }
        for (PGPF6hQ_2.C0046PGPF6hQ_2 c0046PGPF6hQ_2 : qxJ9d_1.KQgRr5e_0()) {
            ByteBuffer KQgRr5e_04 = Xgtqvk_8.KQgRr5e_0(context, resources, c0046PGPF6hQ_2.KQgRr5e_0());
            if (KQgRr5e_04 == null || !KQgRr5e_0(KQgRr5e_03, KQgRr5e_04, c0046PGPF6hQ_2.QxJ9d_1(), c0046PGPF6hQ_2.PGPF6hQ_2(), c0046PGPF6hQ_2.m339KQgRr5e_0())) {
                return null;
            }
        }
        return KQgRr5e_0(KQgRr5e_03);
    }
}
