package androidx.emoji2.text;

import android.content.Context;
import android.os.Build;
import androidx.emoji2.text.C0229g;
import androidx.emoji2.text.EmojiCompatInitializer;
import androidx.lifecycle.AbstractC0424i;
import androidx.lifecycle.C0402b;
import androidx.lifecycle.InterfaceC0404c;
import androidx.lifecycle.InterfaceC0434m;
import androidx.lifecycle.ProcessLifecycleInitializer;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;
import p011d0.C0623v;
import p068w0.C1790a;
import p068w0.InterfaceC1791b;

/* loaded from: classes.dex */
public class EmojiCompatInitializer implements InterfaceC1791b<Boolean> {

    /* renamed from: androidx.emoji2.text.EmojiCompatInitializer$a */
    /* loaded from: classes.dex */
    public static class C0214a extends C0229g.AbstractC0233c {
        public C0214a(Context context) {
            super(new C0215b(context));
            m4378b(1);
        }
    }

    /* renamed from: androidx.emoji2.text.EmojiCompatInitializer$b */
    /* loaded from: classes.dex */
    public static class C0215b implements C0229g.InterfaceC0237g {

        /* renamed from: a */
        public final Context f1058a;

        /* renamed from: androidx.emoji2.text.EmojiCompatInitializer$b$a */
        /* loaded from: classes.dex */
        public class C0216a extends C0229g.AbstractC0238h {

            /* renamed from: a */
            public final /* synthetic */ C0229g.AbstractC0238h f1059a;

            /* renamed from: b */
            public final /* synthetic */ ThreadPoolExecutor f1060b;

            public C0216a(C0229g.AbstractC0238h abstractC0238h, ThreadPoolExecutor threadPoolExecutor) {
                this.f1059a = abstractC0238h;
                this.f1060b = threadPoolExecutor;
            }

            @Override // androidx.emoji2.text.C0229g.AbstractC0238h
            /* renamed from: a */
            public void mo4375a(Throwable th) {
                try {
                    this.f1059a.mo4375a(th);
                } finally {
                    this.f1060b.shutdown();
                }
            }

            @Override // androidx.emoji2.text.C0229g.AbstractC0238h
            /* renamed from: b */
            public void mo4374b(C0255p c0255p) {
                try {
                    this.f1059a.mo4374b(c0255p);
                } finally {
                    this.f1060b.shutdown();
                }
            }
        }

        public C0215b(Context context) {
            this.f1058a = context.getApplicationContext();
        }

        @Override // androidx.emoji2.text.C0229g.InterfaceC0237g
        /* renamed from: a */
        public void mo4336a(final C0229g.AbstractC0238h abstractC0238h) {
            final ThreadPoolExecutor m4423b = C0219b.m4423b("EmojiCompatInitializer");
            m4423b.execute(new Runnable() { // from class: androidx.emoji2.text.h
                @Override // java.lang.Runnable
                public final void run() {
                    EmojiCompatInitializer.C0215b.this.m4425d(abstractC0238h, m4423b);
                }
            });
        }

        /* renamed from: c */
        public void m4425d(C0229g.AbstractC0238h abstractC0238h, ThreadPoolExecutor threadPoolExecutor) {
            try {
                C0247m m4419a = C0221c.m4419a(this.f1058a);
                if (m4419a == null) {
                    throw new RuntimeException("EmojiCompat font provider not available on this device.");
                }
                m4419a.m4340c(threadPoolExecutor);
                m4419a.m4379a().mo4336a(new C0216a(abstractC0238h, threadPoolExecutor));
            } catch (Throwable th) {
                abstractC0238h.mo4375a(th);
                threadPoolExecutor.shutdown();
            }
        }
    }

    /* renamed from: androidx.emoji2.text.EmojiCompatInitializer$c */
    /* loaded from: classes.dex */
    public static class RunnableC0217c implements Runnable {
        @Override // java.lang.Runnable
        public void run() {
            try {
                C0623v.m3248a("EmojiCompat.EmojiCompatInitializer.run");
                if (C0229g.m4397h()) {
                    C0229g.m4403b().m4394k();
                }
            } finally {
                C0623v.m3247b();
            }
        }
    }

    @Override // p068w0.InterfaceC1791b
    /* renamed from: a */
    public List<Class<? extends InterfaceC1791b<?>>> mo393a() {
        return Collections.singletonList(ProcessLifecycleInitializer.class);
    }

    @Override // p068w0.InterfaceC1791b
    /* renamed from: c */
    public Boolean mo392b(Context context) {
        if (Build.VERSION.SDK_INT >= 19) {
            C0229g.m4398g(new C0214a(context));
            m4429d(context);
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }

    /* renamed from: d */
    public void m4429d(Context context) {
        final AbstractC0424i mo421a = ((InterfaceC0434m) C1790a.m396e(context).m395f(ProcessLifecycleInitializer.class)).mo421a();
        mo421a.mo3693a(new InterfaceC0404c() { // from class: androidx.emoji2.text.EmojiCompatInitializer.1
            @Override // androidx.lifecycle.InterfaceC0416e
            /* renamed from: a */
            public void mo3717a(InterfaceC0434m interfaceC0434m) {
                EmojiCompatInitializer.this.m4428e();
                mo421a.mo3691c(this);
            }

            @Override // androidx.lifecycle.InterfaceC0416e
            /* renamed from: b */
            public /* synthetic */ void mo3716b(InterfaceC0434m interfaceC0434m) {
                C0402b.m3728b(this, interfaceC0434m);
            }

            @Override // androidx.lifecycle.InterfaceC0416e
            /* renamed from: c */
            public /* synthetic */ void mo3715c(InterfaceC0434m interfaceC0434m) {
                C0402b.m3729a(this, interfaceC0434m);
            }

            @Override // androidx.lifecycle.InterfaceC0416e
            /* renamed from: e */
            public /* synthetic */ void mo3714e(InterfaceC0434m interfaceC0434m) {
                C0402b.m3727c(this, interfaceC0434m);
            }

            @Override // androidx.lifecycle.InterfaceC0416e
            /* renamed from: f */
            public /* synthetic */ void mo3713f(InterfaceC0434m interfaceC0434m) {
                C0402b.m3725e(this, interfaceC0434m);
            }

            @Override // androidx.lifecycle.InterfaceC0416e
            /* renamed from: g */
            public /* synthetic */ void mo3712g(InterfaceC0434m interfaceC0434m) {
                C0402b.m3726d(this, interfaceC0434m);
            }
        });
    }

    /* renamed from: e */
    public void m4428e() {
        C0219b.m4421d().postDelayed(new RunnableC0217c(), 500L);
    }
}