This is happening me in a Xiaomi device, at least in emulator does not happen.
To be more clear what's happening is the following:
I need that battery optimization disabled to properly run some services from my app.
But without changing configuration what happens is that I get the dialog to warns about battery not being disabled and the need to use it when I start app again, as it had been enabled again.
I don't care much if this is due to personalization layer in the phone and it's usually working on other devices, as I cannot hope to make the app work 100% in any phone terminal, but it would be a problem if battery optimization is enabled again without warning in most devices.
Is there any way to avoid that automatic battery optimization enabling? Or, at the very least, does this usually happen just in a few devices with that API?