Files
rr3-apk/decompiled/sources/com/google/firebase/perf/network/InstrURLConnectionBase.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

394 lines
14 KiB
Java

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");
}
}
}