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,38 @@
package com.google.firebase.remoteconfig;
import java.util.Set;
/* loaded from: classes3.dex */
public final class AutoValue_ConfigUpdate extends ConfigUpdate {
public final Set updatedKeys;
@Override // com.google.firebase.remoteconfig.ConfigUpdate
public Set getUpdatedKeys() {
return this.updatedKeys;
}
public AutoValue_ConfigUpdate(Set set) {
if (set == null) {
throw new NullPointerException("Null updatedKeys");
}
this.updatedKeys = set;
}
public String toString() {
return "ConfigUpdate{updatedKeys=" + this.updatedKeys + "}";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof ConfigUpdate) {
return this.updatedKeys.equals(((ConfigUpdate) obj).getUpdatedKeys());
}
return false;
}
public int hashCode() {
return this.updatedKeys.hashCode() ^ 1000003;
}
}

View File

@@ -0,0 +1,12 @@
package com.google.firebase.remoteconfig;
import java.util.Set;
/* loaded from: classes3.dex */
public abstract class ConfigUpdate {
public abstract Set getUpdatedKeys();
public static ConfigUpdate create(Set set) {
return new AutoValue_ConfigUpdate(set);
}
}

View File

@@ -0,0 +1,8 @@
package com.google.firebase.remoteconfig;
/* loaded from: classes3.dex */
public interface ConfigUpdateListener {
void onError(FirebaseRemoteConfigException firebaseRemoteConfigException);
void onUpdate(ConfigUpdate configUpdate);
}

View File

@@ -0,0 +1,230 @@
package com.google.firebase.remoteconfig;
import android.content.Context;
import android.util.Log;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.SuccessContinuation;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.abt.AbtException;
import com.google.firebase.abt.FirebaseABTesting;
import com.google.firebase.concurrent.FirebaseExecutors;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.remoteconfig.internal.ConfigCacheClient;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler;
import com.google.firebase.remoteconfig.internal.ConfigMetadataClient;
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler;
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfig {
public static final byte[] DEFAULT_VALUE_FOR_BYTE_ARRAY = new byte[0];
public final ConfigCacheClient activatedConfigsCache;
public final ConfigRealtimeHandler configRealtimeHandler;
public final Context context;
public final ConfigCacheClient defaultConfigsCache;
public final Executor executor;
public final ConfigFetchHandler fetchHandler;
public final ConfigCacheClient fetchedConfigsCache;
public final FirebaseABTesting firebaseAbt;
public final FirebaseApp firebaseApp;
public final FirebaseInstallationsApi firebaseInstallations;
public final ConfigMetadataClient frcMetadata;
public final ConfigGetParameterHandler getHandler;
public final RolloutsStateSubscriptionsHandler rolloutsStateSubscriptionsHandler;
public RolloutsStateSubscriptionsHandler getRolloutsStateSubscriptionsHandler() {
return this.rolloutsStateSubscriptionsHandler;
}
public static FirebaseRemoteConfig getInstance() {
return getInstance(FirebaseApp.getInstance());
}
public static FirebaseRemoteConfig getInstance(FirebaseApp firebaseApp) {
return ((RemoteConfigComponent) firebaseApp.get(RemoteConfigComponent.class)).getDefault();
}
public FirebaseRemoteConfig(Context context, FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, FirebaseABTesting firebaseABTesting, Executor executor, ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2, ConfigCacheClient configCacheClient3, ConfigFetchHandler configFetchHandler, ConfigGetParameterHandler configGetParameterHandler, ConfigMetadataClient configMetadataClient, ConfigRealtimeHandler configRealtimeHandler, RolloutsStateSubscriptionsHandler rolloutsStateSubscriptionsHandler) {
this.context = context;
this.firebaseApp = firebaseApp;
this.firebaseInstallations = firebaseInstallationsApi;
this.firebaseAbt = firebaseABTesting;
this.executor = executor;
this.fetchedConfigsCache = configCacheClient;
this.activatedConfigsCache = configCacheClient2;
this.defaultConfigsCache = configCacheClient3;
this.fetchHandler = configFetchHandler;
this.getHandler = configGetParameterHandler;
this.frcMetadata = configMetadataClient;
this.configRealtimeHandler = configRealtimeHandler;
this.rolloutsStateSubscriptionsHandler = rolloutsStateSubscriptionsHandler;
}
public Task fetchAndActivate() {
return fetch().onSuccessTask(this.executor, new SuccessContinuation() { // from class: com.google.firebase.remoteconfig.FirebaseRemoteConfig$$ExternalSyntheticLambda1
@Override // com.google.android.gms.tasks.SuccessContinuation
public final Task then(Object obj) {
Task lambda$fetchAndActivate$1;
lambda$fetchAndActivate$1 = FirebaseRemoteConfig.this.lambda$fetchAndActivate$1((Void) obj);
return lambda$fetchAndActivate$1;
}
});
}
public final /* synthetic */ Task lambda$fetchAndActivate$1(Void r1) {
return activate();
}
public Task activate() {
final Task task = this.fetchedConfigsCache.get();
final Task task2 = this.activatedConfigsCache.get();
return Tasks.whenAllComplete((Task<?>[]) new Task[]{task, task2}).continueWithTask(this.executor, new Continuation() { // from class: com.google.firebase.remoteconfig.FirebaseRemoteConfig$$ExternalSyntheticLambda3
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task3) {
Task lambda$activate$2;
lambda$activate$2 = FirebaseRemoteConfig.this.lambda$activate$2(task, task2, task3);
return lambda$activate$2;
}
});
}
public final /* synthetic */ Task lambda$activate$2(Task task, Task task2, Task task3) {
if (!task.isSuccessful() || task.getResult() == null) {
return Tasks.forResult(Boolean.FALSE);
}
ConfigContainer configContainer = (ConfigContainer) task.getResult();
if (task2.isSuccessful() && !isFetchedFresh(configContainer, (ConfigContainer) task2.getResult())) {
return Tasks.forResult(Boolean.FALSE);
}
return this.activatedConfigsCache.put(configContainer).continueWith(this.executor, new Continuation() { // from class: com.google.firebase.remoteconfig.FirebaseRemoteConfig$$ExternalSyntheticLambda4
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task4) {
boolean processActivatePutTask;
processActivatePutTask = FirebaseRemoteConfig.this.processActivatePutTask(task4);
return Boolean.valueOf(processActivatePutTask);
}
});
}
public Task fetch() {
return this.fetchHandler.fetch().onSuccessTask(FirebaseExecutors.directExecutor(), new SuccessContinuation() { // from class: com.google.firebase.remoteconfig.FirebaseRemoteConfig$$ExternalSyntheticLambda2
@Override // com.google.android.gms.tasks.SuccessContinuation
public final Task then(Object obj) {
Task lambda$fetch$3;
lambda$fetch$3 = FirebaseRemoteConfig.lambda$fetch$3((ConfigFetchHandler.FetchResponse) obj);
return lambda$fetch$3;
}
});
}
public static /* synthetic */ Task lambda$fetch$3(ConfigFetchHandler.FetchResponse fetchResponse) {
return Tasks.forResult(null);
}
public String getString(String str) {
return this.getHandler.getString(str);
}
public boolean getBoolean(String str) {
return this.getHandler.getBoolean(str);
}
public double getDouble(String str) {
return this.getHandler.getDouble(str);
}
public Map getAll() {
return this.getHandler.getAll();
}
public FirebaseRemoteConfigInfo getInfo() {
return this.frcMetadata.getInfo();
}
public Task setConfigSettingsAsync(final FirebaseRemoteConfigSettings firebaseRemoteConfigSettings) {
return Tasks.call(this.executor, new Callable() { // from class: com.google.firebase.remoteconfig.FirebaseRemoteConfig$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
Void lambda$setConfigSettingsAsync$5;
lambda$setConfigSettingsAsync$5 = FirebaseRemoteConfig.this.lambda$setConfigSettingsAsync$5(firebaseRemoteConfigSettings);
return lambda$setConfigSettingsAsync$5;
}
});
}
public final /* synthetic */ Void lambda$setConfigSettingsAsync$5(FirebaseRemoteConfigSettings firebaseRemoteConfigSettings) {
this.frcMetadata.setConfigSettings(firebaseRemoteConfigSettings);
return null;
}
public void startLoadingConfigsFromDisk() {
this.activatedConfigsCache.get();
this.defaultConfigsCache.get();
this.fetchedConfigsCache.get();
}
public final boolean processActivatePutTask(Task task) {
if (!task.isSuccessful()) {
return false;
}
this.fetchedConfigsCache.clear();
ConfigContainer configContainer = (ConfigContainer) task.getResult();
if (configContainer != null) {
updateAbtWithActivatedExperiments(configContainer.getAbtExperiments());
this.rolloutsStateSubscriptionsHandler.publishActiveRolloutsState(configContainer);
return true;
}
Log.e("FirebaseRemoteConfig", "Activated configs written to disk are null.");
return true;
}
public void updateAbtWithActivatedExperiments(JSONArray jSONArray) {
if (this.firebaseAbt == null) {
return;
}
try {
this.firebaseAbt.replaceAllExperiments(toExperimentInfoMaps(jSONArray));
} catch (AbtException e) {
Log.w("FirebaseRemoteConfig", "Could not update ABT experiments.", e);
} catch (JSONException e2) {
Log.e("FirebaseRemoteConfig", "Could not parse ABT experiments from the JSON response.", e2);
}
}
public void setConfigUpdateBackgroundState(boolean z) {
this.configRealtimeHandler.setBackgroundState(z);
}
public static List toExperimentInfoMaps(JSONArray jSONArray) {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
HashMap hashMap = new HashMap();
JSONObject jSONObject = jSONArray.getJSONObject(i);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
hashMap.put(next, jSONObject.getString(next));
}
arrayList.add(hashMap);
}
return arrayList;
}
public static boolean isFetchedFresh(ConfigContainer configContainer, ConfigContainer configContainer2) {
return configContainer2 == null || !configContainer.getFetchTime().equals(configContainer2.getFetchTime());
}
}

View File

@@ -0,0 +1,22 @@
package com.google.firebase.remoteconfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigException;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigClientException extends FirebaseRemoteConfigException {
public FirebaseRemoteConfigClientException(String str) {
super(str);
}
public FirebaseRemoteConfigClientException(String str, Throwable th) {
super(str, th);
}
public FirebaseRemoteConfigClientException(String str, FirebaseRemoteConfigException.Code code) {
super(str, code);
}
public FirebaseRemoteConfigClientException(String str, Throwable th, FirebaseRemoteConfigException.Code code) {
super(str, th, code);
}
}

View File

@@ -0,0 +1,46 @@
package com.google.firebase.remoteconfig;
import com.google.firebase.FirebaseException;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigException extends FirebaseException {
public final Code code;
public FirebaseRemoteConfigException(String str) {
super(str);
this.code = Code.UNKNOWN;
}
public FirebaseRemoteConfigException(String str, Throwable th) {
super(str, th);
this.code = Code.UNKNOWN;
}
public FirebaseRemoteConfigException(String str, Code code) {
super(str);
this.code = code;
}
public FirebaseRemoteConfigException(String str, Throwable th, Code code) {
super(str, th);
this.code = code;
}
public enum Code {
UNKNOWN(0),
CONFIG_UPDATE_STREAM_ERROR(1),
CONFIG_UPDATE_MESSAGE_INVALID(2),
CONFIG_UPDATE_NOT_FETCHED(3),
CONFIG_UPDATE_UNAVAILABLE(4);
private final int value;
public int value() {
return this.value;
}
Code(int i) {
this.value = i;
}
}
}

View File

