package k6; import android.os.Process; import android.os.StrictMode; import android.text.TextUtils; import android.util.Log; import com.google.android.gms.common.api.Api; import java.util.Collection; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /* loaded from: classes2.dex */ public final class a implements ExecutorService { /* renamed from: b, reason: collision with root package name */ private static final long f11267b = TimeUnit.SECONDS.toMillis(10); /* renamed from: c, reason: collision with root package name */ private static volatile int f11268c; /* renamed from: a, reason: collision with root package name */ private final ExecutorService f11269a; /* renamed from: k6.a$a, reason: collision with other inner class name */ public static final class C0168a { /* renamed from: a, reason: collision with root package name */ private final boolean f11270a; /* renamed from: b, reason: collision with root package name */ private int f11271b; /* renamed from: c, reason: collision with root package name */ private int f11272c; /* renamed from: d, reason: collision with root package name */ private b f11273d = b.f11279d; /* renamed from: e, reason: collision with root package name */ private String f11274e; /* renamed from: f, reason: collision with root package name */ private long f11275f; C0168a(boolean z10) { this.f11270a = z10; } public a a() { if (TextUtils.isEmpty(this.f11274e)) { throw new IllegalArgumentException("Name must be non-null and non-empty, but given: " + this.f11274e); } ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(this.f11271b, this.f11272c, this.f11275f, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), new c(this.f11274e, this.f11273d, this.f11270a)); if (this.f11275f != 0) { threadPoolExecutor.allowCoreThreadTimeOut(true); } return new a(threadPoolExecutor); } public C0168a b(String str) { this.f11274e = str; return this; } public C0168a c(int i10) { this.f11271b = i10; this.f11272c = i10; return this; } } public interface b { /* renamed from: a, reason: collision with root package name */ public static final b f11276a = new C0169a(); /* renamed from: b, reason: collision with root package name */ public static final b f11277b; /* renamed from: c, reason: collision with root package name */ public static final b f11278c; /* renamed from: d, reason: collision with root package name */ public static final b f11279d; /* renamed from: k6.a$b$a, reason: collision with other inner class name */ class C0169a implements b { C0169a() { } @Override // k6.a.b public void a(Throwable th) { } } /* renamed from: k6.a$b$b, reason: collision with other inner class name */ class C0170b implements b { C0170b() { } @Override // k6.a.b public void a(Throwable th) { if (th == null || !Log.isLoggable("ImageModuleExecutor", 6)) { return; } Log.e("ImageModuleExecutor", "Request threw uncaught throwable", th); } } class c implements b { c() { } @Override // k6.a.b public void a(Throwable th) { if (th != null) { throw new RuntimeException("Request threw uncaught throwable", th); } } } static { C0170b c0170b = new C0170b(); f11277b = c0170b; f11278c = new c(); f11279d = c0170b; } void a(Throwable th); } private static final class c implements ThreadFactory { /* renamed from: a, reason: collision with root package name */ private final String f11280a; /* renamed from: b, reason: collision with root package name */ final b f11281b; /* renamed from: c, reason: collision with root package name */ final boolean f11282c; /* renamed from: d, reason: collision with root package name */ private int f11283d; /* renamed from: k6.a$c$a, reason: collision with other inner class name */ class C0171a extends Thread { C0171a(Runnable runnable, String str) { super(runnable, str); } @Override // java.lang.Thread, java.lang.Runnable public void run() { Process.setThreadPriority(9); if (c.this.f11282c) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectNetwork().penaltyDeath().build()); } try { super.run(); } catch (Throwable th) { c.this.f11281b.a(th); } } } c(String str, b bVar, boolean z10) { this.f11280a = str; this.f11281b = bVar; this.f11282c = z10; } @Override // java.util.concurrent.ThreadFactory public synchronized Thread newThread(Runnable runnable) { C0171a c0171a; c0171a = new C0171a(runnable, "ImageModule-" + this.f11280a + "-thread-" + this.f11283d); this.f11283d = this.f11283d + 1; return c0171a; } } a(ExecutorService executorService) { this.f11269a = executorService; } public static int a() { if (f11268c == 0) { f11268c = Math.min(4, k6.b.a()); } return f11268c; } public static C0168a b() { return new C0168a(true).c(a() >= 4 ? 2 : 1).b("animation"); } public static a c() { return b().a(); } public static C0168a d() { return new C0168a(true).c(1).b("disk-cache"); } public static a e() { return d().a(); } public static C0168a f() { return new C0168a(false).c(a()).b("source"); } public static a g() { return f().a(); } public static a h() { return new a(new ThreadPoolExecutor(0, Api.BaseClientBuilder.API_PRIORITY_OTHER, f11267b, TimeUnit.MILLISECONDS, new SynchronousQueue(), new c("source-unlimited", b.f11279d, false))); } @Override // java.util.concurrent.ExecutorService public boolean awaitTermination(long j10, TimeUnit timeUnit) { return this.f11269a.awaitTermination(j10, timeUnit); } @Override // java.util.concurrent.Executor public void execute(Runnable runnable) { this.f11269a.execute(runnable); } @Override // java.util.concurrent.ExecutorService public List invokeAll(Collection collection) { return this.f11269a.invokeAll(collection); } @Override // java.util.concurrent.ExecutorService public Object invokeAny(Collection collection) { return this.f11269a.invokeAny(collection); } @Override // java.util.concurrent.ExecutorService public boolean isShutdown() { return this.f11269a.isShutdown(); } @Override // java.util.concurrent.ExecutorService public boolean isTerminated() { return this.f11269a.isTerminated(); } @Override // java.util.concurrent.ExecutorService public void shutdown() { this.f11269a.shutdown(); } @Override // java.util.concurrent.ExecutorService public List shutdownNow() { return this.f11269a.shutdownNow(); } @Override // java.util.concurrent.ExecutorService public Future submit(Runnable runnable) { return this.f11269a.submit(runnable); } public String toString() { return this.f11269a.toString(); } @Override // java.util.concurrent.ExecutorService public List invokeAll(Collection collection, long j10, TimeUnit timeUnit) { return this.f11269a.invokeAll(collection, j10, timeUnit); } @Override // java.util.concurrent.ExecutorService public Object invokeAny(Collection collection, long j10, TimeUnit timeUnit) { return this.f11269a.invokeAny(collection, j10, timeUnit); } @Override // java.util.concurrent.ExecutorService public Future submit(Runnable runnable, Object obj) { return this.f11269a.submit(runnable, obj); } @Override // java.util.concurrent.ExecutorService public Future submit(Callable callable) { return this.f11269a.submit(callable); } }