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>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
package com.google.firebase.installations.remote;
import com.google.firebase.installations.remote.InstallationResponse;
/* loaded from: classes3.dex */
public final class AutoValue_InstallationResponse extends InstallationResponse {
public final TokenResult authToken;
public final String fid;
public final String refreshToken;
public final InstallationResponse.ResponseCode responseCode;
public final String uri;
@Override // com.google.firebase.installations.remote.InstallationResponse
public TokenResult getAuthToken() {
return this.authToken;
}
@Override // com.google.firebase.installations.remote.InstallationResponse
public String getFid() {
return this.fid;
}
@Override // com.google.firebase.installations.remote.InstallationResponse
public String getRefreshToken() {
return this.refreshToken;
}
@Override // com.google.firebase.installations.remote.InstallationResponse
public InstallationResponse.ResponseCode getResponseCode() {
return this.responseCode;
}
@Override // com.google.firebase.installations.remote.InstallationResponse
public String getUri() {
return this.uri;
}
public AutoValue_InstallationResponse(String str, String str2, String str3, TokenResult tokenResult, InstallationResponse.ResponseCode responseCode) {
this.uri = str;
this.fid = str2;
this.refreshToken = str3;
this.authToken = tokenResult;
this.responseCode = responseCode;
}
public String toString() {
return "InstallationResponse{uri=" + this.uri + ", fid=" + this.fid + ", refreshToken=" + this.refreshToken + ", authToken=" + this.authToken + ", responseCode=" + this.responseCode + "}";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof InstallationResponse)) {
return false;
}
InstallationResponse installationResponse = (InstallationResponse) obj;
String str = this.uri;
if (str != null ? str.equals(installationResponse.getUri()) : installationResponse.getUri() == null) {
String str2 = this.fid;
if (str2 != null ? str2.equals(installationResponse.getFid()) : installationResponse.getFid() == null) {
String str3 = this.refreshToken;
if (str3 != null ? str3.equals(installationResponse.getRefreshToken()) : installationResponse.getRefreshToken() == null) {
TokenResult tokenResult = this.authToken;
if (tokenResult != null ? tokenResult.equals(installationResponse.getAuthToken()) : installationResponse.getAuthToken() == null) {
InstallationResponse.ResponseCode responseCode = this.responseCode;
if (responseCode == null) {
if (installationResponse.getResponseCode() == null) {
return true;
}
} else if (responseCode.equals(installationResponse.getResponseCode())) {
return true;
}
}
}
}
}
return false;
}
public int hashCode() {
String str = this.uri;
int hashCode = ((str == null ? 0 : str.hashCode()) ^ 1000003) * 1000003;
String str2 = this.fid;
int hashCode2 = (hashCode ^ (str2 == null ? 0 : str2.hashCode())) * 1000003;
String str3 = this.refreshToken;
int hashCode3 = (hashCode2 ^ (str3 == null ? 0 : str3.hashCode())) * 1000003;
TokenResult tokenResult = this.authToken;
int hashCode4 = (hashCode3 ^ (tokenResult == null ? 0 : tokenResult.hashCode())) * 1000003;
InstallationResponse.ResponseCode responseCode = this.responseCode;
return hashCode4 ^ (responseCode != null ? responseCode.hashCode() : 0);
}
public static final class Builder extends InstallationResponse.Builder {
public TokenResult authToken;
public String fid;
public String refreshToken;
public InstallationResponse.ResponseCode responseCode;
public String uri;
@Override // com.google.firebase.installations.remote.InstallationResponse.Builder
public InstallationResponse.Builder setAuthToken(TokenResult tokenResult) {
this.authToken = tokenResult;
return this;
}
@Override // com.google.firebase.installations.remote.InstallationResponse.Builder
public InstallationResponse.Builder setFid(String str) {
this.fid = str;
return this;
}
@Override // com.google.firebase.installations.remote.InstallationResponse.Builder
public InstallationResponse.Builder setRefreshToken(String str) {
this.refreshToken = str;
return this;
}
@Override // com.google.firebase.installations.remote.InstallationResponse.Builder
public InstallationResponse.Builder setResponseCode(InstallationResponse.ResponseCode responseCode) {
this.responseCode = responseCode;
return this;
}
@Override // com.google.firebase.installations.remote.InstallationResponse.Builder
public InstallationResponse.Builder setUri(String str) {
this.uri = str;
return this;
}
@Override // com.google.firebase.installations.remote.InstallationResponse.Builder
public InstallationResponse build() {
return new AutoValue_InstallationResponse(this.uri, this.fid, this.refreshToken, this.authToken, this.responseCode);
}
}
}

