1

I am trying to find where in the android source code the event that tells the device to shut down due to low battery it located.

I am currently looking at cyanogenmod source but I imagine this is a common area for all mod sources.

Can anyone point out where this is and if possible how to prevent the phone from shutting down?

To clarify why I want to do this:

I have a faulty phone that always reports the battery level to be zero when I know it is not (I have tested the battery in other phones and other batteries in the faulty phone). Preventing it from shutting down would just extend the life of this otherwise useless phone.

CeejeeB
  • 3,034
  • 4
  • 25
  • 32
  • 1
    Even if you prevent the phone from shutting down through code, it will die when the battery runs out. What are you exactly trying to achieve here? – Raghav Sood Feb 05 '13 at 19:15
  • 2
    I have a faulty phone that always reports the battery level to be zero when I know it is not. Preventing it from shutting down would just extend the live of this otherwise useless phone. – CeejeeB Feb 05 '13 at 19:41
  • The public android sdk does not provide any possibilties to turn of the phone by using code. Maybe you can use reflection to do it, I dont know how. If you are using a rooted phone, this post shows how to reboot a phone, just change to cmd lines. http://stackoverflow.com/questions/2038151/how-to-power-off-an-android-device – Tobias Moe Thorstensen Feb 05 '13 at 19:43
  • I don't plan on using the SDK. I am looking at modifying the android source code. – CeejeeB Feb 05 '13 at 19:47

1 Answers1

2

in BatteryService.java ,when the battery lvl is too low (0%, lower than 3.4v),the service will call shutdownIfNoPower to shutdown system.

By the way, is your phone has been ADC calibrated ? or the calibration data had been destoryed....

nick.yu
  • 89
  • 3
  • Thanks for this. Where abouts is the file BatteryService.java in the source tree? I am unsure what you mean by your second comment can you explain further? – CeejeeB Feb 06 '13 at 10:58
  • Never mind I found the file. For others benefit the file path is services/java/com/android/server/BatteryService.java in android_frameworks_base – CeejeeB Feb 07 '13 at 11:47