diff --git a/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/ModuleAdapter.java b/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/ModuleAdapter.java index aa52e9203..93eff4706 100644 --- a/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/ModuleAdapter.java +++ b/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/ModuleAdapter.java @@ -73,6 +73,9 @@ static Collection findAirshipComponents(@NonNull Str case Modules.NAMED_USER_MODULE: return Collections.singletonList(UAirship.shared().getNamedUser()); + + case Modules.CHANNEL_MODULE: + return Collections.singletonList(UAirship.shared().getChannel()); } Logger.verbose("ModuleAdapter - Unknown module: %s", module); diff --git a/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/Modules.java b/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/Modules.java index 3b753f145..d0ccfe0fb 100644 --- a/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/Modules.java +++ b/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/Modules.java @@ -45,7 +45,12 @@ interface Modules { */ String LOCATION_MODULE = "location"; - List ALL_MODULES = Arrays.asList(PUSH_MODULE, ANALYTICS_MODULE, - MESSAGE_CENTER, IN_APP_MODULE, AUTOMATION_MODULE, NAMED_USER_MODULE, LOCATION_MODULE); + /** + * Channel module + */ + String CHANNEL_MODULE = "channel"; + + List ALL_MODULES = Arrays.asList(PUSH_MODULE, ANALYTICS_MODULE, MESSAGE_CENTER, + IN_APP_MODULE, AUTOMATION_MODULE, NAMED_USER_MODULE, LOCATION_MODULE, CHANNEL_MODULE); } diff --git a/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/RemoteConfigManager.java b/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/RemoteConfigManager.java index 88a743ef2..2dcf9dd11 100644 --- a/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/RemoteConfigManager.java +++ b/urbanairship-core/src/main/java/com/urbanairship/remoteconfig/RemoteConfigManager.java @@ -92,7 +92,7 @@ protected void init() { @Override public JsonMap apply(@NonNull Collection remoteDataPayloads) { // sort the payloads, common first followed by platform-specific - List remoteDataPayloadList = new ArrayList(remoteDataPayloads); + List remoteDataPayloadList = new ArrayList<>(remoteDataPayloads); Collections.sort(remoteDataPayloadList, COMPARE_BY_PAYLOAD_TYPE); // combine the payloads, overwriting common config with platform-specific config diff --git a/urbanairship-core/src/test/java/com/urbanairship/remoteconfig/RemoteConfigManagerTest.java b/urbanairship-core/src/test/java/com/urbanairship/remoteconfig/RemoteConfigManagerTest.java index 2566a28d3..ed0ecb0cf 100644 --- a/urbanairship-core/src/test/java/com/urbanairship/remoteconfig/RemoteConfigManagerTest.java +++ b/urbanairship-core/src/test/java/com/urbanairship/remoteconfig/RemoteConfigManagerTest.java @@ -94,25 +94,25 @@ public void testRemoteDataForegroundRefreshInterval() { @Test public void testRemoteConfig() { - JsonMap module_one_config_common = JsonMap.newBuilder() + JsonMap fooConfig = JsonMap.newBuilder() .put("some_config_name", "some_config_value") .build(); - JsonMap module_two_config_common = JsonMap.newBuilder() + JsonMap barConfig = JsonMap.newBuilder() .put("some_other_config_name", "some_other_config_value") .build(); JsonMap commonData = JsonMap.newBuilder() - .put("module_one", module_one_config_common) - .put("module_two", module_two_config_common) + .put("foo", fooConfig) + .put("bar", barConfig) .build(); - JsonMap module_one_config_platform_specific = JsonMap.newBuilder() + JsonMap androidFooOverrideConfig = JsonMap.newBuilder() .put("some_other_config_name", "some_other_config_value") .build(); JsonMap androidData = JsonMap.newBuilder() - .put("module_one", module_one_config_platform_specific) + .put("foo", androidFooOverrideConfig) .build(); RemoteDataPayload common = createRemoteDataPayload("app_config", System.currentTimeMillis(), commonData); @@ -125,9 +125,9 @@ public void testRemoteConfig() { assertEquals((2 + Modules.ALL_MODULES.size()), config.size()); - assertEquals(module_one_config_platform_specific, config.get("module_one")); + assertEquals(androidFooOverrideConfig, config.get("foo")); - assertEquals(module_two_config_common, config.get("module_two")); + assertEquals(barConfig, config.get("bar")); // All modules without config payloads should be called with a null config for (String module : Modules.ALL_MODULES) {