View File

@@ -0,0 +1,104 @@
package com.google.firebase.installations.remote;
import com.google.firebase.installations.remote.TokenResult;
/* loaded from: classes3.dex */
public final class AutoValue_TokenResult extends TokenResult {
public final TokenResult.ResponseCode responseCode;
public final String token;
public final long tokenExpirationTimestamp;
@Override // com.google.firebase.installations.remote.TokenResult
public TokenResult.ResponseCode getResponseCode() {
return this.responseCode;
}
@Override // com.google.firebase.installations.remote.TokenResult
public String getToken() {
return this.token;
}
@Override // com.google.firebase.installations.remote.TokenResult
public long getTokenExpirationTimestamp() {
return this.tokenExpirationTimestamp;
}
public AutoValue_TokenResult(String str, long j, TokenResult.ResponseCode responseCode) {
this.token = str;
this.tokenExpirationTimestamp = j;
this.responseCode = responseCode;
}
public String toString() {
return "TokenResult{token=" + this.token + ", tokenExpirationTimestamp=" + this.tokenExpirationTimestamp + ", responseCode=" + this.responseCode + "}";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof TokenResult)) {
return false;
}
TokenResult tokenResult = (TokenResult) obj;
String str = this.token;
if (str != null ? str.equals(tokenResult.getToken()) : tokenResult.getToken() == null) {
if (this.tokenExpirationTimestamp == tokenResult.getTokenExpirationTimestamp()) {
TokenResult.ResponseCode responseCode = this.responseCode;
if (responseCode == null) {
if (tokenResult.getResponseCode() == null) {
return true;
}
} else if (responseCode.equals(tokenResult.getResponseCode())) {
return true;
}
}
}
return false;
}
public int hashCode() {
String str = this.token;
int hashCode = str == null ? 0 : str.hashCode();
long j = this.tokenExpirationTimestamp;
int i = (((hashCode ^ 1000003) * 1000003) ^ ((int) (j ^ (j >>> 32)))) * 1000003;
TokenResult.ResponseCode responseCode = this.responseCode;
return i ^ (responseCode != null ? responseCode.hashCode() : 0);
}
public static final class Builder extends TokenResult.Builder {
public TokenResult.ResponseCode responseCode;
public String token;
public Long tokenExpirationTimestamp;
@Override // com.google.firebase.installations.remote.TokenResult.Builder
public TokenResult.Builder setResponseCode(TokenResult.ResponseCode responseCode) {
this.responseCode = responseCode;
return this;
}
@Override // com.google.firebase.installations.remote.TokenResult.Builder
public TokenResult.Builder setToken(String str) {
this.token = str;
return this;
}
@Override // com.google.firebase.installations.remote.TokenResult.Builder
public TokenResult.Builder setTokenExpirationTimestamp(long j) {
this.tokenExpirationTimestamp = Long.valueOf(j);
return this;
}
@Override // com.google.firebase.installations.remote.TokenResult.Builder
public TokenResult build() {
String str = "";
if (this.tokenExpirationTimestamp == null) {
str = " tokenExpirationTimestamp";
}
if (!str.isEmpty()) {
throw new IllegalStateException("Missing required properties:" + str);
}
return new AutoValue_TokenResult(this.token, this.tokenExpirationTimestamp.longValue(), this.responseCode);
}
}
}

