Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. [B]There is no "Misc. bug" or "Wi-Fi Bug" related to Misc.[/B]
  2.  
  3. It's really simple and basic and is in no way "drain". All your battery stats are guessed calculations. They're never accurate. They never have been and never will be.
  4.  
  5. [B]How battery stats work[/B]
  6.  
  7. The battery stats UI shows the percentage of battery that device elements are responsible for using, which is based on a couple of things:
  8.  
  9. 1. /data/system/batterystats.bin
  10. 2. /system/frameworks/frameworks-res.apk/res/xml/power_profile.xml
  11.  
  12. These things contribute in the following way:
  13.  
  14. 1. From the moment Android detects that a close-to-full charge has completed (around 95%), batterystats.bin records how long the device elements are running
  15. 2. This xml file is where the information about how much power each device element “uses”
  16.  
  17. The battery stats UI looks at batterystats.bin to see how long each element has been running (and in what state) since the last charge, applies the value (in mV) for each element stored in power_profiles.xml and comes up with a calculation of the % of battery each element is using.
  18.  
  19. It simply calculates the total mV used by adding up all the element values and the time in state to work out the percentages.
  20.  
  21. Here is a really basic example…
  22.  
  23. [B]power_profile.xml from the Nexus 5[/B]
  24. [code]
  25. <item name="none">0</item>
  26. <item name="screen.on">82.75</item>
  27. <item name="screen.full">201.16</item>
  28. <item name="bluetooth.active">51.55</item>z
  29. <item name="bluetooth.on">0.79</item>
  30. <item name="wifi.on">3.5</item>
  31. <item name="wifi.active">73.24</item>
  32. <item name="wifi.scan">75.48</item>
  33. <item name="dsp.audio">0.1</item>
  34. <item name="dsp.video">0.1</item>
  35. <item name="gps.on">76.23</item>
  36. <item name="radio.active">185.19</item>
  37. <item name="radio.scanning">99.2</item>
  38. [/code]
  39.  
  40. [B]batterystats.bin[/B]
  41. [code]
  42. screen.on = 2 h
  43. bluetooth.active = 3 h
  44. bluetooth.on = 7 h
  45. wifi.on = 6 h
  46. wifi.active = 4 h
  47. [/code]
  48.  
  49. [B]So, if..;[/B]
  50. [code]
  51. screen.on = 165.5
  52. bluetooth.active = 154.65
  53. bluetooth.on = 5.53
  54. wifi.on = 21
  55. wifi.active = 292.96
  56. Total = 639.64
  57. [/code]
  58.  
  59. [B]Then..; [/B]
  60. [code]
  61. screen.on = 26%
  62. bluetooth.active = 24%
  63. bluetooth.on = 1%
  64. wifi.on = 3%
  65. wifi.active = 46%
  66. Total = 100%
  67. [/code]
  68.  
  69.  
  70. That was a basic example of how the battery stats UI makes it’s calculations. Notice how the total is 100%? Well in KK and earlier this was the case. The battery stats UI calculated up to 100%. So even if you had only used 50% of your battery, it would show that device elements had used 100% of your 50% used battery.
  71.  
  72. This meant that as it always had to add up to 100%, it didn't have to be particularly accurate. It takes the values and calculations it knows about and works the portion of that 100% each known value has taken. It knows that 639.64 is 100% therefore Wi-Fi at 292.96 must be 46%....
  73.  
  74. Since Lollipop, it has changed and makes it more difficult for battery stats UI to be so blase about its accuracy. Now it attempts to show you what "actual" percentage of battery has been used. For example, if 50% of your battery has been used, the total of percentage used by device elements will also show as 50%. However, now that the total % of elements might not match the total % of battery used, it is much harder to hide how inaccurate battery stats actually are.
  75.  
  76. [B]Why are they never accurate?[/B]
  77.  
  78. Looking at the power_profile.xml file, you'll see for example, Wi-Fi - there is an "on" value and an "active" value. There are just 2 states. However, what if your router is in your living room and you are in the bedroom? Wi-Fi Active may not be 76.23 at all. Due to a weak signal, it may be 150... But battery stats is not aware that it may be using 150... So it calculates using 76.23.
  79.  
  80. This is where it gets a little more complicated. Lets go back to these calculations, but factor in the new 150 value for bedroom Wi-Fi active;
  81.  
  82. [B]batterystats.bin[/B]
  83. [code]
  84. screen.on = 2 h
  85. bluetooth.active = 3 h
  86. bluetooth.on = 7 h
  87. wifi.on = 6 h
  88. wifi.active = 2 h
  89. wifi.active.InBedroom = 2 h
  90. [/code]
  91.  
  92. [B]So, if..;[/B]
  93. [code]
  94. screen.on = 165.5
  95. bluetooth.active = 154.65
  96. bluetooth.on = 5.53
  97. wifi.on = 21
  98. wifi.active = 152.46
  99. wifi.active.InBedroom = 300
  100. Total = 799.14
  101. [/code]
  102.  
  103. So that is what ACTUALLY happened. But battery stats wouldn't know.. because the power_profile.xml does not have the InBedroom entry at all. So battery stats shows that a total 639.64 of battery has been used, however the physical battery reports that 799.14 has been used. Well, since Lollipop, that discrepancy has to be accounted for to make the battery stats appear more accurate, so the 159.50 difference that is unaccounted for, now will appear as "Miscellaneous". This is not just the case with Wi-Fi, but with everything from screen brightness, to bluetooth to cell reception.
  104.  
  105. [B]Why does Misc. show on some roms and not others?[/B]
  106.  
  107. You may remember a while back that people were reporting the Wi-Fi bug to Google.. Well, simply - they probably got fed up and hid Misc. in stock ROMs. No stock ROMs on the Nexus 5 show Misc. anymore. They just have calculations that no longer add up in total to the amount of % used of your battery.
  108.  
  109. Some people have accused Google of "hiding" the "bug". What we're saying is that there is NO BUG and they hid Misc., which is what caused people to think there was a bug in the first place.
  110.  
  111. The Misc. battery report is still in AOSP code, hidden. However, some roms have provided an option to show Misc. (usually disabled by default), such as SlimRoms for example. Some ROMs have it shown without an option to disable it.
  112.  
  113. You can see their changes here:
  114.  
  115. From Google, the commit that hid Misc.: [url]https://github.com/SlimRoms/packages_apps_Settings/commit/e6793771cedb47aed72f1c64f870b70357746938[/url]
  116. Custom ROM feature for an option to show Misc.: [url]https://github.com/SimpleAOSP-Lollipop/platform_packages_apps_Settings/commit/d025994f90722139dfcf236f275e05236ec47491[/url]
  117.  
  118.  
  119. [b]Summary[/b]
  120.  
  121. There is no such thing as a "Misc. bug" or "Wi-Fi bug". Android attempts to calculate the amount of battery used by each device element, based on a very finite list of values. Since the values are pre-determined in a file, it is not an accurate refelection of reality. When these values in reality are higher than the file, it makes the battery stats show a lower % than reality being used by the elements (most easily seen in Wi-Fi). To make the elements total match the actual % used from the battery, Misc. was created to fill in that discrepancy - However, since people thought it was a bug due to lack of understanding, it has since been hidden.
  122.  
  123. It is NOT a bug.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement