package defpackage;

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.fonts.FontVariationAxis;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;

/* renamed from: ᵼᵢʗ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public class C5284 extends C2025 {

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final Class f19775;

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public final Method f19776;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public final Method f19777;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public final Constructor f19778;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final Method f19779;

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public final Method f19780;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public final Method f19781;

    public C5284() throws NoSuchMethodException, ClassNotFoundException, SecurityException {
        Method methodMo8227;
        Constructor<?> constructor;
        Method methodM10938;
        Method method;
        Method method2;
        Method method3;
        Class<?> cls = null;
        try {
            Class<?> cls2 = Class.forName("android.graphics.FontFamily");
            constructor = cls2.getConstructor(null);
            methodM10938 = m10938(cls2);
            Class<?> cls3 = Integer.TYPE;
            method = cls2.getMethod("addFontFromBuffer", ByteBuffer.class, cls3, FontVariationAxis[].class, cls3, cls3);
            method2 = cls2.getMethod("freeze", null);
            method3 = cls2.getMethod("abortCreation", null);
            methodMo8227 = mo8227(cls2);
            cls = cls2;
        } catch (ClassNotFoundException | NoSuchMethodException unused) {
            methodMo8227 = null;
            constructor = null;
            methodM10938 = null;
            method = null;
            method2 = null;
            method3 = null;
        }
        this.f19775 = cls;
        this.f19778 = constructor;
        this.f19781 = methodM10938;
        this.f19777 = method;
        this.f19780 = method2;
        this.f19776 = method3;
        this.f19779 = methodMo8227;
    }

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public static Method m10938(Class cls) {
        Class<?> cls2 = Integer.TYPE;
        return cls.getMethod("addFontFromAssetManager", AssetManager.class, String.class, cls2, Boolean.TYPE, cls2, cls2, cls2, FontVariationAxis[].class);
    }

    /* renamed from: ˊᵸˊ */
    public Method mo8227(Class cls) throws NoSuchMethodException, SecurityException {
        Class cls2 = Integer.TYPE;
        Method declaredMethod = Typeface.class.getDeclaredMethod("createFromFamiliesWithDefault", Array.newInstance((Class<?>) cls, 1).getClass(), cls2, cls2);
        declaredMethod.setAccessible(true);
        return declaredMethod;
    }

    @Override // defpackage.C2025
    /* renamed from: ˎˏʜʾ */
    public final Typeface mo5609(Context context, C1449 c1449, Resources resources, int i) throws IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException {
        Object objNewInstance;
        if (this.f19781 == null) {
            return super.mo5609(context, c1449, resources, i);
        }
        try {
            objNewInstance = this.f19778.newInstance(null);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException unused) {
            objNewInstance = null;
        }
        if (objNewInstance != null) {
            C1389[] c1389Arr = c1449.f5861;
            int length = c1389Arr.length;
            int i2 = 0;
            while (true) {
                if (i2 < length) {
                    C1389 c1389 = c1389Arr[i2];
                    String str = c1389.f5702;
                    int i3 = c1389.f5699;
                    int i4 = c1389.f5703;
                    boolean z = c1389.f5701;
                    FontVariationAxis[] fontVariationAxisArrFromFontVariationSettings = FontVariationAxis.fromFontVariationSettings(c1389.f5704);
                    C5284 c5284 = this;
                    Context context2 = context;
                    if (c5284.m10941(context2, objNewInstance, str, i3, i4, z ? 1 : 0, fontVariationAxisArrFromFontVariationSettings)) {
                        i2++;
                        this = c5284;
                        context = context2;
                    } else {
                        try {
                            c5284.f19776.invoke(objNewInstance, null);
                            break;
                        } catch (IllegalAccessException | InvocationTargetException unused2) {
                        }
                    }
                } else {
                    C5284 c52842 = this;
                    if (c52842.m10939(objNewInstance)) {
                        return c52842.mo8228(objNewInstance);
                    }
                }
            }
        }
        return null;
    }

    /* renamed from: ᵙᵢᵨᵳ */
    public Typeface mo8228(Object obj) throws ArrayIndexOutOfBoundsException, IllegalArgumentException, NegativeArraySizeException {
        try {
            Object objNewInstance = Array.newInstance((Class<?>) this.f19775, 1);
            Array.set(objNewInstance, 0, obj);
            return (Typeface) this.f19779.invoke(null, objNewInstance, -1, -1);
        } catch (IllegalAccessException | InvocationTargetException unused) {
            return null;
        }
    }

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public final boolean m10939(Object obj) {
        try {
            return ((Boolean) this.f19780.invoke(obj, null)).booleanValue();
        } catch (IllegalAccessException | InvocationTargetException unused) {
            return false;
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final Typeface m10940(Context context, Resources resources, int i, String str, int i2) throws IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException {
        Object objNewInstance;
        if (this.f19781 == null) {
            return super.ᵶᵷᵕ(context, resources, i, str, i2);
        }
        try {
            objNewInstance = this.f19778.newInstance(null);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException unused) {
            objNewInstance = null;
        }
        if (objNewInstance != null) {
            if (!m10941(context, objNewInstance, str, 0, -1, -1, null)) {
                try {
                    this.f19776.invoke(objNewInstance, null);
                } catch (IllegalAccessException | InvocationTargetException unused2) {
                }
            } else if (m10939(objNewInstance)) {
                return mo8228(objNewInstance);
            }
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x001f  */
    @Override // defpackage.C2025
    /* renamed from: ᵹᵝᵶ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final android.graphics.Typeface mo5610(android.content.Context r17, defpackage.C3491[] r18, int r19) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.io.IOException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException {
        /*
            Method dump skipped, instructions count: 245
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C5284.mo5610(android.content.Context, ᵥʾᵵᵗ[], int):android.graphics.Typeface");
    }

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public final boolean m10941(Context context, Object obj, String str, int i, int i2, int i3, FontVariationAxis[] fontVariationAxisArr) {
        try {
            return ((Boolean) this.f19781.invoke(obj, context.getAssets(), str, 0, Boolean.FALSE, Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), fontVariationAxisArr)).booleanValue();
        } catch (IllegalAccessException | InvocationTargetException unused) {
            return false;
        }
    }
}