View File

@@ -0,0 +1,384 @@
package com.google.firebase.installations.remote;
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 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.tasks.Tasks;
import com.google.firebase.heartbeatinfo.HeartBeatController;
import com.google.firebase.inject.Provider;
import com.google.firebase.installations.FirebaseInstallationsException;
import com.google.firebase.installations.remote.InstallationResponse;
import com.google.firebase.installations.remote.TokenResult;
import com.ironsource.nb;
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.apache.http.protocol.HTTP;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class FirebaseInstallationServiceClient {
public static final Pattern EXPIRATION_TIMESTAMP_PATTERN = Pattern.compile("[0-9]+s");
public static final Charset UTF_8 = Charset.forName("UTF-8");
public final Context context;
public final Provider heartBeatProvider;
public final RequestLimiter requestLimiter = new RequestLimiter();
public static boolean isSuccessfulResponseCode(int i) {
return i >= 200 && i < 300;
}
public FirebaseInstallationServiceClient(Context context, Provider provider) {
this.context = context;
this.heartBeatProvider = provider;
}
public InstallationResponse createFirebaseInstallation(String str, String str2, String str3, String str4, String str5) {
int responseCode;
InstallationResponse readCreateResponse;
if (!this.requestLimiter.isRequestAllowed()) {
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
URL fullyQualifiedRequestUri = getFullyQualifiedRequestUri(String.format("projects/%s/installations", str3));
for (int i = 0; i <= 1; i++) {
TrafficStats.setThreadStatsTag(32769);
HttpURLConnection openHttpURLConnection = openHttpURLConnection(fullyQualifiedRequestUri, str);
try {
try {
openHttpURLConnection.setRequestMethod("POST");
openHttpURLConnection.setDoOutput(true);
if (str5 != null) {
openHttpURLConnection.addRequestProperty("x-goog-fis-android-iid-migration-auth", str5);
}
writeFIDCreateRequestBodyToOutputStream(openHttpURLConnection, str2, str4);
responseCode = openHttpURLConnection.getResponseCode();
this.requestLimiter.setNextRequestTime(responseCode);
} catch (IOException | AssertionError unused) {
}
if (isSuccessfulResponseCode(responseCode)) {
readCreateResponse = readCreateResponse(openHttpURLConnection);
} else {
logFisCommunicationError(openHttpURLConnection, str4, str, str3);
if (responseCode == 429) {
throw new FirebaseInstallationsException("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", FirebaseInstallationsException.Status.TOO_MANY_REQUESTS);
}
if (responseCode < 500 || responseCode >= 600) {
logBadConfigError();
readCreateResponse = InstallationResponse.builder().setResponseCode(InstallationResponse.ResponseCode.BAD_CONFIG).build();
}
openHttpURLConnection.disconnect();
TrafficStats.clearThreadStatsTag();
}
openHttpURLConnection.disconnect();
TrafficStats.clearThreadStatsTag();
return readCreateResponse;
} catch (Throwable th) {
openHttpURLConnection.disconnect();
TrafficStats.clearThreadStatsTag();
throw th;
}
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
public final void writeFIDCreateRequestBodyToOutputStream(HttpURLConnection httpURLConnection, String str, String str2) {
writeRequestBodyToOutputStream(httpURLConnection, getJsonBytes(buildCreateFirebaseInstallationRequestBody(str, str2)));
}
public static byte[] getJsonBytes(JSONObject jSONObject) {
return jSONObject.toString().getBytes("UTF-8");
}
public static void writeRequestBodyToOutputStream(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 static JSONObject buildCreateFirebaseInstallationRequestBody(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:18.0.0");
return jSONObject;
} catch (JSONException e) {
throw new IllegalStateException(e);
}
}
public final void writeGenerateAuthTokenRequestBodyToOutputStream(HttpURLConnection httpURLConnection) {
writeRequestBodyToOutputStream(httpURLConnection, getJsonBytes(buildGenerateAuthTokenRequestBody()));
}
public static JSONObject buildGenerateAuthTokenRequestBody() {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("sdkVersion", "a:18.0.0");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("installation", jSONObject);
return jSONObject2;
} catch (JSONException e) {
throw new IllegalStateException(e);
}
}
public final URL getFullyQualifiedRequestUri(String str) {
try {
return new URL(String.format("https://%s/%s/%s", "firebaseinstallations.googleapis.com", "v1", str));
} catch (MalformedURLException e) {
throw new FirebaseInstallationsException(e.getMessage(), FirebaseInstallationsException.Status.UNAVAILABLE);
}
}
public TokenResult generateAuthToken(String str, String str2, String str3, String str4) {
int responseCode;
TokenResult readGenerateAuthTokenResponse;
if (!this.requestLimiter.isRequestAllowed()) {
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
URL fullyQualifiedRequestUri = getFullyQualifiedRequestUri(String.format("projects/%s/installations/%s/authTokens:generate", str3, str2));
for (int i = 0; i <= 1; i++) {
TrafficStats.setThreadStatsTag(32771);
HttpURLConnection openHttpURLConnection = openHttpURLConnection(fullyQualifiedRequestUri, str);
try {
try {
openHttpURLConnection.setRequestMethod("POST");
openHttpURLConnection.addRequestProperty("Authorization", "FIS_v2 " + str4);
openHttpURLConnection.setDoOutput(true);
writeGenerateAuthTokenRequestBodyToOutputStream(openHttpURLConnection);
responseCode = openHttpURLConnection.getResponseCode();
this.requestLimiter.setNextRequestTime(responseCode);
} finally {
openHttpURLConnection.disconnect();
TrafficStats.clearThreadStatsTag();
}
} catch (IOException | AssertionError unused) {
}
if (isSuccessfulResponseCode(responseCode)) {
readGenerateAuthTokenResponse = readGenerateAuthTokenResponse(openHttpURLConnection);
} else {
logFisCommunicationError(openHttpURLConnection, null, str, str3);
if (responseCode == 401 || responseCode == 404) {
readGenerateAuthTokenResponse = TokenResult.builder().setResponseCode(TokenResult.ResponseCode.AUTH_ERROR).build();
} else {
if (responseCode == 429) {
throw new FirebaseInstallationsException("Firebase servers have received too many requests from this client in a short period of time. Please try again later.", FirebaseInstallationsException.Status.TOO_MANY_REQUESTS);
}
if (responseCode < 500 || responseCode >= 600) {
logBadConfigError();
readGenerateAuthTokenResponse = TokenResult.builder().setResponseCode(TokenResult.ResponseCode.BAD_CONFIG).build();
}
}
}
return readGenerateAuthTokenResponse;
}
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
}
public static void logBadConfigError() {
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.");
}
public final HttpURLConnection openHttpURLConnection(URL url, String str) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setUseCaches(false);
httpURLConnection.setReadTimeout(10000);
httpURLConnection.addRequestProperty("Content-Type", nb.L);
httpURLConnection.addRequestProperty("Accept", nb.L);
httpURLConnection.addRequestProperty(HTTP.CONTENT_ENCODING, "gzip");
httpURLConnection.addRequestProperty("Cache-Control", "no-cache");
httpURLConnection.addRequestProperty("X-Android-Package", this.context.getPackageName());
HeartBeatController heartBeatController = (HeartBeatController) this.heartBeatProvider.get();
if (heartBeatController != null) {
try {
httpURLConnection.addRequestProperty("x-firebase-client", (String) Tasks.await(heartBeatController.getHeartBeatsHeader()));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Log.w("ContentValues", "Failed to get heartbeats header", e);
} catch (ExecutionException e2) {
Log.w("ContentValues", "Failed to get heartbeats header", e2);
}
}
httpURLConnection.addRequestProperty("X-Android-Cert", getFingerprintHashForPackage());
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.Status.UNAVAILABLE);
}
}
public final InstallationResponse readCreateResponse(HttpURLConnection httpURLConnection) {
InputStream inputStream = httpURLConnection.getInputStream();
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, UTF_8));
TokenResult.Builder builder = TokenResult.builder();
InstallationResponse.Builder builder2 = InstallationResponse.builder();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName = jsonReader.nextName();
if (nextName.equals("name")) {
builder2.setUri(jsonReader.nextString());
} else if (nextName.equals("fid")) {
builder2.setFid(jsonReader.nextString());
} else if (nextName.equals("refreshToken")) {
builder2.setRefreshToken(jsonReader.nextString());
} else if (nextName.equals("authToken")) {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName2 = jsonReader.nextName();
if (nextName2.equals("token")) {
builder.setToken(jsonReader.nextString());
} else if (nextName2.equals("expiresIn")) {
builder.setTokenExpirationTimestamp(parseTokenExpirationTimestamp(jsonReader.nextString()));
} else {
jsonReader.skipValue();
}
}
builder2.setAuthToken(builder.build());
jsonReader.endObject();
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
jsonReader.close();
inputStream.close();
return builder2.setResponseCode(InstallationResponse.ResponseCode.OK).build();
}
public final TokenResult readGenerateAuthTokenResponse(HttpURLConnection httpURLConnection) {
InputStream inputStream = httpURLConnection.getInputStream();
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, UTF_8));
TokenResult.Builder builder = TokenResult.builder();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String nextName = jsonReader.nextName();
if (nextName.equals("token")) {
builder.setToken(jsonReader.nextString());
} else if (nextName.equals("expiresIn")) {
builder.setTokenExpirationTimestamp(parseTokenExpirationTimestamp(jsonReader.nextString()));
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
jsonReader.close();
inputStream.close();
return builder.setResponseCode(TokenResult.ResponseCode.OK).build();
}
public final String getFingerprintHashForPackage() {
try {
Context context = this.context;
byte[] packageCertificateHashBytes = AndroidUtilsLight.getPackageCertificateHashBytes(context, context.getPackageName());
if (packageCertificateHashBytes == null) {
Log.e("ContentValues", "Could not get fingerprint hash for package: " + this.context.getPackageName());
return null;
}
return Hex.bytesToStringUppercase(packageCertificateHashBytes, false);
} catch (PackageManager.NameNotFoundException e) {
Log.e("ContentValues", "No such package: " + this.context.getPackageName(), e);
return null;
}
}
public static long parseTokenExpirationTimestamp(String str) {
Preconditions.checkArgument(EXPIRATION_TIMESTAMP_PATTERN.matcher(str).matches(), "Invalid Expiration Timestamp.");
if (str == null || str.length() == 0) {
return 0L;
}
return Long.parseLong(str.substring(0, str.length() - 1));
}
public static void logFisCommunicationError(HttpURLConnection httpURLConnection, String str, String str2, String str3) {
String readErrorResponse = readErrorResponse(httpURLConnection);
if (TextUtils.isEmpty(readErrorResponse)) {
return;
}
Log.w("Firebase-Installations", readErrorResponse);
Log.w("Firebase-Installations", availableFirebaseOptions(str, str2, str3));
}
public static String availableFirebaseOptions(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);
}
public static String readErrorResponse(HttpURLConnection httpURLConnection) {
InputStream errorStream = httpURLConnection.getErrorStream();
if (errorStream == null) {
return null;
}
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(errorStream, UTF_8));
try {
try {
StringBuilder sb = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine);
sb.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(), sb);
try {
bufferedReader.close();
} catch (IOException unused) {
}
return format;
} catch (IOException unused2) {
return null;
}
} catch (IOException unused3) {
bufferedReader.close();
return null;
} catch (Throwable th) {
try {
bufferedReader.close();
} catch (IOException unused4) {
}
throw th;
}
}
}

