package o;

import android.content.Context;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
import android.os.Handler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.zA, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C3075zA implements InterfaceC1909mv {
    public final Context l;
    public final C2980yA m;
    public final J7 n;

    /* renamed from: o, reason: collision with root package name */
    public final Object f821o = new Object();
    public Handler p;
    public ThreadPoolExecutor q;
    public ThreadPoolExecutor r;
    public AbstractC0249Jp s;
    public ContentObserver t;

    public C3075zA(Context context, C2980yA c2980yA) {
        AbstractC0249Jp.x(context, "Context cannot be null");
        this.l = context.getApplicationContext();
        this.m = c2980yA;
        this.n = AA.d;
    }

    @Override // o.InterfaceC1909mv
    public final void a(AbstractC0249Jp abstractC0249Jp) {
        synchronized (this.f821o) {
            this.s = abstractC0249Jp;
        }
        synchronized (this.f821o) {
            try {
                if (this.s == null) {
                    return;
                }
                if (this.q == null) {
                    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, 15L, TimeUnit.SECONDS, new LinkedBlockingDeque(), new ThreadFactoryC1126el("emojiCompat"));
                    threadPoolExecutor.allowCoreThreadTimeOut(true);
                    this.r = threadPoolExecutor;
                    this.q = threadPoolExecutor;
                }
                this.q.execute(new RunnableC2108p1(12, this));
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void b() {
        synchronized (this.f821o) {
            try {
                this.s = null;
                ContentObserver contentObserver = this.t;
                if (contentObserver != null) {
                    J7 j7 = this.n;
                    Context context = this.l;
                    j7.getClass();
                    context.getContentResolver().unregisterContentObserver(contentObserver);
                    this.t = null;
                }
                Handler handler = this.p;
                if (handler != null) {
                    handler.removeCallbacks(null);
                }
                this.p = null;
                ThreadPoolExecutor threadPoolExecutor = this.r;
                if (threadPoolExecutor != null) {
                    threadPoolExecutor.shutdown();
                }
                this.q = null;
                this.r = null;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final QA c() {
        try {
            J7 j7 = this.n;
            Context context = this.l;
            C2980yA c2980yA = this.m;
            j7.getClass();
            Object[] objArr = {c2980yA};
            ArrayList arrayList = new ArrayList(1);
            Object obj = objArr[0];
            Objects.requireNonNull(obj);
            arrayList.add(obj);
            C1254g2 c1254g2A = AbstractC2885xA.a(context, Collections.unmodifiableList(arrayList));
            int i = c1254g2A.m;
            if (i != 0) {
                throw new RuntimeException(AbstractC0126Ew.k(i, "fetchFonts failed (", ")"));
            }
            QA[] qaArr = (QA[]) ((List) c1254g2A.n).get(0);
            if (qaArr == null || qaArr.length == 0) {
                throw new RuntimeException("fetchFonts failed (empty result)");
            }
            return qaArr[0];
        } catch (PackageManager.NameNotFoundException e) {
            throw new RuntimeException("provider not found", e);
        }
    }
}
