FORUMS
Remove All Ads from XDA

 View Poll Results: This patch fixes the high "cell standby mobile radio active time" (MRA.BUG)?

I am not affected by the MRA.BUG.
 
22 Vote(s)
8.66%
The patch works (using a custom ROM).
 
17 Vote(s)
6.69%
The patch works (using a Xposed module).
 
64 Vote(s)
25.20%
The patch not works (using custom ROM).
 
10 Vote(s)
3.94%
The patch not works (using Xposed module).
 
63 Vote(s)
24.80%
I want this patch on my ROM.
 
78 Vote(s)
30.71%

[FIX] Cell standby/mobile radio active time issue

371 posts
Thanks Meter: 863
 
By Bazoocaze, Senior Member on 27th August 2015, 11:25 PM
Post Reply Email Thread
Introduction

If you think there is a drain in Lollipop this is not that fix. This fix the "high cell standby mobile radio active time" bug. You can still test this if you want.

Some people are writing that this patch "only" fix the battery radio active time counter. I say that if you know java and take a look on the code you will note that the side effects of this bug includes, among others, not calling various NetworkManagementEvent observers that will have role in other modules of the inner core of Android, and not only the battery stats. So you say me what are the other side effects fixed.

Other people are saying that this patch doesnt fix the "cell standy radio active time" bug, so take your chances, or wait until Marshmallow .

If after the patch you see a "miscellaneous" item in the battery stats, I am sorry for you but this indicates a bug in your RIL module (or other module) which this patch not solve. The bug in the RIL module was only masked by the Lollipop radio active time bug.


Hi,

I'm working on a fix to the Cell standby / Mobile radio active time issue. The bug manifests as a high mobile radio active time on the Cell Standby in the battery stats.

I think I found the bug in the inner core of Android, and I made some fix to test if it works.

In this thread you will find a Cyanogenmod 12.1 (Android 5.1) build for Odin/Xperia ZL with the fix applied. I already flashed this build onto my odin device and the bug seems to be fixed.

So now I want some of you to test this build and see if the bug is definitely gone.


NOTES

- Your device must have bootloader unlocked.
- CyanogenMod and my work comes with NO WARRANTY as usual. Don't blame me for anything you think I deserve.
- This is my other work on fixing droids: http://forum.xda-developers.com/show....php?t=1312398


Patches

I submitted the fix patches to AOSP/Google and CM.

https://android-review.googlesource.com/#/c/168231/
http://review.cyanogenmod.org/#/c/107828/


FAQ

How to install
-Make a backup (using recovery or your preferred tool)
-Download .zip and copy to the phone external sd card
-Boot into recovery (TWRP recommended)
-Install zip cm-12.1-20150827-UNOFFICIAL-odin.zip
-Wipe dalvik/cache
-If you was not on CM12.1 before then Wipe Data
-Reboot
-Wait Android installing apps

How to test
-Enable mobile data (with wifi off)
-Use mobile data (now the bug was triggered)
-Disable mobile data
-Use your device normally and then some hours later look for the mobile radio active time on the battery stats.
-On normal circumstances the display should be the bigger drain. The bug manifests as the Cell Standby being the bigger drain with a high mobile radio active time.
-Please report in this thread if it works or not for you. Thank you!

Can I have a Xposed module of this
- Yes. Thanks to @pyler
http://forum.xda-developers.com/xpos...3#post62570773


Download: flashable ZIP

- 2015-08-27 v1 (new)
http://www.mediafire.com/download/2f...ICIAL-odin.zip
MD5: 3c3641ad6738fad953a90a5d3e745f75


Info about the patches

How to reproduce the bug:
-Enable mobile data (with wifi off)
-Use some mobile data (radio active timer starts in battery stats)
-Disable mobile data (radio active timer keeps running in battery stats)

After some investigation on the issue I found that the BatteryStats
service was not receiving the radio power down notification. The
investigation lead me to the NetworkManagementService.java, where
I found that some code was discarding the radio power change
notifications after the first radio power on.

The problem is that in NetworkManagementServer.java the
notifyInterfaceClassActivity method is discarding the notifications
of radio power change to the BatteryStats (via noteMobileRadioPowerState)
if the fromRadio parameter is false after it's being true some time before.

Even after a detailed analysis, it was unclear what is the real role of
the fromRadio parameter. Changing it to true in the calling methods
solved the issue in the testing unit (Sony Xperia ZL).


Change that introduced the code with the potential to trigger the bug:
-Introduction of "boolean fromRadio" in
NetworkManagementService.java / notifyInterfaceClassActivity()
https://android.googlesource.com/pla...bdc1a07fbe8246

Change that triggered the bug:
-Uncommenting the code that calls notifyInterfaceClassActivity
with fromRadio=true
https://android.googlesource.com/pla...2d236aae1dc7ee


Instructions on how to make an Xposed Module from this patch

XDA member pyler is working on a Xposed module to apply thish patch:
http://forum.xda-developers.com/xpos...3#post62570773

---

You can use and Xposed module to apply this fix on-the-fly. If you decide to make an Xposed module from this patch, please credit my work and put a link to this thread.

How to do:
- on package com.android.server class NetworkManagementService (NetworkManagementService.java)
- verify if the method assinature for notifyInterfaceClassActivity method is correct (have the fromRadio parameter)
- intercept the call for the notifyInterfaceClassActivity method
- change the value of the fromRadio parameter to true
- and then call the original method

package com.android.server
class NetworkManagementService
private void notifyInterfaceClassActivity(int type, int powerState, long tsNanos, boolean fromRadio)


For devs

- CyanogenMod: you can repopick the patch 107828 before building.
- Other ROMS: apply the patch manually, it's tiny. The project is frameworks_base.
- There is no APK alone that solves this, only the xposed module.


