phansier / FlowReactiveNetwork

Android library listening network connection state and Internet connectivity with Coroutines Flow
Apache License 2.0
95 stars 13 forks source link

Android 11 security exception #10

Open semanticer opened 3 years ago

semanticer commented 3 years ago

We are getting this exception from Android 11 users on a regular basis:

Caused by java.lang.SecurityException: Package android does not belong to 10273
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2376)
       at android.os.Parcel.createException(Parcel.java:2360)
       at android.os.Parcel.readException(Parcel.java:2343)
       at android.os.Parcel.readException(Parcel.java:2285)
       at android.net.IConnectivityManager$Stub$Proxy.listenForNetwork(IConnectivityManager.java:3609)
       at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:3710)
       at android.net.ConnectivityManager.registerNetworkCallback(ConnectivityManager.java:4104)
       at android.net.ConnectivityManager.registerNetworkCallback(ConnectivityManager.java:4074)
       at ru.beryukhov.reactivenetwork.network.observing.strategy.MarshmallowNetworkObservingStrategy.observeNetworkConnectivity(MarshmallowNetworkObservingStrategy.kt:49)
       at ru.beryukhov.reactivenetwork.ReactiveNetwork.observeNetworkConnectivity(ReactiveNetwork.kt:64)
       at ru.beryukhov.reactivenetwork.ReactiveNetwork.observeNetworkConnectivity(ReactiveNetwork.kt:43)

This seems to be caused by an issue introduced in Android 11 by google https://issuetracker.google.com/issues/175055271

I know it's not this library's fault but it would be helpful if you'd add some catch mechanism to mitigate this issue.

Thanks for your great work 👍

phansier commented 3 years ago

@semanticer Thanks for the submission. Could you suggest a Pull request with a needed catch mechanism? I will do my best to publish a new version of the library after.