package ῲ.ᨨ.㴹;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.CancellationSignal;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import ῲ.ᨨ.ʬ.C1721;
import ῲ.ᨨ.㿎.AbstractC1869;
import ῲ.㴹.C2286;
import ῲ.㴹.C2288;

/* renamed from: ῲ.ᨨ.㴹.ⁱ  reason: contains not printable characters */
/* compiled from: FontRequestWorker */
public class C1849 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final Object f6284 = new Object();

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final ExecutorService f6285;

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

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final C2288<String, ArrayList<AbstractC1869<C1853>>> f6287 = new C2288<>();

    /* renamed from: ῲ.ᨨ.㴹.ⁱ$ʬ  reason: contains not printable characters */
    /* compiled from: FontRequestWorker */
    public class C1850 implements AbstractC1869<C1853> {

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ String f6288;

        public C1850(String str) {
            this.f6288 = str;
        }

        /* JADX WARNING: Code restructure failed: missing block: B:11:0x001e, code lost:
            if (r0 >= r1.size()) goto L_0x002c;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:12:0x0020, code lost:
            r1.get(r0).accept(r5);
            r0 = r0 + 1;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:13:0x002c, code lost:
            return;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:9:0x0019, code lost:
            r0 = 0;
         */
        /* renamed from: K  reason: contains not printable characters */
        public void accept(C1853 r5) {
            synchronized (C1849.f6284) {
                ArrayList<AbstractC1869<C1853>> arrayList = C1849.f6287.get(this.f6288);
                if (arrayList != null) {
                    C1849.f6287.remove(this.f6288);
                }
            }
        }
    }

    /* renamed from: ῲ.ᨨ.㴹.ⁱ$ῲ  reason: contains not printable characters */
    /* compiled from: FontRequestWorker */
    public class CallableC1851 implements Callable<C1853> {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ Context f6289;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final /* synthetic */ int f6290;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ String f6291;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ C1844 f6292;

        public CallableC1851(String str, Context context, C1844 r3, int i) {
            this.f6291 = str;
            this.f6289 = context;
            this.f6292 = r3;
            this.f6290 = i;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // java.util.concurrent.Callable
        public C1853 call() throws Exception {
            return C1849.m4819(this.f6291, this.f6289, this.f6292, this.f6290);
        }
    }

    /* renamed from: ῲ.ᨨ.㴹.ⁱ$K  reason: contains not printable characters */
    /* compiled from: FontRequestWorker */
    public class C1852 implements AbstractC1869<C1853> {

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ C1843 f6293;

        public C1852(C1843 r1) {
            this.f6293 = r1;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // ῲ.ᨨ.㿎.AbstractC1869
        public void accept(C1853 r2) {
            this.f6293.m4815(r2);
        }
    }

    static {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, (long) 10000, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), new ThreadFactoryC1845("fonts-androidx", 10));
        threadPoolExecutor.allowCoreThreadTimeOut(true);
        f6285 = threadPoolExecutor;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static String m4818(C1844 r1, int i) {
        return r1.f6272 + "-" + i;
    }

    /* renamed from: ῲ.ᨨ.㴹.ⁱ$㸾  reason: contains not printable characters */
    /* compiled from: FontRequestWorker */
    public static final class C1853 {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final int f6294;

        /* renamed from: K  reason: contains not printable characters */
        public final Typeface f6295;

        public C1853(int i) {
            this.f6295 = null;
            this.f6294 = i;
        }

        @SuppressLint({"WrongConstant"})
        public C1853(Typeface typeface) {
            this.f6295 = typeface;
            this.f6294 = 0;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:14:0x004f, code lost:
        r8 = new ῲ.ᨨ.㴹.C1849.CallableC1851(r0, r4, r5, r6);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0054, code lost:
        if (r7 != null) goto L_0x0058;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x0056, code lost:
        r7 = ῲ.ᨨ.㴹.C1849.f6285;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0058, code lost:
        r4 = new ῲ.ᨨ.㴹.C1849.C1850(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0061, code lost:
        if (android.os.Looper.myLooper() != null) goto L_0x006d;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0063, code lost:
        r5 = new android.os.Handler(android.os.Looper.getMainLooper());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x006d, code lost:
        r5 = new android.os.Handler();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x0072, code lost:
        r7.execute(new ῲ.ᨨ.㴹.RunnableC1855(r5, r8, r4));
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:0x007a, code lost:
        return null;
     */
    /* renamed from: K  reason: contains not printable characters */
    public static Typeface m4817(Context context, C1844 r5, int i, Executor executor, C1843 r8) {
        String str = r5.f6272 + "-" + i;
        Typeface r1 = f6286.m5962(str);
        if (r1 != null) {
            r8.m4815(new C1853(r1));
            return r1;
        }
        C1852 k = new C1852(r8);
        synchronized (f6284) {
            ArrayList<AbstractC1869<C1853>> orDefault = f6287.getOrDefault(str, null);
            if (orDefault != null) {
                orDefault.add(k);
                return null;
            }
            ArrayList<AbstractC1869<C1853>> arrayList = new ArrayList<>();
            arrayList.add(k);
            f6287.put(str, arrayList);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static C1853 m4819(String str, Context context, C1844 r9, int i) {
        int i2;
        Typeface r0 = f6286.m5962(str);
        if (r0 != null) {
            return new C1853(r0);
        }
        try {
            C1861 r92 = C1859.m4823(context, r9, null);
            int i3 = r92.f6309;
            int i4 = 1;
            if (i3 != 0) {
                i2 = i3 != 1 ? -3 : -2;
            } else {
                C1847[] r1 = r92.f6308;
                if (!(r1 == null || r1.length == 0)) {
                    for (C1847 r6 : r1) {
                        int i5 = r6.f6278;
                        if (i5 != 0) {
                            if (i5 < 0) {
                                i5 = -3;
                            }
                            i2 = i5;
                        }
                    }
                    i4 = 0;
                }
                i2 = i4;
            }
            if (i2 != 0) {
                return new C1853(i2);
            }
            Typeface r8 = C1721.f6037.m4415(context, (CancellationSignal) null, r92.f6308, i);
            if (r8 == null) {
                return new C1853(-3);
            }
            f6286.m5963(str, r8);
            return new C1853(r8);
        } catch (PackageManager.NameNotFoundException unused) {
            return new C1853(-1);
        }
    }
}