@@ -0,0 +1,15 @@
package com.google.firebase.remoteconfig;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigFetchThrottledException extends FirebaseRemoteConfigException {
public final long throttleEndTimeMillis;
public FirebaseRemoteConfigFetchThrottledException(long j) {
this("Fetch was throttled.", j);
}
public FirebaseRemoteConfigFetchThrottledException(String str, long j) {
super(str);
this.throttleEndTimeMillis = j;
}
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.remoteconfig;
/* loaded from: classes3.dex */
public interface FirebaseRemoteConfigInfo {
int getLastFetchStatus();
}

View File

@@ -0,0 +1,16 @@
package com.google.firebase.remoteconfig;
import androidx.annotation.Keep;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
@Keep
/* loaded from: classes3.dex */
public final class FirebaseRemoteConfigKtxRegistrar implements ComponentRegistrar {
@Override // com.google.firebase.components.ComponentRegistrar
public List<Component> getComponents() {
return CollectionsKt__CollectionsKt.emptyList();
}
}

View File

@@ -0,0 +1,32 @@
package com.google.firebase.remoteconfig;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigException;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigServerException extends FirebaseRemoteConfigException {
public final int httpStatusCode;
public int getHttpStatusCode() {
return this.httpStatusCode;
}
public FirebaseRemoteConfigServerException(int i, String str) {
super(str);
this.httpStatusCode = i;
}
public FirebaseRemoteConfigServerException(int i, String str, Throwable th) {
super(str, th);
this.httpStatusCode = i;
}
public FirebaseRemoteConfigServerException(String str, FirebaseRemoteConfigException.Code code) {
super(str, code);
this.httpStatusCode = -1;
}
public FirebaseRemoteConfigServerException(int i, String str, FirebaseRemoteConfigException.Code code) {
super(str, code);
this.httpStatusCode = i;
}
}

View File

@@ -0,0 +1,47 @@
package com.google.firebase.remoteconfig;
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigSettings {
public final long fetchTimeoutInSeconds;
public final long minimumFetchInterval;
public long getFetchTimeoutInSeconds() {
return this.fetchTimeoutInSeconds;
}
public long getMinimumFetchIntervalInSeconds() {
return this.minimumFetchInterval;
}
public FirebaseRemoteConfigSettings(Builder builder) {
this.fetchTimeoutInSeconds = builder.fetchTimeoutInSeconds;
this.minimumFetchInterval = builder.minimumFetchInterval;
}
public static class Builder {
public long fetchTimeoutInSeconds = 60;
public long minimumFetchInterval = ConfigFetchHandler.DEFAULT_MINIMUM_FETCH_INTERVAL_IN_SECONDS;
public Builder setFetchTimeoutInSeconds(long j) {
if (j < 0) {
throw new IllegalArgumentException(String.format("Fetch connection timeout has to be a non-negative number. %d is an invalid argument", Long.valueOf(j)));
}
this.fetchTimeoutInSeconds = j;
return this;
}
public Builder setMinimumFetchIntervalInSeconds(long j) {
if (j >= 0) {
this.minimumFetchInterval = j;
return this;
}
throw new IllegalArgumentException("Minimum interval between fetches has to be a non-negative number. " + j + " is an invalid argument");
}
public FirebaseRemoteConfigSettings build() {
return new FirebaseRemoteConfigSettings(this);
}
}
}

View File

@@ -0,0 +1,14 @@
package com.google.firebase.remoteconfig;
/* loaded from: classes3.dex */
public interface FirebaseRemoteConfigValue {
boolean asBoolean();
double asDouble();
long asLong();
String asString();
int getSource();
}

View File

@@ -0,0 +1,215 @@
package com.google.firebase.remoteconfig;
import android.app.Application;
import android.content.Context;
import androidx.lifecycle.LifecycleKt$$ExternalSyntheticBackportWithForwarding0;
import com.google.android.gms.common.api.internal.BackgroundDetector;
import com.google.android.gms.common.util.BiConsumer;
import com.google.android.gms.common.util.Clock;
import com.google.android.gms.common.util.DefaultClock;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.abt.FirebaseABTesting;
import com.google.firebase.analytics.connector.AnalyticsConnector;
import com.google.firebase.inject.Provider;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.remoteconfig.internal.ConfigCacheClient;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
import com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient;
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler;
import com.google.firebase.remoteconfig.internal.ConfigMetadataClient;
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler;
import com.google.firebase.remoteconfig.internal.ConfigStorageClient;
import com.google.firebase.remoteconfig.internal.Personalization;
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateFactory;
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
import com.google.firebase.remoteconfig.interop.FirebaseRemoteConfigInterop;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutsStateSubscriber;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes3.dex */
public class RemoteConfigComponent implements FirebaseRemoteConfigInterop {
public static final Clock DEFAULT_CLOCK = DefaultClock.getInstance();
public static final Random DEFAULT_RANDOM = new Random();
public static final Map frcNamespaceInstancesStatic = new HashMap();
public final Provider analyticsConnector;
public final String appId;
public final Context context;
public Map customHeaders;
public final ScheduledExecutorService executor;
public final FirebaseABTesting firebaseAbt;
public final FirebaseApp firebaseApp;
public final FirebaseInstallationsApi firebaseInstallations;
public final Map frcNamespaceInstances;
public static /* synthetic */ AnalyticsConnector lambda$getFetchHandler$0() {
return null;
}
public RemoteConfigComponent(Context context, ScheduledExecutorService scheduledExecutorService, FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, FirebaseABTesting firebaseABTesting, Provider provider) {
this(context, scheduledExecutorService, firebaseApp, firebaseInstallationsApi, firebaseABTesting, provider, true);
}
public RemoteConfigComponent(Context context, ScheduledExecutorService scheduledExecutorService, FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, FirebaseABTesting firebaseABTesting, Provider provider, boolean z) {
this.frcNamespaceInstances = new HashMap();
this.customHeaders = new HashMap();
this.context = context;
this.executor = scheduledExecutorService;
this.firebaseApp = firebaseApp;
this.firebaseInstallations = firebaseInstallationsApi;
this.firebaseAbt = firebaseABTesting;
this.analyticsConnector = provider;
this.appId = firebaseApp.getOptions().getApplicationId();
GlobalBackgroundListener.ensureBackgroundListenerIsRegistered(context);
if (z) {
Tasks.call(scheduledExecutorService, new Callable() { // from class: com.google.firebase.remoteconfig.RemoteConfigComponent$$ExternalSyntheticLambda1
@Override // java.util.concurrent.Callable
public final Object call() {
return RemoteConfigComponent.this.getDefault();
}
});
}
}
public FirebaseRemoteConfig getDefault() {
return get("firebase");
}
public synchronized FirebaseRemoteConfig get(String str) {
ConfigCacheClient cacheClient;
ConfigCacheClient cacheClient2;
ConfigCacheClient cacheClient3;
ConfigMetadataClient metadataClient;
ConfigGetParameterHandler getHandler;
try {
cacheClient = getCacheClient(str, "fetch");
cacheClient2 = getCacheClient(str, "activate");
cacheClient3 = getCacheClient(str, "defaults");
metadataClient = getMetadataClient(this.context, this.appId, str);
getHandler = getGetHandler(cacheClient2, cacheClient3);
final Personalization personalization = getPersonalization(this.firebaseApp, str, this.analyticsConnector);
if (personalization != null) {
getHandler.addListener(new BiConsumer() { // from class: com.google.firebase.remoteconfig.RemoteConfigComponent$$ExternalSyntheticLambda0
@Override // com.google.android.gms.common.util.BiConsumer
public final void accept(Object obj, Object obj2) {
Personalization.this.logArmActive((String) obj, (ConfigContainer) obj2);
}
});
}
} catch (Throwable th) {
throw th;
}
return get(this.firebaseApp, str, this.firebaseInstallations, this.firebaseAbt, this.executor, cacheClient, cacheClient2, cacheClient3, getFetchHandler(str, cacheClient, metadataClient), getHandler, metadataClient, getRolloutsStateSubscriptionsHandler(cacheClient2, cacheClient3));
}
public synchronized FirebaseRemoteConfig get(FirebaseApp firebaseApp, String str, FirebaseInstallationsApi firebaseInstallationsApi, FirebaseABTesting firebaseABTesting, Executor executor, ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2, ConfigCacheClient configCacheClient3, ConfigFetchHandler configFetchHandler, ConfigGetParameterHandler configGetParameterHandler, ConfigMetadataClient configMetadataClient, RolloutsStateSubscriptionsHandler rolloutsStateSubscriptionsHandler) {
try {
if (!this.frcNamespaceInstances.containsKey(str)) {
FirebaseRemoteConfig firebaseRemoteConfig = new FirebaseRemoteConfig(this.context, firebaseApp, firebaseInstallationsApi, isAbtSupported(firebaseApp, str) ? firebaseABTesting : null, executor, configCacheClient, configCacheClient2, configCacheClient3, configFetchHandler, configGetParameterHandler, configMetadataClient, getRealtime(firebaseApp, firebaseInstallationsApi, configFetchHandler, configCacheClient2, this.context, str, configMetadataClient), rolloutsStateSubscriptionsHandler);
firebaseRemoteConfig.startLoadingConfigsFromDisk();
this.frcNamespaceInstances.put(str, firebaseRemoteConfig);
frcNamespaceInstancesStatic.put(str, firebaseRemoteConfig);
}
} catch (Throwable th) {
throw th;
}
return (FirebaseRemoteConfig) this.frcNamespaceInstances.get(str);
}
public final ConfigCacheClient getCacheClient(String str, String str2) {
return ConfigCacheClient.getInstance(this.executor, ConfigStorageClient.getInstance(this.context, String.format("%s_%s_%s_%s.json", "frc", this.appId, str, str2)));
}
public ConfigFetchHttpClient getFrcBackendApiClient(String str, String str2, ConfigMetadataClient configMetadataClient) {
return new ConfigFetchHttpClient(this.context, this.firebaseApp.getOptions().getApplicationId(), str, str2, configMetadataClient.getFetchTimeoutInSeconds(), configMetadataClient.getFetchTimeoutInSeconds());
}
public synchronized ConfigFetchHandler getFetchHandler(String str, ConfigCacheClient configCacheClient, ConfigMetadataClient configMetadataClient) {
try {
} catch (Throwable th) {
throw th;
}
return new ConfigFetchHandler(this.firebaseInstallations, isPrimaryApp(this.firebaseApp) ? this.analyticsConnector : new Provider() { // from class: com.google.firebase.remoteconfig.RemoteConfigComponent$$ExternalSyntheticLambda2
@Override // com.google.firebase.inject.Provider
public final Object get() {
AnalyticsConnector lambda$getFetchHandler$0;
lambda$getFetchHandler$0 = RemoteConfigComponent.lambda$getFetchHandler$0();
return lambda$getFetchHandler$0;
}
}, this.executor, DEFAULT_CLOCK, DEFAULT_RANDOM, configCacheClient, getFrcBackendApiClient(this.firebaseApp.getOptions().getApiKey(), str, configMetadataClient), configMetadataClient, this.customHeaders);
}
public synchronized ConfigRealtimeHandler getRealtime(FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, ConfigFetchHandler configFetchHandler, ConfigCacheClient configCacheClient, Context context, String str, ConfigMetadataClient configMetadataClient) {
return new ConfigRealtimeHandler(firebaseApp, firebaseInstallationsApi, configFetchHandler, configCacheClient, context, str, configMetadataClient, this.executor);
}
public final ConfigGetParameterHandler getGetHandler(ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2) {
return new ConfigGetParameterHandler(this.executor, configCacheClient, configCacheClient2);
}
public static ConfigMetadataClient getMetadataClient(Context context, String str, String str2) {
return new ConfigMetadataClient(context.getSharedPreferences(String.format("%s_%s_%s_%s", "frc", str, str2, "settings"), 0));
}
public static Personalization getPersonalization(FirebaseApp firebaseApp, String str, Provider provider) {
if (isPrimaryApp(firebaseApp) && str.equals("firebase")) {
return new Personalization(provider);
}
return null;
}
public final RolloutsStateSubscriptionsHandler getRolloutsStateSubscriptionsHandler(ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2) {
return new RolloutsStateSubscriptionsHandler(configCacheClient, RolloutsStateFactory.create(configCacheClient, configCacheClient2), this.executor);
}
public static boolean isAbtSupported(FirebaseApp firebaseApp, String str) {
return str.equals("firebase") && isPrimaryApp(firebaseApp);
}
public static boolean isPrimaryApp(FirebaseApp firebaseApp) {
return firebaseApp.getName().equals("[DEFAULT]");
}
public static synchronized void notifyRCInstances(boolean z) {
synchronized (RemoteConfigComponent.class) {
Iterator it = frcNamespaceInstancesStatic.values().iterator();
while (it.hasNext()) {
((FirebaseRemoteConfig) it.next()).setConfigUpdateBackgroundState(z);
}
}
}
@Override // com.google.firebase.remoteconfig.interop.FirebaseRemoteConfigInterop
public void registerRolloutsStateSubscriber(String str, RolloutsStateSubscriber rolloutsStateSubscriber) {
get(str).getRolloutsStateSubscriptionsHandler().registerRolloutsStateSubscriber(rolloutsStateSubscriber);
}
public static class GlobalBackgroundListener implements BackgroundDetector.BackgroundStateChangeListener {
public static final AtomicReference INSTANCE = new AtomicReference();
public static void ensureBackgroundListenerIsRegistered(Context context) {
Application application = (Application) context.getApplicationContext();
AtomicReference atomicReference = INSTANCE;
if (atomicReference.get() == null) {
GlobalBackgroundListener globalBackgroundListener = new GlobalBackgroundListener();
if (LifecycleKt$$ExternalSyntheticBackportWithForwarding0.m(atomicReference, null, globalBackgroundListener)) {
BackgroundDetector.initialize(application);
BackgroundDetector.getInstance().addListener(globalBackgroundListener);
}
}
}
@Override // com.google.android.gms.common.api.internal.BackgroundDetector.BackgroundStateChangeListener
public void onBackgroundStateChanged(boolean z) {
RemoteConfigComponent.notifyRCInstances(z);
}
}
}

View File

@@ -0,0 +1,44 @@
package com.google.firebase.remoteconfig;
import android.content.Context;
import androidx.annotation.Keep;
import com.google.firebase.FirebaseApp;
import com.google.firebase.abt.component.AbtComponent;
import com.google.firebase.analytics.connector.AnalyticsConnector;
import com.google.firebase.annotations.concurrent.Blocking;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentContainer;
import com.google.firebase.components.ComponentFactory;
import com.google.firebase.components.ComponentRegistrar;
import com.google.firebase.components.Dependency;
import com.google.firebase.components.Qualified;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.platforminfo.LibraryVersionComponent;
import com.google.firebase.remoteconfig.interop.FirebaseRemoteConfigInterop;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
@Keep
/* loaded from: classes3.dex */
public class RemoteConfigRegistrar implements ComponentRegistrar {
private static final String LIBRARY_NAME = "fire-rc";
@Override // com.google.firebase.components.ComponentRegistrar
public List<Component> getComponents() {
final Qualified qualified = Qualified.qualified(Blocking.class, ScheduledExecutorService.class);
return Arrays.asList(Component.builder(RemoteConfigComponent.class, FirebaseRemoteConfigInterop.class).name(LIBRARY_NAME).add(Dependency.required(Context.class)).add(Dependency.required(qualified)).add(Dependency.required(FirebaseApp.class)).add(Dependency.required(FirebaseInstallationsApi.class)).add(Dependency.required(AbtComponent.class)).add(Dependency.optionalProvider(AnalyticsConnector.class)).factory(new ComponentFactory() { // from class: com.google.firebase.remoteconfig.RemoteConfigRegistrar$$ExternalSyntheticLambda0
@Override // com.google.firebase.components.ComponentFactory
public final Object create(ComponentContainer componentContainer) {
RemoteConfigComponent lambda$getComponents$0;
lambda$getComponents$0 = RemoteConfigRegistrar.lambda$getComponents$0(Qualified.this, componentContainer);
return lambda$getComponents$0;
}
}).eagerInDefaultApp().build(), LibraryVersionComponent.create(LIBRARY_NAME, "22.0.0"));
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ RemoteConfigComponent lambda$getComponents$0(Qualified qualified, ComponentContainer componentContainer) {
return new RemoteConfigComponent((Context) componentContainer.get(Context.class), (ScheduledExecutorService) componentContainer.get(qualified), (FirebaseApp) componentContainer.get(FirebaseApp.class), (FirebaseInstallationsApi) componentContainer.get(FirebaseInstallationsApi.class), ((AbtComponent) componentContainer.get(AbtComponent.class)).get("frc"), componentContainer.getProvider(AnalyticsConnector.class));
}
}

View File

@@ -0,0 +1,264 @@
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);
}
}

View File

