# CM7 based ROMs not sleeping?



## Jester

I am currently running Liquid 2.4, but have been doing a lot of resource monitoring on this, CM7 (33) and stock. It appears there isn't much difference in power consumption when actively using the phone. However, when the phone is locked there is a sizable difference in the mA draw. On CM7 based ROMs the average amperage draw runs anywhere from 36 - 46mA. One time it dropped to 24mA and other times I've seen in the mid 50s. On stock I have witnessed the amperage draw as low as 8mA. This makes more sense to me and also adds credibility to the general sense many of have that the battery is excessively drained even when not using the phone.

Yesterday I downloaded an app called OS Monitor. I was browsing through the DMesg and noticed things that didn't look right w.r.t. the phone going to sleep (actually not going to sleep!). I really know nothing about kernels and operating systems, but it looks like an issue and want to let the experts know about it. 

Anyway, I did some testing. I would hit my power button to turn the screen off, wait a few minutes and turn it back on and check the log. I found that sometimes tasks refuse to freeze, the sleep process quits and they are restarted. Other times everything seems to be going okay and then something else fails (core_pwrdm). Then it all starts over again. This goes on nonstop when your screen is off. Not only are we not getting the benefit of sleep, we're using resources to cycle the process over and over. Here is a sample of the routine. I should note that I noticed some errors from during the boot sequence that look like they might be in play here too, but I'm not a programmer so I can't say for sure. My hope is that if this appears to be relevant somebody who does know about these things will look into it. I love CM7 and Liquid but the battery life is torturous. 

08/07/2011 09:00:27	[DEBUG] PM: Preparing system for mem slee
08/07/2011 09:00:27	[WARNING] Freezing user space processes ...
08/07/2011 09:00:27	[ERROR] Freezing of tasks aborted after 0.01 seconds (463 tasks refusing to freeze):
08/07/2011 09:00:27	[WARNING] 
08/07/2011 09:00:27	[WARNING] Restarting tasks ... done.
08/07/2011 09:00:27	[INFORMATION] suspend: exit suspend, ret = -16 (2011-08-07 14:00:21.490722635 UTC)
08/07/2011 09:00:28	[INFORMATION] PM: Syncing filesystems ... done.
08/07/2011 09:00:28	[DEBUG] PM: Preparing system for mem slee
08/07/2011 09:00:28	[WARNING] Freezing user space processes ... (elapsed 0.03 seconds) done.
08/07/2011 09:00:28	[WARNING] Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
08/07/2011 09:00:28	[DEBUG] PM: Entering mem sleep
08/07/2011 09:00:28	[WARNING] Suspending console(s) (use no_console_suspend to debug)
08/07/2011 09:00:28	[DEBUG] vfp_pm_save_context: saving vfp state
08/07/2011 09:00:28	[INFORMATION] Powerdomain (core_pwrdm) didn't enter target state 1
08/07/2011 09:00:28	[ERROR] Could not enter target state in pm_suspend
08/07/2011 09:00:28	[INFORMATION] wakeup wake lock: wifi_wake
08/07/2011 09:00:28	[DEBUG] PM: Finishing wakeup.
08/07/2011 09:00:28	[WARNING] Restarting tasks ... done.
08/07/2011 09:00:28	[INFORMATION] suspend: exit suspend, ret = 0 (2011-08-07 14:00:22.971557602 UTC)
08/07/2011 09:00:29	[INFORMATION] PM: Syncing filesystems ... done.
08/07/2011 09:00:29	[DEBUG] PM: Preparing system for mem slee


----------



## x13thangelx

easy solution, use something like SetCPU (the dev posted a free version for registered XDA members) and setup screen off profiles.

Not sure why, but the processor doesnt seem to want to scale back on its own.


----------



## cobjones

@13th..

That only will lower the cpu, it won't put it to sleep.

This must be an animation/screen timeout issue.


----------



## x13thangelx

cobjones said:


> @13th..
> 
> That only will lower the cpu, it won't put it to sleep.
> 
> This must be an animation/screen timeout issue.


Yes i know that but it starts scaling right if you lower it.... Not sure why but it does.


----------



## cobjones

"x13thangelx said:


> Yes i know that but it starts scaling right if you lower it.... Not sure why but it does.


