Files

91 lines
4.7 KiB
Java

package com.google.firebase.concurrent;
import android.annotation.SuppressLint;
import android.os.StrictMode;
import com.google.firebase.annotations.concurrent.Background;
import com.google.firebase.annotations.concurrent.Blocking;
import com.google.firebase.annotations.concurrent.Lightweight;
import com.google.firebase.annotations.concurrent.UiThread;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentContainer;
import com.google.firebase.components.ComponentRegistrar;
import com.google.firebase.components.Lazy;
import com.google.firebase.components.Qualified;
import com.google.firebase.inject.Provider;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
@SuppressLint({"ThreadPoolCreation"})
/* loaded from: classes3.dex */
public class ExecutorsRegistrar implements ComponentRegistrar {
static final Lazy<ScheduledExecutorService> BG_EXECUTOR = new Lazy<>((Provider) new g(0));
static final Lazy<ScheduledExecutorService> LITE_EXECUTOR = new Lazy<>((Provider) new g(1));
static final Lazy<ScheduledExecutorService> BLOCKING_EXECUTOR = new Lazy<>((Provider) new g(2));
static final Lazy<ScheduledExecutorService> SCHEDULER = new Lazy<>((Provider) new g(3));
private static StrictMode.ThreadPolicy bgPolicy() {
StrictMode.ThreadPolicy.Builder detectNetwork = new StrictMode.ThreadPolicy.Builder().detectNetwork();
detectNetwork.detectResourceMismatches();
detectNetwork.detectUnbufferedIo();
return detectNetwork.penaltyLog().build();
}
private static ThreadFactory factory(String str, int i) {
return new CustomThreadFactory(str, i, null);
}
public static /* synthetic */ ScheduledExecutorService lambda$getComponents$4(ComponentContainer componentContainer) {
return BG_EXECUTOR.get();
}
public static /* synthetic */ ScheduledExecutorService lambda$getComponents$5(ComponentContainer componentContainer) {
return BLOCKING_EXECUTOR.get();
}
public static /* synthetic */ ScheduledExecutorService lambda$getComponents$6(ComponentContainer componentContainer) {
return LITE_EXECUTOR.get();
}
public static /* synthetic */ Executor lambda$getComponents$7(ComponentContainer componentContainer) {
return UiExecutor.INSTANCE;
}
public static /* synthetic */ ScheduledExecutorService lambda$static$0() {
return scheduled(Executors.newFixedThreadPool(4, factory("Firebase Background", 10, bgPolicy())));
}
public static /* synthetic */ ScheduledExecutorService lambda$static$1() {
return scheduled(Executors.newFixedThreadPool(Math.max(2, Runtime.getRuntime().availableProcessors()), factory("Firebase Lite", 0, litePolicy())));
}
public static /* synthetic */ ScheduledExecutorService lambda$static$2() {
return scheduled(Executors.newCachedThreadPool(factory("Firebase Blocking", 11)));
}
public static /* synthetic */ ScheduledExecutorService lambda$static$3() {
return Executors.newSingleThreadScheduledExecutor(factory("Firebase Scheduler", 0));
}
private static StrictMode.ThreadPolicy litePolicy() {
return new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build();
}
private static ScheduledExecutorService scheduled(ExecutorService executorService) {
return new DelegatingScheduledExecutorService(executorService, SCHEDULER.get());
}
@Override // com.google.firebase.components.ComponentRegistrar
public List<Component<?>> getComponents() {
return Arrays.asList(Component.builder(Qualified.qualified(Background.class, ScheduledExecutorService.class), Qualified.qualified(Background.class, ExecutorService.class), Qualified.qualified(Background.class, Executor.class)).factory(new M2.a(2)).build(), Component.builder(Qualified.qualified(Blocking.class, ScheduledExecutorService.class), Qualified.qualified(Blocking.class, ExecutorService.class), Qualified.qualified(Blocking.class, Executor.class)).factory(new M2.a(3)).build(), Component.builder(Qualified.qualified(Lightweight.class, ScheduledExecutorService.class), Qualified.qualified(Lightweight.class, ExecutorService.class), Qualified.qualified(Lightweight.class, Executor.class)).factory(new M2.a(4)).build(), Component.builder(Qualified.qualified(UiThread.class, Executor.class)).factory(new M2.a(5)).build());
}
private static ThreadFactory factory(String str, int i, StrictMode.ThreadPolicy threadPolicy) {
return new CustomThreadFactory(str, i, threadPolicy);
}
}