Skip to content
Draft
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
58 changes: 58 additions & 0 deletions sdk-java/src/main/java/ly/count/sdk/java/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@
protected int networkReadTimeout = 30;

/**
* How long to wait between requests in milliseconds. Used to decrease CPU & I/O load on the device.

Check warning on line 107 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*/
protected int networkRequestCooldown = 1000;

/**
* How long to wait between Device ID change & push token requests, in milliseconds.

Check warning on line 112 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'

Check warning on line 112 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
* Required by Countly server, don't change unless you know what you're doing!
*/
protected int networkImportantRequestCooldown = 5000;
Expand All @@ -126,7 +126,7 @@
* This ensures pinning continues to work after certificate prolongation.
* Certificates ({@link #certificatePins}) on the other hand have specific expiry date.
* In case you chose this way of pinning, you MUST ensure that ALL installs of your app
* have both certificates (old & new) until expiry date.

Check warning on line 129 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*/
protected Set<String> publicKeyPins = null;

Expand All @@ -142,7 +142,7 @@
* This ensures pinning continues to work after certificate prolongation.
* Certificates on the other hand have specific expiry date.
* In case you chose this way of pinning, you MUST ensure that ALL installs of your app
* have both certificates (old & new) until expiry date.

Check warning on line 145 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*/
protected Set<String> certificatePins = null;

Expand All @@ -168,7 +168,7 @@
/**
* {@link CrashProcessor}-implementing class which is instantiated when application
* crashes or crash is reported programmatically using {@link Session#addCrashReport(Throwable, boolean, String, Map, String...)}.
* Crash processor helps you to add custom data in event of a crash: custom crash segments & crash logs.

Check warning on line 171 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*/
protected String crashProcessorClass = null;

Expand Down Expand Up @@ -253,6 +253,26 @@
protected boolean locationEnabled = true;
protected boolean autoSendUserProperties = true;

/**
* Seed value for the SDK behavior settings. Used on first init only,
* when no settings have yet been persisted; subsequent inits use the
* value pulled from storage.
*/
protected String sdkBehaviorSettings = null;

/**
* If {@code true}, the SDK skips the periodic {@code /o/sdk?method=sc}
* fetch. The seed JSON from {@link #setSdkBehaviorSettings(String)} (or
* a previously-persisted snapshot) is still applied.
*/
protected boolean sdkBehaviorSettingsRequestsDisabled = false;

/**
* Whether the backoff mechanism may hold the request queue back after the server answered
* slowly. The SDK behavior settings can override it.
*/
protected boolean backoffMechanismEnabled = true;

// TODO: storage limits & configuration
// protected int maxRequestsStored = 0;
// protected int storageDirectory = "";
Expand Down Expand Up @@ -668,7 +688,7 @@
}

/**
* Disable update requests completely. Only begin & end requests will be sent + some special

Check warning on line 691 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
* cases if applicable like User Profile change or Push token updated.
*
* @return {@code this} instance for method chaining
Expand Down Expand Up @@ -766,7 +786,7 @@

/**
* How long to wait between requests in seconds.
* Used to decrease CPU & I/O load on the device in case of batch requests.

Check warning on line 789 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*
* @param milliseconds cooldown period in seconds
* @return {@code this} instance for method chaining
Expand All @@ -784,7 +804,7 @@

/**
* Set read timeout in seconds for HTTP requests SDK sends to Countly server. Defaults to 30.
* Used to decrease CPU & I/O load on the device in case of batch requests.

Check warning on line 807 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*
* @param milliseconds read timeout in milliseconds
* @return {@code this} instance for method chaining
Expand Down Expand Up @@ -812,7 +832,7 @@
* This ensures pinning continues to work after certificate prolongation.
* Certificates ({@link #certificatePins}) on the other hand have specific expiry date.
* In case you chose this way of pinning, you MUST ensure that ALL installs of your app
* have both certificates (old & new) until expiry date.

Check warning on line 835 in sdk-java/src/main/java/ly/count/sdk/java/Config.java

View workflow job for this annotation

GitHub Actions / Release checks (26.8.0)

invalid input: '&'
*
* NOTE: when {@link #serverURL} doesn't have {@code "https://"} public key pinning doesn't work
*
Expand Down Expand Up @@ -1508,4 +1528,42 @@
this.autoSendUserProperties = false;
return this;
}

/**
* Provide an initial SDK behavior settings payload to apply at init time,
* before the first {@code /o/sdk?method=sc} fetch returns. The value is
* the same JSON shape the Countly server emits: {@code {"v":1,"t":<ts>,
* "c":{...}}}. The seed is only used when nothing has been persisted yet.
*
* @param sdkBehaviorSettings serialized config JSON, or {@code null} for none
* @return {@code this} instance for method chaining
*/
public Config setSdkBehaviorSettings(String sdkBehaviorSettings) {
this.sdkBehaviorSettings = sdkBehaviorSettings;
return this;
}

/**
* Disable the periodic SDK behavior settings fetch from the server. Any
* seed JSON or previously-persisted snapshot is still applied at init.
*
* @return {@code this} instance for method chaining
*/
public Config disableSdkBehaviorSettingsUpdates() {
this.sdkBehaviorSettingsRequestsDisabled = true;
return this;
}

/**
* Disable the backoff mechanism. While it is on, a request the server takes long to answer
* makes the SDK wait before it sends the next queued request, which gives a busy server room
* to recover. It never waits while many requests are queued or after an old request. The SDK
* behavior settings can still turn it on or off.
*
* @return {@code this} instance for method chaining
*/
public Config disableBackoffMechanism() {
this.backoffMechanismEnabled = false;
return this;
}
}
Loading
Loading