@@ -0,0 +1,179 @@
package com.google.firebase.remoteconfig.internal;
import androidx.credentials.CredentialManager$$ExternalSyntheticLambda0;
import com.google.android.gms.tasks.OnCanceledListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.SuccessContinuation;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/* loaded from: classes3.dex */
public class ConfigCacheClient {
public Task cachedContainerTask = null;
public final Executor executor;
public final ConfigStorageClient storageClient;
public static final Map clientInstances = new HashMap();
public static final Executor DIRECT_EXECUTOR = new CredentialManager$$ExternalSyntheticLambda0();
public ConfigCacheClient(Executor executor, ConfigStorageClient configStorageClient) {
this.executor = executor;
this.storageClient = configStorageClient;
}
public ConfigContainer getBlocking() {
return getBlocking(5L);
}
public ConfigContainer getBlocking(long j) {
synchronized (this) {
try {
Task task = this.cachedContainerTask;
if (task != null && task.isSuccessful()) {
return (ConfigContainer) this.cachedContainerTask.getResult();
}
try {
return (ConfigContainer) await(get(), j, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException unused) {
return null;
}
} catch (Throwable th) {
throw th;
}
}
}
public Task put(ConfigContainer configContainer) {
return put(configContainer, true);
}
public final /* synthetic */ Void lambda$put$0(ConfigContainer configContainer) {
return this.storageClient.write(configContainer);
}
public Task put(final ConfigContainer configContainer, final boolean z) {
return Tasks.call(this.executor, new Callable() { // from class: com.google.firebase.remoteconfig.internal.ConfigCacheClient$$ExternalSyntheticLambda1
@Override // java.util.concurrent.Callable
public final Object call() {
Void lambda$put$0;
lambda$put$0 = ConfigCacheClient.this.lambda$put$0(configContainer);
return lambda$put$0;
}
}).onSuccessTask(this.executor, new SuccessContinuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigCacheClient$$ExternalSyntheticLambda2
@Override // com.google.android.gms.tasks.SuccessContinuation
public final Task then(Object obj) {
Task lambda$put$1;
lambda$put$1 = ConfigCacheClient.this.lambda$put$1(z, configContainer, (Void) obj);
return lambda$put$1;
}
});
}
public final /* synthetic */ Task lambda$put$1(boolean z, ConfigContainer configContainer, Void r3) {
if (z) {
updateInMemoryConfigContainer(configContainer);
}
return Tasks.forResult(configContainer);
}
public synchronized Task get() {
try {
Task task = this.cachedContainerTask;
if (task != null) {
if (task.isComplete() && !this.cachedContainerTask.isSuccessful()) {
}
}
Executor executor = this.executor;
final ConfigStorageClient configStorageClient = this.storageClient;
Objects.requireNonNull(configStorageClient);
this.cachedContainerTask = Tasks.call(executor, new Callable() { // from class: com.google.firebase.remoteconfig.internal.ConfigCacheClient$$ExternalSyntheticLambda0
@Override // java.util.concurrent.Callable
public final Object call() {
return ConfigStorageClient.this.read();
}
});
} catch (Throwable th) {
throw th;
}
return this.cachedContainerTask;
}
public void clear() {
synchronized (this) {
this.cachedContainerTask = Tasks.forResult(null);
}
this.storageClient.clear();
}
public final synchronized void updateInMemoryConfigContainer(ConfigContainer configContainer) {
this.cachedContainerTask = Tasks.forResult(configContainer);
}
public static synchronized ConfigCacheClient getInstance(Executor executor, ConfigStorageClient configStorageClient) {
ConfigCacheClient configCacheClient;
synchronized (ConfigCacheClient.class) {
try {
String fileName = configStorageClient.getFileName();
Map map = clientInstances;
if (!map.containsKey(fileName)) {
map.put(fileName, new ConfigCacheClient(executor, configStorageClient));
}
configCacheClient = (ConfigCacheClient) map.get(fileName);
} catch (Throwable th) {
throw th;
}
}
return configCacheClient;
}
public static Object await(Task task, long j, TimeUnit timeUnit) {
AwaitListener awaitListener = new AwaitListener();
Executor executor = DIRECT_EXECUTOR;
task.addOnSuccessListener(executor, awaitListener);
task.addOnFailureListener(executor, awaitListener);
task.addOnCanceledListener(executor, awaitListener);
if (!awaitListener.await(j, timeUnit)) {
throw new TimeoutException("Task await timed out.");
}
if (task.isSuccessful()) {
return task.getResult();
}
throw new ExecutionException(task.getException());
}
public static class AwaitListener implements OnSuccessListener, OnFailureListener, OnCanceledListener {
public final CountDownLatch latch;
public AwaitListener() {
this.latch = new CountDownLatch(1);
}
@Override // com.google.android.gms.tasks.OnSuccessListener
public void onSuccess(Object obj) {
this.latch.countDown();
}
@Override // com.google.android.gms.tasks.OnFailureListener
public void onFailure(Exception exc) {
this.latch.countDown();
}
@Override // com.google.android.gms.tasks.OnCanceledListener
public void onCanceled() {
this.latch.countDown();
}
public boolean await(long j, TimeUnit timeUnit) {
return this.latch.await(j, timeUnit);
}
}
}

View File

@@ -0,0 +1,219 @@
package com.google.firebase.remoteconfig.internal;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class ConfigContainer {
public static final Date DEFAULTS_FETCH_TIME = new Date(0);
public JSONArray abtExperiments;
public JSONObject configsJson;
public JSONObject containerJson;
public Date fetchTime;
public JSONObject personalizationMetadata;
public JSONArray rolloutMetadata;
public long templateVersionNumber;
public JSONArray getAbtExperiments() {
return this.abtExperiments;
}
public JSONObject getConfigs() {
return this.configsJson;
}
public Date getFetchTime() {
return this.fetchTime;
}
public JSONObject getPersonalizationMetadata() {
return this.personalizationMetadata;
}
public JSONArray getRolloutMetadata() {
return this.rolloutMetadata;
}
public long getTemplateVersionNumber() {
return this.templateVersionNumber;
}
public ConfigContainer(JSONObject jSONObject, Date date, JSONArray jSONArray, JSONObject jSONObject2, long j, JSONArray jSONArray2) {
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("configs_key", jSONObject);
jSONObject3.put("fetch_time_key", date.getTime());
jSONObject3.put("abt_experiments_key", jSONArray);
jSONObject3.put("personalization_metadata_key", jSONObject2);
jSONObject3.put("template_version_number_key", j);
jSONObject3.put("rollout_metadata_key", jSONArray2);
this.configsJson = jSONObject;
this.fetchTime = date;
this.abtExperiments = jSONArray;
this.personalizationMetadata = jSONObject2;
this.templateVersionNumber = j;
this.rolloutMetadata = jSONArray2;
this.containerJson = jSONObject3;
}
public static ConfigContainer copyOf(JSONObject jSONObject) {
JSONObject optJSONObject = jSONObject.optJSONObject("personalization_metadata_key");
if (optJSONObject == null) {
optJSONObject = new JSONObject();
}
JSONObject jSONObject2 = optJSONObject;
JSONArray optJSONArray = jSONObject.optJSONArray("rollout_metadata_key");
if (optJSONArray == null) {
optJSONArray = new JSONArray();
}
return new ConfigContainer(jSONObject.getJSONObject("configs_key"), new Date(jSONObject.getLong("fetch_time_key")), jSONObject.getJSONArray("abt_experiments_key"), jSONObject2, jSONObject.optLong("template_version_number_key"), optJSONArray);
}
public static ConfigContainer deepCopyOf(JSONObject jSONObject) {
return copyOf(new JSONObject(jSONObject.toString()));
}
public String toString() {
return this.containerJson.toString();
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ConfigContainer) {
return this.containerJson.toString().equals(((ConfigContainer) obj).toString());
}
return false;
}
public final Map createRolloutParameterKeyMap() {
HashMap hashMap = new HashMap();
for (int i = 0; i < getRolloutMetadata().length(); i++) {
JSONObject jSONObject = getRolloutMetadata().getJSONObject(i);
String string = jSONObject.getString("rolloutId");
String string2 = jSONObject.getString("variantId");
JSONArray jSONArray = jSONObject.getJSONArray("affectedParameterKeys");
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
String string3 = jSONArray.getString(i2);
if (!hashMap.containsKey(string3)) {
hashMap.put(string3, new HashMap());
}
Map map = (Map) hashMap.get(string3);
if (map != null) {
map.put(string, string2);
}
}
}
return hashMap;
}
public Set getChangedParams(ConfigContainer configContainer) {
JSONObject configs = deepCopyOf(configContainer.containerJson).getConfigs();
Map createRolloutParameterKeyMap = createRolloutParameterKeyMap();
Map createRolloutParameterKeyMap2 = configContainer.createRolloutParameterKeyMap();
HashSet hashSet = new HashSet();
Iterator<String> keys = getConfigs().keys();
while (keys.hasNext()) {
String next = keys.next();
if (!configContainer.getConfigs().has(next)) {
hashSet.add(next);
} else if (!getConfigs().get(next).equals(configContainer.getConfigs().get(next))) {
hashSet.add(next);
} else if ((getPersonalizationMetadata().has(next) && !configContainer.getPersonalizationMetadata().has(next)) || (!getPersonalizationMetadata().has(next) && configContainer.getPersonalizationMetadata().has(next))) {
hashSet.add(next);
} else if (getPersonalizationMetadata().has(next) && configContainer.getPersonalizationMetadata().has(next) && !getPersonalizationMetadata().getJSONObject(next).toString().equals(configContainer.getPersonalizationMetadata().getJSONObject(next).toString())) {
hashSet.add(next);
} else if (createRolloutParameterKeyMap.containsKey(next) != createRolloutParameterKeyMap2.containsKey(next)) {
hashSet.add(next);
} else if (createRolloutParameterKeyMap.containsKey(next) && createRolloutParameterKeyMap2.containsKey(next) && !((Map) createRolloutParameterKeyMap.get(next)).equals(createRolloutParameterKeyMap2.get(next))) {
hashSet.add(next);
} else {
configs.remove(next);
}
}
Iterator<String> keys2 = configs.keys();
while (keys2.hasNext()) {
hashSet.add(keys2.next());
}
return hashSet;
}
public int hashCode() {
return this.containerJson.hashCode();
}
public static class Builder {
public JSONArray builderAbtExperiments;
public JSONObject builderConfigsJson;
public Date builderFetchTime;
public JSONObject builderPersonalizationMetadata;
public JSONArray builderRolloutMetadata;
public long builderTemplateVersionNumber;
public Builder withFetchTime(Date date) {
this.builderFetchTime = date;
return this;
}
public Builder withTemplateVersionNumber(long j) {
this.builderTemplateVersionNumber = j;
return this;
}
public Builder() {
this.builderConfigsJson = new JSONObject();
this.builderFetchTime = ConfigContainer.DEFAULTS_FETCH_TIME;
this.builderAbtExperiments = new JSONArray();
this.builderPersonalizationMetadata = new JSONObject();
this.builderTemplateVersionNumber = 0L;
this.builderRolloutMetadata = new JSONArray();
}
public Builder replaceConfigsWith(JSONObject jSONObject) {
try {
this.builderConfigsJson = new JSONObject(jSONObject.toString());
} catch (JSONException unused) {
}
return this;
}
public Builder withAbtExperiments(JSONArray jSONArray) {
try {
this.builderAbtExperiments = new JSONArray(jSONArray.toString());
} catch (JSONException unused) {
}
return this;
}
public Builder withPersonalizationMetadata(JSONObject jSONObject) {
try {
this.builderPersonalizationMetadata = new JSONObject(jSONObject.toString());
} catch (JSONException unused) {
}
return this;
}
public Builder withRolloutMetadata(JSONArray jSONArray) {
try {
this.builderRolloutMetadata = new JSONArray(jSONArray.toString());
} catch (JSONException unused) {
}
return this;
}
public ConfigContainer build() {
return new ConfigContainer(this.builderConfigsJson, this.builderFetchTime, this.builderAbtExperiments, this.builderPersonalizationMetadata, this.builderTemplateVersionNumber, this.builderRolloutMetadata);
}
}
public static Builder newBuilder() {
return new Builder();
}
}

View File

