I think this is impossible to do.
As @dain shows, you can tray and measure historical data and do optimization on them, but since there are all kinds of background processes (low connection strength means a lot of searching, Wi-Fi or not, data in the background, new applications, you name it) influence this, so itβs hard to be accurate based on the data collected.
Perhaps you can target certain processes (for example, calling or using a specific application, such as a music player), and check how much energy they use on average, and move from there.
What permission do you use, I think, because of the difference in all the data, you will get some kind of average from this, which would probably be incorrect for the current situation. Perhaps you will be able to "minimum" time "maximum" for activity?
Nanne source share