Skip to content

Rename ConfigMetadataClient to ConfigSharedPrefsClient #6440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.google.firebase.installations.FirebaseInstallationsApi
import com.google.firebase.remoteconfig.internal.ConfigCacheClient
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.ConfigSharedPrefsClient
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler
import java.util.concurrent.Executor

Expand All @@ -41,7 +41,7 @@ fun createRemoteConfig(
defaultConfigsCache: ConfigCacheClient,
fetchHandler: ConfigFetchHandler,
getHandler: ConfigGetParameterHandler,
frcMetadata: ConfigMetadataClient,
frcSharedPrefs: ConfigSharedPrefsClient,
realtimeHandler: ConfigRealtimeHandler,
rolloutsStateSubscriptionsHandler: RolloutsStateSubscriptionsHandler
): FirebaseRemoteConfig {
Expand All @@ -56,7 +56,7 @@ fun createRemoteConfig(
defaultConfigsCache,
fetchHandler,
getHandler,
frcMetadata,
frcSharedPrefs,
realtimeHandler,
rolloutsStateSubscriptionsHandler
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import com.google.firebase.remoteconfig.createRemoteConfig
import com.google.firebase.remoteconfig.internal.ConfigCacheClient
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.ConfigSharedPrefsClient
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler
import org.junit.After
import org.junit.Before
Expand Down Expand Up @@ -142,7 +142,7 @@ class ConfigTests : BaseTestCase() {
defaultConfigsCache = mock(ConfigCacheClient::class.java),
fetchHandler = mock(ConfigFetchHandler::class.java),
getHandler = mockGetHandler,
frcMetadata = mock(ConfigMetadataClient::class.java),
frcSharedPrefs = mock(ConfigSharedPrefsClient::class.java),
realtimeHandler = mock(ConfigRealtimeHandler::class.java),
rolloutsStateSubscriptionsHandler = mock(RolloutsStateSubscriptionsHandler::class.java)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
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.ConfigSharedPrefsClient;
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
import java.util.Date;
import java.util.HashMap;
Expand All @@ -60,7 +60,7 @@ public class FirebaseRemoteConfigIntegrationTest {
@Mock private ConfigCacheClient mockDefaultsCache;
@Mock private ConfigFetchHandler mockFetchHandler;
@Mock private ConfigGetParameterHandler mockGetHandler;
@Mock private ConfigMetadataClient metadataClient;
@Mock private ConfigSharedPrefsClient sharedPrefsClient;
@Mock private ConfigRealtimeHandler mockConfigRealtimeHandler;
@Mock private RolloutsStateSubscriptionsHandler mockRolloutsStateSubscriptionHandler;

Expand Down Expand Up @@ -112,7 +112,7 @@ public void setUp() {
mockDefaultsCache,
mockFetchHandler,
mockGetHandler,
metadataClient,
sharedPrefsClient,
mockConfigRealtimeHandler,
mockRolloutsStateSubscriptionHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler.FetchResponse;
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.ConfigSharedPrefsClient;
import com.google.firebase.remoteconfig.internal.DefaultsXmlParser;
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
import java.util.ArrayList;
Expand Down Expand Up @@ -160,7 +160,7 @@ public static FirebaseRemoteConfig getInstance(@NonNull FirebaseApp app) {
private final ConfigCacheClient defaultConfigsCache;
private final ConfigFetchHandler fetchHandler;
private final ConfigGetParameterHandler getHandler;
private final ConfigMetadataClient frcMetadata;
private final ConfigSharedPrefsClient frcSharedPrefs;
private final FirebaseInstallationsApi firebaseInstallations;
private final ConfigRealtimeHandler configRealtimeHandler;
private final RolloutsStateSubscriptionsHandler rolloutsStateSubscriptionsHandler;
Expand All @@ -181,7 +181,7 @@ public static FirebaseRemoteConfig getInstance(@NonNull FirebaseApp app) {
ConfigCacheClient defaultConfigsCache,
ConfigFetchHandler fetchHandler,
ConfigGetParameterHandler getHandler,
ConfigMetadataClient frcMetadata,
ConfigSharedPrefsClient frcSharedPrefs,
ConfigRealtimeHandler configRealtimeHandler,
RolloutsStateSubscriptionsHandler rolloutsStateSubscriptionsHandler) {
this.context = context;
Expand All @@ -194,7 +194,7 @@ public static FirebaseRemoteConfig getInstance(@NonNull FirebaseApp app) {
this.defaultConfigsCache = defaultConfigsCache;
this.fetchHandler = fetchHandler;
this.getHandler = getHandler;
this.frcMetadata = frcMetadata;
this.frcSharedPrefs = frcSharedPrefs;
this.configRealtimeHandler = configRealtimeHandler;
this.rolloutsStateSubscriptionsHandler = rolloutsStateSubscriptionsHandler;
}
Expand All @@ -208,18 +208,18 @@ public Task<FirebaseRemoteConfigInfo> ensureInitialized() {
Task<ConfigContainer> activatedConfigsTask = activatedConfigsCache.get();
Task<ConfigContainer> defaultsConfigsTask = defaultConfigsCache.get();
Task<ConfigContainer> fetchedConfigsTask = fetchedConfigsCache.get();
Task<FirebaseRemoteConfigInfo> metadataTask = Tasks.call(executor, this::getInfo);
Task<FirebaseRemoteConfigInfo> sharedPrefsTask = Tasks.call(executor, this::getInfo);
Task<String> installationIdTask = firebaseInstallations.getId();
Task<InstallationTokenResult> installationTokenTask = firebaseInstallations.getToken(false);

return Tasks.whenAllComplete(
activatedConfigsTask,
defaultsConfigsTask,
fetchedConfigsTask,
metadataTask,
sharedPrefsTask,
installationIdTask,
installationTokenTask)
.continueWith(executor, (unusedListOfCompletedTasks) -> metadataTask.getResult());
.continueWith(executor, (unusedListOfCompletedTasks) -> sharedPrefsTask.getResult());
}

/**
Expand Down Expand Up @@ -475,7 +475,7 @@ public Map<String, FirebaseRemoteConfigValue> getAll() {
*/
@NonNull
public FirebaseRemoteConfigInfo getInfo() {
return frcMetadata.getInfo();
return frcSharedPrefs.getInfo();
}

/**
Expand All @@ -488,7 +488,7 @@ public Task<Void> setConfigSettingsAsync(@NonNull FirebaseRemoteConfigSettings s
return Tasks.call(
executor,
() -> {
frcMetadata.setConfigSettings(settings);
frcSharedPrefs.setConfigSettings(settings);

// Return value required; return null for Void.
return null;
Expand Down Expand Up @@ -548,14 +548,14 @@ public Task<Void> setDefaultsAsync(@XmlRes int resourceId) {
@NonNull
public Task<Void> reset() {
// Use a Task to avoid throwing potential file I/O errors to the caller and because
// frcMetadata's clear call is blocking.
// frcSharedPrefs's clear call is blocking.
return Tasks.call(
executor,
() -> {
activatedConfigsCache.clear();
fetchedConfigsCache.clear();
defaultConfigsCache.clear();
frcMetadata.clear();
frcSharedPrefs.clear();
return null;
});
}
Expand Down Expand Up @@ -666,7 +666,7 @@ public Task<Void> setCustomSignals(@NonNull CustomSignals customSignalsMap) {
return Tasks.call(
executor,
() -> {
frcMetadata.setCustomSignals(customSignalsMap.customSignals);
frcSharedPrefs.setCustomSignals(customSignalsMap.customSignals);
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
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.ConfigSharedPrefsClient;
import com.google.firebase.remoteconfig.internal.ConfigStorageClient;
import com.google.firebase.remoteconfig.internal.Personalization;
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateFactory;
Expand Down Expand Up @@ -166,7 +166,7 @@ public synchronized FirebaseRemoteConfig get(String namespace) {
ConfigCacheClient fetchedCacheClient = getCacheClient(namespace, FETCH_FILE_NAME);
ConfigCacheClient activatedCacheClient = getCacheClient(namespace, ACTIVATE_FILE_NAME);
ConfigCacheClient defaultsCacheClient = getCacheClient(namespace, DEFAULTS_FILE_NAME);
ConfigMetadataClient metadataClient = getMetadataClient(context, appId, namespace);
ConfigSharedPrefsClient sharedPrefsClient = getSharedPrefsClient(context, appId, namespace);

ConfigGetParameterHandler getHandler = getGetHandler(activatedCacheClient, defaultsCacheClient);
Personalization personalization =
Expand All @@ -187,9 +187,9 @@ public synchronized FirebaseRemoteConfig get(String namespace) {
fetchedCacheClient,
activatedCacheClient,
defaultsCacheClient,
getFetchHandler(namespace, fetchedCacheClient, metadataClient),
getFetchHandler(namespace, fetchedCacheClient, sharedPrefsClient),
getHandler,
metadataClient,
sharedPrefsClient,
rolloutsStateSubscriptionsHandler);
}

Expand All @@ -206,7 +206,7 @@ synchronized FirebaseRemoteConfig get(
ConfigCacheClient defaultsClient,
ConfigFetchHandler fetchHandler,
ConfigGetParameterHandler getHandler,
ConfigMetadataClient metadataClient,
ConfigSharedPrefsClient sharedPrefsClient,
RolloutsStateSubscriptionsHandler rolloutsStateSubscriptionsHandler) {
if (!frcNamespaceInstances.containsKey(namespace)) {
FirebaseRemoteConfig in =
Expand All @@ -221,15 +221,15 @@ synchronized FirebaseRemoteConfig get(
defaultsClient,
fetchHandler,
getHandler,
metadataClient,
sharedPrefsClient,
getRealtime(
firebaseApp,
firebaseInstallations,
fetchHandler,
activatedClient,
context,
namespace,
metadataClient),
sharedPrefsClient),
rolloutsStateSubscriptionsHandler);
in.startLoadingConfigsFromDisk();
frcNamespaceInstances.put(namespace, in);
Expand All @@ -254,30 +254,32 @@ private ConfigCacheClient getCacheClient(String namespace, String configStoreTyp

@VisibleForTesting
ConfigFetchHttpClient getFrcBackendApiClient(
String apiKey, String namespace, ConfigMetadataClient metadataClient) {
String apiKey, String namespace, ConfigSharedPrefsClient sharedPrefsClient) {
String appId = firebaseApp.getOptions().getApplicationId();
return new ConfigFetchHttpClient(
context,
appId,
apiKey,
namespace,
/* connectTimeoutInSeconds= */ metadataClient.getFetchTimeoutInSeconds(),
/* readTimeoutInSeconds= */ metadataClient.getFetchTimeoutInSeconds(),
/* customSignals= */ metadataClient.getCustomSignals());
/* connectTimeoutInSeconds= */ sharedPrefsClient.getFetchTimeoutInSeconds(),
/* readTimeoutInSeconds= */ sharedPrefsClient.getFetchTimeoutInSeconds(),
/* customSignals= */ sharedPrefsClient.getCustomSignals());
}

@VisibleForTesting
synchronized ConfigFetchHandler getFetchHandler(
String namespace, ConfigCacheClient fetchedCacheClient, ConfigMetadataClient metadataClient) {
String namespace,
ConfigCacheClient fetchedCacheClient,
ConfigSharedPrefsClient sharedPrefsClient) {
return new ConfigFetchHandler(
firebaseInstallations,
isPrimaryApp(firebaseApp) ? analyticsConnector : () -> null,
executor,
DEFAULT_CLOCK,
DEFAULT_RANDOM,
fetchedCacheClient,
getFrcBackendApiClient(firebaseApp.getOptions().getApiKey(), namespace, metadataClient),
metadataClient,
getFrcBackendApiClient(firebaseApp.getOptions().getApiKey(), namespace, sharedPrefsClient),
sharedPrefsClient,
this.customHeaders);
}

Expand All @@ -288,15 +290,15 @@ synchronized ConfigRealtimeHandler getRealtime(
ConfigCacheClient activatedCacheClient,
Context context,
String namespace,
ConfigMetadataClient metadataClient) {
ConfigSharedPrefsClient sharedPrefsClient) {
return new ConfigRealtimeHandler(
firebaseApp,
firebaseInstallations,
configFetchHandler,
activatedCacheClient,
context,
namespace,
metadataClient,
sharedPrefsClient,
executor);
}

Expand All @@ -306,13 +308,14 @@ private ConfigGetParameterHandler getGetHandler(
}

@VisibleForTesting
static ConfigMetadataClient getMetadataClient(Context context, String appId, String namespace) {
static ConfigSharedPrefsClient getSharedPrefsClient(
Context context, String appId, String namespace) {
String fileName =
String.format(
"%s_%s_%s_%s",
FIREBASE_REMOTE_CONFIG_FILE_NAME_PREFIX, appId, namespace, PREFERENCES_FILE_NAME);
SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
return new ConfigMetadataClient(preferences);
return new ConfigSharedPrefsClient(preferences);
}

@Nullable
Expand Down
Loading
Loading