I will try it, I just hope it works better than droid overclock...

It would keep my phone at 300 no matter what..


----------



## x13thangelx

cobjones said:


> I will try it, I just hope it works better than droid overclock...
> 
> It would keep my phone at 300 no matter what..


It hasnt been updated to work with 2.3.5, thats why. SetCPU works still though.


----------



## Jester

Thanks guys. Unfortunately, I'm having no luck. I have tried a sleep profile to 300MHz in both SetCPU and Android Overclock. I also disabled the screen off animation just in case. I even tried it in Airplane mode in case one of the radios were affecting it. It's still happening and it seems there are a number of things that fail to suspend. I am convinced more than ever that this is where the CM7 battery life issue stems from. I'm thinking it may a disconnect because of the 2nd init or that something needs to be modified for the stock moto kernels in the D2/X.

I would run some debug routines on it if I knew how. Nevertheless, I'm confident there are people around here who know enough to figure out.


----------



## cubsfan187

My suggestion is to email/pm your findings to one of the development that work on the 2nd unit roms and see what they say. R2doesinc is one I would try. He's a dev of omgb/omfgb.


----------



## x13thangelx

Jester said:


> Thanks guys. Unfortunately, I'm having no luck. I have tried a sleep profile to 300MHz in both SetCPU and Android Overclock. I also disabled the screen off animation just in case. I even tried it in Airplane mode in case one of the radios were affecting it. It's still happening and it seems there are a number of things that fail to suspend. I am convinced more than ever that this is where the CM7 battery life issue stems from. I'm thinking it may a disconnect because of the 2nd init or that something needs to be modified for the stock moto kernels in the D2/X.
> 
> I would run some debug routines on it if I knew how. Nevertheless, I'm confident there are people around here who know enough to figure out.


Lower the max processor speed 1 slot and let me know if it starts it.... that fixed it on my DPro, not sure about my d2g because CpuSpy doesnt want to cooperate with mine....

Yes, that is where the battery issues are coming from but there isnt a known way to fix it with the stock kernel...


----------



## Jester

I tried lowering it a slot and then even tried at a max of 300MHz all the time. It still didn't work. I also tried changing the governor to userspace in the various scenarios. Thanks again for your help.


----------



## x13thangelx

I got a fix for it..... send me the framework-res.apk from it and i can send you a fixed one.

Theres a 2 thats supposed to be a 4 in power_profiles.xml that makes a huuuuuuge difference. Found it yesterday


----------



## Jester

Awesome news! If this works, you'll be making thousands of 2nd init users very happy. I copied it over to computer, but don't see a way of attaching it here. I'll see if I can PM it to you. May need some instruction on putting back though.


----------



## Jester

I can't send it through it PM either. Is it something I can may be able to edit myself? Also, after I copied it to my sd card I plugged in my usb and it didn't connect to my computer. I tried multiple times, even using the USB Mode app that came with CM7 and Liquid, then rebooted. After reboot my phone's notification and ringtone selections are gone. Did I do something wrong by copying it to my sd card or do you suppose it may be related to the USB thing?


----------



## CBlaze

Good work! Gonna foward this over to jbird and rev. The CM7 D2 maintainers


----------



## phoenixus

Awesome news! Keep us updated on what the devs say!


----------



## ExodusC

I'm pretty sure the Droid 2 Global and many of its ROMs are affected by this too.

I run HeXen on my D2G, and my phone rarely ever sleeps. Processes make lots of partial wake locks (android system even). If that power_profiles fix actually works, I think we need to examine other ROMs too.

Sent from my Droid 2 Global via Tapatalk.


----------



## x13thangelx

CBlaze said:


> Good work! Gonna foward this over to jbird and rev. The CM7 D2 maintainers


Rev already knows.... I talk to him on gtalk all the time....


----------



## x13thangelx

Jester said:


> Awesome news! If this works, you'll be making thousands of 2nd init users very happy. I copied it over to computer, but don't see a way of attaching it here. I'll see if I can PM it to you. May need some instruction on putting back though.


Drop it in a zip or upload to megaupload or something and just send me the link to it.


----------



## x13thangelx

ExodusC said:


