Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## XX.XX.XX
* Added a config method to disable server config in the initialization "disableSDKBehaviorSettings()".

## 25.4.0
* ! Minor breaking change ! Removed Secure.ANDROID_ID usage in device id generation. The SDK now exclusively uses random UUIDs for device id generation.
* ! Minor breaking change ! Server Configuration is now enabled by default. Changes made on SDK Manager > SDK Configuration on your server will affect SDK behavior directly.
Expand Down
11 changes: 11 additions & 0 deletions sdk/src/main/java/ly/count/android/sdk/CountlyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public class CountlyConfig {
// Requests older than this value in hours would be dropped (0 means this feature is disabled)
int dropAgeHours = 0;
String sdkBehaviorSettings;
boolean sdkBehaviorSettingsDisabled = false;

/**
* THIS VARIABLE SHOULD NOT BE USED
Expand Down Expand Up @@ -1012,6 +1013,16 @@ public synchronized CountlyConfig setSDKBehaviorSettings(String sdkBehaviorSetti
return this;
}

/**
* Disable the SDK behavior settings
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig disableSDKBehaviorSettings() {
this.sdkBehaviorSettingsDisabled = true;
return this;
}

/**
* APM configuration interface to be used with CountlyConfig
*/
Expand Down
28 changes: 20 additions & 8 deletions sdk/src/main/java/ly/count/android/sdk/ModuleConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ModuleConfiguration extends ModuleBase implements ConfigurationProvider {
Integer serverConfigUpdateInterval;
int currentServerConfigUpdateInterval = 4;
long lastServerConfigFetchTimestamp = -1;
private boolean serverConfigDisabled = false;

ModuleConfiguration(@NonNull Countly cly, @NonNull CountlyConfig config) {
super(cly, config);
Expand All @@ -66,22 +67,27 @@ class ModuleConfiguration extends ModuleBase implements ConfigurationProvider {
immediateRequestGenerator = config.immediateRequestGenerator;
serverConfigUpdateTimer = new CountlyTimer();
serverConfigUpdateInterval = currentServerConfigUpdateInterval;
serverConfigDisabled = config.sdkBehaviorSettingsDisabled;

config.countlyStore.setConfigurationProvider(this);

//load the previously saved configuration
loadConfigFromStorage(config.sdkBehaviorSettings);

//update the config variables according to the new state
updateConfigVariables(config);
if (!serverConfigDisabled) {
//load the previously saved configuration
loadConfigFromStorage(config.sdkBehaviorSettings);

//update the config variables according to the new state
updateConfigVariables(config);
}
}

@Override
void initFinished(@NonNull final CountlyConfig config) {
//once the SDK has loaded, init fetching the server config
L.d("[ModuleConfiguration] initFinished");
fetchConfigFromServer(config);
startServerConfigUpdateTimer();
if (!serverConfigDisabled) {
fetchConfigFromServer(config);
startServerConfigUpdateTimer();
}
}

@Override
Expand Down Expand Up @@ -110,7 +116,6 @@ public void run() {
* Reads from storage to local json objects
*/
void loadConfigFromStorage(@Nullable String sdkBehaviorSettings) {

String sConfig = storageProvider.getServerConfig();

if (Utils.isNullOrEmpty(sConfig)) {
Expand Down Expand Up @@ -256,6 +261,9 @@ void saveAndStoreDownloadedConfig(@NonNull JSONObject config, @NonNull CountlyCo
* }
*/
void fetchConfigFromServer(@NonNull CountlyConfig config) {
if (serverConfigDisabled) {
return;
}
L.v("[ModuleConfiguration] fetchConfigFromServer");

// why _cly? because module configuration is created before module device id, so we need to access it like this
Expand Down Expand Up @@ -283,6 +291,10 @@ void fetchConfigFromServer(@NonNull CountlyConfig config) {
}

void fetchIfTimeIsUpForFetchingServerConfig() {
if (serverConfigDisabled) {
return;
}

if (lastServerConfigFetchTimestamp > 0) {
long currentTime = UtilsTime.currentTimestampMs();
long timePassed = currentTime - lastServerConfigFetchTimestamp;
Expand Down
Loading