package com.ironsource; import android.os.Handler; import com.ironsource.sdk.utils.IronSourceStorageUtils; import java.util.concurrent.TimeUnit; import org.json.JSONObject; /* loaded from: classes2.dex */ public class ra implements de { private static final int e = 5; private static ra f; private qa a; private final JSONObject b; private Thread c; private final String d; private ra(String str, ve veVar, JSONObject jSONObject) { this.d = str; this.a = new qa(veVar.a()); this.b = jSONObject; IronSourceStorageUtils.deleteFolder(b()); IronSourceStorageUtils.makeDir(b()); } public static synchronized ra a(String str, ve veVar, JSONObject jSONObject) { ra raVar; synchronized (ra.class) { try { if (f == null) { f = new ra(str, veVar, jSONObject); } raVar = f; } catch (Throwable th) { throw th; } } return raVar; } private Thread a(oa oaVar, Handler handler) { return new Thread(new fs(oaVar, handler)); } private String b() { return IronSourceStorageUtils.buildAbsolutePathToDirInCache(this.d, x8.D); } private Thread b(zf zfVar, String str, int i, int i2, Handler handler) { if (i <= 0) { i = this.b.optInt("connectionTimeout", 5); } if (i2 <= 0) { i2 = this.b.optInt("readTimeout", 5); } boolean optBoolean = this.b.optBoolean(x8.H, false); TimeUnit timeUnit = TimeUnit.SECONDS; return a(new oa(zfVar, str, (int) timeUnit.toMillis(i), (int) timeUnit.toMillis(i2), optBoolean, b()), handler); } public String a() { return this.d; } @Override // com.ironsource.de public void a(hn hnVar) { this.a.a(hnVar); } @Override // com.ironsource.de public void a(zf zfVar, String str) { int optInt = this.b.optInt("connectionTimeout", 5); int optInt2 = this.b.optInt("readTimeout", 5); boolean optBoolean = this.b.optBoolean(x8.H, false); TimeUnit timeUnit = TimeUnit.SECONDS; Thread a = a(new oa(zfVar, str, (int) timeUnit.toMillis(optInt), (int) timeUnit.toMillis(optInt2), optBoolean, b()), this.a); this.c = a; a.start(); } @Override // com.ironsource.de public void a(zf zfVar, String str, int i, int i2) { b(zfVar, str, i, i2, this.a).start(); } @Override // com.ironsource.de public void a(zf zfVar, String str, int i, int i2, Handler handler) { b(zfVar, str, i, i2, handler).start(); } public boolean c() { Thread thread = this.c; return thread != null && thread.isAlive(); } public synchronized void d() { f = null; qa qaVar = this.a; if (qaVar != null) { qaVar.a(); this.a = null; } } }