@@ -0,0 +1,344 @@
package com.google.firebase.remoteconfig.internal;
import android.text.format.DateUtils;
import com.google.android.gms.common.util.Clock;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.SuccessContinuation;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.analytics.connector.AnalyticsConnector;
import com.google.firebase.inject.Provider;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.installations.InstallationTokenResult;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigException;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchThrottledException;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException;
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
import com.google.firebase.remoteconfig.internal.ConfigMetadataClient;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import org.apache.http.HttpStatus;
/* loaded from: classes3.dex */
public class ConfigFetchHandler {
public final Provider analyticsConnector;
public final Clock clock;
public final Map customHttpHeaders;
public final Executor executor;
public final ConfigCacheClient fetchedConfigsCache;
public final FirebaseInstallationsApi firebaseInstallations;
public final ConfigFetchHttpClient frcBackendApiClient;
public final ConfigMetadataClient frcMetadata;
public final Random randomGenerator;
public static final long DEFAULT_MINIMUM_FETCH_INTERVAL_IN_SECONDS = TimeUnit.HOURS.toSeconds(12);
public static final int[] BACKOFF_TIME_DURATIONS_IN_MINUTES = {2, 4, 8, 16, 32, 64, 128, 256};
public final boolean isThrottleableServerError(int i) {
return i == 429 || i == 502 || i == 503 || i == 504;
}
public ConfigFetchHandler(FirebaseInstallationsApi firebaseInstallationsApi, Provider provider, Executor executor, Clock clock, Random random, ConfigCacheClient configCacheClient, ConfigFetchHttpClient configFetchHttpClient, ConfigMetadataClient configMetadataClient, Map map) {
this.firebaseInstallations = firebaseInstallationsApi;
this.analyticsConnector = provider;
this.executor = executor;
this.clock = clock;
this.randomGenerator = random;
this.fetchedConfigsCache = configCacheClient;
this.frcBackendApiClient = configFetchHttpClient;
this.frcMetadata = configMetadataClient;
this.customHttpHeaders = map;
}
public Task fetch() {
return fetch(this.frcMetadata.getMinimumFetchIntervalInSeconds());
}
public Task fetch(final long j) {
final HashMap hashMap = new HashMap(this.customHttpHeaders);
hashMap.put("X-Firebase-RC-Fetch-Type", FetchType.BASE.getValue() + "/1");
return this.fetchedConfigsCache.get().continueWithTask(this.executor, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$ExternalSyntheticLambda0
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task) {
Task lambda$fetch$0;
lambda$fetch$0 = ConfigFetchHandler.this.lambda$fetch$0(j, hashMap, task);
return lambda$fetch$0;
}
});
}
public Task fetchNowWithTypeAndAttemptNumber(FetchType fetchType, int i) {
final HashMap hashMap = new HashMap(this.customHttpHeaders);
hashMap.put("X-Firebase-RC-Fetch-Type", fetchType.getValue() + "/" + i);
return this.fetchedConfigsCache.get().continueWithTask(this.executor, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$ExternalSyntheticLambda3
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task) {
Task lambda$fetchNowWithTypeAndAttemptNumber$1;
lambda$fetchNowWithTypeAndAttemptNumber$1 = ConfigFetchHandler.this.lambda$fetchNowWithTypeAndAttemptNumber$1(hashMap, task);
return lambda$fetchNowWithTypeAndAttemptNumber$1;
}
});
}
public final /* synthetic */ Task lambda$fetchNowWithTypeAndAttemptNumber$1(Map map, Task task) {
return lambda$fetch$0(task, 0L, map);
}
/* renamed from: fetchIfCacheExpiredAndNotThrottled, reason: merged with bridge method [inline-methods] */
public final Task lambda$fetch$0(Task task, long j, final Map map) {
Task continueWithTask;
final Date date = new Date(this.clock.currentTimeMillis());
if (task.isSuccessful() && areCachedFetchConfigsValid(j, date)) {
return Tasks.forResult(FetchResponse.forLocalStorageUsed(date));
}
Date backoffEndTimeInMillis = getBackoffEndTimeInMillis(date);
if (backoffEndTimeInMillis != null) {
continueWithTask = Tasks.forException(new FirebaseRemoteConfigFetchThrottledException(createThrottledMessage(backoffEndTimeInMillis.getTime() - date.getTime()), backoffEndTimeInMillis.getTime()));
} else {
final Task id = this.firebaseInstallations.getId();
final Task token = this.firebaseInstallations.getToken(false);
continueWithTask = Tasks.whenAllComplete((Task<?>[]) new Task[]{id, token}).continueWithTask(this.executor, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$ExternalSyntheticLambda1
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task2) {
Task lambda$fetchIfCacheExpiredAndNotThrottled$2;
lambda$fetchIfCacheExpiredAndNotThrottled$2 = ConfigFetchHandler.this.lambda$fetchIfCacheExpiredAndNotThrottled$2(id, token, date, map, task2);
return lambda$fetchIfCacheExpiredAndNotThrottled$2;
}
});
}
return continueWithTask.continueWithTask(this.executor, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$ExternalSyntheticLambda2
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task2) {
Task lambda$fetchIfCacheExpiredAndNotThrottled$3;
lambda$fetchIfCacheExpiredAndNotThrottled$3 = ConfigFetchHandler.this.lambda$fetchIfCacheExpiredAndNotThrottled$3(date, task2);
return lambda$fetchIfCacheExpiredAndNotThrottled$3;
}
});
}
public final /* synthetic */ Task lambda$fetchIfCacheExpiredAndNotThrottled$2(Task task, Task task2, Date date, Map map, Task task3) {
if (!task.isSuccessful()) {
return Tasks.forException(new FirebaseRemoteConfigClientException("Firebase Installations failed to get installation ID for fetch.", task.getException()));
}
if (!task2.isSuccessful()) {
return Tasks.forException(new FirebaseRemoteConfigClientException("Firebase Installations failed to get installation auth token for fetch.", task2.getException()));
}
return fetchFromBackendAndCacheResponse((String) task.getResult(), ((InstallationTokenResult) task2.getResult()).getToken(), date, map);
}
public final /* synthetic */ Task lambda$fetchIfCacheExpiredAndNotThrottled$3(Date date, Task task) {
updateLastFetchStatusAndTime(task, date);
return task;
}
public final boolean areCachedFetchConfigsValid(long j, Date date) {
Date lastSuccessfulFetchTime = this.frcMetadata.getLastSuccessfulFetchTime();
if (lastSuccessfulFetchTime.equals(ConfigMetadataClient.LAST_FETCH_TIME_NO_FETCH_YET)) {
return false;
}
return date.before(new Date(lastSuccessfulFetchTime.getTime() + TimeUnit.SECONDS.toMillis(j)));
}
public final Date getBackoffEndTimeInMillis(Date date) {
Date backoffEndTime = this.frcMetadata.getBackoffMetadata().getBackoffEndTime();
if (date.before(backoffEndTime)) {
return backoffEndTime;
}
return null;
}
public final String createThrottledMessage(long j) {
return String.format("Fetch is throttled. Please wait before calling fetch again: %s", DateUtils.formatElapsedTime(TimeUnit.MILLISECONDS.toSeconds(j)));
}
public final Task fetchFromBackendAndCacheResponse(String str, String str2, Date date, Map map) {
try {
final FetchResponse fetchFromBackend = fetchFromBackend(str, str2, date, map);
if (fetchFromBackend.getStatus() != 0) {
return Tasks.forResult(fetchFromBackend);
}
return this.fetchedConfigsCache.put(fetchFromBackend.getFetchedConfigs()).onSuccessTask(this.executor, new SuccessContinuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$ExternalSyntheticLambda4
@Override // com.google.android.gms.tasks.SuccessContinuation
public final Task then(Object obj) {
Task lambda$fetchFromBackendAndCacheResponse$4;
lambda$fetchFromBackendAndCacheResponse$4 = ConfigFetchHandler.lambda$fetchFromBackendAndCacheResponse$4(ConfigFetchHandler.FetchResponse.this, (ConfigContainer) obj);
return lambda$fetchFromBackendAndCacheResponse$4;
}
});
} catch (FirebaseRemoteConfigException e) {
return Tasks.forException(e);
}
}
public static /* synthetic */ Task lambda$fetchFromBackendAndCacheResponse$4(FetchResponse fetchResponse, ConfigContainer configContainer) {
return Tasks.forResult(fetchResponse);
}
public final FetchResponse fetchFromBackend(String str, String str2, Date date, Map map) {
try {
FetchResponse fetch = this.frcBackendApiClient.fetch(this.frcBackendApiClient.createHttpURLConnection(), str, str2, getUserProperties(), this.frcMetadata.getLastFetchETag(), map, getFirstOpenTime(), date);
if (fetch.getFetchedConfigs() != null) {
this.frcMetadata.setLastTemplateVersion(fetch.getFetchedConfigs().getTemplateVersionNumber());
}
if (fetch.getLastFetchETag() != null) {
this.frcMetadata.setLastFetchETag(fetch.getLastFetchETag());
}
this.frcMetadata.resetBackoff();
return fetch;
} catch (FirebaseRemoteConfigServerException e) {
ConfigMetadataClient.BackoffMetadata updateAndReturnBackoffMetadata = updateAndReturnBackoffMetadata(e.getHttpStatusCode(), date);
if (shouldThrottle(updateAndReturnBackoffMetadata, e.getHttpStatusCode())) {
throw new FirebaseRemoteConfigFetchThrottledException(updateAndReturnBackoffMetadata.getBackoffEndTime().getTime());
}
throw createExceptionWithGenericMessage(e);
}
}
public final FirebaseRemoteConfigServerException createExceptionWithGenericMessage(FirebaseRemoteConfigServerException firebaseRemoteConfigServerException) {
String str;
int httpStatusCode = firebaseRemoteConfigServerException.getHttpStatusCode();
if (httpStatusCode == 401) {
str = "The request did not have the required credentials. Please make sure your google-services.json is valid.";
} else if (httpStatusCode == 403) {
str = "The user is not authorized to access the project. Please make sure you are using the API key that corresponds to your Firebase project.";
} else {
if (httpStatusCode == 429) {
throw new FirebaseRemoteConfigClientException("The throttled response from the server was not handled correctly by the FRC SDK.");
}
if (httpStatusCode != 500) {
switch (httpStatusCode) {
case 502:
case HttpStatus.SC_SERVICE_UNAVAILABLE /* 503 */:
case HttpStatus.SC_GATEWAY_TIMEOUT /* 504 */:
str = "The server is unavailable. Please try again later.";
break;
default:
str = "The server returned an unexpected error.";
break;
}
} else {
str = "There was an internal server error.";
}
}
return new FirebaseRemoteConfigServerException(firebaseRemoteConfigServerException.getHttpStatusCode(), "Fetch failed: " + str, firebaseRemoteConfigServerException);
}
public final ConfigMetadataClient.BackoffMetadata updateAndReturnBackoffMetadata(int i, Date date) {
if (isThrottleableServerError(i)) {
updateBackoffMetadataWithLastFailedFetchTime(date);
}
return this.frcMetadata.getBackoffMetadata();
}
public final void updateBackoffMetadataWithLastFailedFetchTime(Date date) {
int numFailedFetches = this.frcMetadata.getBackoffMetadata().getNumFailedFetches() + 1;
this.frcMetadata.setBackoffMetadata(numFailedFetches, new Date(date.getTime() + getRandomizedBackoffDurationInMillis(numFailedFetches)));
}
public final long getRandomizedBackoffDurationInMillis(int i) {
TimeUnit timeUnit = TimeUnit.MINUTES;
int[] iArr = BACKOFF_TIME_DURATIONS_IN_MINUTES;
return (timeUnit.toMillis(iArr[Math.min(i, iArr.length) - 1]) / 2) + this.randomGenerator.nextInt((int) r0);
}
public final boolean shouldThrottle(ConfigMetadataClient.BackoffMetadata backoffMetadata, int i) {
return backoffMetadata.getNumFailedFetches() > 1 || i == 429;
}
public final void updateLastFetchStatusAndTime(Task task, Date date) {
if (task.isSuccessful()) {
this.frcMetadata.updateLastFetchAsSuccessfulAt(date);
return;
}
Exception exception = task.getException();
if (exception == null) {
return;
}
if (exception instanceof FirebaseRemoteConfigFetchThrottledException) {
this.frcMetadata.updateLastFetchAsThrottled();
} else {
this.frcMetadata.updateLastFetchAsFailed();
}
}
public final Map getUserProperties() {
HashMap hashMap = new HashMap();
AnalyticsConnector analyticsConnector = (AnalyticsConnector) this.analyticsConnector.get();
if (analyticsConnector == null) {
return hashMap;
}
for (Map.Entry entry : analyticsConnector.getUserProperties(false).entrySet()) {
hashMap.put((String) entry.getKey(), entry.getValue().toString());
}
return hashMap;
}
public final Long getFirstOpenTime() {
AnalyticsConnector analyticsConnector = (AnalyticsConnector) this.analyticsConnector.get();
if (analyticsConnector == null) {
return null;
}
return (Long) analyticsConnector.getUserProperties(true).get("_fot");
}
public long getTemplateVersionNumber() {
return this.frcMetadata.getLastTemplateVersion();
}
public static class FetchResponse {
public final Date fetchTime;
public final ConfigContainer fetchedConfigs;
public final String lastFetchETag;
public final int status;
public ConfigContainer getFetchedConfigs() {
return this.fetchedConfigs;
}
public String getLastFetchETag() {
return this.lastFetchETag;
}
public int getStatus() {
return this.status;
}
public FetchResponse(Date date, int i, ConfigContainer configContainer, String str) {
this.fetchTime = date;
this.status = i;
this.fetchedConfigs = configContainer;
this.lastFetchETag = str;
}
public static FetchResponse forBackendUpdatesFetched(ConfigContainer configContainer, String str) {
return new FetchResponse(configContainer.getFetchTime(), 0, configContainer, str);
}
public static FetchResponse forBackendHasNoUpdates(Date date, ConfigContainer configContainer) {
return new FetchResponse(date, 1, configContainer, null);
}
public static FetchResponse forLocalStorageUsed(Date date) {
return new FetchResponse(date, 2, null, null);
}
}
public enum FetchType {
BASE("BASE"),
REALTIME("REALTIME");
private final String value;
public String getValue() {
return this.value;
}
FetchType(String str) {
this.value = str;
}
}
}

View File

