what-the-bank/sources/o/AbstractC17450wpZ.java

223 lines
7.2 KiB
Java

package o;
import android.os.Binder;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/* renamed from: o.wpZ, reason: case insensitive filesystem */
/* loaded from: classes.dex */
abstract class AbstractC17450wpZ<Params, Progress, Result> {
private static LWm a;
public static final Executor b;
private static volatile Executor c;
private final FutureTask<Result> i;
private final HBt<Params, Result> j;
private volatile Sts g = Sts.PENDING;
final AtomicBoolean e = new AtomicBoolean();
final AtomicBoolean d = new AtomicBoolean();
/* renamed from: o.wpZ$Sts */
/* loaded from: classes.dex */
public enum Sts {
PENDING,
RUNNING,
FINISHED
}
protected void c(Result result) {
}
protected abstract Result d(Params... paramsArr);
protected void d(Result result) {
}
static {
ThreadFactory threadFactory = new ThreadFactory() { // from class: o.wpZ.2
private final AtomicInteger b = new AtomicInteger(1);
@Override // java.util.concurrent.ThreadFactory
public final Thread newThread(Runnable runnable) {
StringBuilder sb = new StringBuilder("ModernAsyncTask #");
sb.append(this.b.getAndIncrement());
return new Thread(runnable, sb.toString());
}
};
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 128, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue(10), threadFactory);
b = threadPoolExecutor;
c = threadPoolExecutor;
}
static Handler zC_() {
LWm lWm;
synchronized (AbstractC17450wpZ.class) {
if (a == null) {
a = new LWm();
}
lWm = a;
}
return lWm;
}
/* JADX INFO: Access modifiers changed from: package-private */
public AbstractC17450wpZ() {
HBt<Params, Result> hBt = new HBt<Params, Result>(this) { // from class: o.wpZ.1
final AbstractC17450wpZ a;
{
this.a = this;
}
@Override // java.util.concurrent.Callable
public final Result call() throws Exception {
this.a.d.set(true);
Result result = null;
try {
Process.setThreadPriority(10);
result = (Result) this.a.d((Object[]) this.b);
Binder.flushPendingCommands();
return result;
} finally {
}
}
};
this.j = hBt;
this.i = new FutureTask<Result>(this, hBt) { // from class: o.wpZ.3
final AbstractC17450wpZ a;
{
this.a = this;
}
@Override // java.util.concurrent.FutureTask
protected final void done() {
try {
Result result = get();
AbstractC17450wpZ abstractC17450wpZ = this.a;
if (abstractC17450wpZ.d.get()) {
return;
}
AbstractC17450wpZ.zC_().obtainMessage(1, new RVV(abstractC17450wpZ, result)).sendToTarget();
} catch (InterruptedException unused) {
} catch (CancellationException unused2) {
AbstractC17450wpZ abstractC17450wpZ2 = this.a;
if (abstractC17450wpZ2.d.get()) {
return;
}
AbstractC17450wpZ.zC_().obtainMessage(1, new RVV(abstractC17450wpZ2, null)).sendToTarget();
} catch (ExecutionException e) {
throw new RuntimeException("An error occurred while executing doInBackground()", e.getCause());
} catch (Throwable th) {
throw new RuntimeException("An error occurred while executing doInBackground()", th);
}
}
};
}
public final boolean d(boolean z) {
this.e.set(true);
return this.i.cancel(false);
}
/* renamed from: o.wpZ$4, reason: invalid class name */
/* loaded from: classes.dex */
static /* synthetic */ class AnonymousClass4 {
static final int[] b;
static {
int[] iArr = new int[Sts.values().length];
b = iArr;
try {
iArr[Sts.RUNNING.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
b[Sts.FINISHED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public final AbstractC17450wpZ<Params, Progress, Result> c(Executor executor, Params... paramsArr) {
if (this.g != Sts.PENDING) {
int i = AnonymousClass4.b[this.g.ordinal()];
if (i == 1) {
throw new IllegalStateException("Cannot execute task: the task is already running.");
}
if (i == 2) {
throw new IllegalStateException("Cannot execute task: the task has already been executed (a task can be executed only once)");
}
throw new IllegalStateException("We should never reach this state");
}
this.g = Sts.RUNNING;
this.j.b = null;
executor.execute(this.i);
return this;
}
final void b(Result result) {
if (this.e.get()) {
d((AbstractC17450wpZ<Params, Progress, Result>) result);
} else {
c(result);
}
this.g = Sts.FINISHED;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: o.wpZ$LWm */
/* loaded from: classes.dex */
public static class LWm extends Handler {
LWm() {
super(Looper.getMainLooper());
}
/* JADX WARN: Multi-variable type inference failed */
@Override // android.os.Handler
public final void handleMessage(Message message) {
RVV rvv = (RVV) message.obj;
int i = message.what;
if (i == 1) {
rvv.d.b(rvv.b[0]);
} else if (i == 2) {
AbstractC17450wpZ abstractC17450wpZ = rvv.d;
Data[] dataArr = rvv.b;
}
}
}
/* renamed from: o.wpZ$HBt */
/* loaded from: classes.dex */
static abstract class HBt<Params, Result> implements Callable<Result> {
Params[] b;
HBt() {
}
}
/* renamed from: o.wpZ$RVV */
/* loaded from: classes.dex */
static class RVV<Data> {
final Data[] b;
final AbstractC17450wpZ d;
RVV(AbstractC17450wpZ abstractC17450wpZ, Data... dataArr) {
this.d = abstractC17450wpZ;
this.b = dataArr;
}
}
}