Add Discord community version (64-bit only)

- 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
This commit is contained in:
2026-02-18 15:48:36 -08:00
parent c19eb3d7ff
commit c080f0d97f
26930 changed files with 2529574 additions and 0 deletions

View File

@@ -0,0 +1,249 @@
package com.google.firebase.perf.network;
import androidx.annotation.Keep;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.protocol.HttpContext;
/* loaded from: classes3.dex */
public class FirebasePerfHttpClient {
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest) throws IOException {
return execute(httpClient, httpUriRequest, new Timer(), TransportManager.getInstance());
}
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest, HttpContext httpContext) throws IOException {
return execute(httpClient, httpUriRequest, httpContext, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler<T> responseHandler) throws IOException {
return (T) execute(httpClient, httpUriRequest, responseHandler, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler<T> responseHandler, HttpContext httpContext) throws IOException {
return (T) execute(httpClient, httpUriRequest, responseHandler, httpContext, new Timer(), TransportManager.getInstance());
}
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest) throws IOException {
return execute(httpClient, httpHost, httpRequest, new Timer(), TransportManager.getInstance());
}
@Keep
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext) throws IOException {
return execute(httpClient, httpHost, httpRequest, httpContext, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler<? extends T> responseHandler) throws IOException {
return (T) execute(httpClient, httpHost, httpRequest, responseHandler, new Timer(), TransportManager.getInstance());
}
@Keep
public static <T> T execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler<? extends T> responseHandler, HttpContext httpContext) throws IOException {
return (T) execute(httpClient, httpHost, httpRequest, responseHandler, httpContext, new Timer(), TransportManager.getInstance());
}
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpUriRequest);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static HttpResponse execute(HttpClient httpClient, HttpUriRequest httpUriRequest, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpUriRequest, httpContext);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler responseHandler, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpUriRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder));
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpUriRequest httpUriRequest, ResponseHandler responseHandler, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpUriRequest.getURI().toString()).setHttpMethod(httpUriRequest.getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpUriRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpUriRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder), httpContext);
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpHost, httpRequest);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static HttpResponse execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
HttpResponse execute = httpClient.execute(httpHost, httpRequest, httpContext);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setHttpResponseCode(execute.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength2 = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(execute);
if (apacheHttpMessageContentLength2 != null) {
builder.setResponsePayloadBytes(apacheHttpMessageContentLength2.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(execute);
if (apacheHttpResponseContentType != null) {
builder.setResponseContentType(apacheHttpResponseContentType);
}
builder.build();
return execute;
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler responseHandler, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpHost, httpRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder));
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object execute(HttpClient httpClient, HttpHost httpHost, HttpRequest httpRequest, ResponseHandler responseHandler, HttpContext httpContext, Timer timer, TransportManager transportManager) {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
builder.setUrl(httpHost.toURI() + httpRequest.getRequestLine().getUri()).setHttpMethod(httpRequest.getRequestLine().getMethod());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpRequest);
if (apacheHttpMessageContentLength != null) {
builder.setRequestPayloadBytes(apacheHttpMessageContentLength.longValue());
}
timer.reset();
builder.setRequestStartTimeMicros(timer.getMicros());
return httpClient.execute(httpHost, httpRequest, new InstrumentApacheHttpResponseHandler(responseHandler, timer, builder), httpContext);
} catch (IOException e) {
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
}

View File

