AndroidLeakFixes.FLUSH_HANDLER_THREADS cause IdleHandler runs every second
Description
I implemented a IdleHandler to do someting for my HandlerThread, but I see the IdleHandler runs every second. According to the code in AndroidLeakFixes.FLUSH_HANDLER_THREADS, it adds an IdleHandler and postDelayed({}, 1000), so that cause my IdleHandler to be executed per second, is it a potential bug? If it is an intended behavior, how to stop it from affecting my logic ? I don't want to execute my IdleHandler every second.
See the doc here: https://github.com/square/leakcanary/blob/02d0d8b6ebfe8de55c109b904d7b526063f3f852/plumber/plumber-android-core/src/main/java/leakcanary/AndroidLeakFixes.kt#L142-L148
The core issue is that any idle Handler thread will keep a strong reference to the last message that ran, but that message will also be recycled, then accidentally used by a dialog to store some OnClickListener in its callback field, and that field will not be cleared after the dialog is destroyed, so the idle handler will end up keeping a strong reference to on click listeners of destroyed dialogs.
I haven't found any better fix than making sure HandlerThreads aren't ever idle for too long.