We've been lately seeing the following stack trace in our developer console, uniquely reported for Huawei devices running Android 10 (Huawei HUAWEI P smart 2019 (HWPOT-H), 2816MB RAM, Android 10 to be precise):
java.lang.IllegalStateException:
at android.os.Parcel.createException (Parcel.java:2079)
at android.os.Parcel.readException (Parcel.java:2039)
at android.os.Parcel.readException (Parcel.java:1987)
at android.os.INetworkManagementService$Stub$Proxy.setUidCleartextNetworkPolicy (INetworkManagementService.java:2754)
at android.os.StrictMode.setVmPolicy (StrictMode.java:1974)
at android.os.StrictMode.initVmDefaults (StrictMode.java:1414)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6923)
at android.app.ActivityThread.access$2200 (ActivityThread.java:292)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2195)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:213)
at android.app.ActivityThread.main (ActivityThread.java:8147)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)
Caused by: android.os.RemoteException:
at com.android.server.NetworkManagementService.applyUidCleartextNetworkPolicy (NetworkManagementService.java:1577)
at com.android.server.NetworkManagementService.setUidCleartextNetworkPolicy (NetworkManagementService.java:1612)
at android.os.INetworkManagementService$Stub.onTransact (INetworkManagementService.java:1319)
at com.android.server.HwNetworkManagementService.onTransact (HwNetworkManagementService.java:886)
at android.os.Binder.execTransactInternal (Binder.java:1028)
I've traced it back - if I understood correctly - to the fact that we are using StrictMode on our app.
val strictModeVMPolicyBuilder = StrictMode.VmPolicy.Builder()
.detectActivityLeaks()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
strictModeVMPolicyBuilder.detectCleartextNetwork()
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
strictModeVMPolicyBuilder.detectContentUriWithoutPermission()
}
StrictMode.setVmPolicy(strictModeVMPolicyBuilder
.penaltyLog()
.build())
What baffles me is that is is causing/reporting an Exception, though I would expect that it would just log the penalty. Is this an OS bug or is there a way to mitigate the issue?
Thanks for the info!