@@ -0,0 +1,271 @@
package com.google.firebase.remoteconfig.internal;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import androidx.annotation.Keep;
import androidx.core.content.pm.PackageInfoCompat;
import com.ea.nimble.ApplicationEnvironment;
import com.google.android.gms.common.util.AndroidUtilsLight;
import com.google.android.gms.common.util.Hex;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigException;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
import com.ironsource.nb;
import com.ironsource.v8;
import com.mbridge.msdk.foundation.download.Command;
import com.unity3d.ads.core.domain.HandleInvocationsFromAdViewer;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class ConfigFetchHttpClient {
public static final Pattern GMP_APP_ID_PATTERN = Pattern.compile("^[^:]+:([0-9]+):(android|ios|web):([0-9a-f]+)");
public final String apiKey;
public final String appId;
public final long connectTimeoutInSeconds;
public final Context context;
public final String namespace;
public final String projectNumber;
public final long readTimeoutInSeconds;
public ConfigFetchHttpClient(Context context, String str, String str2, String str3, long j, long j2) {
this.context = context;
this.appId = str;
this.apiKey = str2;
this.projectNumber = extractProjectNumberFromAppId(str);
this.namespace = str3;
this.connectTimeoutInSeconds = j;
this.readTimeoutInSeconds = j2;
}
public static String extractProjectNumberFromAppId(String str) {
Matcher matcher = GMP_APP_ID_PATTERN.matcher(str);
if (matcher.matches()) {
return matcher.group(1);
}
return null;
}
public HttpURLConnection createHttpURLConnection() {
try {
return (HttpURLConnection) new URL(getFetchUrl(this.projectNumber, this.namespace)).openConnection();
} catch (IOException e) {
throw new FirebaseRemoteConfigException(e.getMessage());
}
}
@Keep
public ConfigFetchHandler.FetchResponse fetch(HttpURLConnection httpURLConnection, String str, String str2, Map<String, String> map, String str3, Map<String, String> map2, Long l, Date date) throws FirebaseRemoteConfigException {
setUpUrlConnection(httpURLConnection, str3, str2, map2);
try {
try {
setFetchRequestBody(httpURLConnection, createFetchRequestBody(str, str2, map, l).toString().getBytes(nb.N));
httpURLConnection.connect();
int responseCode = httpURLConnection.getResponseCode();
if (responseCode != 200) {
throw new FirebaseRemoteConfigServerException(responseCode, httpURLConnection.getResponseMessage());
}
String headerField = httpURLConnection.getHeaderField(Command.HTTP_HEADER_ETAG);
JSONObject fetchResponseBody = getFetchResponseBody(httpURLConnection);
try {
httpURLConnection.getInputStream().close();
} catch (IOException unused) {
}
ConfigContainer extractConfigs = extractConfigs(fetchResponseBody, date);
if (!backendHasUpdates(fetchResponseBody)) {
return ConfigFetchHandler.FetchResponse.forBackendHasNoUpdates(date, extractConfigs);
}
return ConfigFetchHandler.FetchResponse.forBackendUpdatesFetched(extractConfigs, headerField);
} finally {
httpURLConnection.disconnect();
try {
httpURLConnection.getInputStream().close();
} catch (IOException unused2) {
}
}
} catch (IOException | JSONException e) {
throw new FirebaseRemoteConfigClientException("The client had an error while calling the backend!", e);
}
}
public final void setUpUrlConnection(HttpURLConnection httpURLConnection, String str, String str2, Map map) {
httpURLConnection.setDoOutput(true);
TimeUnit timeUnit = TimeUnit.SECONDS;
httpURLConnection.setConnectTimeout((int) timeUnit.toMillis(this.connectTimeoutInSeconds));
httpURLConnection.setReadTimeout((int) timeUnit.toMillis(this.readTimeoutInSeconds));
httpURLConnection.setRequestProperty("If-None-Match", str);
setCommonRequestHeaders(httpURLConnection, str2);
setCustomRequestHeaders(httpURLConnection, map);
}
public final String getFetchUrl(String str, String str2) {
return String.format("https://firebaseremoteconfig.googleapis.com/v1/projects/%s/namespaces/%s:fetch", str, str2);
}
public final void setCommonRequestHeaders(HttpURLConnection httpURLConnection, String str) {
httpURLConnection.setRequestProperty("X-Goog-Api-Key", this.apiKey);
httpURLConnection.setRequestProperty("X-Android-Package", this.context.getPackageName());
httpURLConnection.setRequestProperty("X-Android-Cert", getFingerprintHashForPackage());
httpURLConnection.setRequestProperty("X-Google-GFE-Can-Retry", "yes");
httpURLConnection.setRequestProperty("X-Goog-Firebase-Installations-Auth", str);
httpURLConnection.setRequestProperty("Content-Type", nb.L);
httpURLConnection.setRequestProperty("Accept", nb.L);
}
public final void setCustomRequestHeaders(HttpURLConnection httpURLConnection, Map map) {
for (Map.Entry entry : map.entrySet()) {
httpURLConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
}
}
public final String getFingerprintHashForPackage() {
try {
Context context = this.context;
byte[] packageCertificateHashBytes = AndroidUtilsLight.getPackageCertificateHashBytes(context, context.getPackageName());
if (packageCertificateHashBytes == null) {
Log.e("FirebaseRemoteConfig", "Could not get fingerprint hash for package: " + this.context.getPackageName());
return null;
}
return Hex.bytesToStringUppercase(packageCertificateHashBytes, false);
} catch (PackageManager.NameNotFoundException e) {
Log.e("FirebaseRemoteConfig", "No such package: " + this.context.getPackageName(), e);
return null;
}
}
public final JSONObject createFetchRequestBody(String str, String str2, Map map, Long l) {
HashMap hashMap = new HashMap();
if (str == null) {
throw new FirebaseRemoteConfigClientException("Fetch failed: Firebase installation id is null.");
}
hashMap.put("appInstanceId", str);
hashMap.put("appInstanceIdToken", str2);
hashMap.put("appId", this.appId);
Locale locale = this.context.getResources().getConfiguration().locale;
hashMap.put(ApplicationEnvironment.NIMBLE_PARAMETER_COUNTRY_CODE, locale.getCountry());
int i = Build.VERSION.SDK_INT;
hashMap.put("languageCode", locale.toLanguageTag());
hashMap.put("platformVersion", Integer.toString(i));
hashMap.put("timeZone", TimeZone.getDefault().getID());
try {
PackageInfo packageInfo = this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0);
if (packageInfo != null) {
hashMap.put(v8.i.W, packageInfo.versionName);
hashMap.put("appBuild", Long.toString(PackageInfoCompat.getLongVersionCode(packageInfo)));
}
} catch (PackageManager.NameNotFoundException unused) {
}
hashMap.put(HandleInvocationsFromAdViewer.KEY_PACKAGE_NAME, this.context.getPackageName());
hashMap.put("sdkVersion", "22.0.0");
hashMap.put("analyticsUserProperties", new JSONObject(map));
if (l != null) {
hashMap.put("firstOpenTime", convertToISOString(l.longValue()));
}
return new JSONObject(hashMap);
}
public final String convertToISOString(long j) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return simpleDateFormat.format(Long.valueOf(j));
}
public final void setFetchRequestBody(HttpURLConnection httpURLConnection, byte[] bArr) {
httpURLConnection.setFixedLengthStreamingMode(bArr.length);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(httpURLConnection.getOutputStream());
bufferedOutputStream.write(bArr);
bufferedOutputStream.flush();
bufferedOutputStream.close();
}
public final JSONObject getFetchResponseBody(URLConnection uRLConnection) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(uRLConnection.getInputStream(), nb.N));
StringBuilder sb = new StringBuilder();
while (true) {
int read = bufferedReader.read();
if (read != -1) {
sb.append((char) read);
} else {
return new JSONObject(sb.toString());
}
}
}
public final boolean backendHasUpdates(JSONObject jSONObject) {
try {
return !jSONObject.get("state").equals("NO_CHANGE");
} catch (JSONException unused) {
return true;
}
}
public static ConfigContainer extractConfigs(JSONObject jSONObject, Date date) {
JSONObject jSONObject2;
JSONArray jSONArray;
JSONObject jSONObject3;
try {
ConfigContainer.Builder withFetchTime = ConfigContainer.newBuilder().withFetchTime(date);
JSONArray jSONArray2 = null;
try {
jSONObject2 = jSONObject.getJSONObject("entries");
} catch (JSONException unused) {
jSONObject2 = null;
}
if (jSONObject2 != null) {
withFetchTime = withFetchTime.replaceConfigsWith(jSONObject2);
}
try {
jSONArray = jSONObject.getJSONArray("experimentDescriptions");
} catch (JSONException unused2) {
jSONArray = null;
}
if (jSONArray != null) {
withFetchTime = withFetchTime.withAbtExperiments(jSONArray);
}
try {
jSONObject3 = jSONObject.getJSONObject("personalizationMetadata");
} catch (JSONException unused3) {
jSONObject3 = null;
}
if (jSONObject3 != null) {
withFetchTime = withFetchTime.withPersonalizationMetadata(jSONObject3);
}
String string = jSONObject.has("templateVersion") ? jSONObject.getString("templateVersion") : null;
if (string != null) {
withFetchTime.withTemplateVersionNumber(Long.parseLong(string));
}
try {
jSONArray2 = jSONObject.getJSONArray("rolloutMetadata");
} catch (JSONException unused4) {
}
if (jSONArray2 != null) {
withFetchTime = withFetchTime.withRolloutMetadata(jSONArray2);
}
return withFetchTime.build();
} catch (JSONException e) {
throw new FirebaseRemoteConfigClientException("Fetch failed: fetch response could not be parsed.", e);
}
}
}

View File

@@ -0,0 +1,180 @@
package com.google.firebase.remoteconfig.internal;
import android.util.Log;
import com.google.android.gms.common.util.BiConsumer;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import org.json.JSONException;
/* loaded from: classes3.dex */
public class ConfigGetParameterHandler {
public final ConfigCacheClient activatedConfigsCache;
public final ConfigCacheClient defaultConfigsCache;
public final Executor executor;
public final Set listeners = new HashSet();
public static final Charset FRC_BYTE_ARRAY_ENCODING = Charset.forName("UTF-8");
public static final Pattern TRUE_REGEX = Pattern.compile("^(1|true|t|yes|y|on)$", 2);
public static final Pattern FALSE_REGEX = Pattern.compile("^(0|false|f|no|n|off|)$", 2);
public ConfigGetParameterHandler(Executor executor, ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2) {
this.executor = executor;
this.activatedConfigsCache = configCacheClient;
this.defaultConfigsCache = configCacheClient2;
}
public String getString(String str) {
String stringFromCache = getStringFromCache(this.activatedConfigsCache, str);
if (stringFromCache != null) {
callListeners(str, getConfigsFromCache(this.activatedConfigsCache));
return stringFromCache;
}
String stringFromCache2 = getStringFromCache(this.defaultConfigsCache, str);
if (stringFromCache2 != null) {
return stringFromCache2;
}
logParameterValueDoesNotExist(str, "String");
return "";
}
public boolean getBoolean(String str) {
String stringFromCache = getStringFromCache(this.activatedConfigsCache, str);
if (stringFromCache != null) {
if (TRUE_REGEX.matcher(stringFromCache).matches()) {
callListeners(str, getConfigsFromCache(this.activatedConfigsCache));
return true;
}
if (FALSE_REGEX.matcher(stringFromCache).matches()) {
callListeners(str, getConfigsFromCache(this.activatedConfigsCache));
return false;
}
}
String stringFromCache2 = getStringFromCache(this.defaultConfigsCache, str);
if (stringFromCache2 != null) {
if (TRUE_REGEX.matcher(stringFromCache2).matches()) {
return true;
}
if (FALSE_REGEX.matcher(stringFromCache2).matches()) {
return false;
}
}
logParameterValueDoesNotExist(str, "Boolean");
return false;
}
public double getDouble(String str) {
Double doubleFromCache = getDoubleFromCache(this.activatedConfigsCache, str);
if (doubleFromCache != null) {
callListeners(str, getConfigsFromCache(this.activatedConfigsCache));
return doubleFromCache.doubleValue();
}
Double doubleFromCache2 = getDoubleFromCache(this.defaultConfigsCache, str);
if (doubleFromCache2 != null) {
return doubleFromCache2.doubleValue();
}
logParameterValueDoesNotExist(str, "Double");
return 0.0d;
}
public FirebaseRemoteConfigValue getValue(String str) {
String stringFromCache = getStringFromCache(this.activatedConfigsCache, str);
if (stringFromCache != null) {
callListeners(str, getConfigsFromCache(this.activatedConfigsCache));
return new FirebaseRemoteConfigValueImpl(stringFromCache, 2);
}
String stringFromCache2 = getStringFromCache(this.defaultConfigsCache, str);
if (stringFromCache2 != null) {
return new FirebaseRemoteConfigValueImpl(stringFromCache2, 1);
}
logParameterValueDoesNotExist(str, "FirebaseRemoteConfigValue");
return new FirebaseRemoteConfigValueImpl("", 0);
}
public Map getAll() {
HashSet<String> hashSet = new HashSet();
hashSet.addAll(getKeySetFromCache(this.activatedConfigsCache));
hashSet.addAll(getKeySetFromCache(this.defaultConfigsCache));
HashMap hashMap = new HashMap();
for (String str : hashSet) {
hashMap.put(str, getValue(str));
}
return hashMap;
}
public void addListener(BiConsumer biConsumer) {
synchronized (this.listeners) {
this.listeners.add(biConsumer);
}
}
public final void callListeners(final String str, final ConfigContainer configContainer) {
if (configContainer == null) {
return;
}
synchronized (this.listeners) {
try {
for (final BiConsumer biConsumer : this.listeners) {
this.executor.execute(new Runnable() { // from class: com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
BiConsumer.this.accept(str, configContainer);
}
});
}
} catch (Throwable th) {
throw th;
}
}
}
public static String getStringFromCache(ConfigCacheClient configCacheClient, String str) {
ConfigContainer configsFromCache = getConfigsFromCache(configCacheClient);
if (configsFromCache == null) {
return null;
}
try {
return configsFromCache.getConfigs().getString(str);
} catch (JSONException unused) {
return null;
}
}
public static Double getDoubleFromCache(ConfigCacheClient configCacheClient, String str) {
ConfigContainer configsFromCache = getConfigsFromCache(configCacheClient);
if (configsFromCache == null) {
return null;
}
try {
return Double.valueOf(configsFromCache.getConfigs().getDouble(str));
} catch (JSONException unused) {
return null;
}
}
public static Set getKeySetFromCache(ConfigCacheClient configCacheClient) {
HashSet hashSet = new HashSet();
ConfigContainer configsFromCache = getConfigsFromCache(configCacheClient);
if (configsFromCache == null) {
return hashSet;
}
Iterator<String> keys = configsFromCache.getConfigs().keys();
while (keys.hasNext()) {
hashSet.add(keys.next());
}
return hashSet;
}
public static ConfigContainer getConfigsFromCache(ConfigCacheClient configCacheClient) {
return configCacheClient.getBlocking();
}
public static void logParameterValueDoesNotExist(String str, String str2) {
Log.w("FirebaseRemoteConfig", String.format("No value of type '%s' exists for parameter key '%s'.", str2, str));
}
}

View File

