discord-jadx/app/src/main/java/c/i/a/f/i/b/x3.java

72 lines
2.4 KiB
Java

package c.i.a.f.i.b;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import androidx.annotation.WorkerThread;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
/* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */
public final class x3 extends i9 {
public x3(k9 k9Var) {
super(k9Var);
}
public static byte[] t(HttpURLConnection httpURLConnection) throws IOException {
InputStream inputStream = null;
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
InputStream inputStream2 = httpURLConnection.getInputStream();
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream2.read(bArr);
if (read > 0) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
byte[] byteArray = byteArrayOutputStream.toByteArray();
inputStream2.close();
return byteArray;
}
}
} catch (Throwable th) {
if (0 != 0) {
inputStream.close();
}
throw th;
}
}
@Override // c.i.a.f.i.b.i9
public final boolean p() {
return false;
}
@WorkerThread
public final HttpURLConnection s(URL url) throws IOException {
URLConnection openConnection = url.openConnection();
if (openConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
httpURLConnection.setDefaultUseCaches(false);
httpURLConnection.setConnectTimeout(60000);
httpURLConnection.setReadTimeout(61000);
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setDoInput(true);
return httpURLConnection;
}
throw new IOException("Failed to obtain HTTP connection");
}
public final boolean u() {
n();
NetworkInfo networkInfo = null;
try {
networkInfo = ((ConnectivityManager) this.a.b.getSystemService("connectivity")).getActiveNetworkInfo();
} catch (SecurityException unused) {
}
return networkInfo != null && networkInfo.isConnected();
}
}