Skip to content

Commit ff596ae

Browse files
Fix lint and build errors.
1 parent bb8336a commit ff596ae

File tree

12 files changed

+60
-52
lines changed

12 files changed

+60
-52
lines changed

firebase-config/src/androidTest/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import com.google.firebase.remoteconfig.internal.ConfigContainer;
3636
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
3737
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler;
38-
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
3938
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler;
39+
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
4040
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
4141
import java.util.Date;
4242
import java.util.HashMap;

firebase-config/src/main/java/com/google/firebase/remoteconfig/FirebaseRemoteConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
3434
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler.FetchResponse;
3535
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler;
36-
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
3736
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler;
37+
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
3838
import com.google.firebase.remoteconfig.internal.DefaultsXmlParser;
3939
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
4040
import java.util.ArrayList;
@@ -667,11 +667,11 @@ private Task<Void> setDefaultsWithStringsMapAsync(Map<String, String> defaultsSt
667667
@NonNull
668668
public Task<Void> setCustomSignals(@NonNull Map<String, Object> customSignals) {
669669
return Tasks.call(
670-
executor,
671-
() -> {
672-
frcMetadata.setCustomSignals(customSignals);
673-
return null;
674-
});
670+
executor,
671+
() -> {
672+
frcMetadata.setCustomSignals(customSignals);
673+
return null;
674+
});
675675
}
676676

