Are you fed up with your smartphone battery draining by lunchtime? Especially when you’re not even using it? Well, a team from Purdue University have set out to tackle this problem by proposing a method that automatically detects “no-sleep energy bugs” — a type of software glitch that can drain your battery without you knowing it.

purdue university, no-sleep energy bugs, smartphone battery, why does my smartphone battery drain so fast, smartphone battery life, smartphone battery status, API,

These annoying software glitches have been dubbed “silent battery killers” due to their frustrating ability to empty a fully-charged phone battery in as little as five hours. To tackle this problem, which is industry-wide, many smartphone manufacturers have adopted an “aggressive sleep policy.”

Y. Charlie Hu, a Purdue University professor of electrical and computer engineering, is heading the research and said: “What this means is that smartphones are always in a sleep mode, by default. When there are no active user interactions such as screen touches, every component, including the central processor, stays off unless an app instructs the operating system to keep it on.”

But what about the various background operations that need to be performed while the phone is idle, such as checking your inbox and backing up your files?

To prevent the phone from going to sleep during such operations, smartphone manufacturers make application programming interfaces, or APIs, available to app developers. The developers insert the APIs into apps to instruct the phone to stay awake long enough to perform necessary operations – however this is what can drain your battery in just a few hours.

“App developers have to explicitly juggle different power control APIs that are exported from the operating systems of the smartphones,” Hu said. “Unfortunately, programmers are only human. They make mistakes when using these APIs, which leads to software bugs that mishandle power control, preventing the phone from engaging the sleep mode. As a result, the phone stays awake and drains the battery.”

The team believes that they have found a way to detect and fix these bugs. Aftering studying 187 bug-ridden Android applications, all of which contained power control APIs, the tool they used to detect the bugs not only detected all 12 previously known instances of no-sleep energy bugs, but also found 30 new ones.

To detect the energy-sucking bugs, the researchers used a modified tool called a compiler that translates code written in computer languages into the binary code that computers understand. The tool is then able to analyze the binary code and automatically and accurately detects the presence of the no-sleep bug.

Any tool that prevents the global population having to constantly recharge their phones (and as a result use more energy), is a must-have in this writer’s book.

+ Purdue University

Images: liewcf,  brendan-c and Andrew*