Washington, June 14 (IANS) A new method will detect software glitches in smartphones called “no-sleep energy bugs,” which can drain batteries while the phones are not in use.

“These energy bugs are a silent battery killer,” said Y. Charlie Hu, Purdue University professor of electrical and computer engineering. “A fully charged phone battery can be drained in as little as five hours.”

Since conserving battery power is critical for smartphones, the industry has adopted “an aggressive sleep policy”, said Hu, who co-authored the paper with doctoral students Abhinav Pathak and Abhilash Jindal and Samuel Midkiff, according to a Purdue statement.

“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 application instructs the operating system to keep it on.”

Researchers studied 187 Android applications that were found to contain Android’s explicit power control APIs, called “wakelocks”. Of the 187 apps, 42 were found to contain errors – or bugs – in their wakelock code.
The findings showed the new tool accurately detected all 12 previously known instances of no-sleep energy bugs and found 30 new bugs in the apps.

The glitch has been found in interactive apps, such as phone applications and services for telephony on Android that must work even though the user isn’t touching the phone. The app may fail to engage the sleep mode after the interactive session is completed.

Various background operations need to be performed while the phone is idle. “For example, a mailer may need to automatically update email by checking with the remote server,” Hu said.

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.

“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,” adds Hu.

Smartphone users, meanwhile, don’t know that their phones have the bugs. “You don’t see any difference,” Hu said. “You put it in your pocket and you think everything is fine. You take it out, and your battery is dead.”

These findings will be presented during the 10th International Conference on Mobile Systems, Applications and Services, or MobiSys 2012, June 25-29 in the UK.