Skip to content

Commit

Permalink
prepare 3.5.0 release (#203)
Browse files Browse the repository at this point in the history
* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Revert "Better implementation of EvaluationReason serialization type
adapter." Wrong branch...

This reverts commit 69c1c9b.

* Gw/ch29266/flagstore (#105)

* Changed shared preferences store system to user a single FlagStore
system that holds all the information on a flag to prevent issues
arising from unsynchronized separate stores for flag meta-data and
values.

* Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class so manager can construct FlagStores of unknown type. Reformatted interfaces. Removed unused imports.

* Handle null case in allFlags, actually commit changes to UserManager.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Hopefully fix edge cases in summary event reporting to pass testing.

* Simplify getFeaturesJsonObject as no longer using -1 as placeholder for null for variations.

* Make Flag non-mutable. Move GsonCache to gson package, move custom serializer/deserializers to classes in gson package and create one for PUT responses. Removed BaseUserSharedPreferences.

* Send summary event even if stored flag doesn't exist.

* Move sendSummaryEvent update code to UserSummaryEventSharedPreferences to synchronize to prevent data race on sending, updating, and clearing event store. Move SummaryEventSharedPreferences and UserSummaryEventSharedPreferences out of response package.

* Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak reference. Fix various warnings.

* Migration code for upcoming flagstore.

* Remove couple of debug messages.

* Handle todos.

* Revert to old String behavior for allFlags, initialize WeakReference in SharedPrefsFlagStore.

* Better implementation of EvaluationReason serialization type adapter.

* Remove isUnknown argument from SummaryEventSharedPreferences methods. Use Runnable instead of Callable in UserManager to avoid useless return nulls. Rename FlagStoreFactoryInterface to FlagStoreFactory.

* Statically initialize Gson instance in GsonCache.

* Make Gson instance in GsonCache final on principle.

* Return json flags as JsonElement in allFlags map. (#106)

* Bump ok-http version to 3.9.1 (#107)

* fix annotations so eval reasons are serialized in events

* fix/expand doc comments for public methods

* typo

* typo

* add version string getter method

* Check for null key before file comparison check. (#110)

* [ch33658] Add unsafeReset() for LDClient testing re-initialization (#111)

Add `unsafeReset()` method to close and clear instances for re-initializing client between tests. Update LDClientTest to call `unsafeReset()` before tests.

* [ch33846] Rename tests to not start with capitals and general refactoring (#112)

* Rename tests to not start with capitals
* Reindent MultiEnvironmentLDClientTest to be consistent
* Optimize imports
* Move TLS patch into TLSUtils
* Make setModernTlsVersionsOnSocket private and remove redundant null check
* Remove code duplication in LDClient track overloaded methods.
* Remove validateParameter in LDClient that was using a NullPointerException as a null test.
* Simplify Debounce to use listener instead of callback.

* Add documentation for flagstore implementation (#113)

* [ch35150] Unit tests and bug fixes (#114)

- Use android test orchestrator to run tests isolated from each other. This prevents the issues testing singletons. Also enabled option to clear package data between runs allowing more extensive flagstore testing.
- Remove unsafe reset as it was added only for allowing testing the LDClient singleton.
- Tests for new FlagStore code.
- Convenience test FlagBuilder
- Fix Migration to not turn all flags into Strings
- Fix issue with clearAndApplyFlagUpdates not generating correct events for listeners.

* Add compatibility behavior to stringVariation and allFlags methods. (#115)

If a Json flag is requested with stringVariation it will serialize it to a String. Json flags will also be serialized to Strings for the map returned by allFlags()

* Update LDUser not to store all fields as Json. (#116)

Add testing rule to setup and teardown Timber trees for debug logging. Add additional LDUser tests. Fixed a bit of flakiness in deletesOlderThanLastFiveStoredUsers test that showed up all of a sudden.

* Add metricValue field to CustomEvent, add overloaded track method for (#118)

creating custom events with metricValues.

* [ch37794] Run connected emulator tests in CircleCI (#120)

* [ch34533] connection status, removing guava, network restructuring. (#117)

* Add ConnectionInformation class.
* Remove all internal uses of Guava.
* Update StreamUpdateProcessor to only debounce ping events.
* Add a connection state monitor to the example app.

* rename repo and package name and apply markdown templates (#121)

* Fix issue that stream could be started before stopping when calling identify. (#122)

* Revert "Fix issue that stream could be started before stopping when calling identify. (#122)"

This reverts commit fdede38.

* Revert "rename repo and package name and apply markdown templates (#121)"

This reverts commit 2215275.

* Revert "Revert "Fix issue that stream could be started before stopping when calling identify. (#122)""

This reverts commit 0849812.

* Revert "Revert "rename repo and package name and apply markdown templates (#121)""

This reverts commit bbbeb81.

* Fix thread leak on identify call from restarting EventProcessor without shutting it down first. (#123)

* Add top level try/catch to migration methods. Check flag version SharedPreferences object for String type before cast. (#124)

* Update Throttler to call runnable on background thread. (#125)

* Fix ConcurrentModificationException of instance map (#126)

Move iteration over client instances for ConnectivityReceiver and PollingUpdater to within LDClient to allow synchronizing on initialization.

* adding a circleci badge to the readme (#127)

* Fix bug where `stop` in StreamUpdateProcessor could not call it's listener when the stream is already closed.

This caused a race condition in repeated stream restarts that could put the SDK in a bad state.

* Change LDAwaitFuture to not treat zero timeout as unlimited timeout

Treating a timeout of zero as unlimited caused a change in behavior when initializing the SDK. This update restores the behavior init had when zero was passed as the timeout argument from pre-2.8.0. Also improves handling of spurious wakeups, and includes test cases for LDAwaitFuture.

* Revert "Merge remote-tracking branch 'remotes/origin/experiment' into next-release"

This reverts commit 3ac167f, reversing
changes made to d26e006.

* CircleCI fixes (#131)

* Better ci fix (#132)

* Speedup tests by building on macOS (#137)

* Background identify fixes (#133)

Add new testing controllers for network and foreground states. For network control, mobile data must be disabled on recent Android versions, updated circleci config to do this. Add new connectivity manager tests. Made EventProcessor and UserManager minimal interfaces for mocking, with actual implementations moved to DefaultEventProcessor and DefaultUserManager. Fixed issue with blocking in background modes.

* Experimentation 1.5 updates (#134)

* add entire compile-time classpath to javadoc classpath

* javadoc fixes: <p/> is not a thing

* do fail on javadoc errors

* add javadoc step, misc CI cleanup

* misc javadoc fixes

* remove unintentional(?) immediate event flush; clean up event tests

* remove unreliable test assumption about elapsed time

* [ch57098] Deprecate LDCountryCode (#141)

Deprecate LDCountryCode class and LDUser setters that take LDCountryCode as an argument.

* Catch `SecurityException` when setting alarm in case there are already (#143)

the maximum allowed number of alarms on Samsung devices.

* Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release
first.

This reverts commit c0e71ae.

* Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patch release"

This reverts commit 23b930f.

* Deprecate public classes (#145)

* Deprecate some unnecessarily public classes, duplicate classes as non-public to
avoid using the deprecated classes.

* [ch61092] Add event payload ID. (#147)

* Add event retry. (#149)

* Fix javadoc comment for release.

* Fix broken merge.

* [ch65133] Deprecate classes (#150)

* Deprecate UserSummaryEventSharedPreferences, SummaryEventSharedPreferences, FeatureFlagFetcher, Util, Debounce.

* Improve Javadoc and reduce interface clutter. (#152)

* Save Javadoc artifact and include logcat in circle output with tee. (#153)

* Save Javadoc artifact on circleci.

* Add step to kill emulator after tests, and tee output of logcat for visibility
during run.

* [ch62120] Background during identify callback (#154)

* Adding more connectivity manager tests.
* Updated internal `Foreground` class to call listeners on a background thread.
* Add some comments explaining the behavior of test controllers.
* Adding fixes for cases where the completion callback may not be called.

* [ch65914] Diagnostic events (#156)

* [ch65352] Expose LDValue rather than Gson types (#158)

* Remove SET_ALARM permission. The comment that this was required for background updating is incorrect, this permission is only for sending broadcasts to an alarm clock application, something we do not do, and should never do. (#159)

* Fix minimum diagnostic recording interval comment. (#160)

* Data since date was not getting reset after each periodic diagnostic event. (#161)

* [ch75315] Add maxCachedUsers configuration option (#162)

Adds maxCachedUsers configuration option for configuring the limit on how many
users have their flags cached locally.

* Configure okhttp cache for polling requests to be stored in a subdirectory of the application cache directory. (#164)

* Fixes ch76614 and add test of null fallback unknown flag event generation. Also some finishing touches to LDValue changes, including LDClientInterface updates, more tests, and improvements to null behavior handling. (#163)

* Removing ldvalue changes before release (#165)

* Revert "[ch65352] Expose LDValue rather than Gson types (#158)"

This reverts commit 1e29a82

* Fixes after revert.

* [ch69437] Support for setting additional headers to be included in requests. (#166)

* [ch89933] Improve resiliency of store for summary events. (#167)

See #105 for the original issue.

* [ch94053] Improve throttler behavior. (#169)

* Add doubleVariation, doubleVariationDetail. (#171)

Deprecates floatVariation, floatVariationDetail.

* Provide pollUri configuration and deprecate baseUri. (#172)

* Fix throttler behavior to ensure attempt count resets are not cancelled (#178)

* [ch98336] Broaden catch statement on scheduling polling alarm (#181)

This is to handle more than just the SecurityException that Samsung throws, as we've gotten an issue report that some devices throw a IllegalStateException instead.

* Removed the guides link

* Include flag key in warning message when converting a json flag to a string (#185)

* (2.x) Prevent NullPointerException when diagnostic processor shut down before starting. (#210)

* Release 2.14.2 (#130)

## [2.14.2] - 2021-06-02
### Fixed
- Added check to prevent `NullPointerException` in `DiagnosticEventProcessor.stopScheduler` when `LDClient.close` is called before the application is foregrounded when the SDK was initialized in the background. ([#127](#127))
- Log message warning that JSON flag was requested as a String has been updated to include the key of the flag requested to assist in discovering which flag is being requested with an unexpected type. ([#116](#116))

* Bump version and update changelog for release.

* Explicitly specify android:exported attribute on manifest receivers. (#211)

* Update java common (#212)

* Flag PendingIntent on new enough platforms as the flag is required on Android S+ (#213)

* Add try for getting network capabilities (#214)

* ch103537 bump java-sdk-common to 1.2 to support inExperiment on eval reason (#215)

* Remove `allowBackup` manifest attribute that can conflict with the application's (#217)

* Update the version to 2.8.9

* Add explicit proguard directives for keeping BroadcastReceivers. (#219)

* Bump Gradle, Android Gradle Plugin, and Dexcount Gradle

* Use the latest 7.1.1 version

* Using the version that still support Java 8 but pin the grgit core behind the scene

* Remove Android Appcompat dependency (#222)

* Bump dependencies and reorganize Gradle file somewhat. (#223)

* Add the null check to prevent multiple allocation of the DiagnosticEventProcessor

* Fix sonatype release plugin (#226)

* Add .ldrelease configuration (#227)

* Add contract test service (#228)

* Fix test service failing on later API versions (#229)

* Add usesCleartextTraffic=true to contract-tests AndroidManifest

This allows the contract tests to work on API level 28 and above

* Fix start-emulator.sh to pick the newest image instead of the oldest

* Refactor CI config into separate jobs with a matrix (#230)

* Don't auto-retry emulator tests (#231)

* Add contract tests for API level 21 (#232)

* Remove unnecessary locking in LDClient (#233)

* Remove `synchronized` keywords from every `LDClient` method

* Treat `instances` as immutable, and swap out the whole map after constructing all the clients

* Use a lock to ensure we don't try to init twice

* Update `ConnectivityManager` so it now manages `DiagnosticEventManager`

* Run contract tests on Android 31, 33 (#234)

* Unsuppress streaming/requests and polling/requests (#236)

* don't create a new executor just to trigger a flush

* remove short publishing timeout, use defaults of 60 retries & 10 seconds

* Serialize null values of `anonymous` as null (#237)

* fix URL path concatenation to avoid double slashes

* fix NPE in edge case where variation is null but value isn't

* use SecureRandom instead of Random, just to make scanners happier

* rm unused

* fix deletion versioning logic, implement tombstones (#244)

* disable contract tests for API 31/33

* use okhttp-eventsource 1.11.3

* ensure timed-out clients get closed in contract tests

* clean up instances map on close (#247)

* clean up instances map on close

* improve atomicity of access to instances, ensure they can't be modified via closed clients

* update more methods that iterate over instances

* rm unnecessary LDClientControl

* use com.launchdarkly.logging with Timber adapter (#235)

* rm unused plugin

* clean up leftover polling alarms

* don't use connection pool/keep-alive for polling requests

* add sub-configuration builder for events

* diagnosticRecordingInterval should also be part of the new builder

* misc fixes

* remove deprecated usages & unused imports

* misc fixes

* revert unnecessary change

* doc comments

* add configuration builders for polling/streaming

* fix polling mode initialization

* fix diagnostic event properties

* fix logic for diagnostic recording interval

* fix tests

* fix defaulting logic

* fix test

* add configuration builder for HTTP

* improve tests

* test cleanup

* fix test

* add configuration builder for service endpoints

* misc fixes

* disable diagnostic events if analytics events are disabled

* deprecations

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* rm duplicated lines

* use regular in-memory storage for summary events (customer-reported performance issue) (#279)

* don't keep summary event counters in SharedPreferences

* don't create a summary event if there's no data

* fix doc comment

* fix @SInCE

* do an initial poll if SDK starts in the background (3.x) (#286)

* add streamEvenInBackground option (3.x) (#287)

Co-authored-by: Gavin Whelan <gwhelan@launchdarkly.com>
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com>
Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com>
Co-authored-by: Elliot <35050275+Apache-HB@users.noreply.github.com>
Co-authored-by: Robert J. Neal <robertjneal@users.noreply.github.com>
Co-authored-by: Louis Chan <lchan@launchdarkly.com>
Co-authored-by: Louis Chan <91093020+louis-launchdarkly@users.noreply.github.com>
Co-authored-by: Alex Engelberg <aengelberg@launchdarkly.com>
Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
  • Loading branch information
11 people committed Dec 23, 2022
1 parent 98afd4b commit c6ec0ac
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.launchdarkly.sdk.android;

import android.net.Uri;

import com.launchdarkly.logging.LDLogger;
import com.launchdarkly.sdk.EvaluationReason;
import com.launchdarkly.sdk.LDUser;
import com.launchdarkly.sdk.LDValue;
Expand Down Expand Up @@ -131,7 +128,6 @@ static final class HttpConfigurationBuilderImpl extends HttpConfigurationBuilder
implements DiagnosticDescription {
@Override
public HttpConfiguration build(ClientContext clientContext) {
LDLogger logger = clientContext.getBaseLogger();
// Build the default headers
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", LDUtil.AUTH_SCHEME + clientContext.getMobileKey());
Expand Down Expand Up @@ -163,7 +159,7 @@ static final class PollingDataSourceBuilderImpl extends PollingDataSourceBuilder
@Override
public DataSource build(ClientContext clientContext) {
return new DataSourceImpl(true, backgroundPollIntervalMillis, 0,
pollIntervalMillis);
pollIntervalMillis, false);
}

@Override
Expand Down Expand Up @@ -200,7 +196,7 @@ static final class StreamingDataSourceBuilderImpl extends StreamingDataSourceBui
@Override
public DataSource build(ClientContext clientContext) {
return new DataSourceImpl(false, backgroundPollIntervalMillis,
initialReconnectDelayMillis, 0);
initialReconnectDelayMillis, 0, streamEvenInBackground);
}

@Override
Expand All @@ -218,17 +214,20 @@ private static final class DataSourceImpl implements DataSource {
private final int backgroundPollIntervalMillis;
private final int initialReconnectDelayMillis;
private final int pollIntervalMillis;
private final boolean streamEvenInBackground;

DataSourceImpl(
boolean streamingDisabled,
int backgroundPollIntervalMillis,
int initialReconnectDelayMillis,
int pollIntervalMillis
int pollIntervalMillis,
boolean streamEvenInBackground
) {
this.streamingDisabled = streamingDisabled;
this.backgroundPollIntervalMillis = backgroundPollIntervalMillis;
this.initialReconnectDelayMillis = initialReconnectDelayMillis;
this.pollIntervalMillis = pollIntervalMillis;
this.streamEvenInBackground = streamEvenInBackground;
}

public boolean isStreamingDisabled() {
Expand All @@ -246,5 +245,9 @@ public int getInitialReconnectDelayMillis() {
public int getPollIntervalMillis() {
return pollIntervalMillis;
}

public boolean isStreamEvenInBackground() {
return streamEvenInBackground;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ class ConnectivityManager {
StandardEndpoints.selectBaseUri(ldConfig.serviceEndpoints.getStreamingBaseUri(),
StandardEndpoints.DEFAULT_STREAMING_BASE_URI, "streaming", logger);

backgroundMode = ldConfig.isDisableBackgroundPolling() ? ConnectionMode.BACKGROUND_DISABLED : ConnectionMode.BACKGROUND_POLLING;
if (ldConfig.isDisableBackgroundPolling()) {
backgroundMode = ConnectionMode.BACKGROUND_DISABLED;
} else {
backgroundMode = dataSourceConfig.isStreamEvenInBackground() ? ConnectionMode.STREAMING :
ConnectionMode.BACKGROUND_POLLING;
}
foregroundMode = dataSourceConfig.isStreamingDisabled() ? ConnectionMode.POLLING : ConnectionMode.STREAMING;

// Currently the background polling interval is owned statically by PollingUpdater, even
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class StreamingDataSourceBuilder implements ComponentConfigurer<

protected int backgroundPollIntervalMillis = LDConfig.DEFAULT_BACKGROUND_POLL_INTERVAL_MILLIS;
protected int initialReconnectDelayMillis = DEFAULT_INITIAL_RECONNECT_DELAY_MILLIS;
protected boolean streamEvenInBackground = false;

/**
* Sets the interval between feature flag updates when the application is running in the background.
Expand Down Expand Up @@ -67,4 +68,24 @@ public StreamingDataSourceBuilder initialReconnectDelayMillis(int initialReconne
initialReconnectDelayMillis;
return this;
}

/**
* Sets whether streaming should be used even if the application is in the background.
* <p>
* By default, this option is false, meaning that if the application is in the background then
* the SDK will turn off the stream connection and use infrequent polling, until the application
* is in the foreground again.
* <p>
* If you set this option to {@code true}, the SDK will continue to use the stream connection
* regardless of foreground/background state. Use this option with caution, since normally it is
* preferable to limit network usage by backgrounded applications.
*
* @param streamEvenInBackground true if streaming should be used even in the background
* @return the builder
* @since 3.4.0
*/
public StreamingDataSourceBuilder streamEvenInBackground(boolean streamEvenInBackground) {
this.streamEvenInBackground = streamEvenInBackground;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,14 @@ public interface DataSource {
* @return the foreground polling interval in milliseconds, or zero if streaming is enabled
*/
int getPollIntervalMillis();

/**
* Returns the option set by
* {@link com.launchdarkly.sdk.android.integrations.StreamingDataSourceBuilder#streamEvenInBackground(boolean)}.
* @return true if streaming mode can continue in the background (if not disabled)
* @since 3.4.0
*/
default boolean isStreamEvenInBackground() {
return false;
}
}

0 comments on commit c6ec0ac

Please sign in to comment.