content: package androidx.emoji2.text;
  
  import android.content.Context;
  import android.os.Build;
  import androidx.core.os.TraceCompat;
  import androidx.emoji2.text.EmojiCompat;
  import androidx.lifecycle.DefaultLifecycleObserver;
  import androidx.lifecycle.Lifecycle;
  import androidx.lifecycle.LifecycleOwner;
  import androidx.lifecycle.ProcessLifecycleInitializer;
  import androidx.startup.AppInitializer;
  import androidx.startup.Initializer;
  import java.util.Collections;
  import java.util.List;
  import java.util.concurrent.ThreadPoolExecutor;
  
  public class EmojiCompatInitializer implements Initializer<Boolean> {
      private static final long STARTUP_THREAD_CREATION_DELAY_MS = 500;
      private static final String S_INITIALIZER_THREAD_NAME = "EmojiCompatInitializer";
  
      static class BackgroundDefaultConfig extends EmojiCompat.Config {
          protected BackgroundDefaultConfig(Context context) {
              super(new BackgroundDefaultLoader(context));
              setMetadataLoadStrategy(1);
          }
      }
  
      static class BackgroundDefaultLoader implements EmojiCompat.MetadataRepoLoader {
          private final Context mContext;
  
          BackgroundDefaultLoader(Context context) {
              this.mContext = context.getApplicationContext();
          }
  
          /* access modifiers changed from: package-private */
          /* renamed from: doLoad */
          public void m29lambda$load$0$androidxemoji2textEmojiCompatInitializer$BackgroundDefaultLoader(final EmojiCompat.MetadataRepoLoaderCallback loaderCallback, final ThreadPoolExecutor executor) {
              try {
                  FontRequestEmojiCompatConfig create = DefaultEmojiCompatConfig.create(this.mContext);
                  if (create != null) {
                      create.setLoadingExecutor(executor);
                      create.getMetadataRepoLoader().load(new EmojiCompat.MetadataRepoLoaderCallback() {
                          public void onFailed(Throwable throwable) {
                              try {
                                  loaderCallback.onFailed(throwable);
                              } finally {
                                  executor.shutdown();
                              }
                          }
  
                          public void onLoaded(MetadataRepo metadataRepo) {
                              try {
                                  loaderCallback.onLoaded(metadataRepo);
                              } finally {
                                  executor.shutdown();
                              }
                          }
                      });
                      return;
                  }
                  throw new RuntimeException("EmojiCompat font provider not available on this device.");
              } catch (Throwable th) {
                  loaderCallback.onFailed(th);
                  executor.shutdown();
              }
          }
  
          public void load(EmojiCompat.MetadataRepoLoaderCallback loaderCallback) {
              ThreadPoolExecutor createBackgroundPriorityExecutor = ConcurrencyHelpers.createBackgroundPriorityExecutor(EmojiCompatInitializer.S_INITIALIZER_THREAD_NAME);
              createBackgroundPriorityExecutor.execute(new EmojiCompatInitializer$BackgroundDefaultLoader$$ExternalSyntheticLambda0(this, loaderCallback, createBackgroundPriorityExecutor));
          }
      }
  
      static class LoadEmojiCompatRunnable implements Runnable {
          LoadEmojiCompatRunnable() {
          }
  
          public void run() {
              try {
                  TraceCompat.beginSection("EmojiCompat.EmojiCompatInitializer.run");
                  if (EmojiCompat.isConfigured()) {
                      EmojiCompat.get().load();
                  }
              } finally {
                  TraceCompat.endSection();
              }
          }
      }
  
      public Boolean create(Context context) {
          if (Build.VERSION.SDK_INT < 19) {
              return false;
          }
          EmojiCompat.init((EmojiCompat.Config) new BackgroundDefaultConfig(context));
          delayUntilFirstResume(context);
          return true;
      }
  
      /* access modifiers changed from: package-private */
      public void delayUntilFirstResume(Context context) {
          final Lifecycle lifecycle = ((LifecycleOwner) AppInitializer.getInstance(context).initializeComponent(ProcessLifecycleInitializer.class)).getLifecycle();
          lifecycle.addObserver(new DefaultLifecycleObserver() {
              public void onResume(LifecycleOwner owner) {
                  EmojiCompatInitializer.this.loadEmojiCompatAfterDelay();
                  lifecycle.removeObserver(this);
              }
          });
      }
  
      public List<Class<? extends Initializer<?>>> dependencies() {
          return Collections.singletonList(ProcessLifecycleInitializer.class);
      }
  
      /* access modifiers changed from: package-private */
      public void loadEmojiCompatAfterDelay() {
          ConcurrencyHelpers.mainHandlerAsync().postDelayed(new LoadEmojiCompatRunnable(), STARTUP_THREAD_CREATION_DELAY_MS);
      }
  }
  