@@ -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,19 @@ 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 == null
238
+ || !deviceCacheValue .isAvailable ()
239
+ || deviceCacheValue .get () != newValue ) {
240
+ deviceCacheManager .setValue (config .getDeviceCacheFlag (), newValue );
241
+ }
242
+
243
+ return newValue ;
236
244
}
237
245
238
246
// 2. If the value exists in device cache, return this value.
239
- Optional <Boolean > deviceCacheValue = getDeviceCacheBoolean (config );
240
247
if (deviceCacheValue .isAvailable ()) {
241
248
return deviceCacheValue .get ();
242
249
}
@@ -257,17 +264,23 @@ private boolean getIsSdkVersionDisabled() {
257
264
// 2. If the value exists in device cache, return this value.
258
265
// 3. Otherwise, return default value.
259
266
SdkDisabledVersions config = SdkDisabledVersions .getInstance ();
267
+ Optional <String > deviceCacheValue = getDeviceCacheString (config );
260
268
261
269
// 1. Reads value from Firebase Remote Config, cache and return this value.
262
270
Optional <String > rcValue = getRemoteConfigString (config );
263
271
if (rcValue .isAvailable ()) {
264
272
// 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 ());
273
+ String newValue = rcValue .get ();
274
+ // Only cache and return this value if it is different from the current value.
275
+ if (deviceCacheValue == null
276
+ || !deviceCacheValue .isAvailable ()
277
+ || !deviceCacheValue .get ().equals (newValue )) {
278
+ deviceCacheManager .setValue (config .getDeviceCacheFlag (), newValue );
279
+ }
280
+ return isFireperfSdkVersionInList (newValue );
267
281
}
268
282
269
283
// 2. If the value exists in device cache, return this value.
270
- Optional <String > deviceCacheValue = getDeviceCacheString (config );
271
284
if (deviceCacheValue .isAvailable ()) {
272
285
return isFireperfSdkVersionInList (deviceCacheValue .get ());
273
286
}
0 commit comments