what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzou.java

55 lines
2.8 KiB
Java

package com.google.android.gms.internal.firebase_ml;
import com.google.android.gms.auth.api.credentials.CredentialsApi;
import com.google.android.gms.common.internal.GmsLogger;
import com.google.android.gms.common.util.IOUtils;
import com.google.firebase.FirebaseApp;
import com.google.firebase.ml.common.FirebaseMLException;
import com.google.firebase.ml.common.modeldownload.FirebaseRemoteModel;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketTimeoutException;
import java.util.Locale;
import javax.net.ssl.HttpsURLConnection;
/* loaded from: classes2.dex */
public final class zzou {
private static final GmsLogger zzaoz = new GmsLogger("RmModelInfoRetriever", "");
/* JADX INFO: Access modifiers changed from: package-private */
public static zzop zzb(FirebaseApp firebaseApp, FirebaseRemoteModel firebaseRemoteModel, zzon zzonVar) throws FirebaseMLException {
if (firebaseRemoteModel.zzmk()) {
return zzof.zza(firebaseRemoteModel, zzonVar);
}
return zzom.zza(firebaseApp, firebaseRemoteModel, zzonVar);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static HttpsURLConnection zza(String str, zzon zzonVar) throws FirebaseMLException {
if (str == null) {
return null;
}
try {
zzoy zzoyVar = new zzoy(str);
GmsLogger gmsLogger = zzaoz;
String valueOf = String.valueOf(str);
gmsLogger.d("RmModelInfoRetriever", valueOf.length() != 0 ? "Checking model URL: ".concat(valueOf) : new String("Checking model URL: "));
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) zzoyVar.openConnection();
httpsURLConnection.setConnectTimeout(CredentialsApi.CREDENTIAL_PICKER_REQUEST_CODE);
httpsURLConnection.connect();
if (httpsURLConnection.getResponseCode() == 200 || httpsURLConnection.getResponseCode() == 304) {
return httpsURLConnection;
}
zzonVar.zza(zzmk.MODEL_INFO_DOWNLOAD_UNSUCCESSFUL_HTTP_STATUS, false);
InputStream errorStream = httpsURLConnection.getErrorStream();
throw new FirebaseMLException(String.format(Locale.getDefault(), "Failed to connect to Firebase ML console server with HTTP status code: %d and error message: %s", Integer.valueOf(httpsURLConnection.getResponseCode()), errorStream == null ? "" : new String(IOUtils.readInputStreamFully(errorStream))), 13);
} catch (SocketTimeoutException e) {
zzonVar.zza(zzmk.TIME_OUT_FETCHING_MODEL_METADATA, false);
throw new FirebaseMLException("Failed to get model URL due to time out", 13, e);
} catch (IOException e2) {
zzonVar.zza(zzmk.MODEL_INFO_DOWNLOAD_CONNECTION_FAILED, false);
throw new FirebaseMLException("Failed to get model URL", 13, e2);
}
}
}