- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
180 lines
7.1 KiB
Java
180 lines
7.1 KiB
Java
package com.google.firebase.perf.network;
|
|
|
|
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
|
|
import com.google.firebase.perf.util.Timer;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class InstrHttpInputStream extends InputStream {
|
|
public final InputStream inputStream;
|
|
public final NetworkRequestMetricBuilder networkMetricBuilder;
|
|
public long timeToResponseInitiated;
|
|
public final Timer timer;
|
|
public long bytesRead = -1;
|
|
public long timeToResponseLastRead = -1;
|
|
|
|
public InstrHttpInputStream(InputStream inputStream, NetworkRequestMetricBuilder networkRequestMetricBuilder, Timer timer) {
|
|
this.timer = timer;
|
|
this.inputStream = inputStream;
|
|
this.networkMetricBuilder = networkRequestMetricBuilder;
|
|
this.timeToResponseInitiated = networkRequestMetricBuilder.getTimeToResponseInitiatedMicros();
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int available() {
|
|
try {
|
|
return this.inputStream.available();
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() {
|
|
long durationMicros = this.timer.getDurationMicros();
|
|
if (this.timeToResponseLastRead == -1) {
|
|
this.timeToResponseLastRead = durationMicros;
|
|
}
|
|
try {
|
|
this.inputStream.close();
|
|
long j = this.bytesRead;
|
|
if (j != -1) {
|
|
this.networkMetricBuilder.setResponsePayloadBytes(j);
|
|
}
|
|
long j2 = this.timeToResponseInitiated;
|
|
if (j2 != -1) {
|
|
this.networkMetricBuilder.setTimeToResponseInitiatedMicros(j2);
|
|
}
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timeToResponseLastRead);
|
|
this.networkMetricBuilder.build();
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public void mark(int i) {
|
|
this.inputStream.mark(i);
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public boolean markSupported() {
|
|
return this.inputStream.markSupported();
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read() {
|
|
try {
|
|
int read = this.inputStream.read();
|
|
long durationMicros = this.timer.getDurationMicros();
|
|
if (this.timeToResponseInitiated == -1) {
|
|
this.timeToResponseInitiated = durationMicros;
|
|
}
|
|
if (read == -1 && this.timeToResponseLastRead == -1) {
|
|
this.timeToResponseLastRead = durationMicros;
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
|
|
this.networkMetricBuilder.build();
|
|
} else {
|
|
long j = this.bytesRead + 1;
|
|
this.bytesRead = j;
|
|
this.networkMetricBuilder.setResponsePayloadBytes(j);
|
|
}
|
|
return read;
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read(byte[] bArr, int i, int i2) {
|
|
try {
|
|
int read = this.inputStream.read(bArr, i, i2);
|
|
long durationMicros = this.timer.getDurationMicros();
|
|
if (this.timeToResponseInitiated == -1) {
|
|
this.timeToResponseInitiated = durationMicros;
|
|
}
|
|
if (read == -1 && this.timeToResponseLastRead == -1) {
|
|
this.timeToResponseLastRead = durationMicros;
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
|
|
this.networkMetricBuilder.build();
|
|
} else {
|
|
long j = this.bytesRead + read;
|
|
this.bytesRead = j;
|
|
this.networkMetricBuilder.setResponsePayloadBytes(j);
|
|
}
|
|
return read;
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read(byte[] bArr) {
|
|
try {
|
|
int read = this.inputStream.read(bArr);
|
|
long durationMicros = this.timer.getDurationMicros();
|
|
if (this.timeToResponseInitiated == -1) {
|
|
this.timeToResponseInitiated = durationMicros;
|
|
}
|
|
if (read == -1 && this.timeToResponseLastRead == -1) {
|
|
this.timeToResponseLastRead = durationMicros;
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
|
|
this.networkMetricBuilder.build();
|
|
} else {
|
|
long j = this.bytesRead + read;
|
|
this.bytesRead = j;
|
|
this.networkMetricBuilder.setResponsePayloadBytes(j);
|
|
}
|
|
return read;
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public void reset() {
|
|
try {
|
|
this.inputStream.reset();
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public long skip(long j) {
|
|
try {
|
|
long skip = this.inputStream.skip(j);
|
|
long durationMicros = this.timer.getDurationMicros();
|
|
if (this.timeToResponseInitiated == -1) {
|
|
this.timeToResponseInitiated = durationMicros;
|
|
}
|
|
if (skip == -1 && this.timeToResponseLastRead == -1) {
|
|
this.timeToResponseLastRead = durationMicros;
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(durationMicros);
|
|
} else {
|
|
long j2 = this.bytesRead + skip;
|
|
this.bytesRead = j2;
|
|
this.networkMetricBuilder.setResponsePayloadBytes(j2);
|
|
}
|
|
return skip;
|
|
} catch (IOException e) {
|
|
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
|
|
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
|
|
throw e;
|
|
}
|
|
}
|
|
}
|