@@ -0,0 +1,80 @@
package com.google.firebase.perf.network;
import androidx.annotation.Keep;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/* loaded from: classes3.dex */
public class FirebasePerfOkHttpClient {
@Keep
public static Response execute(Call call) throws IOException {
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(TransportManager.getInstance());
Timer timer = new Timer();
long micros = timer.getMicros();
try {
Response execute = call.execute();
sendNetworkMetric(execute, builder, micros, timer.getDurationMicros());
return execute;
} catch (IOException e) {
Request request = call.request();
if (request != null) {
HttpUrl url = request.url();
if (url != null) {
builder.setUrl(url.url().toString());
}
if (request.method() != null) {
builder.setHttpMethod(request.method());
}
}
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
@Keep
public static void enqueue(Call call, Callback callback) {
Timer timer = new Timer();
call.enqueue(new InstrumentOkHttpEnqueueCallback(callback, TransportManager.getInstance(), timer, timer.getMicros()));
}
public static void sendNetworkMetric(Response response, NetworkRequestMetricBuilder networkRequestMetricBuilder, long j, long j2) {
Request request = response.request();
if (request == null) {
return;
}
networkRequestMetricBuilder.setUrl(request.url().url().toString());
networkRequestMetricBuilder.setHttpMethod(request.method());
if (request.body() != null) {
long contentLength = request.body().contentLength();
if (contentLength != -1) {
networkRequestMetricBuilder.setRequestPayloadBytes(contentLength);
}
}
ResponseBody body = response.body();
if (body != null) {
long contentLength2 = body.contentLength();
if (contentLength2 != -1) {
networkRequestMetricBuilder.setResponsePayloadBytes(contentLength2);
}
MediaType contentType = body.contentType();
if (contentType != null) {
networkRequestMetricBuilder.setResponseContentType(contentType.toString());
}
}
networkRequestMetricBuilder.setHttpResponseCode(response.code());
networkRequestMetricBuilder.setRequestStartTimeMicros(j);
networkRequestMetricBuilder.setTimeToResponseCompletedMicros(j2);
networkRequestMetricBuilder.build();
}
}

View File

@@ -0,0 +1,108 @@
package com.google.firebase.perf.network;
import androidx.annotation.Keep;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import com.google.firebase.perf.util.URLWrapper;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import javax.net.ssl.HttpsURLConnection;
/* loaded from: classes3.dex */
public class FirebasePerfUrlConnection {
@Keep
public static InputStream openStream(URL url) throws IOException {
return openStream(new URLWrapper(url), TransportManager.getInstance(), new Timer());
}
public static InputStream openStream(URLWrapper uRLWrapper, TransportManager transportManager, Timer timer) {
if (!TransportManager.getInstance().isInitialized()) {
return uRLWrapper.openConnection().getInputStream();
}
timer.reset();
long micros = timer.getMicros();
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
URLConnection openConnection = uRLWrapper.openConnection();
if (openConnection instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) openConnection, timer, builder).getInputStream();
}
if (openConnection instanceof HttpURLConnection) {
return new InstrHttpURLConnection((HttpURLConnection) openConnection, timer, builder).getInputStream();
}
return openConnection.getInputStream();
} catch (IOException e) {
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setUrl(uRLWrapper.toString());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
@Keep
public static Object getContent(URL url) throws IOException {
return getContent(new URLWrapper(url), TransportManager.getInstance(), new Timer());
}
@Keep
public static Object getContent(URL url, Class[] clsArr) throws IOException {
return getContent(new URLWrapper(url), clsArr, TransportManager.getInstance(), new Timer());
}
public static Object getContent(URLWrapper uRLWrapper, TransportManager transportManager, Timer timer) {
timer.reset();
long micros = timer.getMicros();
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
URLConnection openConnection = uRLWrapper.openConnection();
if (openConnection instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) openConnection, timer, builder).getContent();
}
if (openConnection instanceof HttpURLConnection) {
return new InstrHttpURLConnection((HttpURLConnection) openConnection, timer, builder).getContent();
}
return openConnection.getContent();
} catch (IOException e) {
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setUrl(uRLWrapper.toString());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
public static Object getContent(URLWrapper uRLWrapper, Class[] clsArr, TransportManager transportManager, Timer timer) {
timer.reset();
long micros = timer.getMicros();
NetworkRequestMetricBuilder builder = NetworkRequestMetricBuilder.builder(transportManager);
try {
URLConnection openConnection = uRLWrapper.openConnection();
if (openConnection instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) openConnection, timer, builder).getContent(clsArr);
}
if (openConnection instanceof HttpURLConnection) {
return new InstrHttpURLConnection((HttpURLConnection) openConnection, timer, builder).getContent(clsArr);
}
return openConnection.getContent(clsArr);
} catch (IOException e) {
builder.setRequestStartTimeMicros(micros);
builder.setTimeToResponseCompletedMicros(timer.getDurationMicros());
builder.setUrl(uRLWrapper.toString());
NetworkRequestMetricBuilderUtil.logError(builder);
throw e;
}
}
@Keep
public static Object instrument(Object obj) throws IOException {
if (obj instanceof HttpsURLConnection) {
return new InstrHttpsURLConnection((HttpsURLConnection) obj, new Timer(), NetworkRequestMetricBuilder.builder(TransportManager.getInstance()));
}
return obj instanceof HttpURLConnection ? new InstrHttpURLConnection((HttpURLConnection) obj, new Timer(), NetworkRequestMetricBuilder.builder(TransportManager.getInstance())) : obj;
}
}

View File

@@ -0,0 +1,179 @@
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;
}
}
}

View File