Supporters

Unexpected but not least important, the following people appreciated my work and made ​​a donation or special thanks:

phoneturf
The Following 130 Users Say Thank You to Bazoocaze For This Useful Post: [ View ] Gift Bazoocaze Ad-Free
 
 
28th August 2015, 01:21 PM |#2  
OP Senior Member
Flag Porto Alegre
Thanks Meter: 863
 
Donate to Me
More
I submitted the fix patches to AOSP/Google and CM.

https://android-review.googlesource.com/#/c/168231/
http://review.cyanogenmod.org/#/c/107828/
The Following 25 Users Say Thank You to Bazoocaze For This Useful Post: [ View ] Gift Bazoocaze Ad-Free
28th August 2015, 02:43 PM |#3  
jgcaap's Avatar
Senior Member
Flag Porto
Thanks Meter: 19,270
 
Donate to Me
More
good work! finally a patch
The Following User Says Thank You to jgcaap For This Useful Post: [ View ] Gift jgcaap Ad-Free
28th August 2015, 02:56 PM |#4  
Senior Member
Thanks Meter: 1,440
 
More
Sounds Awesome!!! @jgcaap Could you please spin a build with this patch and let us all know if it fixed it on bacon as well?
@YoshiShaPow @kantjer @fusionjack @temasek
28th August 2015, 03:48 PM |#5  
Senior Member
Thanks Meter: 119
 
More
This is what Android has become, the bug second most stared on their tracker is fixed by volunteers on XDA.
In general that does not make me very happy, but the work you did for them is awesome, thank you!
The Following 4 Users Say Thank You to user822 For This Useful Post: [ View ] Gift user822 Ad-Free
28th August 2015, 04:48 PM |#6  
Senior Member
Thanks Meter: 438
 
More
I'm a little confused now... Does this really fix the battery drain or is it just a fix for false measurement in batterystats? Because battery life on mobile data is much worse than on wifi for me since Android 5/5.1
The Following User Says Thank You to reaper90 For This Useful Post: [ View ] Gift reaper90 Ad-Free
28th August 2015, 04:53 PM |#7  
Senior Member
Flag Toronto, Ontario
Thanks Meter: 28
 
More
It appears from your patch that this is only a reporting issue in the battery stats, and that the mobile radio IS being shut down, it just isn't being reported properly. If this is the case, do you have any idea why the battery performance in Lollipop is som much worse than KitKat?
28th August 2015, 05:10 PM |#8  
OP Senior Member
Flag Porto Alegre
Thanks Meter: 863
 
Donate to Me
More
Quote:
Originally Posted by acwest

It appears from your patch that this is only a reporting issue in the battery stats, and that the mobile radio IS being shut down, it just isn't being reported properly. If this is the case, do you have any idea why the battery performance in Lollipop is som much worse than KitKat?

Yes. In my device the radio IS being shut down properly. But in fact the code is a mess and I think there are many other bugs in the networking module.

I was on stock Kitkat and now I'm getting the same battery duration on CM12.1 (4h display on + 30m GPS/3G). Need more tests to detect more issues.

Anyway, I found another issue that I want to investigate that is the mobile data radio being activated and deactivated for a few seconds every time the wifi is connected.
The Following 3 Users Say Thank You to Bazoocaze For This Useful Post: [ View ] Gift Bazoocaze Ad-Free
28th August 2015, 05:16 PM |#9  
Senior Member
Flag Toronto, Ontario
Thanks Meter: 28
 
More
Quote:
Originally Posted by Bazoocaze

Yes. In my device the radio IS being shut down properly. But in fact the code is a mess and I think there are many other bugs in the networking module.

I was on stock Kitkat and now I'm getting the same battery duration on CM12.1 (4h display on + 30m GPS/3G). Need more tests to detect more issues.

Anyway, I found another issue that I want to investigate that is the mobile data radio being activated and deactivated for a few seconds every time the wifi is connected.

Interesting. I was beginning to suspect that the Radio active time being displayed was a reporting issue, if the radio was really turned on as much as it claims, I think battery life would be much worse. Your patch is useful in that I now have a good idea of where to add logging statements to try see if there ARE issues with the actual radio active time.
28th August 2015, 05:16 PM |#10  
OP Senior Member
Flag Porto Alegre
Thanks Meter: 863
 
Donate to Me
More
Quote:
Originally Posted by reaper90

I'm a little confused now... Does this really fix the battery drain or is it just a fix for false measurement in batterystats? Because battery life on mobile data is much worse than on wifi for me since Android 5/5.1

I do not know for sure. This will only solve the "mobile radio active time" issue on my device, where there is not a drain, but only the false measurement.
But if there is a problem in the RIL module of your device this patch will not solve the drain.
The Following 3 Users Say Thank You to Bazoocaze For This Useful Post: [ View ] Gift Bazoocaze Ad-Free
28th August 2015, 05:19 PM |#11  
OP Senior Member
Flag Porto Alegre
Thanks Meter: 863
 
Donate to Me
More
Quote:
Originally Posted by acwest

Interesting. I was beginning to suspect that the Radio active time being displayed was a reporting issue, if the radio was really turned on as much as it claims, I think battery life would be much worse. Your patch is useful in that I now have a good idea of where to add logging statements to try see if there ARE issues with the actual radio active time.

You ARE CORRECT.

I concluded the same when I put the decice in ariplane mode for several hours: the battery percent was the same at the end, but the mobile radio active counter keeps running for several hours, indicanting that the radio was turned of properly (same battery percent) but the timer keeps running.
The Following 2 Users Say Thank You to Bazoocaze For This Useful Post: [ View ] Gift Bazoocaze Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes