23
23
import com .google .firebase .perf .BuildConfig ;
24
24
import com .google .firebase .perf .config .ConfigurationConstants .CollectionDeactivated ;
25
25
import com .google .firebase .perf .config .ConfigurationConstants .CollectionEnabled ;
26
- import com .google .firebase .perf .config .ConfigurationConstants .FragmentSamplingRate ;
27
26
import com .google .firebase .perf .config .ConfigurationConstants .ExperimentTTID ;
27
+ import com .google .firebase .perf .config .ConfigurationConstants .FragmentSamplingRate ;
28
28
import com .google .firebase .perf .config .ConfigurationConstants .LogSourceName ;
29
29
import com .google .firebase .perf .config .ConfigurationConstants .NetworkEventCountBackground ;
30
30
import com .google .firebase .perf .config .ConfigurationConstants .NetworkEventCountForeground ;
@@ -115,11 +115,21 @@ public void setMetadataBundle(ImmutableBundle bundle) {
115
115
116
116
/** Default API to call for whether performance monitoring is currently silent. */
117
117
public boolean isPerformanceMonitoringEnabled () {
118
+ saveExperimentFlagToDeviceCache ();
118
119
Boolean isPerformanceCollectionEnabled = getIsPerformanceCollectionEnabled ();
119
120
return (isPerformanceCollectionEnabled == null || isPerformanceCollectionEnabled == true )
120
121
&& getIsServiceCollectionEnabled ();
121
122
}
122
123
124
+ // TODO: remove after _experiment_as_ttid is finished
125
+ private void saveExperimentFlagToDeviceCache () {
126
+ ExperimentTTID config = ExperimentTTID .getInstance ();
127
+ Optional <Boolean > rcValue = getRemoteConfigBoolean (config );
128
+ if (rcValue .isAvailable ()) {
129
+ deviceCacheManager .setValue (config .getDeviceCacheFlag (), rcValue .get ());
130
+ }
131
+ }
132
+
123
133
/** Returns whether developers have enabled Firebase Performance event collection. */
124
134
@ Nullable
125
135
public Boolean getIsPerformanceCollectionEnabled () {
@@ -772,7 +782,7 @@ public float getFragmentSamplingRate() {
772
782
public boolean getIsExperimentTTIDEnabled () {
773
783
// Order of precedence is:
774
784
// 1. If the value exists in Android Manifest, return this value.
775
- // 2. If the value exists through Firebase Remote Config, cache and return this value.
785
+ // 2. Cannot read value from RC because it's not initalized yet
776
786
// 3. If the value exists in device cache, return this value.
777
787
// 4. Otherwise, return default value.
778
788
ExperimentTTID config = ExperimentTTID .getInstance ();
@@ -783,13 +793,7 @@ public boolean getIsExperimentTTIDEnabled() {
783
793
return metadataValue .get ();
784
794
}
785
795
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
-
796
+ // 2. Cannot read value from RC because it's not initialized yet.
793
797
// 3. Reads value from cache layer.
794
798
Optional <Boolean > deviceCacheValue = getDeviceCacheBoolean (config );
795
799
if (deviceCacheValue .isAvailable ()) {
0 commit comments