- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
265 lines
12 KiB
Java
265 lines
12 KiB
Java
package com.google.firebase.remoteconfig.internal;
|
|
|
|
import com.google.android.gms.tasks.Continuation;
|
|
import com.google.android.gms.tasks.Task;
|
|
import com.google.android.gms.tasks.Tasks;
|
|
import com.google.firebase.remoteconfig.ConfigUpdate;
|
|
import com.google.firebase.remoteconfig.ConfigUpdateListener;
|
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException;
|
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfigException;
|
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException;
|
|
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.net.HttpURLConnection;
|
|
import java.util.Iterator;
|
|
import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class ConfigAutoFetch {
|
|
public final ConfigCacheClient activatedCache;
|
|
public final ConfigFetchHandler configFetchHandler;
|
|
public final Set eventListeners;
|
|
public final HttpURLConnection httpURLConnection;
|
|
public final Random random = new Random();
|
|
public final ConfigUpdateListener retryCallback;
|
|
public final ScheduledExecutorService scheduledExecutorService;
|
|
|
|
public ConfigAutoFetch(HttpURLConnection httpURLConnection, ConfigFetchHandler configFetchHandler, ConfigCacheClient configCacheClient, Set set, ConfigUpdateListener configUpdateListener, ScheduledExecutorService scheduledExecutorService) {
|
|
this.httpURLConnection = httpURLConnection;
|
|
this.configFetchHandler = configFetchHandler;
|
|
this.activatedCache = configCacheClient;
|
|
this.eventListeners = set;
|
|
this.retryCallback = configUpdateListener;
|
|
this.scheduledExecutorService = scheduledExecutorService;
|
|
}
|
|
|
|
public final synchronized void propagateErrors(FirebaseRemoteConfigException firebaseRemoteConfigException) {
|
|
Iterator it = this.eventListeners.iterator();
|
|
while (it.hasNext()) {
|
|
((ConfigUpdateListener) it.next()).onError(firebaseRemoteConfigException);
|
|
}
|
|
}
|
|
|
|
public final synchronized void executeAllListenerCallbacks(ConfigUpdate configUpdate) {
|
|
Iterator it = this.eventListeners.iterator();
|
|
while (it.hasNext()) {
|
|
((ConfigUpdateListener) it.next()).onUpdate(configUpdate);
|
|
}
|
|
}
|
|
|
|
public final synchronized boolean isEventListenersEmpty() {
|
|
return this.eventListeners.isEmpty();
|
|
}
|
|
|
|
public final String parseAndValidateConfigUpdateMessage(String str) {
|
|
int indexOf = str.indexOf(123);
|
|
int lastIndexOf = str.lastIndexOf(125);
|
|
return (indexOf < 0 || lastIndexOf < 0 || indexOf >= lastIndexOf) ? "" : str.substring(indexOf, lastIndexOf + 1);
|
|
}
|
|
|
|
public void listenForNotifications() {
|
|
HttpURLConnection httpURLConnection = this.httpURLConnection;
|
|
if (httpURLConnection == null) {
|
|
return;
|
|
}
|
|
try {
|
|
InputStream inputStream = httpURLConnection.getInputStream();
|
|
handleNotifications(inputStream);
|
|
inputStream.close();
|
|
} catch (IOException unused) {
|
|
} catch (Throwable th) {
|
|
this.httpURLConnection.disconnect();
|
|
throw th;
|
|
}
|
|
this.httpURLConnection.disconnect();
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:11:0x003b, code lost:
|
|
|
|
r5 = new org.json.JSONObject(r4);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:12:0x0044, code lost:
|
|
|
|
if (r5.has("featureDisabled") == false) goto L37;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:14:0x004a, code lost:
|
|
|
|
if (r5.getBoolean("featureDisabled") == false) goto L38;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:16:0x004c, code lost:
|
|
|
|
r9.retryCallback.onError(new com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException("The server is temporarily unavailable. Try again in a few minutes.", com.google.firebase.remoteconfig.FirebaseRemoteConfigException.Code.CONFIG_UPDATE_UNAVAILABLE));
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:24:0x0061, code lost:
|
|
|
|
if (isEventListenersEmpty() == false) goto L21;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:26:0x0068, code lost:
|
|
|
|
if (r5.has("latestTemplateVersionNumber") == false) goto L41;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:28:0x006a, code lost:
|
|
|
|
r6 = r9.configFetchHandler.getTemplateVersionNumber();
|
|
r4 = r5.getLong("latestTemplateVersionNumber");
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:29:0x0076, code lost:
|
|
|
|
if (r4 <= r6) goto L42;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:31:0x0078, code lost:
|
|
|
|
autoFetch(3, r4);
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public final void handleNotifications(java.io.InputStream r10) {
|
|
/*
|
|
r9 = this;
|
|
java.lang.String r0 = "latestTemplateVersionNumber"
|
|
java.lang.String r1 = "featureDisabled"
|
|
java.io.BufferedReader r2 = new java.io.BufferedReader
|
|
java.io.InputStreamReader r3 = new java.io.InputStreamReader
|
|
java.lang.String r4 = "utf-8"
|
|
r3.<init>(r10, r4)
|
|
r2.<init>(r3)
|
|
java.lang.String r3 = ""
|
|
L12:
|
|
r4 = r3
|
|
L13:
|
|
java.lang.String r5 = r2.readLine()
|
|
if (r5 == 0) goto L96
|
|
java.lang.StringBuilder r6 = new java.lang.StringBuilder
|
|
r6.<init>()
|
|
r6.append(r4)
|
|
r6.append(r5)
|
|
java.lang.String r4 = r6.toString()
|
|
java.lang.String r6 = "}"
|
|
boolean r5 = r5.contains(r6)
|
|
if (r5 == 0) goto L13
|
|
java.lang.String r4 = r9.parseAndValidateConfigUpdateMessage(r4)
|
|
boolean r5 = r4.isEmpty()
|
|
if (r5 == 0) goto L3b
|
|
goto L13
|
|
L3b:
|
|
org.json.JSONObject r5 = new org.json.JSONObject // Catch: org.json.JSONException -> L5b
|
|
r5.<init>(r4) // Catch: org.json.JSONException -> L5b
|
|
boolean r4 = r5.has(r1) // Catch: org.json.JSONException -> L5b
|
|
if (r4 == 0) goto L5d
|
|
boolean r4 = r5.getBoolean(r1) // Catch: org.json.JSONException -> L5b
|
|
if (r4 == 0) goto L5d
|
|
com.google.firebase.remoteconfig.ConfigUpdateListener r4 = r9.retryCallback // Catch: org.json.JSONException -> L5b
|
|
com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException r5 = new com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException // Catch: org.json.JSONException -> L5b
|
|
java.lang.String r6 = "The server is temporarily unavailable. Try again in a few minutes."
|
|
com.google.firebase.remoteconfig.FirebaseRemoteConfigException$Code r7 = com.google.firebase.remoteconfig.FirebaseRemoteConfigException.Code.CONFIG_UPDATE_UNAVAILABLE // Catch: org.json.JSONException -> L5b
|
|
r5.<init>(r6, r7) // Catch: org.json.JSONException -> L5b
|
|
r4.onError(r5) // Catch: org.json.JSONException -> L5b
|
|
goto L96
|
|
L5b:
|
|
r4 = move-exception
|
|
goto L7d
|
|
L5d:
|
|
boolean r4 = r9.isEventListenersEmpty() // Catch: org.json.JSONException -> L5b
|
|
if (r4 == 0) goto L64
|
|
goto L96
|
|
L64:
|
|
boolean r4 = r5.has(r0) // Catch: org.json.JSONException -> L5b
|
|
if (r4 == 0) goto L12
|
|
com.google.firebase.remoteconfig.internal.ConfigFetchHandler r4 = r9.configFetchHandler // Catch: org.json.JSONException -> L5b
|
|
long r6 = r4.getTemplateVersionNumber() // Catch: org.json.JSONException -> L5b
|
|
long r4 = r5.getLong(r0) // Catch: org.json.JSONException -> L5b
|
|
int r6 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
|
|
if (r6 <= 0) goto L12
|
|
r6 = 3
|
|
r9.autoFetch(r6, r4) // Catch: org.json.JSONException -> L5b
|
|
goto L12
|
|
L7d:
|
|
com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException r5 = new com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException
|
|
java.lang.Throwable r6 = r4.getCause()
|
|
com.google.firebase.remoteconfig.FirebaseRemoteConfigException$Code r7 = com.google.firebase.remoteconfig.FirebaseRemoteConfigException.Code.CONFIG_UPDATE_MESSAGE_INVALID
|
|
java.lang.String r8 = "Unable to parse config update message."
|
|
r5.<init>(r8, r6, r7)
|
|
r9.propagateErrors(r5)
|
|
java.lang.String r5 = "FirebaseRemoteConfig"
|
|
java.lang.String r6 = "Unable to parse latest config update message."
|
|
android.util.Log.e(r5, r6, r4)
|
|
goto L12
|
|
L96:
|
|
r2.close()
|
|
r10.close()
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.remoteconfig.internal.ConfigAutoFetch.handleNotifications(java.io.InputStream):void");
|
|
}
|
|
|
|
public final void autoFetch(final int i, final long j) {
|
|
if (i == 0) {
|
|
propagateErrors(new FirebaseRemoteConfigServerException("Unable to fetch the latest version of the template.", FirebaseRemoteConfigException.Code.CONFIG_UPDATE_NOT_FETCHED));
|
|
} else {
|
|
this.scheduledExecutorService.schedule(new Runnable() { // from class: com.google.firebase.remoteconfig.internal.ConfigAutoFetch.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ConfigAutoFetch.this.fetchLatestConfig(i, j);
|
|
}
|
|
}, this.random.nextInt(4), TimeUnit.SECONDS);
|
|
}
|
|
}
|
|
|
|
public synchronized Task fetchLatestConfig(int i, final long j) {
|
|
final int i2;
|
|
final Task fetchNowWithTypeAndAttemptNumber;
|
|
final Task task;
|
|
i2 = i - 1;
|
|
fetchNowWithTypeAndAttemptNumber = this.configFetchHandler.fetchNowWithTypeAndAttemptNumber(ConfigFetchHandler.FetchType.REALTIME, 3 - i2);
|
|
task = this.activatedCache.get();
|
|
return Tasks.whenAllComplete((Task<?>[]) new Task[]{fetchNowWithTypeAndAttemptNumber, task}).continueWithTask(this.scheduledExecutorService, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigAutoFetch$$ExternalSyntheticLambda0
|
|
@Override // com.google.android.gms.tasks.Continuation
|
|
public final Object then(Task task2) {
|
|
Task lambda$fetchLatestConfig$0;
|
|
lambda$fetchLatestConfig$0 = ConfigAutoFetch.this.lambda$fetchLatestConfig$0(fetchNowWithTypeAndAttemptNumber, task, j, i2, task2);
|
|
return lambda$fetchLatestConfig$0;
|
|
}
|
|
});
|
|
}
|
|
|
|
public final /* synthetic */ Task lambda$fetchLatestConfig$0(Task task, Task task2, long j, int i, Task task3) {
|
|
if (!task.isSuccessful()) {
|
|
return Tasks.forException(new FirebaseRemoteConfigClientException("Failed to auto-fetch config update.", task.getException()));
|
|
}
|
|
if (!task2.isSuccessful()) {
|
|
return Tasks.forException(new FirebaseRemoteConfigClientException("Failed to get activated config for auto-fetch", task2.getException()));
|
|
}
|
|
ConfigFetchHandler.FetchResponse fetchResponse = (ConfigFetchHandler.FetchResponse) task.getResult();
|
|
ConfigContainer configContainer = (ConfigContainer) task2.getResult();
|
|
if (!fetchResponseIsUpToDate(fetchResponse, j).booleanValue()) {
|
|
autoFetch(i, j);
|
|
return Tasks.forResult(null);
|
|
}
|
|
if (fetchResponse.getFetchedConfigs() == null) {
|
|
return Tasks.forResult(null);
|
|
}
|
|
if (configContainer == null) {
|
|
configContainer = ConfigContainer.newBuilder().build();
|
|
}
|
|
Set changedParams = configContainer.getChangedParams(fetchResponse.getFetchedConfigs());
|
|
if (changedParams.isEmpty()) {
|
|
return Tasks.forResult(null);
|
|
}
|
|
executeAllListenerCallbacks(ConfigUpdate.create(changedParams));
|
|
return Tasks.forResult(null);
|
|
}
|
|
|
|
public static Boolean fetchResponseIsUpToDate(ConfigFetchHandler.FetchResponse fetchResponse, long j) {
|
|
if (fetchResponse.getFetchedConfigs() != null) {
|
|
return Boolean.valueOf(fetchResponse.getFetchedConfigs().getTemplateVersionNumber() >= j);
|
|
}
|
|
return Boolean.valueOf(fetchResponse.getStatus() == 1);
|
|
}
|
|
}
|