Skip to content

Commit 0ae206b

Browse files
committed
better comments and added local RC lookup back
1 parent fb7a74f commit 0ae206b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/config/ConfigResolver.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ public float getFragmentSamplingRate() {
772772
public boolean getIsExperimentTTIDEnabled() {
773773
// Order of precedence is:
774774
// 1. If the value exists in Android Manifest, return this value.
775-
// 2. Cannot read value from RC because it's not initalized yet
775+
// 2. If the value exists through Firebase Remote Config, cache and return this value.
776776
// 3. If the value exists in device cache, return this value.
777777
// 4. Otherwise, return default value.
778778
ExperimentTTID config = ExperimentTTID.getInstance();
@@ -783,7 +783,13 @@ public boolean getIsExperimentTTIDEnabled() {
783783
return metadataValue.get();
784784
}
785785

786-
// 2. Cannot read value from RC because it's not initialized yet.
786+
// 2. Reads value from Firebase Remote Config, saves this value in cache layer if valid.
787+
Optional<Boolean> rcValue = getRemoteConfigBoolean(config);
788+
if (rcValue.isAvailable()) {
789+
deviceCacheManager.setValue(config.getDeviceCacheFlag(), rcValue.get());
790+
return rcValue.get();
791+
}
792+
787793
// 3. Reads value from cache layer.
788794
Optional<Boolean> deviceCacheValue = getDeviceCacheBoolean(config);
789795
if (deviceCacheValue.isAvailable()) {

firebase-perf/src/main/java/com/google/firebase/perf/config/RemoteConfigManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ protected void syncConfigValues(Map<String, FirebaseRemoteConfigValue> newlyFetc
342342
}
343343
}
344344

345-
// Save to device cache upon successful RC fetchAndActivate
345+
// TODO: remove after experiment is over and experiment RC flag is no longer needed
346+
// Save ExperimentTTID flag to device cache upon successful RC fetchAndActivate, because reading
347+
// is done quite early and it is possible that RC isn't initialized yet.
346348
ExperimentTTID flag = ExperimentTTID.getInstance();
347349
FirebaseRemoteConfigValue rcValue = allRcConfigMap.get(flag.getRemoteConfigFlag());
348350
if (rcValue != null) {

0 commit comments

Comments
 (0)