@@ -0,0 +1,158 @@
package com.google.firebase.remoteconfig.internal;
import android.content.SharedPreferences;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
import java.util.Date;
/* loaded from: classes3.dex */
public class ConfigMetadataClient {
public static final Date LAST_FETCH_TIME_NO_FETCH_YET = new Date(-1);
public static final Date NO_BACKOFF_TIME = new Date(-1);
public final SharedPreferences frcMetadata;
public final Object frcInfoLock = new Object();
public final Object backoffMetadataLock = new Object();
public final Object realtimeBackoffMetadataLock = new Object();
public ConfigMetadataClient(SharedPreferences sharedPreferences) {
this.frcMetadata = sharedPreferences;
}
public long getFetchTimeoutInSeconds() {
return this.frcMetadata.getLong("fetch_timeout_in_seconds", 60L);
}
public long getMinimumFetchIntervalInSeconds() {
return this.frcMetadata.getLong("minimum_fetch_interval_in_seconds", ConfigFetchHandler.DEFAULT_MINIMUM_FETCH_INTERVAL_IN_SECONDS);
}
public Date getLastSuccessfulFetchTime() {
return new Date(this.frcMetadata.getLong("last_fetch_time_in_millis", -1L));
}
public String getLastFetchETag() {
return this.frcMetadata.getString("last_fetch_etag", null);
}
public long getLastTemplateVersion() {
return this.frcMetadata.getLong("last_template_version", 0L);
}
public FirebaseRemoteConfigInfo getInfo() {
FirebaseRemoteConfigInfoImpl build;
synchronized (this.frcInfoLock) {
long j = this.frcMetadata.getLong("last_fetch_time_in_millis", -1L);
int i = this.frcMetadata.getInt("last_fetch_status", 0);
build = FirebaseRemoteConfigInfoImpl.newBuilder().withLastFetchStatus(i).withLastSuccessfulFetchTimeInMillis(j).withConfigSettings(new FirebaseRemoteConfigSettings.Builder().setFetchTimeoutInSeconds(this.frcMetadata.getLong("fetch_timeout_in_seconds", 60L)).setMinimumFetchIntervalInSeconds(this.frcMetadata.getLong("minimum_fetch_interval_in_seconds", ConfigFetchHandler.DEFAULT_MINIMUM_FETCH_INTERVAL_IN_SECONDS)).build()).build();
}
return build;
}
public void setConfigSettings(FirebaseRemoteConfigSettings firebaseRemoteConfigSettings) {
synchronized (this.frcInfoLock) {
this.frcMetadata.edit().putLong("fetch_timeout_in_seconds", firebaseRemoteConfigSettings.getFetchTimeoutInSeconds()).putLong("minimum_fetch_interval_in_seconds", firebaseRemoteConfigSettings.getMinimumFetchIntervalInSeconds()).commit();
}
}
public void updateLastFetchAsSuccessfulAt(Date date) {
synchronized (this.frcInfoLock) {
this.frcMetadata.edit().putInt("last_fetch_status", -1).putLong("last_fetch_time_in_millis", date.getTime()).apply();
}
}
public void updateLastFetchAsFailed() {
synchronized (this.frcInfoLock) {
this.frcMetadata.edit().putInt("last_fetch_status", 1).apply();
}
}
public void updateLastFetchAsThrottled() {
synchronized (this.frcInfoLock) {
this.frcMetadata.edit().putInt("last_fetch_status", 2).apply();
}
}
public void setLastFetchETag(String str) {
synchronized (this.frcInfoLock) {
this.frcMetadata.edit().putString("last_fetch_etag", str).apply();
}
}
public void setLastTemplateVersion(long j) {
synchronized (this.frcInfoLock) {
this.frcMetadata.edit().putLong("last_template_version", j).apply();
}
}
public BackoffMetadata getBackoffMetadata() {
BackoffMetadata backoffMetadata;
synchronized (this.backoffMetadataLock) {
backoffMetadata = new BackoffMetadata(this.frcMetadata.getInt("num_failed_fetches", 0), new Date(this.frcMetadata.getLong("backoff_end_time_in_millis", -1L)));
}
return backoffMetadata;
}
public void setBackoffMetadata(int i, Date date) {
synchronized (this.backoffMetadataLock) {
this.frcMetadata.edit().putInt("num_failed_fetches", i).putLong("backoff_end_time_in_millis", date.getTime()).apply();
}
}
public void resetBackoff() {
setBackoffMetadata(0, NO_BACKOFF_TIME);
}
public static class BackoffMetadata {
public Date backoffEndTime;
public int numFailedFetches;
public Date getBackoffEndTime() {
return this.backoffEndTime;
}
public int getNumFailedFetches() {
return this.numFailedFetches;
}
public BackoffMetadata(int i, Date date) {
this.numFailedFetches = i;
this.backoffEndTime = date;
}
}
public RealtimeBackoffMetadata getRealtimeBackoffMetadata() {
RealtimeBackoffMetadata realtimeBackoffMetadata;
synchronized (this.realtimeBackoffMetadataLock) {
realtimeBackoffMetadata = new RealtimeBackoffMetadata(this.frcMetadata.getInt("num_failed_realtime_streams", 0), new Date(this.frcMetadata.getLong("realtime_backoff_end_time_in_millis", -1L)));
}
return realtimeBackoffMetadata;
}
public void setRealtimeBackoffMetadata(int i, Date date) {
synchronized (this.realtimeBackoffMetadataLock) {
this.frcMetadata.edit().putInt("num_failed_realtime_streams", i).putLong("realtime_backoff_end_time_in_millis", date.getTime()).apply();
}
}
public void resetRealtimeBackoff() {
setRealtimeBackoffMetadata(0, NO_BACKOFF_TIME);
}
public static class RealtimeBackoffMetadata {
public Date backoffEndTime;
public int numFailedStreams;
public Date getBackoffEndTime() {
return this.backoffEndTime;
}
public int getNumFailedStreams() {
return this.numFailedStreams;
}
public RealtimeBackoffMetadata(int i, Date date) {
this.numFailedStreams = i;
this.backoffEndTime = date;
}
}
}

View File

@@ -0,0 +1,49 @@
package com.google.firebase.remoteconfig.internal;
import android.content.Context;
import com.google.firebase.FirebaseApp;
import com.google.firebase.installations.FirebaseInstallationsApi;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
/* loaded from: classes3.dex */
public class ConfigRealtimeHandler {
public final ConfigCacheClient activatedCacheClient;
public final ConfigFetchHandler configFetchHandler;
public final ConfigRealtimeHttpClient configRealtimeHttpClient;
public final Context context;
public final FirebaseApp firebaseApp;
public final FirebaseInstallationsApi firebaseInstallations;
public final Set listeners;
public final ConfigMetadataClient metadataClient;
public final String namespace;
public final ScheduledExecutorService scheduledExecutorService;
public ConfigRealtimeHandler(FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, ConfigFetchHandler configFetchHandler, ConfigCacheClient configCacheClient, Context context, String str, ConfigMetadataClient configMetadataClient, ScheduledExecutorService scheduledExecutorService) {
LinkedHashSet linkedHashSet = new LinkedHashSet();
this.listeners = linkedHashSet;
this.configRealtimeHttpClient = new ConfigRealtimeHttpClient(firebaseApp, firebaseInstallationsApi, configFetchHandler, configCacheClient, context, str, linkedHashSet, configMetadataClient, scheduledExecutorService);
this.firebaseApp = firebaseApp;
this.configFetchHandler = configFetchHandler;
this.firebaseInstallations = firebaseInstallationsApi;
this.activatedCacheClient = configCacheClient;
this.context = context;
this.namespace = str;
this.metadataClient = configMetadataClient;
this.scheduledExecutorService = scheduledExecutorService;
}
public final synchronized void beginRealtime() {
if (!this.listeners.isEmpty()) {
this.configRealtimeHttpClient.startHttpConnection();
}
}
public synchronized void setBackgroundState(boolean z) {
this.configRealtimeHttpClient.setRealtimeBackgroundState(z);
if (!z) {
beginRealtime();
}
}
}

View File

@@ -0,0 +1,409 @@
package com.google.firebase.remoteconfig.internal;
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import com.google.android.gms.common.util.AndroidUtilsLight;
import com.google.android.gms.common.util.Clock;
import com.google.android.gms.common.util.DefaultClock;
import com.google.android.gms.common.util.Hex;
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.FirebaseApp;
import com.google.firebase.installations.FirebaseInstallationsApi;
import com.google.firebase.installations.InstallationTokenResult;
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.ironsource.nb;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class ConfigRealtimeHttpClient {
public static final int[] BACKOFF_TIME_DURATIONS_IN_MINUTES = {2, 4, 8, 16, 32, 64, 128, 256};
public static final Pattern GMP_APP_ID_PATTERN = Pattern.compile("^[^:]+:([0-9]+):(android|ios|web):([0-9a-f]+)");
public ConfigCacheClient activatedCache;
public final ConfigFetchHandler configFetchHandler;
public final Context context;
public final FirebaseApp firebaseApp;
public final FirebaseInstallationsApi firebaseInstallations;
public int httpRetriesRemaining;
public final Set listeners;
public final ConfigMetadataClient metadataClient;
public final String namespace;
public final ScheduledExecutorService scheduledExecutorService;
public final int ORIGINAL_RETRIES = 8;
public boolean isHttpConnectionRunning = false;
public final Random random = new Random();
public final Clock clock = DefaultClock.getInstance();
public boolean isRealtimeDisabled = false;
public boolean isInBackground = false;
public final boolean isStatusCodeRetryable(int i) {
return i == 408 || i == 429 || i == 502 || i == 503 || i == 504;
}
public void setRealtimeBackgroundState(boolean z) {
this.isInBackground = z;
}
public ConfigRealtimeHttpClient(FirebaseApp firebaseApp, FirebaseInstallationsApi firebaseInstallationsApi, ConfigFetchHandler configFetchHandler, ConfigCacheClient configCacheClient, Context context, String str, Set set, ConfigMetadataClient configMetadataClient, ScheduledExecutorService scheduledExecutorService) {
this.listeners = set;
this.scheduledExecutorService = scheduledExecutorService;
this.httpRetriesRemaining = Math.max(8 - configMetadataClient.getRealtimeBackoffMetadata().getNumFailedStreams(), 1);
this.firebaseApp = firebaseApp;
this.configFetchHandler = configFetchHandler;
this.firebaseInstallations = firebaseInstallationsApi;
this.activatedCache = configCacheClient;
this.context = context;
this.namespace = str;
this.metadataClient = configMetadataClient;
}
public static String extractProjectNumberFromAppId(String str) {
Matcher matcher = GMP_APP_ID_PATTERN.matcher(str);
if (matcher.matches()) {
return matcher.group(1);
}
return null;
}
public final String getFingerprintHashForPackage() {
try {
Context context = this.context;
byte[] packageCertificateHashBytes = AndroidUtilsLight.getPackageCertificateHashBytes(context, context.getPackageName());
if (packageCertificateHashBytes == null) {
Log.e("FirebaseRemoteConfig", "Could not get fingerprint hash for package: " + this.context.getPackageName());
return null;
}
return Hex.bytesToStringUppercase(packageCertificateHashBytes, false);
} catch (PackageManager.NameNotFoundException unused) {
StringBuilder sb = new StringBuilder();
sb.append("No such package: ");
sb.append(this.context.getPackageName());
return null;
}
}
public final void setCommonRequestHeaders(HttpURLConnection httpURLConnection, String str) {
httpURLConnection.setRequestProperty("X-Goog-Firebase-Installations-Auth", str);
httpURLConnection.setRequestProperty("X-Goog-Api-Key", this.firebaseApp.getOptions().getApiKey());
httpURLConnection.setRequestProperty("X-Android-Package", this.context.getPackageName());
httpURLConnection.setRequestProperty("X-Android-Cert", getFingerprintHashForPackage());
httpURLConnection.setRequestProperty("X-Google-GFE-Can-Retry", "yes");
httpURLConnection.setRequestProperty("X-Accept-Response-Streaming", "true");
httpURLConnection.setRequestProperty("Content-Type", nb.L);
httpURLConnection.setRequestProperty("Accept", nb.L);
}
public final JSONObject createRequestBody(String str) {
HashMap hashMap = new HashMap();
hashMap.put("project", extractProjectNumberFromAppId(this.firebaseApp.getOptions().getApplicationId()));
hashMap.put("namespace", this.namespace);
hashMap.put("lastKnownVersionNumber", Long.toString(this.configFetchHandler.getTemplateVersionNumber()));
hashMap.put("appId", this.firebaseApp.getOptions().getApplicationId());
hashMap.put("sdkVersion", "22.0.0");
hashMap.put("appInstanceId", str);
return new JSONObject(hashMap);
}
public void setRequestParams(HttpURLConnection httpURLConnection, String str, String str2) {
httpURLConnection.setRequestMethod("POST");
setCommonRequestHeaders(httpURLConnection, str2);
byte[] bytes = createRequestBody(str).toString().getBytes(nb.N);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(httpURLConnection.getOutputStream());
bufferedOutputStream.write(bytes);
bufferedOutputStream.flush();
bufferedOutputStream.close();
}
public final synchronized void propagateErrors(FirebaseRemoteConfigException firebaseRemoteConfigException) {
Iterator it = this.listeners.iterator();
while (it.hasNext()) {
((ConfigUpdateListener) it.next()).onError(firebaseRemoteConfigException);
}
}
public final void updateBackoffMetadataWithLastFailedStreamConnectionTime(Date date) {
int numFailedStreams = this.metadataClient.getRealtimeBackoffMetadata().getNumFailedStreams() + 1;
this.metadataClient.setRealtimeBackoffMetadata(numFailedStreams, new Date(date.getTime() + getRandomizedBackoffDurationInMillis(numFailedStreams)));
}
public final long getRandomizedBackoffDurationInMillis(int i) {
int length = BACKOFF_TIME_DURATIONS_IN_MINUTES.length;
if (i >= length) {
i = length;
}
return (TimeUnit.MINUTES.toMillis(r0[i - 1]) / 2) + this.random.nextInt((int) r0);
}
public final synchronized void enableBackoff() {
this.isRealtimeDisabled = true;
}
public final synchronized boolean canMakeHttpStreamConnection() {
boolean z;
if (!this.listeners.isEmpty() && !this.isHttpConnectionRunning && !this.isRealtimeDisabled) {
z = this.isInBackground ? false : true;
}
return z;
}
public final String getRealtimeURL(String str) {
return String.format("https://firebaseremoteconfigrealtime.googleapis.com/v1/projects/%s/namespaces/%s:streamFetchInvalidations", extractProjectNumberFromAppId(this.firebaseApp.getOptions().getApplicationId()), str);
}
public final URL getUrl() {
try {
return new URL(getRealtimeURL(this.namespace));
} catch (MalformedURLException unused) {
Log.e("FirebaseRemoteConfig", "URL is malformed");
return null;
}
}
public Task createRealtimeConnection() {
final Task token = this.firebaseInstallations.getToken(false);
final Task id = this.firebaseInstallations.getId();
return Tasks.whenAllComplete((Task<?>[]) new Task[]{token, id}).continueWithTask(this.scheduledExecutorService, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient$$ExternalSyntheticLambda1
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task) {
Task lambda$createRealtimeConnection$0;
lambda$createRealtimeConnection$0 = ConfigRealtimeHttpClient.this.lambda$createRealtimeConnection$0(token, id, task);
return lambda$createRealtimeConnection$0;
}
});
}
public final /* synthetic */ Task lambda$createRealtimeConnection$0(Task task, Task task2, Task task3) {
if (!task.isSuccessful()) {
return Tasks.forException(new FirebaseRemoteConfigClientException("Firebase Installations failed to get installation auth token for config update listener connection.", task.getException()));
}
if (!task2.isSuccessful()) {
return Tasks.forException(new FirebaseRemoteConfigClientException("Firebase Installations failed to get installation ID for config update listener connection.", task2.getException()));
}
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) getUrl().openConnection();
setRequestParams(httpURLConnection, (String) task2.getResult(), ((InstallationTokenResult) task.getResult()).getToken());
return Tasks.forResult(httpURLConnection);
} catch (IOException e) {
return Tasks.forException(new FirebaseRemoteConfigClientException("Failed to open HTTP stream connection", e));
}
}
public void startHttpConnection() {
makeRealtimeHttpConnection(0L);
}
public synchronized void retryHttpConnectionWhenBackoffEnds() {
makeRealtimeHttpConnection(Math.max(0L, this.metadataClient.getRealtimeBackoffMetadata().getBackoffEndTime().getTime() - new Date(this.clock.currentTimeMillis()).getTime()));
}
public final synchronized void makeRealtimeHttpConnection(long j) {
try {
if (canMakeHttpStreamConnection()) {
int i = this.httpRetriesRemaining;
if (i > 0) {
this.httpRetriesRemaining = i - 1;
this.scheduledExecutorService.schedule(new Runnable() { // from class: com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient.1
@Override // java.lang.Runnable
public void run() {
ConfigRealtimeHttpClient.this.beginRealtimeHttpStream();
}
}, j, TimeUnit.MILLISECONDS);
} else if (!this.isInBackground) {
propagateErrors(new FirebaseRemoteConfigClientException("Unable to connect to the server. Check your connection and try again.", FirebaseRemoteConfigException.Code.CONFIG_UPDATE_STREAM_ERROR));
}
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized void resetRetryCount() {
this.httpRetriesRemaining = 8;
}
public final synchronized void setIsHttpConnectionRunning(boolean z) {
this.isHttpConnectionRunning = z;
}
public synchronized ConfigAutoFetch startAutoFetch(HttpURLConnection httpURLConnection) {
return new ConfigAutoFetch(httpURLConnection, this.configFetchHandler, this.activatedCache, this.listeners, new ConfigUpdateListener() { // from class: com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient.2
@Override // com.google.firebase.remoteconfig.ConfigUpdateListener
public void onUpdate(ConfigUpdate configUpdate) {
}
@Override // com.google.firebase.remoteconfig.ConfigUpdateListener
public void onError(FirebaseRemoteConfigException firebaseRemoteConfigException) {
ConfigRealtimeHttpClient.this.enableBackoff();
ConfigRealtimeHttpClient.this.propagateErrors(firebaseRemoteConfigException);
}
}, this.scheduledExecutorService);
}
public final String parseForbiddenErrorResponseMessage(InputStream inputStream) {
StringBuilder sb = new StringBuilder();
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine);
}
} catch (IOException unused) {
if (sb.length() == 0) {
return "Unable to connect to the server, access is forbidden. HTTP status code: 403";
}
}
return sb.toString();
}
public void beginRealtimeHttpStream() {
if (canMakeHttpStreamConnection()) {
if (new Date(this.clock.currentTimeMillis()).before(this.metadataClient.getRealtimeBackoffMetadata().getBackoffEndTime())) {
retryHttpConnectionWhenBackoffEnds();
} else {
final Task createRealtimeConnection = createRealtimeConnection();
Tasks.whenAllComplete((Task<?>[]) new Task[]{createRealtimeConnection}).continueWith(this.scheduledExecutorService, new Continuation() { // from class: com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient$$ExternalSyntheticLambda0
@Override // com.google.android.gms.tasks.Continuation
public final Object then(Task task) {
Task lambda$beginRealtimeHttpStream$1;
lambda$beginRealtimeHttpStream$1 = ConfigRealtimeHttpClient.this.lambda$beginRealtimeHttpStream$1(createRealtimeConnection, task);
return lambda$beginRealtimeHttpStream$1;
}
});
}
}
}
public final /* synthetic */ Task lambda$beginRealtimeHttpStream$1(Task task, Task task2) {
Integer num;
Throwable th;
HttpURLConnection httpURLConnection;
FirebaseRemoteConfigServerException firebaseRemoteConfigServerException;
boolean isStatusCodeRetryable;
boolean z = true;
try {
} catch (IOException unused) {
httpURLConnection = null;
num = null;
} catch (Throwable th2) {
num = null;
th = th2;
httpURLConnection = null;
}
if (!task.isSuccessful()) {
throw new IOException(task.getException());
}
setIsHttpConnectionRunning(true);
httpURLConnection = (HttpURLConnection) task.getResult();
try {
num = Integer.valueOf(httpURLConnection.getResponseCode());
try {
if (num.intValue() == 200) {
resetRetryCount();
this.metadataClient.resetRealtimeBackoff();
startAutoFetch(httpURLConnection).listenForNotifications();
}
closeRealtimeHttpStream(httpURLConnection);
setIsHttpConnectionRunning(false);
isStatusCodeRetryable = isStatusCodeRetryable(num.intValue());
if (isStatusCodeRetryable) {
updateBackoffMetadataWithLastFailedStreamConnectionTime(new Date(this.clock.currentTimeMillis()));
}
} catch (IOException unused2) {
closeRealtimeHttpStream(httpURLConnection);
setIsHttpConnectionRunning(false);
if (num != null && !isStatusCodeRetryable(num.intValue())) {
z = false;
}
if (z) {
updateBackoffMetadataWithLastFailedStreamConnectionTime(new Date(this.clock.currentTimeMillis()));
}
if (!z && num.intValue() != 200) {
String format = String.format("Unable to connect to the server. Try again in a few minutes. HTTP status code: %d", num);
if (num.intValue() == 403) {
format = parseForbiddenErrorResponseMessage(httpURLConnection.getErrorStream());
}
firebaseRemoteConfigServerException = new FirebaseRemoteConfigServerException(num.intValue(), format, FirebaseRemoteConfigException.Code.CONFIG_UPDATE_STREAM_ERROR);
propagateErrors(firebaseRemoteConfigServerException);
return Tasks.forResult(null);
}
retryHttpConnectionWhenBackoffEnds();
return Tasks.forResult(null);
} catch (Throwable th3) {
th = th3;
closeRealtimeHttpStream(httpURLConnection);
setIsHttpConnectionRunning(false);
if (num != null && !isStatusCodeRetryable(num.intValue())) {
z = false;
}
if (z) {
updateBackoffMetadataWithLastFailedStreamConnectionTime(new Date(this.clock.currentTimeMillis()));
}
if (z || num.intValue() == 200) {
retryHttpConnectionWhenBackoffEnds();
} else {
String format2 = String.format("Unable to connect to the server. Try again in a few minutes. HTTP status code: %d", num);
if (num.intValue() == 403) {
format2 = parseForbiddenErrorResponseMessage(httpURLConnection.getErrorStream());
}
propagateErrors(new FirebaseRemoteConfigServerException(num.intValue(), format2, FirebaseRemoteConfigException.Code.CONFIG_UPDATE_STREAM_ERROR));
}
throw th;
}
} catch (IOException unused3) {
num = null;
} catch (Throwable th4) {
num = null;
th = th4;
}
if (!isStatusCodeRetryable && num.intValue() != 200) {
String format3 = String.format("Unable to connect to the server. Try again in a few minutes. HTTP status code: %d", num);
if (num.intValue() == 403) {
format3 = parseForbiddenErrorResponseMessage(httpURLConnection.getErrorStream());
}
firebaseRemoteConfigServerException = new FirebaseRemoteConfigServerException(num.intValue(), format3, FirebaseRemoteConfigException.Code.CONFIG_UPDATE_STREAM_ERROR);
propagateErrors(firebaseRemoteConfigServerException);
return Tasks.forResult(null);
}
retryHttpConnectionWhenBackoffEnds();
return Tasks.forResult(null);
}
public void closeRealtimeHttpStream(HttpURLConnection httpURLConnection) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
try {
httpURLConnection.getInputStream().close();
if (httpURLConnection.getErrorStream() != null) {
httpURLConnection.getErrorStream().close();
}
} catch (IOException unused) {
}
}
}
}