> I'm pretty sure the Droid 2 Global and many of its ROMs are affected by this too.
> 
> I run HeXen on my D2G, and my phone rarely ever sleeps. Processes make lots of partial wake locks (android system even). If that power_profiles fix actually works, I think we need to examine other ROMs too.
> 
> Sent from my Droid 2 Global via Tapatalk.


I'll look into it.... atleast Angel and Hexen. Not going to do anything with Hexen though because it gets great battery life and is done until we get a fully working CM (Fenuxx and I both agree'd that there was no point in having another rom with the same problems as all of the ones we have now). Plan on updating Angel one more time to 1.0 anyways, I'll fix it in it.


----------



## UrbanBounca

x13thangelx said:


> Drop it in a zip or upload to megaupload or something and just send me the link to it.


http://www.multiupload.com/RHEBZ1931D


----------



## JBirdVegas

I don't think this will help your battery life as much as you are thinking ... Don't get me wrong it helps but we have been using


Code:


 <!-- Power consumption in suspend -->	<br />
  <item name="cpu.idle">2</item>

In the d2 power_profile.xml (https://github.com/CyanogenMod/andr...works/base/core/res/res/xml/power_profile.xml LINE 48) the whole time and we still get complaints about battery life and the cpu cycling while "sleeping"


----------



## UrbanBounca

x13thangelx said:


> I got a fix for it..... send me the framework-res.apk from it and i can send you a fixed one.
> 
> Theres a 2 thats supposed to be a 4 in power_profiles.xml that makes a huuuuuuge difference. Found it yesterday





JBirdVegas said:


> I don't think this will help your battery life as much as you are thinking ... Don't get me wrong it helps but we have been using
> 
> 
> Code:
> 
> 
> <!-- Power consumption in suspend -->	<br />
> <item name="cpu.idle">2</item>
> 
> In the d2 power_profile.xml (https://github.com/CyanogenMod/andr...works/base/core/res/res/xml/power_profile.xml LINE 48) the whole time and we still get complaints about battery life and the cpu cycling while "sleeping"


You're using a "2", and he said the fix is using a "4". Would that work?


----------



## x13thangelx

UrbanBounca said:


> You're using a "2", and he said the fix is using a "4". Would that work?


It does.... makes the phone start to use Deep Sleep where it wouldnt before....


----------



## UrbanBounca

x13thangelx said:


> It does.... makes the phone start to use Deep Sleep where it wouldnt before....


Can you make the change? I uploaded and linked _framework-res.apk_ on the previous page.


----------



## x13thangelx

http://www.megaupload.com/?d=ZOEYLGT3

Flashable zip for it.

RevNumbers ended up doing it for me. Apk Manager wouldnt compile for me right....

Fixed it.... was causing bootloops because Rev is bad at signing things lol


----------



## UrbanBounca

x13thangelx said:


> http://x13thangelx.synik4l.net/Liquid-sleep.zip
> 
> Flashable zip for it.
> 
> RevNumbers ended up doing it for me. Apk Manager wouldnt compile for me right....


I'll have to try it later tonight. Apparently, data/cache wipe _after_ flashing it will cause a bootloop.


----------



## x13thangelx

UrbanBounca said:


> I'll have to try it later tonight. Apparently, data/cache wipe _after_ flashing it will cause a bootloop.


shouldnt have to wipe, its just the framework-res.apk...


----------



## UrbanBounca

x13thangelx said:


> shouldnt have to wipe, its just the framework-res.apk...


OK, I made that assumption since framework is pretty important.


----------



## cobjones

Is that zip for the D2?


----------



## x13thangelx

cobjones said:


> Is that zip for the D2?


Its for Liquid 2.4 so yea.

Fixed the zip btw, shouldnt cause anymore bootloops


----------



## Jester

x13thangelx said:


> Its for Liquid 2.4 so yea.
> 
> Fixed the zip btw, shouldnt cause anymore bootloops


Wow, progress! Going to try it right now. Hope I do it right.


----------



## aceoyame

So not for D2G?


----------



## Jester

Jester said:


> Wow, progress! Going to try it right now. Hope I do it right.


Bootloop. SBF time.


----------



## Jester

Something's wrong. I sbf'd and it seemed to go the way it should, but when it rebooted I still got the Liquid animation except rolling at hyper speed. After a little bit letting it roll through some cycles I pulled the battery. RSDLite said manually power on the phone so I did all this with the cable connected. When it happened again I pulled the battery and disconnected the cable. Same results: a very fast bootloop of the Liquid animation. I'm trying to sbf again. If anyone is reading and knows of something I might be doing wrong, please let me know.


----------



## x13thangelx

Jester said:


> Something's wrong. I sbf'd and it seemed to go the way it should, but when it rebooted I still got the Liquid animation except rolling at hyper speed. After a little bit letting it roll through some cycles I pulled the battery. RSDLite said manually power on the phone so I did all this with the cable connected. When it happened again I pulled the battery and disconnected the cable. Same results: a very fast bootloop of the Liquid animation. I'm trying to sbf again. If anyone is reading and knows of something I might be doing wrong, please let me know.


Boot into recovery and wipe data....


----------



## x13thangelx

aceoyame said:


> So not for D2G?


Its only for Liquid as that was the one the OP asked about....


----------



## Jester

x13thangelx said:


> Boot into recovery and wipe data....


Okay, so I'm at the part where sbf is 100% executed and it's bootlooping. I just want to confrim what you mean by the above. I should disconnect, pull battery, install battery, arrow+power, then search button, right?


----------



## aceoyame

Oh well shit I just tried the power profiles in a test of my 4.4 rom lol. We shall see if it gets good power management I guess... Any significant difference between this one and the one in the recent nightlies that people said has proper deep sleep?

Edit: It seems to work great! the cpu is scaling properly and goes to deep sleep as soon as the screen is off.


----------



## Jester

It's X+power. doh!


----------



## UrbanBounca

x13thangelx said:


> Its for Liquid 2.4 so yea.
> 
> Fixed the zip btw, shouldnt cause anymore bootloops


I used it on CM7. The _framework-res.apk_ I uploaded was from CM7.


----------



## Jester

Alright, I'm back to last night's nandroid. Thanks for your help. I'm not sure if it bootlooped because of me or the file. I mounted system and cache, then did an install from zip on it.

Anyway, I'm curious about that value (4). Is it defining the amperage draw for power saving mode? Or is it a level, or a value tied to some other setting (that may or may not need to be tweaked)? Is the framework-res the only place where we might find something that affects power management? I read stuff about improperly set alarm functions hosing sleep too.


----------



## Jester

UrbanBounca said:


> I used it on CM7. The _framework-res.apk_ I uploaded was from CM7.


Ah shoot, then you need to try this new file.


----------



## UrbanBounca

I need to straighten everything out. 13th asked for the _framework-res.apk_ in a CM7 thread, so I assumed he wanted the file from CM7, which is what I uploaded. That said, is the file that he corrected supposed to be used on CM7 or Liquid?


----------



## Jester

UrbanBounca said:



> I need to straighten everything out. 13th asked for the _framework-res.apk_ in a CM7 thread, so I assumed he wanted the file from CM7, which is what I uploaded. That said, is the file that he corrected supposed to be used on CM7 or Liquid?


I was going to give him a Liquid one but couldn't figure out how to (until he replied). You sent yours and he tweaked it. Nothing was said whether it was CM7 or Liquid, we just did some _assuming _I guess.


----------



## x13thangelx

UrbanBounca said:


> I need to straighten everything out. 13th asked for the _framework-res.apk_ in a CM7 thread, so I assumed he wanted the file from CM7, which is what I uploaded. That said, is the file that he corrected supposed to be used on CM7 or Liquid?


Should work on any cm based tbh. Was asking for one from Liquid since thats what the OP was complaining about.


----------



## ExodusC

Is there any way you could released a fixed framework file for HeXen, just so we can test it?

Sent from my Droid 2 Global via Tapatalk.


----------



## UrbanBounca

x13thangelx said:


> Should work on any cm based tbh. Was asking for one from Liquid since thats what the OP was complaining about.


That's what I figured, and it's causing FC's on CM7. Can you make changes to a CM7 framework-res.apk?


----------



## aceoyame

Honestly...

I dont like the idea of dropping different frameworks from different roms in. What I did to use the change was go in the apk > res > xml and pulled the power profile xml file out and dropped it in the framework I was using. Worked great.


----------



## cobjones

The fix didn't work for me... I do use the multidock (with screen off though), so that might be a problem.


----------



## x13thangelx

ExodusC said:


> Is there any way you could released a fixed framework file for HeXen, just so we can test it?
> 
> Sent from my Droid 2 Global via Tapatalk.


Hexen and Angel already has it, already checked.... They dont have the 5th slot in the power profiles though so that might be why it wont sleep on 1.2 ghz but will on 1 ghz. I'll check into it for hexen but not going to with Angel because im working on an update for it.


----------



## UrbanBounca

x13thangelx said:


> Hexen and Angel already has it, already checked.... They dont have the 5th slot in the power profiles though so that might be why it wont sleep on 1.2 ghz but will on 1 ghz. I'll check into it for hexen but not going to with Angel because im working on an update for it.


How about a .zip for CM7?


----------



## Jester

Hi x13thangelx,

You're probably aware that Rev included the fix in an unofficial nightly. Here's the message I left in the other thread:

_Thanks Rev. It flashed fine for me, but my initial examination of the log indicates that it still isn't making it into sleep mode. I'll play around tomorrow and try some of x13thangelx's scaling suggestions too. I did notice some errors regarding power management during the boot sequence. I'll look into those too and if I think anything might be useful I'll pass it along._


----------



## ExodusC

Jester said:


> Hi x13thangelx,
> 
> You're probably aware that Rev included the fix in an unofficial nightly. Here's the message I left in the other thread:
> 
> _Thanks Rev. It flashed fine for me, but my initial examination of the log indicates that it still isn't making it into sleep mode. I'll play around tomorrow and try some of x13thangelx's scaling suggestions too. I did notice some errors regarding power management during the boot sequence. I'll look into those too and if I think anything might be useful I'll pass it along._


Well, it's good to hear we're finally rooting out the problem.

It's kind of frustrating when other users are telling you that something is configured wrong on your part and that's why you get terrible battery life... Believe me, I've followed every guide there is.


----------



## Jester

Well, I'm using Rev's special nightly and I've tried a bunch of stuff with scaling and governors but I still can't get the phone to sleep, and the screen off amperage draw remains consistent with earlier CM7 versions I've tried as well as Liquid 2.4. I was going to ask Rev if he would be willing to make one with a cpu.idle value of 10 for me to try (the lowest average amperage draw I viewed with stock was 8mA), but I stumbled upon something else we should pursue first. I looked at the power_profile from a Squidly ROM from way back (pretty much stock with a lot of blur removed) and from Liberty 1.5 by opening it in notepad. Hard to read, but you can make out a lot of the things are the same, however the cpu.idle doesn't appear to have a value assigned to it. I just can't say that for sure because XML in a text viewer doesn't work well. Can someone check it out and compare it to ours? (I d/led a xml reader but it didn't work and added junkware)

Here's the Liberty 1.5 power profile: http://dl.dropbox.com/u/12696835/Liberty_power_profile.zip

Here's CM7's from github: https://github.com/CyanogenMod/andr...works/base/core/res/res/xml/power_profile.xml

I realize the setting in this file is only one of many possible causes, but it seems logical to exhaust this route. I suspect there's a different PM problem associated with wifi sending wake locks but I've been doing all this testing without wifi. Once we can get the system to sleep as it should it should be easier to address wifi.

Thanks


----------



## x13thangelx

Can you send the xml without editing/opening it?

for future reference, you can use either eclipse or jedit (with the xml plugin) to view xml files without it corrupting them.


----------



## Jester

Oh shoot. I didn't know it breaks it. Let me see how I can swing it.


----------



## Jester

I open the Liberty zip with 7-zip, copied the framework-res.apk to my desktop, then added it to a zip. I hope that should keep everything clean. If not instruct me on what to do. In the meantime I'll check out the eclipse thing.

http://dl.dropbox.com/u/12696835/Liberty_framework-res.zip

Thanks!


----------



## Jester

Jester said:


> I open the Liberty zip with 7-zip, copied the framework-res.apk to my desktop, then added it to a zip. I hope that should keep everything clean. If not instruct me on what to do. In the meantime I'll check out the eclipse thing.
> 
> http://dl.dropbox.com/u/12696835/Liberty_framework-res.zip
> 
> Thanks!


Have a chance to look at it yet? I'm afraid I'm too green to be able to use eclipse because it's still got goofy formatting, but I think I found something about it. Looking through the text and little squares, it appears that it may not be that cpu.idle has no value like I thought, but that cpu.idle is set as part of the power array! And the value is 8!


----------



## x13thangelx

Jester said:


> Have a chance to look at it yet? I'm afraid I'm too green to be able to use eclipse because it's still got goofy formatting, but I think I found something about it. Looking through the text and little squares, it appears that it may not be that cpu.idle has no value like I thought, but that cpu.idle is set as part of the power array! And the value is 8!


Have to decompile the apk then go to the xml.... makes it readable. Havent messed with it yet, taking most of the day away from android after i got pissed off with it earlier. I'll look at it tomorrow though.


----------



## iluvamk

i have been following the thread. i'm currently on liquid 2.6. am willing to test fix for that as i am on vacation and currently have nothing better to do then mess around. to all developers working on fix. . .thank you.


----------



## Jester

"x13thangelx said:


> Have to decompile the apk then go to the xml.... makes it readable. Havent messed with it yet, taking most of the day away from android after i got pissed off with it earlier. I'll look at it tomorrow though.


No worries. I know you're going out of your way to help and I appreciate it. Hope I didn't sound pushy. I was just exited about what I think I found.

Sent from my DROID2 using RootzWiki Forums


----------



## x13thangelx

Jester said:


> No worries. I know you're going out of your way to help and I appreciate it. Hope I didn't sound pushy. I was just exited about what I think I found.
> 
> Sent from my DROID2 using RootzWiki Forums


Its cool..... Looked at it, it has it as a 4.


Code:


   <item name="cpu.idle">4</item>


----------



## Jester

Darn it. The special characters must make things change up a lot. Sorry to put you through that. Again, thanks for helping.


----------



## x13thangelx

Jester said:


> Darn it. The special characters must make things change up a lot. Sorry to put you through that. Again, thanks for helping.


Nah, its that you have to decompile it in order to read the files inside it. png's you can still see because they only get compressed as opposed to encoded.

Its cool, took all of 2 minutes when I actually thought to do it.


----------



## iluvamk

flashable fix available?


----------



## x13thangelx

iluvamk said:


> flashable fix available?


for what rom?


----------



## iluvamk

Am on liquid 2.6 now. That or cm7. Can flash to whichever to test. Liquid not sleeping according to cpuspy.


----------



## ram130

Also will it work for CM4DX?


----------



## x13thangelx

iluvamk said:


> Am on liquid 2.6 now. That or cm7. Can flash to whichever to test. Liquid not sleeping according to cpuspy.


For CM7, just use one of RevNumbers unofficial nightlies (they have extra goodies built in also). For liquid, i still need a framework-res.apk to change.


----------



## iluvamk

On its way


----------



## jaydubbs

x13thangelx said:


> For CM7, just use one of RevNumbers unofficial nightlies (they have extra goodies built in also). For liquid, i still need a framework-res.apk to change.


If I send you the Liquid GB framework-res.apk for the DX can you take a look at it and see if you can change the cpu.idle?


----------



## x13thangelx

jaydubbs said:


> If I send you the Liquid GB framework-res.apk for the DX can you take a look at it and see if you can change the cpu.idle?


yes.... not hard to


----------



## phoenixus

I'm currently running official build 37 but I want to test out this battery fix...can I install Revs latest nightly and only wipe cache/dalvik cache? Or do I need to do a full wipe?


----------



## ram130

I got 104% deep sleep about 4hours out of 8 leaving my phone unplugged last night on rev nightlies. Gonna test the official nightlies next. And maybe stock.


----------



## jaydubbs

x13thangelx said:


> yes.... not hard to


I zipped it up and put it on Megaupload: http://www.megaupload.com/?d=94YLIX4A

Thanks for the help!


----------



## SimsDelt

Could you edit the framework I'm attaching with the xml edit... it is CM7 Official Nightly 40... apparently one of the last good builds before things started going haywire.

http://www.mediafire.com/?94lpnd03xcy8ip4

Thanks... also... when your done you could post it back here or pm me the link... I'll check back throughout the day tomorrow. Thanks again so much... if I knew how to do it myself I would.


----------

