package X6FRs_4.IMuAHx_6.X6FRs_4.PGPF6hQ_2;

import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.Base64;
import android.util.TypedValue;
import android.util.Xml;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/* compiled from: FontResourcesParserCompat.java */
/* loaded from: classes.dex */
public class PGPF6hQ_2 {

    /* compiled from: FontResourcesParserCompat.java */
    /* loaded from: classes.dex */
    public interface KQgRr5e_0 {
    }

    /* compiled from: FontResourcesParserCompat.java */
    /* loaded from: classes.dex */
    public static final class Mqv2r_3 implements KQgRr5e_0 {
        public final int KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final X6FRs_4.IMuAHx_6.XnFJ5_9.KQgRr5e_0 f517KQgRr5e_0;
        public final int QxJ9d_1;

        public Mqv2r_3(X6FRs_4.IMuAHx_6.XnFJ5_9.KQgRr5e_0 kQgRr5e_0, int i, int i2) {
            this.f517KQgRr5e_0 = kQgRr5e_0;
            this.QxJ9d_1 = i;
            this.KQgRr5e_0 = i2;
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public X6FRs_4.IMuAHx_6.XnFJ5_9.KQgRr5e_0 m337KQgRr5e_0() {
            return this.f517KQgRr5e_0;
        }

        public int QxJ9d_1() {
            return this.KQgRr5e_0;
        }

        public int KQgRr5e_0() {
            return this.QxJ9d_1;
        }
    }

    /* compiled from: FontResourcesParserCompat.java */
    /* renamed from: X6FRs_4.IMuAHx_6.X6FRs_4.PGPF6hQ_2.PGPF6hQ_2$PGPF6hQ_2  reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static final class C0046PGPF6hQ_2 {
        public int KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final String f518KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public boolean f519KQgRr5e_0;
        public int PGPF6hQ_2;
        public int QxJ9d_1;

        /* renamed from: QxJ9d_1  reason: collision with other field name */
        public String f520QxJ9d_1;

