package ῲ.ᨨ.ʬ;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Handler;
import android.util.Log;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import ῲ.ᨨ.ῲ.ῲ.AbstractC1798;
import ῲ.ᨨ.ῲ.ῲ.AbstractC1799;
import ῲ.ᨨ.ῲ.ῲ.C1796;
import ῲ.ᨨ.ῲ.ῲ.C1797;
import ῲ.ᨨ.㴹.C1843;
import ῲ.ᨨ.㴹.C1844;
import ῲ.ᨨ.㴹.C1849;
import ῲ.ᨨ.㴹.C1857;
import ῲ.ᨨ.㴹.CallableC1858;
import ῲ.ᨨ.㴹.RunnableC1848;
import ῲ.ᨨ.㴹.RunnableC1854;
import ῲ.㴹.C2286;

@SuppressLint({"NewApi"})
/* renamed from: ῲ.ᨨ.ʬ.㸾  reason: contains not printable characters */
/* compiled from: TypefaceCompat */
public class C1721 {

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final C2286<String, Typeface> f6036 = new C2286<>(16);

    /* renamed from: K  reason: contains not printable characters */
    public static final C1719 f6037;

    static {
        int i = Build.VERSION.SDK_INT;
        if (i >= 29) {
            f6037 = new C1715();
        } else if (i >= 28) {
            f6037 = new C1723();
        } else if (i >= 26) {
            f6037 = new C1717();
        } else {
            if (i >= 24) {
                if (C1720.f6035 == null) {
                    Log.w("TypefaceCompatApi24Impl", "Unable to collect necessary private methods.Fallback to legacy implementation.");
                }
                if (C1720.f6035 != null) {
                    f6037 = new C1720();
                }
            }
            int i2 = Build.VERSION.SDK_INT;
            f6037 = new C1709();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static String m4426(Resources resources, int i, int i2) {
        return resources.getResourcePackageName(i) + "-" + i + "-" + i2;
    }

    /* renamed from: ῲ.ᨨ.ʬ.㸾$K  reason: contains not printable characters */
    /* compiled from: TypefaceCompat */
    public static class C1722 extends C1857 {

        /* renamed from: K  reason: contains not printable characters */
        public AbstractC1799 f6038;

        public C1722(AbstractC1799 r1) {
            this.f6038 = r1;
        }

        @Override // ῲ.ᨨ.㴹.C1857
        /* renamed from: K  reason: contains not printable characters */
        public void m4428(Typeface typeface) {
            AbstractC1799 r0 = this.f6038;
            if (r0 != null) {
                r0.onFontRetrieved(typeface);
            }
        }

        @Override // ῲ.ᨨ.㴹.C1857
        /* renamed from: K  reason: contains not printable characters */
        public void m4427(int i) {
            AbstractC1799 r0 = this.f6038;
            if (r0 != null) {
                r0.onFontRetrievalFailed(i);
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:9:0x0024, code lost:
        if (r0.equals(r4) == false) goto L_0x0028;
     */
    /* renamed from: K  reason: contains not printable characters */
    public static Typeface m4425(Context context, AbstractC1798 r6, Resources resources, int i, int i2, AbstractC1799 r10, Handler handler, boolean z) {
        Typeface typeface;
        Typeface typeface2;
        if (r6 instanceof C1797) {
            C1797 r62 = (C1797) r6;
            String str = r62.f6149;
            typeface = null;
            if (str != null && !str.isEmpty()) {
                typeface2 = Typeface.create(str, 0);
                Typeface create = Typeface.create(Typeface.DEFAULT, 0);
                if (typeface2 != null) {
                }
            }
            typeface2 = null;
            if (typeface2 != null) {
                if (r10 != null) {
                    r10.callbackSuccessAsync(typeface2, handler);
                }
                return typeface2;
            }
            boolean z2 = true;
            if (!z ? r10 != null : r62.f6146 != 0) {
                z2 = false;
            }
            int i3 = z ? r62.f6147 : -1;
            Handler handler2 = AbstractC1799.getHandler(handler);
            C1722 k = new C1722(r10);
            C1844 r63 = r62.f6148;
            C1843 r102 = new C1843(k, handler2);
            if (z2) {
                String r11 = C1849.m4818(r63, i2);
                Typeface r0 = C1849.f6286.m5962(r11);
                if (r0 != null) {
                    r102.f6266.post(new RunnableC1854(r102, r102.f6267, r0));
                    typeface = r0;
                } else if (i3 == -1) {
                    C1849.C1853 r5 = C1849.m4819(r11, context, r63, i2);
                    r102.m4815(r5);
                    typeface = r5.f6295;
                } else {
                    try {
                        try {
                            C1849.C1853 r52 = (C1849.C1853) C1849.f6285.submit(new CallableC1858(r11, context, r63, i2)).get((long) i3, TimeUnit.MILLISECONDS);
                            r102.m4815(r52);
                            typeface = r52.f6295;
                        } catch (ExecutionException e) {
                            throw new RuntimeException(e);
                        } catch (InterruptedException e2) {
                            throw e2;
                        } catch (TimeoutException unused) {
                            throw new InterruptedException("timeout");
                        }
                    } catch (InterruptedException unused2) {
                        r102.f6266.post(new RunnableC1848(r102, r102.f6267, -3));
                    }
                }
            } else {
                typeface = C1849.m4817(context, r63, i2, null, r102);
            }
        } else {
            typeface = f6037.m4417(context, (C1796) r6, resources, i2);
            if (r10 != null) {
                if (typeface != null) {
                    r10.callbackSuccessAsync(typeface, handler);
                } else {
                    r10.callbackFailAsync(-3, handler);
                }
            }
        }
        if (typeface != null) {
            f6036.m5963(m4426(resources, i, i2), typeface);
        }
        return typeface;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Typeface m4423(Context context, Resources resources, int i, String str, int i2) {
        Typeface r6 = f6037.m4414(context, resources, i, str, i2);
        if (r6 != null) {
            f6036.m5963(m4426(resources, i, i2), r6);
        }
        return r6;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Typeface m4424(Context context, Typeface typeface, int i) {
        if (context != null) {
            int i2 = Build.VERSION.SDK_INT;
            return Typeface.create(typeface, i);
        }
        throw new IllegalArgumentException("Context cannot be null");
    }
}
