package p037.p106;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.util.Xml;
import android.view.InflateException;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.SwitchPreference;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: renamed from: މ.ގ.ވ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C2286 {

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public static final Class<?>[] f7276 = {Context.class, AttributeSet.class};

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public static final HashMap<String, Constructor> f7277 = new HashMap<>();

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Context f7278;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public C2287 f7280;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final Object[] f7279 = new Object[2];

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public String[] f7281 = {Preference.class.getPackage().getName() + ".", SwitchPreference.class.getPackage().getName() + "."};

    public C2286(Context context, C2287 c2287) {
        this.f7278 = context;
        this.f7280 = c2287;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Preference m4328(String str, AttributeSet attributeSet) {
        try {
            return -1 == str.indexOf(46) ? m4329(str, this.f7281, attributeSet) : m4329(str, (String[]) null, attributeSet);
        } catch (InflateException e) {
            throw e;
        } catch (ClassNotFoundException e2) {
            InflateException inflateException = new InflateException(attributeSet.getPositionDescription() + ": Error inflating class (not found)" + str);
            inflateException.initCause(e2);
            throw inflateException;
        } catch (Exception e3) {
            InflateException inflateException2 = new InflateException(attributeSet.getPositionDescription() + ": Error inflating class " + str);
            inflateException2.initCause(e3);
            throw inflateException2;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Preference m4329(String str, String[] strArr, AttributeSet attributeSet) throws ClassNotFoundException {
        Class<?> cls;
        Constructor<?> constructor = f7277.get(str);
        if (constructor == null) {
            try {
                try {
                    ClassLoader classLoader = this.f7278.getClassLoader();
                    if (strArr == null || strArr.length == 0) {
                        cls = Class.forName(str, false, classLoader);
                    } else {
                        cls = null;
                        ClassNotFoundException e = null;
                        for (String str2 : strArr) {
                            try {
                                cls = Class.forName(str2 + str, false, classLoader);
                                break;
                            } catch (ClassNotFoundException e2) {
                                e = e2;
                            }
                        }
                        if (cls == null) {
                            if (e != null) {
                                throw e;
                            }
                            throw new InflateException(attributeSet.getPositionDescription() + ": Error inflating class " + str);
                        }
                    }
                    constructor = cls.getConstructor(f7276);
                    constructor.setAccessible(true);
                    f7277.put(str, constructor);
                } catch (ClassNotFoundException e3) {
                    throw e3;
                }
            } catch (Exception e4) {
                InflateException inflateException = new InflateException(attributeSet.getPositionDescription() + ": Error inflating class " + str);
                inflateException.initCause(e4);
                throw inflateException;
            }
        }
        Object[] objArr = this.f7279;
        objArr[1] = attributeSet;
        return (Preference) constructor.newInstance(objArr);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public Preference m4330(XmlPullParser xmlPullParser, PreferenceGroup preferenceGroup) {
        int next;
        synchronized (this.f7279) {
            AttributeSet attributeSetAsAttributeSet = Xml.asAttributeSet(xmlPullParser);
            this.f7279[0] = this.f7278;
            do {
                try {
                    try {
                        try {
                            next = xmlPullParser.next();
                            if (next == 2) {
                                break;
                            }
                        } catch (XmlPullParserException e) {
                            InflateException inflateException = new InflateException(e.getMessage());
                            inflateException.initCause(e);
                            throw inflateException;
                        }
                    } catch (InflateException e2) {
                        throw e2;
                    }
                } catch (IOException e3) {
                    InflateException inflateException2 = new InflateException(xmlPullParser.getPositionDescription() + ": " + e3.getMessage());
                    inflateException2.initCause(e3);
                    throw inflateException2;
                }
            } while (next != 1);
            if (next != 2) {
                throw new InflateException(xmlPullParser.getPositionDescription() + ": No start tag found!");
            }
            PreferenceGroup preferenceGroup2 = (PreferenceGroup) m4328(xmlPullParser.getName(), attributeSetAsAttributeSet);
            if (preferenceGroup == null) {
                preferenceGroup2.m385(this.f7280);
                preferenceGroup = preferenceGroup2;
            }
            m4331(xmlPullParser, preferenceGroup, attributeSetAsAttributeSet);
        }
        return preferenceGroup;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m4331(XmlPullParser xmlPullParser, Preference preference, AttributeSet attributeSet) throws XmlPullParserException, IOException {
        int depth = xmlPullParser.getDepth();
        while (true) {
            int next = xmlPullParser.next();
            if ((next == 3 && xmlPullParser.getDepth() <= depth) || next == 1) {
                return;
            }
            if (next == 2) {
                String name = xmlPullParser.getName();
                if ("intent".equals(name)) {
                    try {
                        preference.f1019 = Intent.parseIntent(this.f7278.getResources(), xmlPullParser, attributeSet);
                    } catch (IOException e) {
                        XmlPullParserException xmlPullParserException = new XmlPullParserException("Error parsing preference");
                        xmlPullParserException.initCause(e);
                        throw xmlPullParserException;
                    }
                } else if ("extra".equals(name)) {
                    this.f7278.getResources().parseBundleExtra("extra", attributeSet, preference.m396());
                    try {
                        int depth2 = xmlPullParser.getDepth();
                        while (true) {
                            int next2 = xmlPullParser.next();
                            if (next2 == 1 || (next2 == 3 && xmlPullParser.getDepth() <= depth2)) {
                                break;
                            }
                        }
                    } catch (IOException e2) {
                        XmlPullParserException xmlPullParserException2 = new XmlPullParserException("Error parsing preference");
                        xmlPullParserException2.initCause(e2);
                        throw xmlPullParserException2;
                    }
                } else {
                    Preference preferenceM4328 = m4328(name, attributeSet);
                    ((PreferenceGroup) preference).m406(preferenceM4328);
                    m4331(xmlPullParser, preferenceM4328, attributeSet);
                }
            }
        }
    }
}