View File

@@ -0,0 +1,89 @@
package com.google.firebase.remoteconfig.internal;
import android.content.Context;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class ConfigStorageClient {
public static final Map clientInstances = new HashMap();
public final Context context;
public final String fileName;
public String getFileName() {
return this.fileName;
}
public ConfigStorageClient(Context context, String str) {
this.context = context;
this.fileName = str;
}
public synchronized Void write(ConfigContainer configContainer) {
FileOutputStream openFileOutput = this.context.openFileOutput(this.fileName, 0);
try {
openFileOutput.write(configContainer.toString().getBytes("UTF-8"));
} finally {
openFileOutput.close();
}
return null;
}
public synchronized ConfigContainer read() {
FileInputStream fileInputStream;
Throwable th;
try {
fileInputStream = this.context.openFileInput(this.fileName);
} catch (FileNotFoundException | JSONException unused) {
fileInputStream = null;
} catch (Throwable th2) {
fileInputStream = null;
th = th2;
}
try {
int available = fileInputStream.available();
byte[] bArr = new byte[available];
fileInputStream.read(bArr, 0, available);
ConfigContainer copyOf = ConfigContainer.copyOf(new JSONObject(new String(bArr, "UTF-8")));
fileInputStream.close();
return copyOf;
} catch (FileNotFoundException | JSONException unused2) {
if (fileInputStream != null) {
fileInputStream.close();
}
return null;
} catch (Throwable th3) {
th = th3;
if (fileInputStream != null) {
fileInputStream.close();
}
throw th;
}
}
public synchronized Void clear() {
this.context.deleteFile(this.fileName);
return null;
}
public static synchronized ConfigStorageClient getInstance(Context context, String str) {
ConfigStorageClient configStorageClient;
synchronized (ConfigStorageClient.class) {
try {
Map map = clientInstances;
if (!map.containsKey(str)) {
map.put(str, new ConfigStorageClient(context, str));
}
configStorageClient = (ConfigStorageClient) map.get(str);
} catch (Throwable th) {
throw th;
}
}
return configStorageClient;
}
}

View File

@@ -0,0 +1,54 @@
package com.google.firebase.remoteconfig.internal;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigInfoImpl implements FirebaseRemoteConfigInfo {
public final FirebaseRemoteConfigSettings configSettings;
public final int lastFetchStatus;
public final long lastSuccessfulFetchTimeInMillis;
@Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo
public int getLastFetchStatus() {
return this.lastFetchStatus;
}
public FirebaseRemoteConfigInfoImpl(long j, int i, FirebaseRemoteConfigSettings firebaseRemoteConfigSettings) {
this.lastSuccessfulFetchTimeInMillis = j;
this.lastFetchStatus = i;
this.configSettings = firebaseRemoteConfigSettings;
}
public static class Builder {
public FirebaseRemoteConfigSettings builderConfigSettings;
public int builderLastFetchStatus;
public long builderLastSuccessfulFetchTimeInMillis;
public Builder withConfigSettings(FirebaseRemoteConfigSettings firebaseRemoteConfigSettings) {
this.builderConfigSettings = firebaseRemoteConfigSettings;
return this;
}
public Builder withLastFetchStatus(int i) {
this.builderLastFetchStatus = i;
return this;
}
public Builder withLastSuccessfulFetchTimeInMillis(long j) {
this.builderLastSuccessfulFetchTimeInMillis = j;
return this;
}
public Builder() {
}
public FirebaseRemoteConfigInfoImpl build() {
return new FirebaseRemoteConfigInfoImpl(this.builderLastSuccessfulFetchTimeInMillis, this.builderLastFetchStatus, this.builderConfigSettings);
}
}
public static Builder newBuilder() {
return new Builder();
}
}

View File

@@ -0,0 +1,79 @@
package com.google.firebase.remoteconfig.internal;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
/* loaded from: classes3.dex */
public class FirebaseRemoteConfigValueImpl implements FirebaseRemoteConfigValue {
public final int source;
public final String value;
@Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
public int getSource() {
return this.source;
}
public FirebaseRemoteConfigValueImpl(String str, int i) {
this.value = str;
this.source = i;
}
@Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
public long asLong() {
if (this.source == 0) {
return 0L;
}
String asTrimmedString = asTrimmedString();
try {
return Long.valueOf(asTrimmedString).longValue();
} catch (NumberFormatException e) {
throw new IllegalArgumentException(String.format("[Value: %s] cannot be converted to a %s.", asTrimmedString, "long"), e);
}
}
@Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
public double asDouble() {
if (this.source == 0) {
return 0.0d;
}
String asTrimmedString = asTrimmedString();
try {
return Double.valueOf(asTrimmedString).doubleValue();
} catch (NumberFormatException e) {
throw new IllegalArgumentException(String.format("[Value: %s] cannot be converted to a %s.", asTrimmedString, "double"), e);
}
}
@Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
public String asString() {
if (this.source == 0) {
return "";
}
throwIfNullValue();
return this.value;
}
@Override // com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
public boolean asBoolean() {
if (this.source == 0) {
return false;
}
String asTrimmedString = asTrimmedString();
if (ConfigGetParameterHandler.TRUE_REGEX.matcher(asTrimmedString).matches()) {
return true;
}
if (ConfigGetParameterHandler.FALSE_REGEX.matcher(asTrimmedString).matches()) {
return false;
}
throw new IllegalArgumentException(String.format("[Value: %s] cannot be converted to a %s.", asTrimmedString, "boolean"));
}
public final void throwIfNullValue() {
if (this.value == null) {
throw new IllegalArgumentException("Value is null, and cannot be converted to the desired type.");
}
}
public final String asTrimmedString() {
return asString().trim();
}
}

View File

@@ -0,0 +1,58 @@
package com.google.firebase.remoteconfig.internal;
import android.os.Bundle;
import com.google.firebase.analytics.connector.AnalyticsConnector;
import com.google.firebase.inject.Provider;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class Personalization {
public final Provider analyticsConnector;
public final Map loggedChoiceIds = Collections.synchronizedMap(new HashMap());
public Personalization(Provider provider) {
this.analyticsConnector = provider;
}
public void logArmActive(String str, ConfigContainer configContainer) {
JSONObject optJSONObject;
AnalyticsConnector analyticsConnector = (AnalyticsConnector) this.analyticsConnector.get();
if (analyticsConnector == null) {
return;
}
JSONObject personalizationMetadata = configContainer.getPersonalizationMetadata();
if (personalizationMetadata.length() < 1) {
return;
}
JSONObject configs = configContainer.getConfigs();
if (configs.length() >= 1 && (optJSONObject = personalizationMetadata.optJSONObject(str)) != null) {
String optString = optJSONObject.optString("choiceId");
if (optString.isEmpty()) {
return;
}
synchronized (this.loggedChoiceIds) {
try {
if (optString.equals(this.loggedChoiceIds.get(str))) {
return;
}
this.loggedChoiceIds.put(str, optString);
Bundle bundle = new Bundle();
bundle.putString("arm_key", str);
bundle.putString("arm_value", configs.optString(str));
bundle.putString("personalization_id", optJSONObject.optString("personalizationId"));
bundle.putInt("arm_index", optJSONObject.optInt("armIndex", -1));
bundle.putString("group", optJSONObject.optString("group"));
analyticsConnector.logEvent("fp", "personalization_assignment", bundle);
Bundle bundle2 = new Bundle();
bundle2.putString("_fpid", optString);
analyticsConnector.logEvent("fp", "_fpc", bundle2);
} catch (Throwable th) {
throw th;
}
}
}
}
}

View File