        public C0046PGPF6hQ_2(String str, int i, boolean z, String str2, int i2, int i3) {
            this.f518KQgRr5e_0 = str;
            this.KQgRr5e_0 = i;
            this.f519KQgRr5e_0 = z;
            this.f520QxJ9d_1 = str2;
            this.QxJ9d_1 = i2;
            this.PGPF6hQ_2 = i3;
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public String m338KQgRr5e_0() {
            return this.f518KQgRr5e_0;
        }

        public int PGPF6hQ_2() {
            return this.KQgRr5e_0;
        }

        /* renamed from: QxJ9d_1  reason: collision with other method in class */
        public String m340QxJ9d_1() {
            return this.f520QxJ9d_1;
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public boolean m339KQgRr5e_0() {
            return this.f519KQgRr5e_0;
        }

        public int QxJ9d_1() {
            return this.QxJ9d_1;
        }

        public int KQgRr5e_0() {
            return this.PGPF6hQ_2;
        }
    }

    /* compiled from: FontResourcesParserCompat.java */
    /* loaded from: classes.dex */
    public static final class QxJ9d_1 implements KQgRr5e_0 {
        public final C0046PGPF6hQ_2[] KQgRr5e_0;

        public QxJ9d_1(C0046PGPF6hQ_2[] c0046PGPF6hQ_2Arr) {
            this.KQgRr5e_0 = c0046PGPF6hQ_2Arr;
        }

        public C0046PGPF6hQ_2[] KQgRr5e_0() {
            return this.KQgRr5e_0;
        }
    }

    public static KQgRr5e_0 KQgRr5e_0(XmlPullParser xmlPullParser, Resources resources) throws XmlPullParserException, IOException {
        int next;
        do {
            next = xmlPullParser.next();
            if (next == 2) {
                break;
            }
        } while (next != 1);
        if (next == 2) {
            return QxJ9d_1(xmlPullParser, resources);
        }
        throw new XmlPullParserException("No start tag found");
    }

    public static KQgRr5e_0 PGPF6hQ_2(XmlPullParser xmlPullParser, Resources resources) throws XmlPullParserException, IOException {
        TypedArray obtainAttributes = resources.obtainAttributes(Xml.asAttributeSet(xmlPullParser), X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily);
        String string = obtainAttributes.getString(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily_fontProviderAuthority);
        String string2 = obtainAttributes.getString(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily_fontProviderPackage);
        String string3 = obtainAttributes.getString(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily_fontProviderQuery);
        int resourceId = obtainAttributes.getResourceId(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily_fontProviderCerts, 0);
        int integer = obtainAttributes.getInteger(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily_fontProviderFetchStrategy, 1);
        int integer2 = obtainAttributes.getInteger(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamily_fontProviderFetchTimeout, 500);
        obtainAttributes.recycle();
        if (string != null && string2 != null && string3 != null) {
            while (xmlPullParser.next() != 3) {
                KQgRr5e_0(xmlPullParser);
            }
            return new Mqv2r_3(new X6FRs_4.IMuAHx_6.XnFJ5_9.KQgRr5e_0(string, string2, string3, KQgRr5e_0(resources, resourceId)), integer, integer2);
        }
        ArrayList arrayList = new ArrayList();
        while (xmlPullParser.next() != 3) {
            if (xmlPullParser.getEventType() == 2) {
                if (xmlPullParser.getName().equals("font")) {
                    arrayList.add(m336KQgRr5e_0(xmlPullParser, resources));
                } else {
                    KQgRr5e_0(xmlPullParser);
                }
            }
        }
        if (arrayList.isEmpty()) {
            return null;
        }
        return new QxJ9d_1((C0046PGPF6hQ_2[]) arrayList.toArray(new C0046PGPF6hQ_2[arrayList.size()]));
    }

    public static KQgRr5e_0 QxJ9d_1(XmlPullParser xmlPullParser, Resources resources) throws XmlPullParserException, IOException {
        xmlPullParser.require(2, null, "font-family");
        if (xmlPullParser.getName().equals("font-family")) {
            return PGPF6hQ_2(xmlPullParser, resources);
        }
        KQgRr5e_0(xmlPullParser);
        return null;
    }

    public static int KQgRr5e_0(TypedArray typedArray, int i) {
        if (Build.VERSION.SDK_INT >= 21) {
            return typedArray.getType(i);
        }
        TypedValue typedValue = new TypedValue();
        typedArray.getValue(i, typedValue);
        return typedValue.type;
    }

    public static List<List<byte[]>> KQgRr5e_0(Resources resources, int i) {
        if (i == 0) {
            return Collections.emptyList();
        }
        TypedArray obtainTypedArray = resources.obtainTypedArray(i);
        try {
            if (obtainTypedArray.length() == 0) {
                return Collections.emptyList();
            }
            ArrayList arrayList = new ArrayList();
            if (KQgRr5e_0(obtainTypedArray, 0) == 1) {
                for (int i2 = 0; i2 < obtainTypedArray.length(); i2++) {
                    int resourceId = obtainTypedArray.getResourceId(i2, 0);
                    if (resourceId != 0) {
                        arrayList.add(KQgRr5e_0(resources.getStringArray(resourceId)));
                    }
                }
            } else {
                arrayList.add(KQgRr5e_0(resources.getStringArray(i)));
            }
            return arrayList;
        } finally {
            obtainTypedArray.recycle();
        }
    }

    public static List<byte[]> KQgRr5e_0(String[] strArr) {
        ArrayList arrayList = new ArrayList();
        for (String str : strArr) {
            arrayList.add(Base64.decode(str, 0));
        }
        return arrayList;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static C0046PGPF6hQ_2 m336KQgRr5e_0(XmlPullParser xmlPullParser, Resources resources) throws XmlPullParserException, IOException {
        TypedArray obtainAttributes = resources.obtainAttributes(Xml.asAttributeSet(xmlPullParser), X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont);
        int i = obtainAttributes.getInt(obtainAttributes.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_fontWeight) ? X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_fontWeight : X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_android_fontWeight, 400);
        boolean z = 1 == obtainAttributes.getInt(obtainAttributes.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_fontStyle) ? X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_fontStyle : X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_android_fontStyle, 0);
        int i2 = obtainAttributes.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_ttcIndex) ? X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_ttcIndex : X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_android_ttcIndex;
        String string = obtainAttributes.getString(obtainAttributes.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_fontVariationSettings) ? X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_fontVariationSettings : X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_android_fontVariationSettings);
        int i3 = obtainAttributes.getInt(i2, 0);
        int i4 = obtainAttributes.hasValue(X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_font) ? X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_font : X6FRs_4.IMuAHx_6.PGPF6hQ_2.FontFamilyFont_android_font;
        int resourceId = obtainAttributes.getResourceId(i4, 0);
        String string2 = obtainAttributes.getString(i4);
        obtainAttributes.recycle();
        while (xmlPullParser.next() != 3) {
            KQgRr5e_0(xmlPullParser);
        }
        return new C0046PGPF6hQ_2(string2, i, z, string, i3, resourceId);
    }

    public static void KQgRr5e_0(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        int i = 1;
        while (i > 0) {
            int next = xmlPullParser.next();
            if (next == 2) {
                i++;
            } else if (next == 3) {
                i--;
            }
        }
    }
}
