@@ -221,6 +221,7 @@ private boolean getIsSdkEnabled() {
221
221
// 2. If the value exists in device cache, return this value.
222
222
// 3. Otherwise, return default value.
223
223
SdkEnabled config = SdkEnabled .getInstance ();
224
+ Optional <Boolean > deviceCacheValue = getDeviceCacheBoolean (config );
224
225
225
226
// 1. Reads value from Firebase Remote Config, saves this value in cache layer if fetch status
226
227
// is not failure.
@@ -230,13 +231,17 @@ private boolean getIsSdkEnabled() {
230
231
if (remoteConfigManager .isLastFetchFailed ()) {
231
232
return false ;
232
233
}
233
- // b. Cache and return this value.
234
- deviceCacheManager .setValue (config .getDeviceCacheFlag (), rcValue .get ());
235
- return rcValue .get ();
234
+
235
+ Boolean newValue = rcValue .get ();
236
+ // b. Only cache and return this value if it is different from the current value.
237
+ if (!deviceCacheValue .isAvailable () || deviceCacheValue .get () != newValue ) {
238
+ deviceCacheManager .setValue (config .getDeviceCacheFlag (), newValue );
239
+ }
240
+
241
+ return newValue ;
236
242
}
237
243
238
244
// 2. If the value exists in device cache, return this value.
239
- Optional <Boolean > deviceCacheValue = getDeviceCacheBoolean (config );
240
245
if (deviceCacheValue .isAvailable ()) {
241
246
return deviceCacheValue .get ();
242
247
}
@@ -257,17 +262,21 @@ private boolean getIsSdkVersionDisabled() {
257
262
// 2. If the value exists in device cache, return this value.
258
263
// 3. Otherwise, return default value.
259
264
SdkDisabledVersions config = SdkDisabledVersions .getInstance ();
265
+ Optional <String > deviceCacheValue = getDeviceCacheString (config );
260
266
261
267
// 1. Reads value from Firebase Remote Config, cache and return this value.
262
268
Optional <String > rcValue = getRemoteConfigString (config );
263
269
if (rcValue .isAvailable ()) {
264
270
// Do not check FRC last fetch status because it is the most recent value device can get.
265
- deviceCacheManager .setValue (config .getDeviceCacheFlag (), rcValue .get ());
266
- return isFireperfSdkVersionInList (rcValue .get ());
271
+ String newValue = rcValue .get ();
272
+ // Only cache and return this value if it is different from the current value.
273
+ if (!deviceCacheValue .isAvailable () || !deviceCacheValue .get ().equals (newValue )) {
274
+ deviceCacheManager .setValue (config .getDeviceCacheFlag (), newValue );
275
+ }
276
+ return isFireperfSdkVersionInList (newValue );
267
277
}
268
278
269
279
// 2. If the value exists in device cache, return this value.
270
- Optional <String > deviceCacheValue = getDeviceCacheString (config );
271
280
if (deviceCacheValue .isAvailable ()) {
272
281
return isFireperfSdkVersionInList (deviceCacheValue .get ());
273
282
}
0 commit comments