PhotoRoom v4.8.2版本的 MD5 值为:c40a01bb3380c0f75c0cb6ac6760f295
以下内容为反编译后的 c.java 源代码,内容仅作参考
package bk;
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 bk.d;
import bk.f;
import com.adjust.sdk.Constants;
import com.google.android.gms.common.internal.s;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.installations.i;
import fg.j;
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 org.json.JSONException;
import org.json.JSONObject;
public class c {
private static final Pattern f13258d = Pattern.compile("[0-9]+s");
private static final Charset f13259e = Charset.forName(Constants.ENCODING);
private final Context f13260a;
private final yj.b f13261b;
private final e f13262c = new e();
public c(Context context, yj.b bVar) {
this.f13260a = context;
this.f13261b = bVar;
}
private static String a(String str, String str2, 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, 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.4");
return jSONObject;
} catch (JSONException e11) {
throw new IllegalStateException(e11);
}
}
private static JSONObject c() {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("sdkVersion", "a:17.1.4");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("installation", jSONObject);
return jSONObject2;
} catch (JSONException e11) {
throw new IllegalStateException(e11);
}
}
private String f() {
try {
Context context = this.f13260a;
byte[] a11 = fg.a.a(context, context.getPackageName());
if (a11 == null) {
Log.e("ContentValues", "Could not get fingerprint hash for package: " + this.f13260a.getPackageName());
return null;
}
return j.c(a11, false);
} catch (PackageManager.NameNotFoundException e11) {
Log.e("ContentValues", "No such package: " + this.f13260a.getPackageName(), e11);
return null;
}
}
private URL g(String str) {
try {
return new URL(String.format("https://%s/%s/%s", "firebaseinstallations.googleapis.com", "v1", str));
} catch (MalformedURLException e11) {
throw new i(e11.getMessage(), i.a.UNAVAILABLE);
}
}
private static byte[] h(JSONObject jSONObject) {
return jSONObject.toString().getBytes(Constants.ENCODING);
}
private static boolean i(int i11) {
return i11 >= 200 && i11 < 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, String str2, String str3) {
String o11 = o(httpURLConnection);
if (TextUtils.isEmpty(o11)) {
return;
}
Log.w("Firebase-Installations", o11);
Log.w("Firebase-Installations", a(str, str2, str3));
}
private HttpURLConnection l(URL url, String str) {
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.f13260a.getPackageName());
wj.i iVar = (wj.i) this.f13261b.get();
if (iVar != null) {
try {
httpURLConnection.addRequestProperty("x-firebase-client", (String) Tasks.await(iVar.a()));
} catch (InterruptedException e11) {
Thread.currentThread().interrupt();
Log.w("ContentValues", "Failed to get heartbeats header", e11);
} catch (ExecutionException e12) {
Log.w("ContentValues", "Failed to get heartbeats header", e12);
}
}
httpURLConnection.addRequestProperty("X-Android-Cert", f());
httpURLConnection.addRequestProperty("x-goog-api-key", str);
return httpURLConnection;
} catch (IOException unused) {
throw new i("Firebase Installations Service is unavailable. Please try again later.", i.a.UNAVAILABLE);
}
}
static long m(String str) {
s.b(f13258d.matcher(str).matches(), "Invalid Expiration Timestamp.");
if (str == null || str.length() == 0) {
return 0L;
}
return Long.parseLong(str.substring(0, str.length() - 1));
}
private d n(HttpURLConnection httpURLConnection) {
InputStream inputStream = httpURLConnection.getInputStream();
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, f13259e));
f.a a11 = f.a();
d.a a12 = d.a();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName = jsonReader.nextName();
if (nextName.equals("name")) {
a12.f(jsonReader.nextString());
} else if (nextName.equals("fid")) {
a12.c(jsonReader.nextString());
} else if (nextName.equals("refreshToken")) {
a12.d(jsonReader.nextString());
} else if (nextName.equals("authToken")) {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName2 = jsonReader.nextName();
if (nextName2.equals("token")) {
a11.c(jsonReader.nextString());
} else if (nextName2.equals("expiresIn")) {
a11.d(m(jsonReader.nextString()));
} else {
jsonReader.skipValue();
}
}
a12.b(a11.a());
jsonReader.endObject();
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
jsonReader.close();
inputStream.close();
return a12.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, f13259e));
try {
try {
StringBuilder sb2 = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb2.append(readLine);
sb2.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(), sb2);
try {
bufferedReader.close();
} catch (IOException unused) {
}
return format;
} catch (IOException unused2) {
return null;
}
} catch (IOException unused3) {
bufferedReader.close();
return null;
} catch (Throwable th2) {
try {
bufferedReader.close();
} catch (IOException unused4) {
}
throw th2;
}
}
private f p(HttpURLConnection httpURLConnection) {
InputStream inputStream = httpURLConnection.getInputStream();
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, f13259e));
f.a a11 = f.a();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName = jsonReader.nextName();
if (nextName.equals("token")) {
a11.c(jsonReader.nextString());
} else if (nextName.equals("expiresIn")) {
a11.d(m(jsonReader.nextString()));
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
jsonReader.close();
inputStream.close();
return a11.b(f.b.OK).a();
}
private void q(HttpURLConnection httpURLConnection, String str, String str2) {
s(httpURLConnection, h(b(str, str2)));
}
private void r(HttpURLConnection httpURLConnection) {
s(httpURLConnection, h(c()));
}
private static void s(URLConnection uRLConnection, byte[] bArr) {
OutputStream outputStream = uRLConnection.getOutputStream();
if (outputStream == null) {
throw new IOException("Cannot send request to FIS servers. No OutputStream available.");
}
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
try {
gZIPOutputStream.write(bArr);
} finally {
try {
gZIPOutputStream.close();
outputStream.close();
} catch (IOException unused) {
}
}
}
public d d(String str, String str2, String str3, String str4, String str5) {
int responseCode;
d n11;
if (this.f13262c.b()) {
URL g11 = g(String.format("projects/%s/installations", str3));
for (int i11 = 0; i11 <= 1; i11++) {
TrafficStats.setThreadStatsTag(32769);
HttpURLConnection l11 = l(g11, str);
try {
l11.setRequestMethod("POST");
l11.setDoOutput(true);
if (str5 != null) {
l11.addRequestProperty("x-goog-fis-android-iid-migration-auth", str5);
}
q(l11, str2, str4);
responseCode = l11.getResponseCode();
this.f13262c.f(responseCode);
} catch (IOException | AssertionError unused) {
} catch (Throwable th2) {
l11.disconnect();
TrafficStats.clearThreadStatsTag();
throw th2;
}
if (i(responseCode)) {
n11 = n(l11);
} else {
k(l11, str4, str, str3);
if (responseCode == 429) {
throw new i("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", i.a.TOO_MANY_REQUESTS);
}
if (responseCode < 500 || responseCode >= 600) {
j();
n11 = d.a().e(d.b.BAD_CONFIG).a();
} else {
l11.disconnect();
TrafficStats.clearThreadStatsTag();
}
}
l11.disconnect();
TrafficStats.clearThreadStatsTag();
return n11;
}
throw new i("Firebase Installations Service is unavailable. Please try again later.", i.a.UNAVAILABLE);
}
throw new i("Firebase Installations Service is unavailable. Please try again later.", i.a.UNAVAILABLE);
}
public f e(String str, String str2, String str3, String str4) {
int responseCode;
f p11;
if (this.f13262c.b()) {
URL g11 = g(String.format("projects/%s/installations/%s/authTokens:generate", str3, str2));
for (int i11 = 0; i11 <= 1; i11++) {
TrafficStats.setThreadStatsTag(32771);
HttpURLConnection l11 = l(g11, str);
try {
l11.setRequestMethod("POST");
l11.addRequestProperty("Authorization", "FIS_v2 " + str4);
l11.setDoOutput(true);
r(l11);
responseCode = l11.getResponseCode();
this.f13262c.f(responseCode);
} catch (IOException | AssertionError unused) {
} catch (Throwable th2) {
l11.disconnect();
TrafficStats.clearThreadStatsTag();
throw th2;
}
if (i(responseCode)) {
p11 = p(l11);
} else {
k(l11, null, str, str3);
if (responseCode != 401 && responseCode != 404) {
if (responseCode == 429) {
throw new i("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", i.a.TOO_MANY_REQUESTS);
}
if (responseCode < 500 || responseCode >= 600) {
j();
p11 = f.a().b(f.b.BAD_CONFIG).a();
} else {
l11.disconnect();
TrafficStats.clearThreadStatsTag();
}
}
p11 = f.a().b(f.b.AUTH_ERROR).a();
}
l11.disconnect();
TrafficStats.clearThreadStatsTag();
return p11;
}
throw new i("Firebase Installations Service is unavailable. Please try again later.", i.a.UNAVAILABLE);
}
throw new i("Firebase Installations Service is unavailable. Please try again later.", i.a.UNAVAILABLE);
}
}