172 lines
5.6 KiB
Java
172 lines
5.6 KiB
Java
package c.f.j.p;
|
|
|
|
import android.os.SystemClock;
|
|
import c.f.d.g.g;
|
|
import c.f.d.g.i;
|
|
import c.f.j.j.e;
|
|
import c.f.j.j.f;
|
|
import c.f.j.p.a0;
|
|
import c.f.j.p.n0;
|
|
import c.f.j.r.b;
|
|
import com.facebook.common.references.CloseableReference;
|
|
import com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.HashMap;
|
|
import java.util.Objects;
|
|
/* compiled from: NetworkFetchProducer */
|
|
public class m0 implements v0<e> {
|
|
public final g a;
|
|
public final c.f.d.g.a b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final n0 f485c;
|
|
|
|
/* compiled from: NetworkFetchProducer */
|
|
public class a implements n0.a {
|
|
public final /* synthetic */ x a;
|
|
|
|
public a(x xVar) {
|
|
this.a = xVar;
|
|
}
|
|
|
|
public void a(Throwable th) {
|
|
m0 m0Var = m0.this;
|
|
x xVar = this.a;
|
|
Objects.requireNonNull(m0Var);
|
|
xVar.a().k(xVar.b, "NetworkFetchProducer", th, null);
|
|
xVar.a().c(xVar.b, "NetworkFetchProducer", false);
|
|
xVar.b.n("network");
|
|
xVar.a.c(th);
|
|
}
|
|
|
|
/* JADX INFO: finally extract failed */
|
|
public void b(InputStream inputStream, int i) throws IOException {
|
|
b.b();
|
|
m0 m0Var = m0.this;
|
|
x xVar = this.a;
|
|
i e = i > 0 ? m0Var.a.e(i) : m0Var.a.a();
|
|
byte[] bArr = m0Var.b.get(16384);
|
|
while (true) {
|
|
try {
|
|
int read = inputStream.read(bArr);
|
|
if (read < 0) {
|
|
n0 n0Var = m0Var.f485c;
|
|
int i2 = ((MemoryPooledByteBufferOutputStream) e).k;
|
|
a0 a0Var = (a0) n0Var;
|
|
Objects.requireNonNull(a0Var);
|
|
((a0.a) xVar).f = a0Var.f462c.now();
|
|
m0Var.c(e, xVar);
|
|
m0Var.b.release(bArr);
|
|
e.close();
|
|
b.b();
|
|
return;
|
|
} else if (read > 0) {
|
|
e.write(bArr, 0, read);
|
|
m0Var.d(e, xVar);
|
|
int i3 = ((MemoryPooledByteBufferOutputStream) e).k;
|
|
xVar.a.a(i > 0 ? ((float) i3) / ((float) i) : 1.0f - ((float) Math.exp(((double) (-i3)) / 50000.0d)));
|
|
}
|
|
} catch (Throwable th) {
|
|
m0Var.b.release(bArr);
|
|
e.close();
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public m0(g gVar, c.f.d.g.a aVar, n0 n0Var) {
|
|
this.a = gVar;
|
|
this.b = aVar;
|
|
this.f485c = n0Var;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:12:0x002c */
|
|
/* JADX WARNING: Removed duplicated region for block: B:14:0x0031 */
|
|
public static void e(i iVar, int i, c.f.j.d.a aVar, l<e> lVar, w0 w0Var) {
|
|
Throwable th;
|
|
CloseableReference C = CloseableReference.C(((MemoryPooledByteBufferOutputStream) iVar).b());
|
|
e eVar = null;
|
|
try {
|
|
e eVar2 = new e(C);
|
|
try {
|
|
eVar2.r = null;
|
|
eVar2.p();
|
|
w0Var.h(f.NETWORK);
|
|
lVar.b(eVar2, i);
|
|
eVar2.close();
|
|
if (C != null) {
|
|
C.close();
|
|
}
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
eVar = eVar2;
|
|
if (eVar != null) {
|
|
eVar.close();
|
|
}
|
|
if (C != null) {
|
|
C.close();
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
if (eVar != null) {
|
|
}
|
|
if (C != null) {
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@Override // c.f.j.p.v0
|
|
public void b(l<e> lVar, w0 w0Var) {
|
|
w0Var.o().e(w0Var, "NetworkFetchProducer");
|
|
Objects.requireNonNull((a0) this.f485c);
|
|
a0.a aVar = new a0.a(lVar, w0Var);
|
|
n0 n0Var = this.f485c;
|
|
a aVar2 = new a(aVar);
|
|
a0 a0Var = (a0) n0Var;
|
|
Objects.requireNonNull(a0Var);
|
|
aVar.d = a0Var.f462c.now();
|
|
w0Var.f(new z(a0Var, a0Var.b.submit(new y(a0Var, aVar, aVar2)), aVar2));
|
|
}
|
|
|
|
public void c(i iVar, x xVar) {
|
|
HashMap hashMap;
|
|
int i = ((MemoryPooledByteBufferOutputStream) iVar).k;
|
|
if (!xVar.a().g(xVar.b, "NetworkFetchProducer")) {
|
|
hashMap = null;
|
|
} else {
|
|
Objects.requireNonNull((a0) this.f485c);
|
|
a0.a aVar = (a0.a) xVar;
|
|
hashMap = new HashMap(4);
|
|
hashMap.put("queue_time", Long.toString(aVar.e - aVar.d));
|
|
hashMap.put("fetch_time", Long.toString(aVar.f - aVar.e));
|
|
hashMap.put("total_time", Long.toString(aVar.f - aVar.d));
|
|
hashMap.put("image_size", Integer.toString(i));
|
|
}
|
|
y0 a2 = xVar.a();
|
|
a2.j(xVar.b, "NetworkFetchProducer", hashMap);
|
|
a2.c(xVar.b, "NetworkFetchProducer", true);
|
|
xVar.b.n("network");
|
|
e(iVar, 1, null, xVar.a, xVar.b);
|
|
}
|
|
|
|
public void d(i iVar, x xVar) {
|
|
boolean z2;
|
|
long uptimeMillis = SystemClock.uptimeMillis();
|
|
if (!xVar.b.p()) {
|
|
z2 = false;
|
|
} else {
|
|
Objects.requireNonNull(this.f485c);
|
|
z2 = true;
|
|
}
|
|
if (z2 && uptimeMillis - xVar.f505c >= 100) {
|
|
xVar.f505c = uptimeMillis;
|
|
xVar.a().a(xVar.b, "NetworkFetchProducer", "intermediate_result");
|
|
e(iVar, 0, null, xVar.a, xVar.b);
|
|
}
|
|
}
|
|
}
|