package defpackage;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* renamed from: ˑʿﹳ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public class C2025 extends ˀʾˀᵛ {

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public static Constructor f8125;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public static Method f8126;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public static Method f8127;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public static boolean f8128;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public static Class f8129;

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public static void m5607() throws NoSuchMethodException, ClassNotFoundException, SecurityException {
        Method method;
        Class<?> cls;
        Method method2;
        if (f8128) {
            return;
        }
        f8128 = true;
        Constructor<?> constructor = null;
        try {
            cls = Class.forName("android.graphics.FontFamily");
            Constructor<?> constructor2 = cls.getConstructor(null);
            method2 = cls.getMethod("addFontWeightStyle", String.class, Integer.TYPE, Boolean.TYPE);
            method = Typeface.class.getMethod("createFromFamiliesWithDefault", Array.newInstance(cls, 1).getClass());
            constructor = constructor2;
        } catch (ClassNotFoundException | NoSuchMethodException unused) {
            method = null;
            cls = null;
            method2 = null;
        }
        f8125 = constructor;
        f8129 = cls;
        f8127 = method2;
        f8126 = method;
    }

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public static boolean m5608(Object obj, String str, int i, boolean z) throws NoSuchMethodException, ClassNotFoundException, SecurityException {
        m5607();
        try {
            return ((Boolean) f8127.invoke(obj, str, Integer.valueOf(i), Boolean.valueOf(z))).booleanValue();
        } catch (IllegalAccessException | InvocationTargetException e) {
            C1260.m3814(e);
            return false;
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public Typeface mo5609(Context context, C1449 c1449, Resources resources, int i) throws IllegalAccessException, NoSuchMethodException, InstantiationException, ClassNotFoundException, SecurityException, ArrayIndexOutOfBoundsException, IllegalArgumentException, InvocationTargetException, NegativeArraySizeException {
        m5607();
        try {
            Object objNewInstance = f8125.newInstance(null);
            for (C1389 c1389 : c1449.f5861) {
                File file = ᵺᵣᵬ.ˌʾˀ(context);
                if (file == null) {
                    return null;
                }
                try {
                    if (!ᵺᵣᵬ.ˇʼʤˎ(file, resources, c1389.f5700)) {
                        return null;
                    }
                    if (!m5608(objNewInstance, file.getPath(), c1389.f5703, c1389.f5701)) {
                        return null;
                    }
                    file.delete();
                } catch (RuntimeException unused) {
                    return null;
                } finally {
                    file.delete();
                }
            }
            m5607();
            try {
                Object objNewInstance2 = Array.newInstance((Class<?>) f8129, 1);
                Array.set(objNewInstance2, 0, objNewInstance);
                return (Typeface) f8126.invoke(null, objNewInstance2);
            } catch (IllegalAccessException | InvocationTargetException e) {
                C1260.m3814(e);
                return null;
            }
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException e2) {
            C1260.m3814(e2);
            return null;
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public Typeface mo5610(Context context, C3491[] c3491Arr, int i) throws IOException {
        Typeface typefaceCreateFromFile;
        String str;
        if (c3491Arr.length >= 1) {
            try {
                ParcelFileDescriptor parcelFileDescriptorOpenFileDescriptor = context.getContentResolver().openFileDescriptor(ˀʾˀᵛ.ˌᵜᵹᵩ(c3491Arr, i).f13069, "r", null);
                if (parcelFileDescriptorOpenFileDescriptor != null) {
                    try {
                        try {
                            str = Os.readlink("/proc/self/fd/" + parcelFileDescriptorOpenFileDescriptor.getFd());
                        } finally {
                        }
                    } catch (ErrnoException unused) {
                    }
                    File file = OsConstants.S_ISREG(Os.stat(str).st_mode) ? new File(str) : null;
                    if (file != null && file.canRead()) {
                        Typeface typefaceCreateFromFile2 = Typeface.createFromFile(file);
                        parcelFileDescriptorOpenFileDescriptor.close();
                        return typefaceCreateFromFile2;
                    }
                    FileInputStream fileInputStream = new FileInputStream(parcelFileDescriptorOpenFileDescriptor.getFileDescriptor());
                    try {
                        File file2 = ᵺᵣᵬ.ˌʾˀ(context);
                        if (file2 == null) {
                            typefaceCreateFromFile = null;
                        } else {
                            try {
                                if (ᵺᵣᵬ.ˏˋٴ(file2, fileInputStream)) {
                                    typefaceCreateFromFile = Typeface.createFromFile(file2.getPath());
                                    file2.delete();
                                }
                            } catch (RuntimeException unused2) {
                            } catch (Throwable th) {
                                file2.delete();
                                throw th;
                            }
                            file2.delete();
                            typefaceCreateFromFile = null;
                        }
                        fileInputStream.close();
                        parcelFileDescriptorOpenFileDescriptor.close();
                        return typefaceCreateFromFile;
                    } finally {
                    }
                }
                if (parcelFileDescriptorOpenFileDescriptor != null) {
                    parcelFileDescriptorOpenFileDescriptor.close();
                    return null;
                }
            } catch (IOException unused3) {
            }
        }
        return null;
    }
}
