launchdarkly / android-client-sdk

LaunchDarkly Client-side SDK for Android
Other
45 stars 23 forks source link

SecurityException on LDUtil.isInternetConnected check using LD v3.0.0 #129

Closed maxkohne closed 3 years ago

maxkohne commented 3 years ago

Describe the bug

We are receiving reports of crashes from our crash reporting services. This has been happening since we upgraded to v3.0.0 of LaunchDarkly. So far, we have only seen reports from Android 11 users and all happen to be on different models of Samsung Galaxy devices (Galaxy A50, Galaxy A51, Galaxy A52, Galaxy S10, and Galaxy Z Fold2 5G). All crashes happened in the background according to Crashlytics.

To reproduce We cannot reproduce in-house but we are seeing Bugsnag and Crashlytic events for this crash. We do not own any Samsung Galaxy models either.

Expected behavior Don't expect to crash in a background state.

Logs

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4200010 (has extras) } in com.launchdarkly.sdk.android.ConnectivityReceiver@1e98b08
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1676)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(-.java:2)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8512)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by java.lang.SecurityException: Package android does not belong to 10627
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)
       at android.os.Parcel.createException(Parcel.java:2369)
       at android.os.Parcel.readException(Parcel.java:2352)
       at android.os.Parcel.readException(Parcel.java:2294)
       at android.net.IConnectivityManager$Stub$Proxy.getNetworkCapabilities(IConnectivityManager.java:3347)
       at android.net.ConnectivityManager.getNetworkCapabilities(ConnectivityManager.java:1549)
       at com.launchdarkly.sdk.android.LDUtil.isInternetConnected(LDUtil.java:43)
       at com.launchdarkly.sdk.android.ConnectivityReceiver.onReceive(ConnectivityReceiver.java:24)
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1666)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(-.java:2)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8512)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

SDK version v3.0.0

Language version, developer tools Kotlin 1.4.30

OS/platform Android 11

maxkohne commented 3 years ago

Looks like this is a Google issue:

https://issuetracker.google.com/issues/175055271

gwhelanLD commented 3 years ago

Hi @maxkohne,

Thanks for bringing this to our attention. We'll look at whether we can avoid this issue altogether or if we have to resort to simply catching and ignoring this SecurityException. I've filed it internal so we can schedule time to address the issue.

Thanks, @gwhelanLD

barnhill commented 3 years ago

It appears this was deprecated in API 28, could this be the culprit? https://developer.android.com/reference/android/net/ConnectivityManager#CONNECTIVITY_ACTION

ssaxena01 commented 3 years ago

This exception is causing a large volume of crashes for our users on SDK v3.0.0. When do you anticipate a fix for it ? @gwhelanLD

nicbell commented 3 years ago

We are seeing large volumes of this crash too with 3.0.1. Only happening on Android 11 in the background.

adavis commented 3 years ago

Could you all try this same approach to address?

gwhelanLD commented 3 years ago

Closing this issue as it was fixed in the 3.0.2 release.

Thanks, @gwhelanLD