View File

@@ -0,0 +1,40 @@
package com.google.firebase.installations.remote;
import com.google.firebase.installations.remote.AutoValue_InstallationResponse;
/* loaded from: classes3.dex */
public abstract class InstallationResponse {
public static abstract class Builder {
public abstract InstallationResponse build();
public abstract Builder setAuthToken(TokenResult tokenResult);
public abstract Builder setFid(String str);
public abstract Builder setRefreshToken(String str);
public abstract Builder setResponseCode(ResponseCode responseCode);
public abstract Builder setUri(String str);
}
public enum ResponseCode {
OK,
BAD_CONFIG
}
public abstract TokenResult getAuthToken();
public abstract String getFid();
public abstract String getRefreshToken();
public abstract ResponseCode getResponseCode();
public abstract String getUri();
public static Builder builder() {
return new AutoValue_InstallationResponse.Builder();
}
}

View File

@@ -0,0 +1,49 @@
package com.google.firebase.installations.remote;
import com.google.firebase.installations.Utils;
import java.util.concurrent.TimeUnit;
/* loaded from: classes3.dex */
public class RequestLimiter {
public static final long MAXIMUM_BACKOFF_DURATION_FOR_CONFIGURATION_ERRORS = TimeUnit.HOURS.toMillis(24);
public static final long MAXIMUM_BACKOFF_DURATION_FOR_SERVER_ERRORS = TimeUnit.MINUTES.toMillis(30);
public int attemptCount;
public long nextRequestTime;
public final Utils utils = Utils.getInstance();
public static boolean isRetryableError(int i) {
return i == 429 || (i >= 500 && i < 600);
}
public static boolean isSuccessfulOrRequiresNewFidCreation(int i) {
return (i >= 200 && i < 300) || i == 401 || i == 404;
}
public synchronized void setNextRequestTime(int i) {
if (isSuccessfulOrRequiresNewFidCreation(i)) {
resetBackoffStrategy();
return;
}
this.attemptCount++;
this.nextRequestTime = this.utils.currentTimeInMillis() + getBackoffDuration(i);
}
public final synchronized void resetBackoffStrategy() {
this.attemptCount = 0;
}
public final synchronized long getBackoffDuration(int i) {
if (isRetryableError(i)) {
return (long) Math.min(Math.pow(2.0d, this.attemptCount) + this.utils.getRandomDelayForSyncPrevention(), MAXIMUM_BACKOFF_DURATION_FOR_SERVER_ERRORS);
}
return MAXIMUM_BACKOFF_DURATION_FOR_CONFIGURATION_ERRORS;
}
public synchronized boolean isRequestAllowed() {
boolean z;
if (this.attemptCount != 0) {
z = this.utils.currentTimeInMillis() > this.nextRequestTime;
}
return z;
}
}

View File

@@ -0,0 +1,33 @@
package com.google.firebase.installations.remote;
import com.google.firebase.installations.remote.AutoValue_TokenResult;
/* loaded from: classes3.dex */
public abstract class TokenResult {
public static abstract class Builder {
public abstract TokenResult build();
public abstract Builder setResponseCode(ResponseCode responseCode);
public abstract Builder setToken(String str);
public abstract Builder setTokenExpirationTimestamp(long j);
}
public enum ResponseCode {
OK,
BAD_CONFIG,
AUTH_ERROR
}
public abstract ResponseCode getResponseCode();
public abstract String getToken();
public abstract long getTokenExpirationTimestamp();
public static Builder builder() {
return new AutoValue_TokenResult.Builder().setTokenExpirationTimestamp(0L);
}
}