Skip to content

Commit 196a896

Browse files
committed
Version 2.5.4 (#59)
* Polling for flag updates might block the main thread * Outbound HTTP requests now have an authentication scheme token in Authorization request headers * Refactored map synchronization to avoid crashes in apps build with Gradle 3.3.0-alpha11 * Restored support for network connectivity detection in Android 7.0+ devices
1 parent 53ad9ce commit 196a896

File tree

12 files changed

+111
-19
lines changed

12 files changed

+111
-19
lines changed

.circleci/config.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/launchdarkly/android-client-private
5+
docker:
6+
- image: circleci/android:api-27-alpha
7+
environment:
8+
JVM_OPTS: -Xmx3200m
9+
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
10+
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
11+
12+
steps:
13+
- checkout
14+
- restore_cache:
15+
keys:
16+
# This branch if available
17+
- v1-dep-{{ .Branch }}-
18+
# Default branch if not
19+
- v1-dep-master-
20+
# Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
21+
- v1-dep-
22+
23+
- run:
24+
name: Download Dependencies
25+
command: ./gradlew androidDependencies
26+
- run: sudo mkdir -p $CIRCLE_TEST_REPORTS
27+
- run: sudo apt-get -y -qq install awscli
28+
- run: sudo mkdir -p /usr/local/android-sdk-linux/licenses
29+
30+
- save_cache:
31+
key: v1-dep-{{ .Branch }}-{{ epoch }}
32+
paths:
33+
# This is a broad list of cache paths to include many possible development environments
34+
# You can probably delete some of these entries
35+
- vendor/bundle
36+
- ~/virtualenvs
37+
- ~/.m2
38+
- ~/.ivy2
39+
- ~/.bundle
40+
- ~/.go_workspace
41+
- ~/.gradle
42+
- ~/.cache/bower
43+
# These cache paths were specified in the 1.0 config
44+
- /usr/local/android-sdk-linux/platforms/android-26
45+
- /usr/local/android-sdk-linux/build-tools/26.0.2
46+
- /usr/local/android-sdk-linux/platforms/android-27
47+
- /usr/local/android-sdk-linux/build-tools/27.0.3
48+
- /usr/local/android-sdk-linux/extras/android/m2repository
49+
- run: unset ANDROID_NDK_HOME
50+
51+
- run: ./gradlew :launchdarkly-android-client:assembleDebug --console=plain -PdisablePreDex
52+
- run: ./gradlew :launchdarkly-android-client:test --console=plain -PdisablePreDex
53+
54+
- run: ./gradlew packageRelease --console=plain -PdisablePreDex
55+
- run:
56+
name: Run Tests
57+
command: ./gradlew test
58+
59+
- run:
60+
name: Save test results
61+
command: |
62+
mkdir -p ~/tests/test-results
63+
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/tests/test-results/ \;
64+
when: always
65+
- store_test_results:
66+
path: ~/tests
67+
- store_artifacts:
68+
path: ~/tests

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
All notable changes to the LaunchDarkly Android SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
55

6+
## [2.5.4] - 2018-10-25
7+
### Changed
8+
- Outbound HTTP requests now have an authentication scheme token in `Authorization` request headers
9+
10+
### Fixed
11+
- Polling for flag updates might block the main thread
12+
- Refactored map synchronization to avoid crashes in apps build with Gradle 3.3.0-alpha11
13+
- Restored support for network connectivity detection in Android 7.0+ devices
14+
615
## [2.5.3] - 2018-09-27
716
### Fixed
817
- Restored support for initializing `LDClient` on non-main threads

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Check out the included example app, or follow things here:
88
1. Declare this dependency:
99

1010
```
11-
compile 'com.launchdarkly:launchdarkly-android-client:2.5.3'
11+
compile 'com.launchdarkly:launchdarkly-android-client:2.5.4'
1212
```
1313
1. In your application configure and initialize the client:
1414

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
buildscript {
44
repositories {
5-
jcenter()
65
mavenCentral()
76
google()
7+
jcenter()
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.0.1'
@@ -20,9 +20,9 @@ buildscript {
2020

2121
allprojects {
2222
repositories {
23-
jcenter()
2423
mavenCentral()
2524
google()
25+
jcenter()
2626
}
2727
}
2828

@@ -40,4 +40,4 @@ subprojects {
4040
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
4141
}
4242
}
43-
}
43+
}

launchdarkly-android-client/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'io.codearte.nexus-staging'
77

88
allprojects {
99
group = 'com.launchdarkly'
10-
version = '2.5.3'
10+
version = '2.5.4'
1111
sourceCompatibility = 1.7
1212
targetCompatibility = 1.7
1313
}
@@ -96,10 +96,10 @@ repositories {
9696

9797
buildscript {
9898
repositories {
99-
jcenter()
10099
mavenCentral()
101100
mavenLocal()
102101
google()
102+
jcenter()
103103
}
104104
dependencies {
105105
classpath 'org.ajoberstar:gradle-git:1.5.0-rc.1'

launchdarkly-android-client/src/main/java/com/launchdarkly/android/ConnectivityReceiver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
public class ConnectivityReceiver extends BroadcastReceiver {
1212

13+
static final String CONNECTIVITY_CHANGE = "android.net.conn.CONNECTIVITY_CHANGE";
14+
1315
@Override
1416
public void onReceive(Context context, Intent intent) {
1517
if (isInternetConnected(context)) {

launchdarkly-android-client/src/main/java/com/launchdarkly/android/LDClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import android.app.Application;
44
import android.content.Context;
5+
import android.content.IntentFilter;
56
import android.content.SharedPreferences;
7+
import android.os.Build;
68
import android.support.annotation.NonNull;
79

810
import com.google.common.annotations.VisibleForTesting;
@@ -55,6 +57,7 @@ public class LDClient implements LDClientInterface, Closeable {
5557
private final UpdateProcessor updateProcessor;
5658
private final FeatureFlagFetcher fetcher;
5759
private final Throttler throttler;
60+
private ConnectivityReceiver connectivityReceiver;
5861

5962
private volatile boolean isOffline = false;
6063
private volatile boolean isAppForegrounded = true;
@@ -226,6 +229,12 @@ public void run() {
226229
setOnlineStatus();
227230
}
228231
}, RETRY_TIME_MS, MAX_RETRY_TIME_MS);
232+
233+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
234+
connectivityReceiver = new ConnectivityReceiver();
235+
IntentFilter filter = new IntentFilter(ConnectivityReceiver.CONNECTIVITY_CHANGE);
236+
application.registerReceiver(connectivityReceiver, filter);
237+
}
229238
}
230239

231240
/**
@@ -518,6 +527,9 @@ public JsonElement jsonVariation(String flagKey, JsonElement fallback) {
518527
public void close() throws IOException {
519528
updateProcessor.stop();
520529
eventProcessor.close();
530+
if (connectivityReceiver != null && application.get() != null) {
531+
application.get().unregisterReceiver(connectivityReceiver);
532+
}
521533
}
522534

523535
/**

launchdarkly-android-client/src/main/java/com/launchdarkly/android/LDConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class LDConfig {
1717

1818
static final String SHARED_PREFS_BASE_KEY = "LaunchDarkly-";
1919
static final String USER_AGENT_HEADER_VALUE = "AndroidClient/" + BuildConfig.VERSION_NAME;
20+
static final String AUTH_SCHEME = "api_key ";
2021
static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
2122
static final Gson GSON = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
2223

@@ -98,7 +99,7 @@ public LDConfig(String mobileKey,
9899

99100
public Request.Builder getRequestBuilder() {
100101
return new Request.Builder()
101-
.addHeader("Authorization", mobileKey)
102+
.addHeader("Authorization", LDConfig.AUTH_SCHEME + mobileKey)
102103
.addHeader("User-Agent", USER_AGENT_HEADER_VALUE);
103104
}
104105

launchdarkly-android-client/src/main/java/com/launchdarkly/android/PollingUpdater.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ public void onReceive(Context context, Intent intent) {
3131
Timber.e("UserManager singleton was accessed before it was initialized! doing nothing");
3232
return;
3333
}
34-
userManager.updateCurrentUser().get(15, TimeUnit.SECONDS);
34+
userManager.updateCurrentUser();
3535
} else {
3636
Timber.d("onReceive with no internet connection! Skipping fetch.");
3737
}
38-
} catch (InterruptedException | ExecutionException e) {
39-
Timber.e(e, "Exception caught when awaiting update");
40-
} catch (TimeoutException e) {
41-
Timber.e(e, "Feature Flag update timed out");
4238
} catch (LaunchDarklyException e) {
4339
Timber.e(e, "Exception when getting client");
4440
}

launchdarkly-android-client/src/main/java/com/launchdarkly/android/StreamUpdateProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public synchronized ListenableFuture<Void> start() {
5858
stop();
5959
Timber.d("Starting.");
6060
Headers headers = new Headers.Builder()
61-
.add("Authorization", config.getMobileKey())
61+
.add("Authorization", LDConfig.AUTH_SCHEME + config.getMobileKey())
6262
.add("User-Agent", LDConfig.USER_AGENT_HEADER_VALUE)
6363
.add("Accept", "text/event-stream")
6464
.build();

0 commit comments

Comments
 (0)