@@ -0,0 +1,69 @@
package com.google.firebase.remoteconfig.internal.rollouts;
import android.util.Log;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException;
import com.google.firebase.remoteconfig.internal.ConfigCacheClient;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutsState;
import java.util.HashSet;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class RolloutsStateFactory {
public ConfigCacheClient activatedConfigsCache;
public ConfigCacheClient defaultConfigsCache;
public RolloutsStateFactory(ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2) {
this.activatedConfigsCache = configCacheClient;
this.defaultConfigsCache = configCacheClient2;
}
public RolloutsState getActiveRolloutsState(ConfigContainer configContainer) {
JSONArray rolloutMetadata = configContainer.getRolloutMetadata();
long templateVersionNumber = configContainer.getTemplateVersionNumber();
HashSet hashSet = new HashSet();
for (int i = 0; i < rolloutMetadata.length(); i++) {
try {
JSONObject jSONObject = rolloutMetadata.getJSONObject(i);
String string = jSONObject.getString("rolloutId");
JSONArray jSONArray = jSONObject.getJSONArray("affectedParameterKeys");
if (jSONArray.length() > 1) {
Log.w("FirebaseRemoteConfig", String.format("Rollout has multiple affected parameter keys.Only the first key will be included in RolloutsState. rolloutId: %s, affectedParameterKeys: %s", string, jSONArray));
}
String optString = jSONArray.optString(0, "");
hashSet.add(RolloutAssignment.builder().setRolloutId(string).setVariantId(jSONObject.getString("variantId")).setParameterKey(optString).setParameterValue(getParameterValue(optString)).setTemplateVersion(templateVersionNumber).build());
} catch (JSONException e) {
throw new FirebaseRemoteConfigClientException("Exception parsing rollouts metadata to create RolloutsState.", e);
}
}
return RolloutsState.create(hashSet);
}
public final String getParameterValue(String str) {
String stringFromCache = getStringFromCache(this.activatedConfigsCache, str);
if (stringFromCache != null) {
return stringFromCache;
}
String stringFromCache2 = getStringFromCache(this.defaultConfigsCache, str);
return stringFromCache2 != null ? stringFromCache2 : "";
}
public static String getStringFromCache(ConfigCacheClient configCacheClient, String str) {
ConfigContainer blocking = configCacheClient.getBlocking();
if (blocking == null) {
return null;
}
try {
return blocking.getConfigs().getString(str);
} catch (JSONException unused) {
return null;
}
}
public static RolloutsStateFactory create(ConfigCacheClient configCacheClient, ConfigCacheClient configCacheClient2) {
return new RolloutsStateFactory(configCacheClient, configCacheClient2);
}
}

View File

@@ -0,0 +1,72 @@
package com.google.firebase.remoteconfig.internal.rollouts;
import android.util.Log;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.remoteconfig.FirebaseRemoteConfigException;
import com.google.firebase.remoteconfig.internal.ConfigCacheClient;
import com.google.firebase.remoteconfig.internal.ConfigContainer;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutsState;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutsStateSubscriber;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
/* loaded from: classes3.dex */
public class RolloutsStateSubscriptionsHandler {
public ConfigCacheClient activatedConfigsCache;
public Executor executor;
public RolloutsStateFactory rolloutsStateFactory;
public Set subscribers = Collections.newSetFromMap(new ConcurrentHashMap());
public RolloutsStateSubscriptionsHandler(ConfigCacheClient configCacheClient, RolloutsStateFactory rolloutsStateFactory, Executor executor) {
this.activatedConfigsCache = configCacheClient;
this.rolloutsStateFactory = rolloutsStateFactory;
this.executor = executor;
}
public void registerRolloutsStateSubscriber(final RolloutsStateSubscriber rolloutsStateSubscriber) {
this.subscribers.add(rolloutsStateSubscriber);
final Task task = this.activatedConfigsCache.get();
task.addOnSuccessListener(this.executor, new OnSuccessListener() { // from class: com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler$$ExternalSyntheticLambda1
@Override // com.google.android.gms.tasks.OnSuccessListener
public final void onSuccess(Object obj) {
RolloutsStateSubscriptionsHandler.this.lambda$registerRolloutsStateSubscriber$1(task, rolloutsStateSubscriber, (ConfigContainer) obj);
}
});
}
public final /* synthetic */ void lambda$registerRolloutsStateSubscriber$1(Task task, final RolloutsStateSubscriber rolloutsStateSubscriber, ConfigContainer configContainer) {
try {
ConfigContainer configContainer2 = (ConfigContainer) task.getResult();
if (configContainer2 != null) {
final RolloutsState activeRolloutsState = this.rolloutsStateFactory.getActiveRolloutsState(configContainer2);
this.executor.execute(new Runnable() { // from class: com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
RolloutsStateSubscriber.this.onRolloutsStateChanged(activeRolloutsState);
}
});
}
} catch (FirebaseRemoteConfigException e) {
Log.w("FirebaseRemoteConfig", "Exception publishing RolloutsState to subscriber. Continuing to listen for changes.", e);
}
}
public void publishActiveRolloutsState(ConfigContainer configContainer) {
try {
final RolloutsState activeRolloutsState = this.rolloutsStateFactory.getActiveRolloutsState(configContainer);
for (final RolloutsStateSubscriber rolloutsStateSubscriber : this.subscribers) {
this.executor.execute(new Runnable() { // from class: com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
RolloutsStateSubscriber.this.onRolloutsStateChanged(activeRolloutsState);
}
});
}
} catch (FirebaseRemoteConfigException e) {
Log.w("FirebaseRemoteConfig", "Exception publishing RolloutsState to subscribers. Continuing to listen for changes.", e);
}
}
}

View File

@@ -0,0 +1,8 @@
package com.google.firebase.remoteconfig.interop;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutsStateSubscriber;
/* loaded from: classes3.dex */
public interface FirebaseRemoteConfigInterop {
void registerRolloutsStateSubscriber(String str, RolloutsStateSubscriber rolloutsStateSubscriber);
}

View File

@@ -0,0 +1,37 @@
package com.google.firebase.remoteconfig.interop.rollouts;
import com.google.firebase.encoders.FieldDescriptor;
import com.google.firebase.encoders.ObjectEncoder;
import com.google.firebase.encoders.ObjectEncoderContext;
import com.google.firebase.encoders.config.Configurator;
import com.google.firebase.encoders.config.EncoderConfig;
/* loaded from: classes3.dex */
public final class AutoRolloutAssignmentEncoder implements Configurator {
public static final Configurator CONFIG = new AutoRolloutAssignmentEncoder();
@Override // com.google.firebase.encoders.config.Configurator
public void configure(EncoderConfig encoderConfig) {
RolloutAssignmentEncoder rolloutAssignmentEncoder = RolloutAssignmentEncoder.INSTANCE;
encoderConfig.registerEncoder(RolloutAssignment.class, rolloutAssignmentEncoder);
encoderConfig.registerEncoder(AutoValue_RolloutAssignment.class, rolloutAssignmentEncoder);
}
public static final class RolloutAssignmentEncoder implements ObjectEncoder {
public static final RolloutAssignmentEncoder INSTANCE = new RolloutAssignmentEncoder();
public static final FieldDescriptor ROLLOUTID_DESCRIPTOR = FieldDescriptor.of("rolloutId");
public static final FieldDescriptor VARIANTID_DESCRIPTOR = FieldDescriptor.of("variantId");
public static final FieldDescriptor PARAMETERKEY_DESCRIPTOR = FieldDescriptor.of("parameterKey");
public static final FieldDescriptor PARAMETERVALUE_DESCRIPTOR = FieldDescriptor.of("parameterValue");
public static final FieldDescriptor TEMPLATEVERSION_DESCRIPTOR = FieldDescriptor.of("templateVersion");
@Override // com.google.firebase.encoders.ObjectEncoder
public void encode(RolloutAssignment rolloutAssignment, ObjectEncoderContext objectEncoderContext) {
objectEncoderContext.add(ROLLOUTID_DESCRIPTOR, rolloutAssignment.getRolloutId());
objectEncoderContext.add(VARIANTID_DESCRIPTOR, rolloutAssignment.getVariantId());
objectEncoderContext.add(PARAMETERKEY_DESCRIPTOR, rolloutAssignment.getParameterKey());
objectEncoderContext.add(PARAMETERVALUE_DESCRIPTOR, rolloutAssignment.getParameterValue());
objectEncoderContext.add(TEMPLATEVERSION_DESCRIPTOR, rolloutAssignment.getTemplateVersion());
}
}
}

View File

@@ -0,0 +1,142 @@
package com.google.firebase.remoteconfig.interop.rollouts;
import com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment;
/* loaded from: classes3.dex */
public final class AutoValue_RolloutAssignment extends RolloutAssignment {
public final String parameterKey;
public final String parameterValue;
public final String rolloutId;
public final long templateVersion;
public final String variantId;
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment
public String getParameterKey() {
return this.parameterKey;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment
public String getParameterValue() {
return this.parameterValue;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment
public String getRolloutId() {
return this.rolloutId;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment
public long getTemplateVersion() {
return this.templateVersion;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment
public String getVariantId() {
return this.variantId;
}
public AutoValue_RolloutAssignment(String str, String str2, String str3, String str4, long j) {
this.rolloutId = str;
this.variantId = str2;
this.parameterKey = str3;
this.parameterValue = str4;
this.templateVersion = j;
}
public String toString() {
return "RolloutAssignment{rolloutId=" + this.rolloutId + ", variantId=" + this.variantId + ", parameterKey=" + this.parameterKey + ", parameterValue=" + this.parameterValue + ", templateVersion=" + this.templateVersion + "}";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof RolloutAssignment)) {
return false;
}
RolloutAssignment rolloutAssignment = (RolloutAssignment) obj;
return this.rolloutId.equals(rolloutAssignment.getRolloutId()) && this.variantId.equals(rolloutAssignment.getVariantId()) && this.parameterKey.equals(rolloutAssignment.getParameterKey()) && this.parameterValue.equals(rolloutAssignment.getParameterValue()) && this.templateVersion == rolloutAssignment.getTemplateVersion();
}
public int hashCode() {
int hashCode = (((((((this.rolloutId.hashCode() ^ 1000003) * 1000003) ^ this.variantId.hashCode()) * 1000003) ^ this.parameterKey.hashCode()) * 1000003) ^ this.parameterValue.hashCode()) * 1000003;
long j = this.templateVersion;
return hashCode ^ ((int) (j ^ (j >>> 32)));
}
public static final class Builder extends RolloutAssignment.Builder {
public String parameterKey;
public String parameterValue;
public String rolloutId;
public byte set$0;
public long templateVersion;
public String variantId;
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment.Builder
public RolloutAssignment.Builder setTemplateVersion(long j) {
this.templateVersion = j;
this.set$0 = (byte) (this.set$0 | 1);
return this;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment.Builder
public RolloutAssignment.Builder setRolloutId(String str) {
if (str == null) {
throw new NullPointerException("Null rolloutId");
}
this.rolloutId = str;
return this;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment.Builder
public RolloutAssignment.Builder setVariantId(String str) {
if (str == null) {
throw new NullPointerException("Null variantId");
}
this.variantId = str;
return this;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment.Builder
public RolloutAssignment.Builder setParameterKey(String str) {
if (str == null) {
throw new NullPointerException("Null parameterKey");
}
this.parameterKey = str;
return this;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment.Builder
public RolloutAssignment.Builder setParameterValue(String str) {
if (str == null) {
throw new NullPointerException("Null parameterValue");
}
this.parameterValue = str;
return this;
}
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutAssignment.Builder
public RolloutAssignment build() {
if (this.set$0 != 1 || this.rolloutId == null || this.variantId == null || this.parameterKey == null || this.parameterValue == null) {
StringBuilder sb = new StringBuilder();
if (this.rolloutId == null) {
sb.append(" rolloutId");
}
if (this.variantId == null) {
sb.append(" variantId");
}
if (this.parameterKey == null) {
sb.append(" parameterKey");
}
if (this.parameterValue == null) {
sb.append(" parameterValue");
}
if ((1 & this.set$0) == 0) {
sb.append(" templateVersion");
}
throw new IllegalStateException("Missing required properties:" + ((Object) sb));
}
return new AutoValue_RolloutAssignment(this.rolloutId, this.variantId, this.parameterKey, this.parameterValue, this.templateVersion);
}
}
}

View File

@@ -0,0 +1,38 @@
package com.google.firebase.remoteconfig.interop.rollouts;
import java.util.Set;
/* loaded from: classes3.dex */
public final class AutoValue_RolloutsState extends RolloutsState {
public final Set rolloutAssignments;
@Override // com.google.firebase.remoteconfig.interop.rollouts.RolloutsState
public Set getRolloutAssignments() {
return this.rolloutAssignments;
}
public AutoValue_RolloutsState(Set set) {
if (set == null) {
throw new NullPointerException("Null rolloutAssignments");
}
this.rolloutAssignments = set;
}
public String toString() {
return "RolloutsState{rolloutAssignments=" + this.rolloutAssignments + "}";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof RolloutsState) {
return this.rolloutAssignments.equals(((RolloutsState) obj).getRolloutAssignments());
}
return false;
}
public int hashCode() {
return this.rolloutAssignments.hashCode() ^ 1000003;
}
}

View File

@@ -0,0 +1,38 @@
package com.google.firebase.remoteconfig.interop.rollouts;
import com.google.firebase.encoders.DataEncoder;
import com.google.firebase.encoders.json.JsonDataEncoderBuilder;
import com.google.firebase.remoteconfig.interop.rollouts.AutoValue_RolloutAssignment;
/* loaded from: classes3.dex */
public abstract class RolloutAssignment {
public static final DataEncoder ROLLOUT_ASSIGNMENT_JSON_ENCODER = new JsonDataEncoderBuilder().configureWith(AutoRolloutAssignmentEncoder.CONFIG).build();
public static abstract class Builder {
public abstract RolloutAssignment build();
public abstract Builder setParameterKey(String str);
public abstract Builder setParameterValue(String str);
public abstract Builder setRolloutId(String str);
public abstract Builder setTemplateVersion(long j);
public abstract Builder setVariantId(String str);
}
public abstract String getParameterKey();
public abstract String getParameterValue();
public abstract String getRolloutId();
public abstract long getTemplateVersion();
public abstract String getVariantId();
public static Builder builder() {
return new AutoValue_RolloutAssignment.Builder();
}
}

View File

@@ -0,0 +1,12 @@
package com.google.firebase.remoteconfig.interop.rollouts;
import java.util.Set;
/* loaded from: classes3.dex */
public abstract class RolloutsState {
public abstract Set getRolloutAssignments();
public static RolloutsState create(Set set) {
return new AutoValue_RolloutsState(set);
}
}

View File

@@ -0,0 +1,6 @@
package com.google.firebase.remoteconfig.interop.rollouts;
/* loaded from: classes3.dex */
public interface RolloutsStateSubscriber {
void onRolloutsStateChanged(RolloutsState rolloutsState);
}

View File

@@ -0,0 +1,16 @@
package com.google.firebase.remoteconfig.ktx;
import androidx.annotation.Keep;
import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
@Keep
/* loaded from: classes3.dex */
public final class FirebaseRemoteConfigKtxRegistrar implements ComponentRegistrar {
@Override // com.google.firebase.components.ComponentRegistrar
public List<Component> getComponents() {
return CollectionsKt__CollectionsKt.emptyList();
}
}