677677
/**

firebase-config/src/main/java/com/google/firebase/remoteconfig/RemoteConfigComponent.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
3737
import com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient;
3838
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler;
39-
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
4039
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler;
40+
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
4141
import com.google.firebase.remoteconfig.internal.ConfigStorageClient;
4242
import com.google.firebase.remoteconfig.internal.Personalization;
4343
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateFactory;
@@ -268,7 +268,9 @@ ConfigFetchHttpClient getFrcBackendApiClient(
268268

269269
@VisibleForTesting
270270
synchronized ConfigFetchHandler getFetchHandler(
271-
String namespace, ConfigCacheClient fetchedCacheClient, ConfigSharedPrefsClient metadataClient) {
271+
String namespace,
272+
ConfigCacheClient fetchedCacheClient,
273+
ConfigSharedPrefsClient metadataClient) {
272274
return new ConfigFetchHandler(
273275
firebaseInstallations,
274276
isPrimaryApp(firebaseApp) ? analyticsConnector : () -> null,
@@ -306,7 +308,8 @@ private ConfigGetParameterHandler getGetHandler(
306308
}
307309

308310
@VisibleForTesting
309-
static ConfigSharedPrefsClient getMetadataClient(Context context, String appId, String namespace) {
311+
static ConfigSharedPrefsClient getMetadataClient(
312+
Context context, String appId, String namespace) {
310313
String fileName =
311314
String.format(
312315
"%s_%s_%s_%s",

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigFetchHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private JSONObject createFetchRequestBody(
308308
String installationAuthToken,
309309
Map<String, String> analyticsUserProperties,
310310
Long firstOpenTime)
311-
throws FirebaseRemoteConfigClientException {
311+
throws FirebaseRemoteConfigClientException {
312312
Map<String, Object> requestBodyMap = new HashMap<>();
313313

314314
if (installationId == null) {

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigSharedPrefsClient.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@
3030
import androidx.annotation.WorkerThread;
3131
import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo;
3232
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
33-
34-
import org.json.JSONException;
35-
import org.json.JSONObject;
36-
3733
import java.lang.annotation.Retention;
3834
import java.util.Date;
3935
import java.util.HashMap;
4036
import java.util.Iterator;
4137
import java.util.Map;
42-
import java.util.Objects;
38+
import org.json.JSONException;
39+
import org.json.JSONObject;
4340

4441
/**
4542
* Client for handling Firebase Remote Config (FRC) metadata that is saved to disk and persisted
@@ -265,17 +262,25 @@ public void setCustomSignals(Map<String, Object> newCustomSignals) {
265262
// Retrieve existing custom signals
266263
Map<String, Object> existingCustomSignals = getCustomSignals();
267264

268-
// Merge new signals with existing ones (new signals take precedence)
269-
existingCustomSignals.putAll(newCustomSignals);
270-
271-
// Ignore key-value pairs with null values, which signify unset signals.
272-
existingCustomSignals.values().removeIf(Objects::isNull);
265+
for (Map.Entry<String, Object> entry : newCustomSignals.entrySet()) {
266+
String key = entry.getKey();
267+
Object value = entry.getValue();
268+
269+
// Merge new signals with existing ones, overwriting existing keys.
270+
// Also, remove entries where the new value is null.
271+
if (value != null) {
272+
existingCustomSignals.put(key, value);
273+
} else {
274+
existingCustomSignals.remove(key);
275+
}
276+
}
273277
frcMetadata
274-
.edit()
275-
.putString(CUSTOM_SIGNALS, new JSONObject(existingCustomSignals).toString())
276-
.commit();
278+
.edit()
279+
.putString(CUSTOM_SIGNALS, new JSONObject(existingCustomSignals).toString())
280+
.commit();
277281
}
278282
}
283+
279284
public Map<String, Object> getCustomSignals() {
280285
String jsonString = frcMetadata.getString(CUSTOM_SIGNALS, "{}");
281286
try {
@@ -292,7 +297,6 @@ public Map<String, Object> getCustomSignals() {
292297
}
293298
}
294299

295-
296300
void resetBackoff() {
297301
setBackoffMetadata(NO_FAILED_FETCHES, NO_BACKOFF_TIME);
298302
}

firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler;
7373
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler.FetchResponse;
7474
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler;
75-
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
7675
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler;
7776
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHttpClient;
77+
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient;
7878
import com.google.firebase.remoteconfig.internal.FakeHttpURLConnection;
7979
import com.google.firebase.remoteconfig.internal.Personalization;
8080
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler;
@@ -350,7 +350,8 @@ public void onError(@NonNull FirebaseRemoteConfigException error) {
350350
mockRetryListener,
351351
scheduledExecutorService);
352352
realtimeMetadataClient =
353-
new ConfigSharedPrefsClient(context.getSharedPreferences("test_file", Context.MODE_PRIVATE));
353+
new ConfigSharedPrefsClient(
354+
context.getSharedPreferences("test_file", Context.MODE_PRIVATE));
354355
configRealtimeHttpClient =
355356
new ConfigRealtimeHttpClient(
356357
firebaseApp,

firebase-config/src/test/java/com/google/firebase/remoteconfig/RemoteConfigTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import com.google.firebase.platforminfo.UserAgentPublisher
2929
import com.google.firebase.remoteconfig.internal.ConfigCacheClient
3030
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler
3131
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler
32-
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient
3332
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler
33+
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient
3434
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler
3535
import org.junit.After
3636
import org.junit.Before

firebase-config/src/test/java/com/google/firebase/remoteconfig/TestConstructorUtil.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ import com.google.firebase.installations.FirebaseInstallationsApi
2323
import com.google.firebase.remoteconfig.internal.ConfigCacheClient
2424
import com.google.firebase.remoteconfig.internal.ConfigFetchHandler
2525
import com.google.firebase.remoteconfig.internal.ConfigGetParameterHandler
26-
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient
2726
import com.google.firebase.remoteconfig.internal.ConfigRealtimeHandler
27+
import com.google.firebase.remoteconfig.internal.ConfigSharedPrefsClient
2828
import com.google.firebase.remoteconfig.internal.rollouts.RolloutsStateSubscriptionsHandler
2929
import java.util.concurrent.Executor
3030

3131
// This method is a workaround for testing. It enable us to create a FirebaseRemoteConfig object
3232
// with mocks using the package-private constructor.
3333
fun createRemoteConfig(
34-
context: Context?,
35-
firebaseApp: FirebaseApp,
36-
firebaseInstallations: FirebaseInstallationsApi,
37-
firebaseAbt: FirebaseABTesting?,
38-
executor: Executor,
39-
fetchedConfigsCache: ConfigCacheClient,
40-
activatedConfigsCache: ConfigCacheClient,
41-
defaultConfigsCache: ConfigCacheClient,
42-
fetchHandler: ConfigFetchHandler,
43-
getHandler: ConfigGetParameterHandler,
44-
frcMetadata: ConfigSharedPrefsClient,
45-
realtimeHandler: ConfigRealtimeHandler,
46-
rolloutsStateSubscriptionsHandler: RolloutsStateSubscriptionsHandler
34+
context: Context?,
35+
firebaseApp: FirebaseApp,
36+
firebaseInstallations: FirebaseInstallationsApi,
37+
firebaseAbt: FirebaseABTesting?,
38+
executor: Executor,
39+
fetchedConfigsCache: ConfigCacheClient,
40+
activatedConfigsCache: ConfigCacheClient,
41+
defaultConfigsCache: ConfigCacheClient,
42+
fetchHandler: ConfigFetchHandler,
43+
getHandler: ConfigGetParameterHandler,
44+
frcMetadata: ConfigSharedPrefsClient,
45+
realtimeHandler: ConfigRealtimeHandler,
46+
rolloutsStateSubscriptionsHandler: RolloutsStateSubscriptionsHandler
4747
): FirebaseRemoteConfig {
4848
return FirebaseRemoteConfig(
4949
context,

firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigFetchHandlerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public void setUp() throws Exception {
143143
context = ApplicationProvider.getApplicationContext();
144144
mockClock = new MockClock(0L);
145145
metadataClient =
146-
new ConfigSharedPrefsClient(context.getSharedPreferences("test_file", Context.MODE_PRIVATE));
146+
new ConfigSharedPrefsClient(
147+
context.getSharedPreferences("test_file", Context.MODE_PRIVATE));
147148

148149
loadBackendApiClient();
149150
loadInstallationIdAndAuthToken();

firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigFetchHttpClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ public class ConfigFetchHttpClientTest {
8686
"etag-" + PROJECT_NUMBER + "-" + DEFAULT_NAMESPACE + "-fetch-%d";
8787
private static final String FIRST_ETAG = String.format(ETAG_FORMAT, 1);
8888
private static final String SECOND_ETAG = String.format(ETAG_FORMAT, 2);
89-
private static final Map<String, Object> SAMPLE_CUSTOM_SIGNALS = ImmutableMap.of(
89+
private static final Map<String, Object> SAMPLE_CUSTOM_SIGNALS =
90+
ImmutableMap.of(
9091
"subscription", "premium",
91-
"age", "20"
92-
);
92+
"age", "20");
9393

9494
private Context context;
9595
private ConfigFetchHttpClient configFetchHttpClient;
@@ -245,7 +245,7 @@ public void fetch_setsAllElementsOfRequestBody_sendsRequestBodyToServer() throws
245245
assertThat(requestBody.getJSONObject(ANALYTICS_USER_PROPERTIES).toString())
246246
.isEqualTo(new JSONObject(customUserProperties).toString());
247247
assertThat(requestBody.getJSONObject(CUSTOM_SIGNALS).toString())
248-
.isEqualTo(new JSONObject(SAMPLE_CUSTOM_SIGNALS).toString());
248+
.isEqualTo(new JSONObject(SAMPLE_CUSTOM_SIGNALS).toString());
249249
}
250250

251251
@Test

0 commit comments

Comments
 (0)