I'm trying to disable one of Android StrictMode checks - detection of untagged sockets.
I have several reasons to do this:
Some libraries used in our app e.g. Crashlytics / Picasso e.t.c. are using OkHttp internally and StrictMode detects untagged socket problem in OkHttp code (I don't have access to code of third party libraries to fix this problem there)
I need to clear my logs from strict mode untagged socket errors which I can't fix to remove noise for other StrictMode problem detection
To enable VmPolicy We use VmPolicy.Builder.detectAll() method
By looking in sources of StrictMode I've found method VmPolicy.Builder.permitUntaggedSockets but it annotated as @hidden
and can't be used on API = 28
The only solution to this problem I've found is to copy detectAll()
method body to my code and remove call to detectUntaggedSockets()
but it seems to me error prone and weakly maintainable.
May be some one can suggest better solution to described problem?
Any information about "Why permitUntaggedSockets()
became hidden in API 28" are really appreciated.
Crashlytics: Details about StrictMode problem
OkHttp: Bug report about Untagged socket problem
so for your question was:
Any information about "Why permitUntaggedSockets() became hidden in API 28" are really appreciated.
My answer is ( that is a good question ! XD) I think that the StictMode needs at least a good JavaDoc we are not asking too much.
The good news for you is that there is a solution for this problem which is based on a new the 28-API and here is my code snippet: https://gist.github.com/houssemzaier/cf69f9a614f9550408872349e5798e0b
Have a good day!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With