@@ -0,0 +1,89 @@
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.OutputStream;
/* loaded from: classes3.dex */
public final class InstrHttpOutputStream extends OutputStream {
public long bytesWritten = -1;
public NetworkRequestMetricBuilder networkMetricBuilder;
public final OutputStream outputStream;
public final Timer timer;
public InstrHttpOutputStream(OutputStream outputStream, NetworkRequestMetricBuilder networkRequestMetricBuilder, Timer timer) {
this.outputStream = outputStream;
this.networkMetricBuilder = networkRequestMetricBuilder;
this.timer = timer;
}
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() {
long j = this.bytesWritten;
if (j != -1) {
this.networkMetricBuilder.setRequestPayloadBytes(j);
}
this.networkMetricBuilder.setTimeToRequestCompletedMicros(this.timer.getDurationMicros());
try {
this.outputStream.close();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream, java.io.Flushable
public void flush() {
try {
this.outputStream.flush();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream
public void write(int i) {
try {
this.outputStream.write(i);
long j = this.bytesWritten + 1;
this.bytesWritten = j;
this.networkMetricBuilder.setRequestPayloadBytes(j);
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream
public void write(byte[] bArr) {
try {
this.outputStream.write(bArr);
long length = this.bytesWritten + bArr.length;
this.bytesWritten = length;
this.networkMetricBuilder.setRequestPayloadBytes(length);
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
@Override // java.io.OutputStream
public void write(byte[] bArr, int i, int i2) {
try {
this.outputStream.write(bArr, i, i2);
long j = this.bytesWritten + i2;
this.bytesWritten = j;
this.networkMetricBuilder.setRequestPayloadBytes(j);
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
}

View File

@@ -0,0 +1,298 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.Permission;
import java.util.Map;
/* loaded from: classes3.dex */
public final class InstrHttpURLConnection extends HttpURLConnection {
public final InstrURLConnectionBase delegate;
public InstrHttpURLConnection(HttpURLConnection httpURLConnection, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
super(httpURLConnection.getURL());
this.delegate = new InstrURLConnectionBase(httpURLConnection, timer, networkRequestMetricBuilder);
}
@Override // java.net.URLConnection
public void connect() {
this.delegate.connect();
}
@Override // java.net.HttpURLConnection
public void disconnect() {
this.delegate.disconnect();
}
@Override // java.net.URLConnection
public Object getContent() {
return this.delegate.getContent();
}
@Override // java.net.URLConnection
public Object getContent(Class[] clsArr) {
return this.delegate.getContent(clsArr);
}
@Override // java.net.URLConnection
public InputStream getInputStream() {
return this.delegate.getInputStream();
}
@Override // java.net.URLConnection
public long getLastModified() {
return this.delegate.getLastModified();
}
@Override // java.net.URLConnection
public OutputStream getOutputStream() {
return this.delegate.getOutputStream();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public Permission getPermission() {
return this.delegate.getPermission();
}
@Override // java.net.HttpURLConnection
public int getResponseCode() {
return this.delegate.getResponseCode();
}
@Override // java.net.HttpURLConnection
public String getResponseMessage() {
return this.delegate.getResponseMessage();
}
@Override // java.net.URLConnection
public long getExpiration() {
return this.delegate.getExpiration();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderField(int i) {
return this.delegate.getHeaderField(i);
}
@Override // java.net.URLConnection
public String getHeaderField(String str) {
return this.delegate.getHeaderField(str);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public long getHeaderFieldDate(String str, long j) {
return this.delegate.getHeaderFieldDate(str, j);
}
@Override // java.net.URLConnection
public int getHeaderFieldInt(String str, int i) {
return this.delegate.getHeaderFieldInt(str, i);
}
@Override // java.net.URLConnection
public long getHeaderFieldLong(String str, long j) {
return this.delegate.getHeaderFieldLong(str, j);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderFieldKey(int i) {
return this.delegate.getHeaderFieldKey(i);
}
@Override // java.net.URLConnection
public Map getHeaderFields() {
return this.delegate.getHeaderFields();
}
@Override // java.net.URLConnection
public String getContentEncoding() {
return this.delegate.getContentEncoding();
}
@Override // java.net.URLConnection
public int getContentLength() {
return this.delegate.getContentLength();
}
@Override // java.net.URLConnection
public long getContentLengthLong() {
return this.delegate.getContentLengthLong();
}
@Override // java.net.URLConnection
public String getContentType() {
return this.delegate.getContentType();
}
@Override // java.net.URLConnection
public long getDate() {
return this.delegate.getDate();
}
@Override // java.net.URLConnection
public void addRequestProperty(String str, String str2) {
this.delegate.addRequestProperty(str, str2);
}
public boolean equals(Object obj) {
return this.delegate.equals(obj);
}
@Override // java.net.URLConnection
public boolean getAllowUserInteraction() {
return this.delegate.getAllowUserInteraction();
}
@Override // java.net.URLConnection
public int getConnectTimeout() {
return this.delegate.getConnectTimeout();
}
@Override // java.net.URLConnection
public boolean getDefaultUseCaches() {
return this.delegate.getDefaultUseCaches();
}
@Override // java.net.URLConnection
public boolean getDoInput() {
return this.delegate.getDoInput();
}
@Override // java.net.URLConnection
public boolean getDoOutput() {
return this.delegate.getDoOutput();
}
@Override // java.net.HttpURLConnection
public InputStream getErrorStream() {
return this.delegate.getErrorStream();
}
@Override // java.net.URLConnection
public long getIfModifiedSince() {
return this.delegate.getIfModifiedSince();
}
@Override // java.net.HttpURLConnection
public boolean getInstanceFollowRedirects() {
return this.delegate.getInstanceFollowRedirects();
}
@Override // java.net.URLConnection
public int getReadTimeout() {
return this.delegate.getReadTimeout();
}
@Override // java.net.HttpURLConnection
public String getRequestMethod() {
return this.delegate.getRequestMethod();
}
@Override // java.net.URLConnection
public Map getRequestProperties() {
return this.delegate.getRequestProperties();
}
@Override // java.net.URLConnection
public String getRequestProperty(String str) {
return this.delegate.getRequestProperty(str);
}
@Override // java.net.URLConnection
public URL getURL() {
return this.delegate.getURL();
}
@Override // java.net.URLConnection
public boolean getUseCaches() {
return this.delegate.getUseCaches();
}
public int hashCode() {
return this.delegate.hashCode();
}
@Override // java.net.URLConnection
public void setAllowUserInteraction(boolean z) {
this.delegate.setAllowUserInteraction(z);
}
@Override // java.net.HttpURLConnection
public void setChunkedStreamingMode(int i) {
this.delegate.setChunkedStreamingMode(i);
}
@Override // java.net.URLConnection
public void setConnectTimeout(int i) {
this.delegate.setConnectTimeout(i);
}
@Override // java.net.URLConnection
public void setDefaultUseCaches(boolean z) {
this.delegate.setDefaultUseCaches(z);
}
@Override // java.net.URLConnection
public void setDoInput(boolean z) {
this.delegate.setDoInput(z);
}
@Override // java.net.URLConnection
public void setDoOutput(boolean z) {
this.delegate.setDoOutput(z);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(int i) {
this.delegate.setFixedLengthStreamingMode(i);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(long j) {
this.delegate.setFixedLengthStreamingMode(j);
}
@Override // java.net.URLConnection
public void setIfModifiedSince(long j) {
this.delegate.setIfModifiedSince(j);
}
@Override // java.net.HttpURLConnection
public void setInstanceFollowRedirects(boolean z) {
this.delegate.setInstanceFollowRedirects(z);
}
@Override // java.net.URLConnection
public void setReadTimeout(int i) {
this.delegate.setReadTimeout(i);
}
@Override // java.net.HttpURLConnection
public void setRequestMethod(String str) {
this.delegate.setRequestMethod(str);
}
@Override // java.net.URLConnection
public void setRequestProperty(String str, String str2) {
this.delegate.setRequestProperty(str, str2);
}
@Override // java.net.URLConnection
public void setUseCaches(boolean z) {
this.delegate.setUseCaches(z);
}
@Override // java.net.URLConnection
public String toString() {
return this.delegate.toString();
}
@Override // java.net.HttpURLConnection
public boolean usingProxy() {
return this.delegate.usingProxy();
}
}

View File

@@ -0,0 +1,349 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.security.Permission;
import java.security.Principal;
import java.security.cert.Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
/* loaded from: classes3.dex */
public final class InstrHttpsURLConnection extends HttpsURLConnection {
public final InstrURLConnectionBase delegate;
public final HttpsURLConnection httpsURLConnection;
public InstrHttpsURLConnection(HttpsURLConnection httpsURLConnection, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
super(httpsURLConnection.getURL());
this.httpsURLConnection = httpsURLConnection;
this.delegate = new InstrURLConnectionBase(httpsURLConnection, timer, networkRequestMetricBuilder);
}
@Override // java.net.URLConnection
public void connect() {
this.delegate.connect();
}
@Override // java.net.HttpURLConnection
public void disconnect() {
this.delegate.disconnect();
}
@Override // java.net.URLConnection
public Object getContent() {
return this.delegate.getContent();
}
@Override // java.net.URLConnection
public Object getContent(Class[] clsArr) {
return this.delegate.getContent(clsArr);
}
@Override // java.net.URLConnection
public InputStream getInputStream() {
return this.delegate.getInputStream();
}
@Override // java.net.URLConnection
public long getLastModified() {
return this.delegate.getLastModified();
}
@Override // java.net.URLConnection
public OutputStream getOutputStream() {
return this.delegate.getOutputStream();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public Permission getPermission() {
return this.delegate.getPermission();
}
@Override // java.net.HttpURLConnection
public int getResponseCode() {
return this.delegate.getResponseCode();
}
@Override // java.net.HttpURLConnection
public String getResponseMessage() {
return this.delegate.getResponseMessage();
}
@Override // java.net.URLConnection
public long getExpiration() {
return this.delegate.getExpiration();
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderField(int i) {
return this.delegate.getHeaderField(i);
}
@Override // java.net.URLConnection
public String getHeaderField(String str) {
return this.delegate.getHeaderField(str);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public long getHeaderFieldDate(String str, long j) {
return this.delegate.getHeaderFieldDate(str, j);
}
@Override // java.net.URLConnection
public int getHeaderFieldInt(String str, int i) {
return this.delegate.getHeaderFieldInt(str, i);
}
@Override // java.net.URLConnection
public long getHeaderFieldLong(String str, long j) {
return this.delegate.getHeaderFieldLong(str, j);
}
@Override // java.net.HttpURLConnection, java.net.URLConnection
public String getHeaderFieldKey(int i) {
return this.delegate.getHeaderFieldKey(i);
}
@Override // java.net.URLConnection
public Map getHeaderFields() {
return this.delegate.getHeaderFields();
}
@Override // java.net.URLConnection
public String getContentEncoding() {
return this.delegate.getContentEncoding();
}
@Override // java.net.URLConnection
public int getContentLength() {
return this.delegate.getContentLength();
}
@Override // java.net.URLConnection
public long getContentLengthLong() {
return this.delegate.getContentLengthLong();
}
@Override // java.net.URLConnection
public String getContentType() {
return this.delegate.getContentType();
}
@Override // java.net.URLConnection
public long getDate() {
return this.delegate.getDate();
}
@Override // java.net.URLConnection
public void addRequestProperty(String str, String str2) {
this.delegate.addRequestProperty(str, str2);
}
public boolean equals(Object obj) {
return this.delegate.equals(obj);
}
@Override // java.net.URLConnection
public boolean getAllowUserInteraction() {
return this.delegate.getAllowUserInteraction();
}
@Override // java.net.URLConnection
public int getConnectTimeout() {
return this.delegate.getConnectTimeout();
}
@Override // java.net.URLConnection
public boolean getDefaultUseCaches() {
return this.delegate.getDefaultUseCaches();
}
@Override // java.net.URLConnection
public boolean getDoInput() {
return this.delegate.getDoInput();
}
@Override // java.net.URLConnection
public boolean getDoOutput() {
return this.delegate.getDoOutput();
}
@Override // java.net.HttpURLConnection
public InputStream getErrorStream() {
return this.delegate.getErrorStream();
}
@Override // java.net.URLConnection
public long getIfModifiedSince() {
return this.delegate.getIfModifiedSince();
}
@Override // java.net.HttpURLConnection
public boolean getInstanceFollowRedirects() {
return this.delegate.getInstanceFollowRedirects();
}
@Override // java.net.URLConnection
public int getReadTimeout() {
return this.delegate.getReadTimeout();
}
@Override // java.net.HttpURLConnection
public String getRequestMethod() {
return this.delegate.getRequestMethod();
}
@Override // java.net.URLConnection
public Map getRequestProperties() {
return this.delegate.getRequestProperties();
}
@Override // java.net.URLConnection
public String getRequestProperty(String str) {
return this.delegate.getRequestProperty(str);
}
@Override // java.net.URLConnection
public URL getURL() {
return this.delegate.getURL();
}
@Override // java.net.URLConnection
public boolean getUseCaches() {
return this.delegate.getUseCaches();
}
public int hashCode() {
return this.delegate.hashCode();
}
@Override // java.net.URLConnection
public void setAllowUserInteraction(boolean z) {
this.delegate.setAllowUserInteraction(z);
}
@Override // java.net.HttpURLConnection
public void setChunkedStreamingMode(int i) {
this.delegate.setChunkedStreamingMode(i);
}
@Override // java.net.URLConnection
public void setConnectTimeout(int i) {
this.delegate.setConnectTimeout(i);
}
@Override // java.net.URLConnection
public void setDefaultUseCaches(boolean z) {
this.delegate.setDefaultUseCaches(z);
}
@Override // java.net.URLConnection
public void setDoInput(boolean z) {
this.delegate.setDoInput(z);
}
@Override // java.net.URLConnection
public void setDoOutput(boolean z) {
this.delegate.setDoOutput(z);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(int i) {
this.delegate.setFixedLengthStreamingMode(i);
}
@Override // java.net.HttpURLConnection
public void setFixedLengthStreamingMode(long j) {
this.delegate.setFixedLengthStreamingMode(j);
}
@Override // java.net.URLConnection
public void setIfModifiedSince(long j) {
this.delegate.setIfModifiedSince(j);
}
@Override // java.net.HttpURLConnection
public void setInstanceFollowRedirects(boolean z) {
this.delegate.setInstanceFollowRedirects(z);
}
@Override // java.net.URLConnection
public void setReadTimeout(int i) {
this.delegate.setReadTimeout(i);
}
@Override // java.net.HttpURLConnection
public void setRequestMethod(String str) {
this.delegate.setRequestMethod(str);
}
@Override // java.net.URLConnection
public void setRequestProperty(String str, String str2) {
this.delegate.setRequestProperty(str, str2);
}
@Override // java.net.URLConnection
public void setUseCaches(boolean z) {
this.delegate.setUseCaches(z);
}
@Override // java.net.URLConnection
public String toString() {
return this.delegate.toString();
}
@Override // java.net.HttpURLConnection
public boolean usingProxy() {
return this.delegate.usingProxy();
}
@Override // javax.net.ssl.HttpsURLConnection
public String getCipherSuite() {
return this.httpsURLConnection.getCipherSuite();
}
@Override // javax.net.ssl.HttpsURLConnection
public HostnameVerifier getHostnameVerifier() {
return this.httpsURLConnection.getHostnameVerifier();
}
@Override // javax.net.ssl.HttpsURLConnection
public Certificate[] getLocalCertificates() {
return this.httpsURLConnection.getLocalCertificates();
}
@Override // javax.net.ssl.HttpsURLConnection
public Principal getLocalPrincipal() {
return this.httpsURLConnection.getLocalPrincipal();
}
@Override // javax.net.ssl.HttpsURLConnection
public Principal getPeerPrincipal() {
return this.httpsURLConnection.getPeerPrincipal();
}
@Override // javax.net.ssl.HttpsURLConnection
public Certificate[] getServerCertificates() {
return this.httpsURLConnection.getServerCertificates();
}
@Override // javax.net.ssl.HttpsURLConnection
public SSLSocketFactory getSSLSocketFactory() {
return this.httpsURLConnection.getSSLSocketFactory();
}
@Override // javax.net.ssl.HttpsURLConnection
public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
this.httpsURLConnection.setHostnameVerifier(hostnameVerifier);
}
@Override // javax.net.ssl.HttpsURLConnection
public void setSSLSocketFactory(SSLSocketFactory sSLSocketFactory) {
this.httpsURLConnection.setSSLSocketFactory(sSLSocketFactory);
}
}

View File

@@ -0,0 +1,393 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.Permission;
import java.util.Map;
/* loaded from: classes3.dex */
public class InstrURLConnectionBase {
public static final AndroidLogger logger = AndroidLogger.getInstance();
public final HttpURLConnection httpUrlConnection;
public final NetworkRequestMetricBuilder networkMetricBuilder;
public long timeRequestedInMicros = -1;
public long timeToResponseInitiatedInMicros = -1;
public final Timer timer;
public InstrURLConnectionBase(HttpURLConnection httpURLConnection, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
this.httpUrlConnection = httpURLConnection;
this.networkMetricBuilder = networkRequestMetricBuilder;
this.timer = timer;
networkRequestMetricBuilder.setUrl(httpURLConnection.getURL().toString());
}
public void connect() {
if (this.timeRequestedInMicros == -1) {
this.timer.reset();
long micros = this.timer.getMicros();
this.timeRequestedInMicros = micros;
this.networkMetricBuilder.setRequestStartTimeMicros(micros);
}
try {
this.httpUrlConnection.connect();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public void disconnect() {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.build();
this.httpUrlConnection.disconnect();
}
public Object getContent() {
updateRequestInfo();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
try {
Object content = this.httpUrlConnection.getContent();
if (content instanceof InputStream) {
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
return new InstrHttpInputStream((InputStream) content, this.networkMetricBuilder, this.timer);
}
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
this.networkMetricBuilder.setResponsePayloadBytes(this.httpUrlConnection.getContentLength());
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.build();
return content;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public Object getContent(Class[] clsArr) {
updateRequestInfo();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
try {
Object content = this.httpUrlConnection.getContent(clsArr);
if (content instanceof InputStream) {
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
return new InstrHttpInputStream((InputStream) content, this.networkMetricBuilder, this.timer);
}
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
this.networkMetricBuilder.setResponsePayloadBytes(this.httpUrlConnection.getContentLength());
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.build();
return content;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public InputStream getInputStream() {
updateRequestInfo();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
this.networkMetricBuilder.setResponseContentType(this.httpUrlConnection.getContentType());
try {
InputStream inputStream = this.httpUrlConnection.getInputStream();
return inputStream != null ? new InstrHttpInputStream(inputStream, this.networkMetricBuilder, this.timer) : inputStream;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public long getLastModified() {
updateRequestInfo();
return this.httpUrlConnection.getLastModified();
}
public OutputStream getOutputStream() {
try {
OutputStream outputStream = this.httpUrlConnection.getOutputStream();
return outputStream != null ? new InstrHttpOutputStream(outputStream, this.networkMetricBuilder, this.timer) : outputStream;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public Permission getPermission() {
try {
return this.httpUrlConnection.getPermission();
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public int getResponseCode() {
updateRequestInfo();
if (this.timeToResponseInitiatedInMicros == -1) {
long durationMicros = this.timer.getDurationMicros();
this.timeToResponseInitiatedInMicros = durationMicros;
this.networkMetricBuilder.setTimeToResponseInitiatedMicros(durationMicros);
}
try {
int responseCode = this.httpUrlConnection.getResponseCode();
this.networkMetricBuilder.setHttpResponseCode(responseCode);
return responseCode;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public String getResponseMessage() {
updateRequestInfo();
if (this.timeToResponseInitiatedInMicros == -1) {
long durationMicros = this.timer.getDurationMicros();
this.timeToResponseInitiatedInMicros = durationMicros;
this.networkMetricBuilder.setTimeToResponseInitiatedMicros(durationMicros);
}
try {
String responseMessage = this.httpUrlConnection.getResponseMessage();
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
return responseMessage;
} catch (IOException e) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
throw e;
}
}
public long getExpiration() {
updateRequestInfo();
return this.httpUrlConnection.getExpiration();
}
public String getHeaderField(int i) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderField(i);
}
public String getHeaderField(String str) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderField(str);
}
public long getHeaderFieldDate(String str, long j) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldDate(str, j);
}
public int getHeaderFieldInt(String str, int i) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldInt(str, i);
}
public long getHeaderFieldLong(String str, long j) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldLong(str, j);
}
public String getHeaderFieldKey(int i) {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFieldKey(i);
}
public Map getHeaderFields() {
updateRequestInfo();
return this.httpUrlConnection.getHeaderFields();
}
public String getContentEncoding() {
updateRequestInfo();
return this.httpUrlConnection.getContentEncoding();
}
public int getContentLength() {
updateRequestInfo();
return this.httpUrlConnection.getContentLength();
}
public long getContentLengthLong() {
updateRequestInfo();
return this.httpUrlConnection.getContentLengthLong();
}
public String getContentType() {
updateRequestInfo();
return this.httpUrlConnection.getContentType();
}
public long getDate() {
updateRequestInfo();
return this.httpUrlConnection.getDate();
}
public void addRequestProperty(String str, String str2) {
this.httpUrlConnection.addRequestProperty(str, str2);
}
public boolean equals(Object obj) {
return this.httpUrlConnection.equals(obj);
}
public boolean getAllowUserInteraction() {
return this.httpUrlConnection.getAllowUserInteraction();
}
public int getConnectTimeout() {
return this.httpUrlConnection.getConnectTimeout();
}
public boolean getDefaultUseCaches() {
return this.httpUrlConnection.getDefaultUseCaches();
}
public boolean getDoInput() {
return this.httpUrlConnection.getDoInput();
}
public boolean getDoOutput() {
return this.httpUrlConnection.getDoOutput();
}
public InputStream getErrorStream() {
updateRequestInfo();
try {
this.networkMetricBuilder.setHttpResponseCode(this.httpUrlConnection.getResponseCode());
} catch (IOException unused) {
logger.debug("IOException thrown trying to obtain the response code");
}
InputStream errorStream = this.httpUrlConnection.getErrorStream();
return errorStream != null ? new InstrHttpInputStream(errorStream, this.networkMetricBuilder, this.timer) : errorStream;
}
public long getIfModifiedSince() {
return this.httpUrlConnection.getIfModifiedSince();
}
public boolean getInstanceFollowRedirects() {
return this.httpUrlConnection.getInstanceFollowRedirects();
}
public int getReadTimeout() {
return this.httpUrlConnection.getReadTimeout();
}
public String getRequestMethod() {
return this.httpUrlConnection.getRequestMethod();
}
public Map getRequestProperties() {
return this.httpUrlConnection.getRequestProperties();
}
public String getRequestProperty(String str) {
return this.httpUrlConnection.getRequestProperty(str);
}
public URL getURL() {
return this.httpUrlConnection.getURL();
}
public boolean getUseCaches() {
return this.httpUrlConnection.getUseCaches();
}
public int hashCode() {
return this.httpUrlConnection.hashCode();
}
public void setAllowUserInteraction(boolean z) {
this.httpUrlConnection.setAllowUserInteraction(z);
}
public void setChunkedStreamingMode(int i) {
this.httpUrlConnection.setChunkedStreamingMode(i);
}
public void setConnectTimeout(int i) {
this.httpUrlConnection.setConnectTimeout(i);
}
public void setDefaultUseCaches(boolean z) {
this.httpUrlConnection.setDefaultUseCaches(z);
}
public void setDoInput(boolean z) {
this.httpUrlConnection.setDoInput(z);
}
public void setDoOutput(boolean z) {
this.httpUrlConnection.setDoOutput(z);
}
public void setFixedLengthStreamingMode(int i) {
this.httpUrlConnection.setFixedLengthStreamingMode(i);
}
public void setFixedLengthStreamingMode(long j) {
this.httpUrlConnection.setFixedLengthStreamingMode(j);
}
public void setIfModifiedSince(long j) {
this.httpUrlConnection.setIfModifiedSince(j);
}
public void setInstanceFollowRedirects(boolean z) {
this.httpUrlConnection.setInstanceFollowRedirects(z);
}
public void setReadTimeout(int i) {
this.httpUrlConnection.setReadTimeout(i);
}
public void setRequestMethod(String str) {
this.httpUrlConnection.setRequestMethod(str);
}
public void setRequestProperty(String str, String str2) {
if ("User-Agent".equalsIgnoreCase(str)) {
this.networkMetricBuilder.setUserAgent(str2);
}
this.httpUrlConnection.setRequestProperty(str, str2);
}
public void setUseCaches(boolean z) {
this.httpUrlConnection.setUseCaches(z);
}
public String toString() {
return this.httpUrlConnection.toString();
}
public boolean usingProxy() {
return this.httpUrlConnection.usingProxy();
}
public final void updateRequestInfo() {
if (this.timeRequestedInMicros == -1) {
this.timer.reset();
long micros = this.timer.getMicros();
this.timeRequestedInMicros = micros;
this.networkMetricBuilder.setRequestStartTimeMicros(micros);
}
String requestMethod = getRequestMethod();
if (requestMethod != null) {
this.networkMetricBuilder.setHttpMethod(requestMethod);
} else if (getDoOutput()) {
this.networkMetricBuilder.setHttpMethod("POST");
} else {
this.networkMetricBuilder.setHttpMethod("GET");
}
}
}

View File

@@ -0,0 +1,35 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.util.Timer;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
/* loaded from: classes3.dex */
public class InstrumentApacheHttpResponseHandler implements ResponseHandler {
public final NetworkRequestMetricBuilder networkMetricBuilder;
public final ResponseHandler responseHandlerDelegate;
public final Timer timer;
public InstrumentApacheHttpResponseHandler(ResponseHandler responseHandler, Timer timer, NetworkRequestMetricBuilder networkRequestMetricBuilder) {
this.responseHandlerDelegate = responseHandler;
this.timer = timer;
this.networkMetricBuilder = networkRequestMetricBuilder;
}
@Override // org.apache.http.client.ResponseHandler
public Object handleResponse(HttpResponse httpResponse) {
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
this.networkMetricBuilder.setHttpResponseCode(httpResponse.getStatusLine().getStatusCode());
Long apacheHttpMessageContentLength = NetworkRequestMetricBuilderUtil.getApacheHttpMessageContentLength(httpResponse);
if (apacheHttpMessageContentLength != null) {
this.networkMetricBuilder.setResponsePayloadBytes(apacheHttpMessageContentLength.longValue());
}
String apacheHttpResponseContentType = NetworkRequestMetricBuilderUtil.getApacheHttpResponseContentType(httpResponse);
if (apacheHttpResponseContentType != null) {
this.networkMetricBuilder.setResponseContentType(apacheHttpResponseContentType);
}
this.networkMetricBuilder.build();
return this.responseHandlerDelegate.handleResponse(httpResponse);
}
}

View File

@@ -0,0 +1,50 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import com.google.firebase.perf.transport.TransportManager;
import com.google.firebase.perf.util.Timer;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.Request;
import okhttp3.Response;
/* loaded from: classes3.dex */
public class InstrumentOkHttpEnqueueCallback implements Callback {
public final Callback callback;
public final NetworkRequestMetricBuilder networkMetricBuilder;
public final long startTimeMicros;
public final Timer timer;
public InstrumentOkHttpEnqueueCallback(Callback callback, TransportManager transportManager, Timer timer, long j) {
this.callback = callback;
this.networkMetricBuilder = NetworkRequestMetricBuilder.builder(transportManager);
this.startTimeMicros = j;
this.timer = timer;
}
@Override // okhttp3.Callback
public void onFailure(Call call, IOException iOException) {
Request request = call.request();
if (request != null) {
HttpUrl url = request.url();
if (url != null) {
this.networkMetricBuilder.setUrl(url.url().toString());
}
if (request.method() != null) {
this.networkMetricBuilder.setHttpMethod(request.method());
}
}
this.networkMetricBuilder.setRequestStartTimeMicros(this.startTimeMicros);
this.networkMetricBuilder.setTimeToResponseCompletedMicros(this.timer.getDurationMicros());
NetworkRequestMetricBuilderUtil.logError(this.networkMetricBuilder);
this.callback.onFailure(call, iOException);
}
@Override // okhttp3.Callback
public void onResponse(Call call, Response response) {
FirebasePerfOkHttpClient.sendNetworkMetric(response, this.networkMetricBuilder, this.startTimeMicros, this.timer.getDurationMicros());
this.callback.onResponse(call, response);
}
}

View File

@@ -0,0 +1,46 @@
package com.google.firebase.perf.network;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.metrics.NetworkRequestMetricBuilder;
import java.util.regex.Pattern;
import org.apache.http.Header;
import org.apache.http.HttpMessage;
import org.apache.http.HttpResponse;
/* loaded from: classes3.dex */
public abstract class NetworkRequestMetricBuilderUtil {
public static final Pattern FLG_USER_AGENT_PATTERN = Pattern.compile("(^|.*\\s)datatransport/\\S+ android/($|\\s.*)");
public static Long getApacheHttpMessageContentLength(HttpMessage httpMessage) {
try {
Header firstHeader = httpMessage.getFirstHeader("content-length");
if (firstHeader != null) {
return Long.valueOf(Long.parseLong(firstHeader.getValue()));
}
return null;
} catch (NumberFormatException unused) {
AndroidLogger.getInstance().debug("The content-length value is not a valid number");
return null;
}
}
public static String getApacheHttpResponseContentType(HttpResponse httpResponse) {
String value;
Header firstHeader = httpResponse.getFirstHeader("content-type");
if (firstHeader == null || (value = firstHeader.getValue()) == null) {
return null;
}
return value;
}
public static void logError(NetworkRequestMetricBuilder networkRequestMetricBuilder) {
if (!networkRequestMetricBuilder.hasHttpResponseCode()) {
networkRequestMetricBuilder.setNetworkClientErrorReason();
}
networkRequestMetricBuilder.build();
}
public static boolean isAllowedUserAgent(String str) {
return str == null || !FLG_USER_AGENT_PATTERN.matcher(str).matches();
}
}