Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0.2 #134

Merged
merged 202 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
b87b6ed
Add support for TLS 1.2 on API 16+
farhanjkhan May 8, 2018
2931d51
Add back final keyword
farhanjkhan May 9, 2018
5bab855
Bumping the minSdkVersion from 15 to 16
farhanjkhan May 9, 2018
f853d84
Merge branch 'next-release' into feature/tls_1_2
arun251 Aug 14, 2018
024a75b
Merge pull request #64 from launchdarkly/feature/tls_1_2
arun251 Aug 14, 2018
ff65ca3
Merge branch 'master' into next-release
arun251 Sep 12, 2018
44eed4a
Circle CI 2.0
nejifresh Sep 25, 2018
ba1fe52
Created new branch for multi-environment sdk feature
torchhound Oct 1, 2018
c47d2d5
Stub out new LDConfig and LDConfig.Builder code for multi-environment.
gavwhela Oct 1, 2018
73e4b98
Added overloaded init method in LDClient for creating secondary insta…
torchhound Oct 2, 2018
3962f10
Added getForMobileKey methods
torchhound Oct 2, 2018
c020ff9
Added LDClient init test for secondary environment, added exception t…
torchhound Oct 2, 2018
1956014
Move primary instance into general instances map. Begin on methods ef…
gavwhela Oct 2, 2018
cf10753
Removed incorrect LDClient test
torchhound Oct 2, 2018
a09191d
Fixed 1 failing test in LDClient, added multi-environment test file, …
torchhound Oct 2, 2018
e318b61
Removed unnecessary ListenableFuture in LDClient init, changed identi…
torchhound Oct 2, 2018
0fbe675
Added setOnlineStatus multi-environment changes
torchhound Oct 3, 2018
afe797a
Moved primaryEnvironmentName to LDConfig, simplifying by removing pri…
gavwhela Oct 6, 2018
babd1cd
Add back in constructor without environment to UserManager
gavwhela Oct 6, 2018
33fd8d7
Specialize HttpFeatureFlagFetcher to the environment, looks like User…
gavwhela Oct 6, 2018
eb93b8c
Added SharedPreferences migration strategy
Oct 6, 2018
43ded05
Merged UserManager changes
Oct 6, 2018
b595b6c
All tests pass, fixed migration strategy to conform to spec, fixed pr…
torchhound Oct 8, 2018
e8ac421
Update StreamUpdateProcessor construct to take an environment for the…
gavwhela Oct 9, 2018
441fa93
Fix issue with LDConfig mobileKeys hashmap creation.
gavwhela Oct 9, 2018
f0b68e6
Combine futures so LDClient init future waits on all online instances…
gavwhela Oct 10, 2018
1a039e1
Propagate IOException on closing instances to caller.
gavwhela Oct 10, 2018
baea3ff
Merge futures for identify call.
gavwhela Oct 10, 2018
fc665cf
Some changes from code review.
gavwhela Oct 11, 2018
783375d
Removed static from instanceId and now old SharedPreferences will onl…
Oct 11, 2018
f82c03f
Fixed instanceId
torchhound Oct 11, 2018
be1dd1c
Updates from PR review.
gavwhela Oct 17, 2018
f647f3b
Merge pull request #83 from launchdarkly/circlecimigrate
arun251 Oct 17, 2018
3dbab83
Merge branch 'master' into next-release
arun251 Oct 25, 2018
a8d4b53
Added version and flagVersion, if available
jamesthacker Nov 6, 2018
f2c456e
refactor(LDClient, LDConfig): changes for PR
torchhound Dec 12, 2018
9215b65
refactor(LDClient): changed isInternetConnected behavior for PR
torchhound Dec 12, 2018
5cce5b8
refactor(LDClient): removed async getForMobileKeys and wait seconds v…
torchhound Dec 12, 2018
f2d1343
Bugfix/timber cleanup (#92)
jamesthacker Jan 12, 2019
081ee16
Merge pull request #91 from launchdarkly/bugfix/ping-event-versions
gavwhela Jan 12, 2019
cac1e27
Fix crash when example app is backgrounded twice.
gwhelanLD Jan 14, 2019
ceaa85a
Merge pull request #93 from launchdarkly/bugfix/example-background-crash
torchhound Jan 15, 2019
84569fe
Merge remote-tracking branch 'remotes/origin/multi-environment' into …
gwhelanLD Jan 16, 2019
cd02ea3
Add security provider update mechanism using Google Play Services to
gwhelanLD Jan 22, 2019
6b135f4
Shared Preferences Fix for Multi Environment (#94)
torchhound Jan 22, 2019
55eef13
Fix edge cases in how multi-environment handles connection changes.
gwhelanLD Jan 22, 2019
562fd56
fix(UserManagerTest.java): incorrect number of arguments to UserManag…
Jan 22, 2019
9edb050
Remove line of testing code accidentally left in and refactor shared
gwhelanLD Jan 22, 2019
34c942a
Final fixes to store migration. Should be fairly future proof.
gwhelanLD Jan 22, 2019
fd0560c
Merge branch 'master' into next-release
gwhelanLD Jan 24, 2019
6ca1acd
Merge branch 'master' into next-release
gwhelanLD Jan 24, 2019
3b8faca
Merge branch 'master' into next-release
gwhelanLD Feb 4, 2019
964c5cd
Fix issue with primitive variation calls always returning null if fal…
gwhelanLD Feb 6, 2019
5fcd6b1
Remove CircleCI V1 config file. (#97)
gwhelanLD Feb 6, 2019
1f5eb1f
Remove getting/comparing versions as floats (#99)
gwhelanLD Feb 11, 2019
ae3791a
Include values in unknown summary events and compare values for (#100)
gwhelanLD Feb 11, 2019
a6061cf
simplify flag property deserialization
eli-darkly Feb 12, 2019
21677be
rm debugging
eli-darkly Feb 12, 2019
8d23b67
misc cleanup
eli-darkly Feb 12, 2019
86fb7f9
rm debugging
eli-darkly Feb 12, 2019
dc2d450
add eval reason data model classes
eli-darkly Feb 12, 2019
1b785e9
Merge branch 'next-release' into eb/ch31900/store-query-properties
eli-darkly Feb 12, 2019
2a76698
Merge branch 'eb/ch31900/store-query-properties' into eb/ch31891/eval…
eli-darkly Feb 12, 2019
18a488d
misc fixes
eli-darkly Feb 12, 2019
eb5a98f
serialize reason
eli-darkly Feb 12, 2019
eea98fc
Merge pull request #101 from launchdarkly/eb/ch31900/store-query-prop…
eli-darkly Feb 13, 2019
352eb42
add ability to receive evaluation reasons from LD
eli-darkly Feb 13, 2019
a82e02d
Merge pull request #102 from launchdarkly/eb/ch31891/eval-reasons
eli-darkly Feb 14, 2019
c544f75
Merge pull request #103 from launchdarkly/eb/ch31891/get-reasons
eli-darkly Feb 14, 2019
503cfcb
Changed shared preferences store system to user a single FlagStore
gwhelanLD Feb 14, 2019
213dd47
add methods to get value with explanation; refactor existing variatio…
eli-darkly Feb 15, 2019
bd6ad95
Abstract FlagStoreManager from FlagStore, new FlagStoreFactory class …
gwhelanLD Feb 15, 2019
8460f0c
Handle null case in allFlags, actually commit changes to UserManager.
gwhelanLD Feb 15, 2019
d7e5d64
Merge branch 'gw/ch29266/flagstore' into eb/ch31891/variation-detail
eli-darkly Feb 15, 2019
f565301
Hopefully fix edge cases in summary event reporting to pass testing.
gwhelanLD Feb 15, 2019
0b3d570
Hopefully fix edge cases in summary event reporting to pass testing.
gwhelanLD Feb 16, 2019
709e107
Simplify getFeaturesJsonObject as no longer using -1 as placeholder f…
gwhelanLD Feb 16, 2019
1804437
Make Flag non-mutable. Move GsonCache to gson package, move custom se…
gwhelanLD Feb 19, 2019
261d90c
Send summary event even if stored flag doesn't exist.
gwhelanLD Feb 21, 2019
f4fb467
Move sendSummaryEvent update code to UserSummaryEventSharedPreference…
gwhelanLD Feb 21, 2019
7489890
Update SharedPrefsFlagStore to hold StoreUpdatedListener in weak refe…
gwhelanLD Feb 22, 2019
5766828
Migration code for upcoming flagstore.
gwhelanLD Feb 22, 2019
57f645d
Remove couple of debug messages.
gwhelanLD Feb 22, 2019
aeec638
Handle todos.
gwhelanLD Feb 22, 2019
c654453
Revert to old String behavior for allFlags, initialize WeakReference …
gwhelanLD Feb 22, 2019
19a9401
Merge branch 'gw/ch29266/flagstore' into eb/ch31891/variation-detail
eli-darkly Feb 22, 2019
69c1c9b
Better implementation of EvaluationReason serialization type adapter.
gwhelanLD Feb 26, 2019
23fd36a
Revert "Better implementation of EvaluationReason serialization type
gwhelanLD Feb 26, 2019
becd7e5
Gw/ch29266/flagstore (#105)
gwhelanLD Feb 26, 2019
76f4650
Return json flags as JsonElement in allFlags map. (#106)
gwhelanLD Feb 26, 2019
c246a27
Merge branch 'next-release' into eb/ch31891/variation-detail
eli-darkly Feb 27, 2019
54ac5cf
Bump ok-http version to 3.9.1 (#107)
gwhelanLD Mar 1, 2019
8e36a32
fix annotations so eval reasons are serialized in events
eli-darkly Mar 2, 2019
85a5adf
Merge pull request #104 from launchdarkly/eb/ch31891/variation-detail
eli-darkly Mar 2, 2019
84ecc29
fix/expand doc comments for public methods
eli-darkly Mar 5, 2019
46948c0
typo
eli-darkly Mar 5, 2019
192e4da
typo
eli-darkly Mar 5, 2019
1a7f34b
Merge pull request #108 from launchdarkly/eb/ch33404/doc-comments
eli-darkly Mar 5, 2019
ea73393
add version string getter method
eli-darkly Mar 6, 2019
12fcfe1
Merge pull request #109 from launchdarkly/eb/ch33470/version-getter
eli-darkly Mar 6, 2019
723363d
Check for null key before file comparison check. (#110)
gwhelanLD Mar 8, 2019
2e6a5bf
[ch33658] Add unsafeReset() for LDClient testing re-initialization (#…
gwhelanLD Mar 12, 2019
7ca817e
[ch33846] Rename tests to not start with capitals and general refacto…
gwhelanLD Mar 12, 2019
071bfb5
Add documentation for flagstore implementation (#113)
gwhelanLD Mar 13, 2019
cf593d8
Merge branch 'master' into next-release
eli-darkly Mar 13, 2019
3777e9d
[ch35150] Unit tests and bug fixes (#114)
gwhelanLD Mar 28, 2019
77eff6f
Add compatibility behavior to stringVariation and allFlags methods. (…
gwhelanLD Mar 28, 2019
6606fa9
Merge branch 'master' of github.com:launchdarkly/android-client into …
gwhelanLD Apr 11, 2019
26ac3ee
Update LDUser not to store all fields as Json. (#116)
gwhelanLD Apr 11, 2019
4e76a48
Add metricValue field to CustomEvent, add overloaded track method for…
gwhelanLD Apr 19, 2019
c1e7510
Merge branch 'master' into next-release
gwhelanLD Apr 23, 2019
5cca201
[ch37794] Run connected emulator tests in CircleCI (#120)
gwhelanLD Apr 29, 2019
496fc69
[ch34533] connection status, removing guava, network restructuring. (…
gwhelanLD Apr 29, 2019
2215275
rename repo and package name and apply markdown templates (#121)
bwoskow-ld Apr 30, 2019
fdede38
Fix issue that stream could be started before stopping when calling i…
gwhelanLD May 2, 2019
697d870
Merge branch 'master' into next-release
gwhelanLD May 2, 2019
0849812
Revert "Fix issue that stream could be started before stopping when c…
bwoskow-ld May 3, 2019
bbbeb81
Revert "rename repo and package name and apply markdown templates (#1…
bwoskow-ld May 3, 2019
146ba99
Revert "Revert "Fix issue that stream could be started before stoppin…
bwoskow-ld May 3, 2019
330e2e2
Revert "Revert "rename repo and package name and apply markdown templ…
bwoskow-ld May 3, 2019
f202096
Merge branch 'master' of github.com:launchdarkly/android-client-sdk-p…
bwoskow-ld May 3, 2019
466318b
Merge branch 'master' into next-release
bwoskow-ld May 6, 2019
6f90344
Merge branch 'master' into next-release
bwoskow-ld May 6, 2019
e49b5f8
Fix thread leak on identify call from restarting EventProcessor witho…
gwhelanLD May 14, 2019
2e2e1a1
Merge branch 'master' into next-release
gwhelanLD May 21, 2019
d458246
Add top level try/catch to migration methods. Check flag version Shar…
gwhelanLD May 21, 2019
0f39494
Merge branch 'master' into next-release
gwhelanLD May 22, 2019
b6852af
Update Throttler to call runnable on background thread. (#125)
gwhelanLD Jun 14, 2019
c32e62b
Fix ConcurrentModificationException of instance map (#126)
gwhelanLD Jun 14, 2019
7ea8f8d
Merge branch 'master' into next-release
gwhelanLD Jun 14, 2019
2fb3e78
adding a circleci badge to the readme (#127)
bwoskow-ld Jul 5, 2019
bf50576
Fix bug where `stop` in StreamUpdateProcessor could not call it's lis…
gwhelanLD Jul 29, 2019
75ac7cf
Change LDAwaitFuture to not treat zero timeout as unlimited timeout
gwhelanLD Jul 29, 2019
d26e006
Merge branch 'master' into next-release
gwhelanLD Jul 29, 2019
3ac167f
Merge remote-tracking branch 'remotes/origin/experiment' into next-re…
gwhelanLD Sep 23, 2019
857451d
Revert "Merge remote-tracking branch 'remotes/origin/experiment' into…
gwhelanLD Oct 2, 2019
5088361
CircleCI fixes (#131)
gwhelanLD Oct 3, 2019
de0d059
Better ci fix (#132)
gwhelanLD Oct 7, 2019
56464a1
Speedup tests by building on macOS (#137)
gwhelanLD Oct 16, 2019
b653664
Background identify fixes (#133)
gwhelanLD Oct 16, 2019
6143d48
Experimentation 1.5 updates (#134)
gwhelanLD Oct 25, 2019
c9837e9
add entire compile-time classpath to javadoc classpath
eli-darkly Nov 14, 2019
17aee4a
javadoc fixes: <p/> is not a thing
eli-darkly Nov 14, 2019
05c2bc3
do fail on javadoc errors
eli-darkly Nov 14, 2019
bc68267
add javadoc step, misc CI cleanup
eli-darkly Nov 14, 2019
73e10da
misc javadoc fixes
eli-darkly Nov 14, 2019
8779723
Merge pull request #138 from launchdarkly/eb/ch56106/javadoc
eli-darkly Nov 14, 2019
f90b00d
remove unintentional(?) immediate event flush; clean up event tests
eli-darkly Nov 14, 2019
b1d45b9
remove unreliable test assumption about elapsed time
eli-darkly Nov 14, 2019
d1af310
Merge pull request #139 from launchdarkly/eb/ch56105/event-flush-tests
eli-darkly Nov 14, 2019
c0e71ae
[ch57098] Deprecate LDCountryCode (#141)
gwhelanLD Nov 25, 2019
ea19a16
Catch `SecurityException` when setting alarm in case there are alread…
gwhelanLD Dec 9, 2019
23b930f
Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can do a patc…
gwhelanLD Jan 3, 2020
df8c273
Merge branch 'master' of github.com:launchdarkly/android-client-sdk
gwhelanLD Jan 3, 2020
7dd0e39
Revert "Revert "[ch57098] Deprecate LDCountryCode (#141)" so we can d…
gwhelanLD Jan 3, 2020
8519f7b
Deprecate public classes (#145)
gwhelanLD Jan 10, 2020
b598051
[ch61092] Add event payload ID. (#147)
gwhelanLD Jan 16, 2020
8ac37f0
Add event retry. (#149)
gwhelanLD Jan 24, 2020
c6dbf6f
Merge branch 'next-release'
gwhelanLD Jan 30, 2020
89f6e14
Fix javadoc comment for release.
gwhelanLD Jan 30, 2020
59169e1
Fix broken merge.
gwhelanLD Jan 30, 2020
f8d8da9
Merge branch 'master' of github.com:launchdarkly/android-client-sdk
gwhelanLD Jan 30, 2020
86989e9
[ch65133] Deprecate classes (#150)
gwhelanLD Feb 11, 2020
b99a268
Improve Javadoc and reduce interface clutter. (#152)
gwhelanLD Feb 12, 2020
4082207
Save Javadoc artifact and include logcat in circle output with tee. (…
gwhelanLD Feb 12, 2020
4f50176
[ch62120] Background during identify callback (#154)
gwhelanLD Feb 18, 2020
3de7975
[ch65914] Diagnostic events (#156)
gwhelanLD Feb 28, 2020
059dd08
Merge branch 'master' of github.com:launchdarkly/android-client-sdk
gwhelanLD Feb 28, 2020
1e29a82
[ch65352] Expose LDValue rather than Gson types (#158)
gwhelanLD Mar 13, 2020
b62a377
Remove SET_ALARM permission. The comment that this was required for b…
gwhelanLD Mar 20, 2020
e97a2d1
Fix minimum diagnostic recording interval comment. (#160)
gwhelanLD Mar 20, 2020
dfb8fed
Data since date was not getting reset after each periodic diagnostic …
gwhelanLD Mar 20, 2020
c06c619
[ch75315] Add maxCachedUsers configuration option (#162)
gwhelanLD May 27, 2020
1a49d7e
Configure okhttp cache for polling requests to be stored in a subdire…
gwhelanLD May 28, 2020
b2583c5
Fixes ch76614 and add test of null fallback unknown flag event genera…
gwhelanLD May 28, 2020
60ba2c3
Removing ldvalue changes before release (#165)
gwhelanLD May 29, 2020
644afee
Merge branch 'master' of github.com:launchdarkly/android-client-sdk
gwhelanLD May 29, 2020
c1106f0
[ch69437] Support for setting additional headers to be included in re…
gwhelanLD Aug 5, 2020
15025f5
Merge remote-tracking branch 'public/master' into master
gwhelanLD Aug 7, 2020
7143459
[ch89933] Improve resiliency of store for summary events. (#167)
gwhelanLD Sep 17, 2020
8f32137
[ch94053] Improve throttler behavior. (#169)
gwhelanLD Nov 14, 2020
cebcaec
Add doubleVariation, doubleVariationDetail. (#171)
gwhelanLD Dec 4, 2020
325ac9e
Provide pollUri configuration and deprecate baseUri. (#172)
gwhelanLD Dec 4, 2020
32c5288
Fix throttler behavior to ensure attempt count resets are not cancell…
gwhelanLD Dec 18, 2020
c9ecc2b
Merge remote-tracking branch 'public/master'
gwhelanLD Dec 18, 2020
2567262
[ch98336] Broaden catch statement on scheduling polling alarm (#181)
gwhelanLD Jan 13, 2021
f3a2119
Merge remote-tracking branch 'public/master'
gwhelanLD Jan 14, 2021
202ed86
Removed the guides link
bwoskow-ld Feb 3, 2021
33f56b2
Include flag key in warning message when converting a json flag to a …
apache-hb Feb 23, 2021
aa6ba29
Merge remote-tracking branch 'public/master'
gwhelanLD May 7, 2021
0ffc1ff
Merge remote-tracking branch 'public/2.x' into 2.x
gwhelanLD Jun 2, 2021
505e8d2
(2.x) Prevent NullPointerException when diagnostic processor shut dow…
gwhelanLD Jun 2, 2021
30c10e5
Release 2.14.2 (#130)
gwhelanLD Jun 2, 2021
266099d
Merge remote-tracking branch 'public/2.x' into 2.x
gwhelanLD Jun 2, 2021
ba2aabc
Bump version and update changelog for release.
gwhelanLD Jun 2, 2021
55af88f
Merge branch '2.x'
gwhelanLD Jun 2, 2021
11983c6
Explicitly specify android:exported attribute on manifest receivers. …
gwhelanLD Jun 15, 2021
fbbe20c
Update java common (#212)
gwhelanLD Jun 16, 2021
0a8920f
Merge remote-tracking branch 'public/master'
gwhelanLD Jun 25, 2021
47776a2
Flag PendingIntent on new enough platforms as the flag is required on…
gwhelanLD Jul 14, 2021
393d131
Add try for getting network capabilities (#214)
gwhelanLD Jul 14, 2021
a551bb4
Update version and changelog prior to release.
gwhelanLD Jul 16, 2021
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

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

## [3.0.2] - 2021-07-16
### Fixed
- Catch `SecurityException` when thrown on call to `getNetworkCapabilities` used to detect current network availability. ([#129](https://github.com/launchdarkly/android-client-sdk/issues/129))
- Explicitely flag `PendingIntent`s as `FLAG_IMMUTABLE` on Android SDK versions that support doing so. Explicitly specifying mutability is required when targeting Android S+. ([#133](https://github.com/launchdarkly/android-client-sdk/issues/133))

## [3.0.1] - 2021-06-25
### Fixed
- The Android manifest has been updated to explicitly specify the `android:exported` attribute on declared `receiver` elements. This is to meet [new requirements](https://developer.android.com/about/versions/12/behavior-changes-12#exported) in the upcoming Android 12 release.
Expand Down
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ dependencies {

implementation(project(":launchdarkly-android-client-sdk"))
// Comment the previous line and uncomment this one to depend on the published artifact:
//implementation("com.launchdarkly:launchdarkly-android-client-sdk:3.0.1")
//implementation("com.launchdarkly:launchdarkly-android-client-sdk:3.0.2")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
version=3.0.1
version=3.0.2

sonatypeUsername=
sonatypePassword=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,34 @@ class LDUtil {
* @param context Context for getting the ConnectivityManager
* @return whether device is connected to the internet
*/
@SuppressWarnings("deprecation")
static boolean isInternetConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// TODO: at the point our min version is >= 23 we can remove the old compat code
if (Build.VERSION.SDK_INT >= 23) {
Network net = cm.getActiveNetwork();
if (net == null)
return false;

NetworkCapabilities nwc = cm.getNetworkCapabilities(net);

// the older solution was cleaner but android went and
// deprecated it :^)
// hasTransport(NET_CAPABILITY_INTERNET) always returns false on emulators
// so we check these instead
return nwc != null && (
nwc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|| nwc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
|| nwc.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)
|| nwc.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)
);
} else {
NetworkInfo active = cm.getActiveNetworkInfo();
return active != null && active.isConnectedOrConnecting();
try {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (Build.VERSION.SDK_INT >= 23) {
Network net = cm.getActiveNetwork();
if (net == null)
return false;

NetworkCapabilities nwc = cm.getNetworkCapabilities(net);

// the older solution was cleaner but android went and
// deprecated it :^)
// hasTransport(NET_CAPABILITY_INTERNET) always returns false on emulators
// so we check these instead
return nwc != null && (
nwc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|| nwc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
|| nwc.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)
|| nwc.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)
);
} else {
NetworkInfo active = cm.getActiveNetworkInfo();
return active != null && active.isConnectedOrConnecting();
}
} catch (SecurityException ignored) {
// See https://issuetracker.google.com/issues/175055271
// We should fallback to assuming network is available
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.SystemClock;

import static android.app.PendingIntent.FLAG_IMMUTABLE;

/**
* Used internally by the SDK.
*/
Expand Down Expand Up @@ -58,7 +61,11 @@ private static Intent getAlarmIntent(Context context) {
}

private static PendingIntent getPendingIntent(Context context) {
return PendingIntent.getBroadcast(context, 0, getAlarmIntent(context), 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return PendingIntent.getBroadcast(context, 0, getAlarmIntent(context), FLAG_IMMUTABLE);
} else {
return PendingIntent.getBroadcast(context, 0, getAlarmIntent(context), 0);
}
}

private static AlarmManager getAlarmManager(Context context) {
Expand Down