• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Does anybody know what part defines the shutdown when the battery gets low?

dsmryder

Android Expert
I know this may be too general, but I plan on changing our ROMs to benefit from this first. What I want to do is place a 5second wait when the battery gets too low. As some of you probably have seen, sometimes when you use the phone from a low drain state, then go to a high drain state (like wip it out to take a picture with the flash) the sudden load causes the phone to go into emergency shutdown. I just want to give the phone enough time to save the whole picture. I've had it happen one other time, but I can't remember what I was doing.

What I have found so far is the kernel uses power.c. I have no idea how it works yet, but I'll look into it later (I don't know C)

I hope someone can shortcut me to the answer. It would help the whole MT community.
 
The first thing I would do is integrate all the camera stuff from the kernel I have been working on, I have a suspicion that may be the problem. As a matter of fact, I'll do it today and send you a PM with the new kernel. I haven't had this happen, I have only really seen posts with this happening with the camera, not much out there that this happens any other time. When I saw those posts it made me think 2 things, charging the flash or battery has a bad cell, or both. And, the kernel has lines for .preflash_light and .torch_light. Don't know if it will help, but since the kernel is fresh in my head it should only take a minute to put together. Nothing too experimental, I'll just do the camera and maybe the touch drivers. I'll look at the power thing when I'm there, and see what I can do.
 
I sent you a PM with the link to the modified kernel. I updated the touchscreen, camera and hdmi, along with a few minor changes, and built with a modified Sharp defconfig to include anything that was in the original. So there is added support for file systems and more debugging. If you don't mind, I'll post the kernel so people with this problem can test it out.

EDIT: I can't remember off the top of my head what the exact issue was but switching from back to front cam has no issues that I can see and no auto focus click.

EDIT 2: I may also be able to fix the wifi BT sleep issues also after looking at the source.
 
I found some links that should be helpful and it seems it may be a system setting and does not have to do with the kernel.

Hints:
a few post about this happening on a different phone
http://forum.xda-developers.com/showthread.php?t=873759
where it may be located
http://forum.xda-developers.com/showthread.php?t=1234738

Basic Android power management details, battery last few pages:
Android power management

Yeah I've seen that before, but I didn't look closely enough. I found the shutdown manager (ShutdownThread.java) and I think I could do the delay here, but that would be global. It also has the list of imports that might prove useful. As always I have a ton of shtuff to do so I am going to come back to this maybe tomorrow. I think I'll make the branch tonight and see if I can remember how to initiate a wait state. I wonder if it will be different sence it's java instead of android (I know android uses the java language, but they use their own libraries).

EDIT: Like I said, I need to look into this further. I just found the battery service. I think this is specificly where I want to mess around
 
Speaking on the battery I had an interesting experience with the battery life on my replacement phone running CM7.It was draining at 2% per minute til I hit about 80%.When I got to the 70%ish mark my phone turned off saying 0% battery.I tried turning it back on still 0% battery.When I waited like 2 minutes it was at 67% battery life.It worked normally til about 40%ish when it turned off again.I waited and again it turned on but at around 20% battery life.For like 3 days I was having these problems.I also saw while charging the battery while the phone was off it was saying it was fully charged when it was no way it could be.It would go from 0% charge to 100% while off in like 20 minutes.I would have to unplug and let it set for like 10 minutes then it would charge back normally.I have screenshots I will post when I get the chance.It's very interesting.Also this happened using 2 different batteries.One being a replacement battery the other a new battery.....both had same issues.
 
Speaking on the battery I had an interesting experience with the battery life on my replacement phone running CM7.It was draining at 2% per minute til I hit about 80%.When I got to the 70%ish mark my phone turned off saying 0% battery.I tried turning it back on still 0% battery.When I waited like 2 minutes it was at 67% battery life.It worked normally til about 40%ish when it turned off again.I waited and again it turned on but at around 20% battery life.For like 3 days I was having these problems.I also saw while charging the battery while the phone was off it was saying it was fully charged when it was no way it could be.It would go from 0% charge to 100% while off in like 20 minutes.I would have to unplug and let it set for like 10 minutes then it would charge back normally.I have screenshots I will post when I get the chance.It's very interesting.Also this happened using 2 different batteries.One being a replacement battery the other a new battery.....both had same issues.

It sounds like you have a bad battery. Basicly if the battery has a bad cell or some weak cells then it would have a high voltage when unloaded and then as soon as the load hits the phone would turn itself off. If you have another battery I would start there. The battery gauge is run on a delayed and buffered scale and won't show a sudden drop just because the battery experianced a load, such as the camera taking a picture.
And it helps if I read the whole post.
Can we presume you tried to reflash and clear out the caches?

And if I didn't post it before, I did find the code to the issue I was looking for. It's under frameworks/base/services/java/com/android/server/BatteryService.java around line 175.
 
And it helps if I read the whole post.
Can we presume you tried to reflash and clear out the caches?

And if I didn't post it before, I did find the code to the issue I was looking for. It's under frameworks/base/services/java/com/android/server/BatteryService.java around line 175.
Yep did all that still have issues.I think it's an issue of the phone not charging the battery properly.I really need to post the screenshots of the battery usage.
 
screenshot-1355779631072_zps41407b16.png


Old battery usage after full charge.As you can see it went to 0% and I turned it back on and it was at same percentage.This was on CM7 test ROM B
 
screenshot-1355784891481_zpse33339e4.png


This is from the new battery.It had said it was fully charged when I had the phone off.As you can see its a sharp drop.
 
Back
Top Bottom