[Sony Xperia ZL] Bazoocaze:
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://xdaforums.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://xdaforums.com/xposed/modules/xposed-mobileradioactivefix-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://xdaforums.com/xposed/modules/xposed-mobileradioactivefix-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