[FIX] Cell standby/mobile radio active time issue

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

  • I am not affected by the MRA.BUG.

    Votes: 21 8.3%
  • The patch works (using a custom ROM).

    Votes: 17 6.7%
  • The patch works (using a Xposed module).

    Votes: 63 25.0%
  • The patch not works (using custom ROM).

    Votes: 10 4.0%
  • The patch not works (using Xposed module).

    Votes: 63 25.0%
  • I want this patch on my ROM.

    Votes: 78 31.0%

  • Total voters
    252
Search This thread

Bazoocaze

Senior Member
Aug 13, 2011
371
857
Porto Alegre
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. :cool:

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

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/showthread.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/xpo...oactivefix-t3189393/post62570773#post62570773


Download: flashable ZIP

- 2015-08-27 v1 (new)
http://www.mediafire.com/download/2f0igf17ixs52zc/cm-12.1-20150827-UNOFFICIAL-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/platform/frameworks/base/+/2ffa11e4b71c545e34533ef827bdc1a07fbe8246

Change that triggered the bug:
-Uncommenting the code that calls notifyInterfaceClassActivity
with fromRadio=true
https://android.googlesource.com/platform/frameworks/base/+/2d4b4ed681efcfb64c4d2b4d2a2d236aae1dc7ee


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/xpo...oactivefix-t3189393/post62570773#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
 
Last edited:

reaper90

Senior Member
May 11, 2011
1,015
406
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
 
  • Like
Reactions: pritamdutt

acwest

Senior Member
Oct 19, 2010
139
29
Toronto, Ontario
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?
 

Bazoocaze

Senior Member
Aug 13, 2011
371
857
Porto Alegre
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.
 

acwest

Senior Member
Oct 19, 2010
139
29
Toronto, Ontario
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.
 

Bazoocaze

Senior Member
Aug 13, 2011
371
857
Porto Alegre
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.
 

Bazoocaze

Senior Member
Aug 13, 2011
371
857
Porto Alegre
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.
 

acwest

Senior Member
Oct 19, 2010
139
29
Toronto, Ontario
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.

This is a good news/bad news situation. Good news, you have found the cause of the high radio active times. Bad news, something is still draining the battery. At least now we have better information...
Excellent work on pathing the issue, by the way...
 

taufiqs

Senior Member
Sep 17, 2012
548
137
So anyone here has made the module for xposed?

Sent from my Oneplus One using Tapatalk

---------- Post added at 12:58 PM ---------- Previous post was at 12:54 PM ----------

@jgcaap would you like to share link for your build that has this patch?

Thanks

Sent from my Oneplus One using Tapatalk
 

marco2012

Senior Member
Sep 7, 2010
313
132
Could anyone make either a xposed module or a flashable zip that we can use on bacon OnePlus One 5.1.1 to fix the mobile radio active issue? Thanks :)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 129
    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. :cool:

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

    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/showthread.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/xpo...oactivefix-t3189393/post62570773#post62570773


    Download: flashable ZIP

    - 2015-08-27 v1 (new)
    http://www.mediafire.com/download/2f0igf17ixs52zc/cm-12.1-20150827-UNOFFICIAL-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/platform/frameworks/base/+/2ffa11e4b71c545e34533ef827bdc1a07fbe8246

    Change that triggered the bug:
    -Uncommenting the code that calls notifyInterfaceClassActivity
    with fromRadio=true
    https://android.googlesource.com/platform/frameworks/base/+/2d4b4ed681efcfb64c4d2b4d2a2d236aae1dc7ee


    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/xpo...oactivefix-t3189393/post62570773#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
    8
    There is absolutely no hard time. ;)

    I just laught on the face of people that think they are smart but don't know how the inner core of Android works nor how to debug the inner core. :cool:

    I do not have the drain on my device (read post #8 and #10), I have only the active time issue, that is now gone on my device thanks to my researching. Unfortunatelly the active time issue is present on ALL androids LP, because it's on the inner core of Android. Regarding the drain, can't debug and fix an issue not present on my device.

    For you that think you are smart, why did you not fixed the LP drain for us (but not for me, because my LP device is now working fine)? After several months there is nothing about that. Oh, I know, you want badly to contribute to xml translations.

    Anyway, this is the nice part on Android: people can contribute where they want, other people test and if it works people will use it. If it not works or people do not want then they will not use it. And if people fells unconfortable people will blame the voluntary contributions.

    Take a lesson on how to help people knowing more about what I am used to contribute fo fix droids: http://forum.xda-developers.com/showthread.php?t=1312398

    PS: 10,340 downloads of the Xposed module. :p
    5
    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

    Done
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone