Warkop v5.73.0版本的 MD5 值为:a4330ec2d6f5e146f59fc7622f3cdb45
以下内容为反编译后的 c.java 源代码,内容仅作参考
package ld;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.TrafficStats;
import android.text.TextUtils;
import android.util.JsonReader;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.util.AndroidUtilsLight;
import com.google.android.gms.common.util.Hex;
import com.google.android.gms.common.util.VisibleForTesting;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.installations.FirebaseInstallationsException;
import com.inappstory.sdk.network.NetworkHandler;
import fd.i;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;
import ld.d;
import ld.f;
import org.json.JSONException;
import org.json.JSONObject;
public class c {
private static final Pattern f90243d = Pattern.compile("[0-9]+s");
private static final Charset f90244e = Charset.forName("UTF-8");
private final Context f90245a;
private final hd.b<i> f90246b;
private final e f90247c = new e();
public c(@NonNull Context context, @NonNull hd.b<i> bVar) {
this.f90245a = context;
this.f90246b = bVar;
}
private static String a(String str, @NonNull String str2, @NonNull String str3) {
String str4;
Object[] objArr = new Object[3];
objArr[0] = str2;
objArr[1] = str3;
if (TextUtils.isEmpty(str)) {
str4 = "";
} else {
str4 = ", " + str;
}
objArr[2] = str4;
return String.format("Firebase options used while communicating with Firebase server APIs: %s, %s%s", objArr);
}
private static JSONObject b(String str, @NonNull String str2) {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("fid", str);
jSONObject.put("appId", str2);
jSONObject.put("authVersion", "FIS_v2");
jSONObject.put("sdkVersion", "a:17.1.3");
return jSONObject;
} catch (JSONException e15) {
throw new IllegalStateException(e15);
}
}
private static JSONObject c() {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("sdkVersion", "a:17.1.3");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("installation", jSONObject);
return jSONObject2;
} catch (JSONException e15) {
throw new IllegalStateException(e15);
}
}
private String f() {
try {
Context context = this.f90245a;
byte[] packageCertificateHashBytes = AndroidUtilsLight.getPackageCertificateHashBytes(context, context.getPackageName());
if (packageCertificateHashBytes == null) {
Log.e("ContentValues", "Could not get fingerprint hash for package: " + this.f90245a.getPackageName());
return null;
}
return Hex.bytesToStringUppercase(packageCertificateHashBytes, false);
} catch (PackageManager.NameNotFoundException e15) {
Log.e("ContentValues", "No such package: " + this.f90245a.getPackageName(), e15);
return null;
}
}
private URL g(String str) throws FirebaseInstallationsException {
try {
return new URL(String.format("https://%s/%s/%s", "firebaseinstallations.googleapis.com", "v1", str));
} catch (MalformedURLException e15) {
throw new FirebaseInstallationsException(e15.getMessage(), FirebaseInstallationsException.a.UNAVAILABLE);
}
}
private static byte[] h(JSONObject jSONObject) throws IOException {
return jSONObject.toString().getBytes("UTF-8");
}
private static boolean i(int i15) {
return i15 >= 200 && i15 < 300;
}
private static void j() {
Log.e("Firebase-Installations", "Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.");
}
private static void k(HttpURLConnection httpURLConnection, String str, @NonNull String str2, @NonNull String str3) {
String o15 = o(httpURLConnection);
if (!TextUtils.isEmpty(o15)) {
Log.w("Firebase-Installations", o15);
Log.w("Firebase-Installations", a(str, str2, str3));
}
}
private HttpURLConnection l(URL url, String str) throws FirebaseInstallationsException {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setUseCaches(false);
httpURLConnection.setReadTimeout(10000);
httpURLConnection.addRequestProperty("Content-Type", "application/json");
httpURLConnection.addRequestProperty("Accept", "application/json");
httpURLConnection.addRequestProperty("Content-Encoding", "gzip");
httpURLConnection.addRequestProperty("Cache-Control", "no-cache");
httpURLConnection.addRequestProperty("X-Android-Package", this.f90245a.getPackageName());
i iVar = this.f90246b.get();
if (iVar != null) {
try {
httpURLConnection.addRequestProperty("x-firebase-client", (String) Tasks.await(iVar.b()));
} catch (InterruptedException e15) {
Thread.currentThread().interrupt();
Log.w("ContentValues", "Failed to get heartbeats header", e15);
} catch (ExecutionException e16) {
Log.w("ContentValues", "Failed to get heartbeats header", e16);
}
}
httpURLConnection.addRequestProperty("X-Android-Cert", f());
httpURLConnection.addRequestProperty("x-goog-api-key", str);
return httpURLConnection;
} catch (IOException unused) {
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.a.UNAVAILABLE);
}
}
@VisibleForTesting
static long m(String str) {
Preconditions.checkArgument(f90243d.matcher(str).matches(), "Invalid Expiration Timestamp.");
if (str != null && str.length() != 0) {
return Long.parseLong(str.substring(0, str.length() - 1));
}
return 0L;
}
private d n(HttpURLConnection httpURLConnection) throws AssertionError, IOException {
InputStream inputStream = httpURLConnection.getInputStream();
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, f90244e));
f.a a15 = f.a();
d.a a16 = d.a();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName = jsonReader.nextName();
if (nextName.equals(AppMeasurementSdk.ConditionalUserProperty.NAME)) {
a16.f(jsonReader.nextString());
} else if (nextName.equals("fid")) {
a16.c(jsonReader.nextString());
} else if (nextName.equals("refreshToken")) {
a16.d(jsonReader.nextString());
} else if (nextName.equals("authToken")) {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName2 = jsonReader.nextName();
if (nextName2.equals("token")) {
a15.c(jsonReader.nextString());
} else if (nextName2.equals("expiresIn")) {
a15.d(m(jsonReader.nextString()));
} else {
jsonReader.skipValue();
}
}
a16.b(a15.a());
jsonReader.endObject();
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
jsonReader.close();
inputStream.close();
return a16.e(d.b.OK).a();
}
private static String o(HttpURLConnection httpURLConnection) {
InputStream errorStream = httpURLConnection.getErrorStream();
if (errorStream == null) {
return null;
}
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(errorStream, f90244e));
try {
try {
StringBuilder sb5 = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb5.append(readLine);
sb5.append('\n');
}
String format = String.format("Error when communicating with the Firebase Installations server API. HTTP response: [%d %s: %s]", Integer.valueOf(httpURLConnection.getResponseCode()), httpURLConnection.getResponseMessage(), sb5);
try {
bufferedReader.close();
} catch (IOException unused) {
}
return format;
} catch (IOException unused2) {
return null;
}
} catch (IOException unused3) {
bufferedReader.close();
return null;
} catch (Throwable th4) {
try {
bufferedReader.close();
} catch (IOException unused4) {
}
throw th4;
}
}
private f p(HttpURLConnection httpURLConnection) throws AssertionError, IOException {
InputStream inputStream = httpURLConnection.getInputStream();
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, f90244e));
f.a a15 = f.a();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName = jsonReader.nextName();
if (nextName.equals("token")) {
a15.c(jsonReader.nextString());
} else if (nextName.equals("expiresIn")) {
a15.d(m(jsonReader.nextString()));
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
jsonReader.close();
inputStream.close();
return a15.b(f.b.OK).a();
}
private void q(HttpURLConnection httpURLConnection, String str, @NonNull String str2) throws IOException {
s(httpURLConnection, h(b(str, str2)));
}
private void r(HttpURLConnection httpURLConnection) throws IOException {
s(httpURLConnection, h(c()));
}
private static void s(URLConnection uRLConnection, byte[] bArr) throws IOException {
OutputStream outputStream = uRLConnection.getOutputStream();
if (outputStream != null) {
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
try {
gZIPOutputStream.write(bArr);
try {
return;
} catch (IOException unused) {
return;
}
} finally {
try {
gZIPOutputStream.close();
outputStream.close();
} catch (IOException unused2) {
}
}
}
throw new IOException("Cannot send request to FIS servers. No OutputStream available.");
}
@NonNull
public d d(@NonNull String str, String str2, @NonNull String str3, @NonNull String str4, String str5) throws FirebaseInstallationsException {
int responseCode;
d n15;
if (this.f90247c.b()) {
URL g15 = g(String.format("projects/%s/installations", str3));
for (int i15 = 0; i15 <= 1; i15++) {
TrafficStats.setThreadStatsTag(32769);
HttpURLConnection l15 = l(g15, str);
try {
try {
l15.setRequestMethod(NetworkHandler.POST);
l15.setDoOutput(true);
if (str5 != null) {
l15.addRequestProperty("x-goog-fis-android-iid-migration-auth", str5);
}
q(l15, str2, str4);
responseCode = l15.getResponseCode();
this.f90247c.f(responseCode);
} catch (IOException | AssertionError unused) {
}
if (i(responseCode)) {
n15 = n(l15);
} else {
k(l15, str4, str, str3);
if (responseCode != 429) {
if (responseCode < 500 || responseCode >= 600) {
j();
n15 = d.a().e(d.b.BAD_CONFIG).a();
}
l15.disconnect();
TrafficStats.clearThreadStatsTag();
} else {
throw new FirebaseInstallationsException("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", FirebaseInstallationsException.a.TOO_MANY_REQUESTS);
}
}
l15.disconnect();
TrafficStats.clearThreadStatsTag();
return n15;
} catch (Throwable th4) {
l15.disconnect();
TrafficStats.clearThreadStatsTag();
throw th4;
}
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.a.UNAVAILABLE);
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.a.UNAVAILABLE);
}
@NonNull
public f e(@NonNull String str, @NonNull String str2, @NonNull String str3, @NonNull String str4) throws FirebaseInstallationsException {
int responseCode;
f p15;
if (this.f90247c.b()) {
URL g15 = g(String.format("projects/%s/installations/%s/authTokens:generate", str3, str2));
for (int i15 = 0; i15 <= 1; i15++) {
TrafficStats.setThreadStatsTag(32771);
HttpURLConnection l15 = l(g15, str);
try {
try {
l15.setRequestMethod(NetworkHandler.POST);
l15.addRequestProperty("Authorization", "FIS_v2 " + str4);
l15.setDoOutput(true);
r(l15);
responseCode = l15.getResponseCode();
this.f90247c.f(responseCode);
} finally {
l15.disconnect();
TrafficStats.clearThreadStatsTag();
}
} catch (IOException | AssertionError unused) {
}
if (i(responseCode)) {
p15 = p(l15);
} else {
k(l15, null, str, str3);
if (responseCode != 401 && responseCode != 404) {
if (responseCode != 429) {
if (responseCode < 500 || responseCode >= 600) {
j();
p15 = f.a().b(f.b.BAD_CONFIG).a();
}
} else {
throw new FirebaseInstallationsException("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", FirebaseInstallationsException.a.TOO_MANY_REQUESTS);
}
} else {
p15 = f.a().b(f.b.AUTH_ERROR).a();
}
}
return p15;
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.a.UNAVAILABLE);
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.a.UNAVAILABLE);
}
}