The Truth About Kernels and Battery Life by flar2

When it comes to Android kernels, the number one topic of discussion these days is battery life. But there are many myths about the relationship between kernel and battery life. At one extreme, there are those who make outrageous claims about radical changes to battery life minutes or hours after installing a kernel. At the other extreme are those who think the kernel makes absolutely no difference at all to battery life. The truth lies somewhere in the middle.

Before we get to the “truth” of the matter, I want to clarify a few things.

First, the kernel does not “drain” battery. Many times, a user installs a kernel and then reports back soon after that the kernel has caused massive battery drain (and probably also something to the effect that the kernel is crap and the dev should burn in hell for his efforts). To prove it, they post screenshots from battery monitoring apps showing “kernel” as the major source of drain. This is very misleading. On Android devices, the kernel provides a mechanism for keeping the phone awake, called a wakelock. Processes running on the device (e.g. apps and services) can ask the kernel for a wakelock, and the kernel will oblige. So yes, the kernel is technically keeping the phone awake, but only because an app or service has asked it to. It is these apps and services that are misbehaving and causing drain, not the kernel.

But that is not to say the kernel does not cause any battery drain. It still uses memory and does work, but the amount it uses is exceedingly small compared to the Android system, apps and services. There are also special hardware cases, such as the sweep2wake feature on the Nexus 5, which requires that the LCD panel remain powered on in order to work. This drains more battery than if the device were suspended normally, but still does not cause “massive” drain. On the Nexus 5, sweep2wake adds roughly 2% per hour drain while the screen is off. Not insignificant, but far less than the phone normally uses while the screen is on. Because of this, a strong myth has developed, claiming that sweep2wake and doubletap2wake cause battery drain. Except for the Nexus 5, it is just that, a myth. On the vast majority of devices, the battery drain from sweep2wake is negligible, usually something zero and 0.5% per hour, which would “cost” no more than 5% battery usage over the course of a workday. A perfectly acceptable trade-off for the convenience.

The second thing I want to clarify pertains to measurement. How do we measure battery life? I like to look at percent usage per hour. Many battery monitoring apps can give you this statistic, but you have to pay attention and set custom time points if you want to distinguish the stats further and really understand battery usage. If you do want to measure and compare, make sure you do so under similar conditions. And you must do so over a reasonable time period, which means days rather than hours. If you have some routines where you use the same apps every day, this would be a good way to test and compare. The battery monitor in EX Kernel Manager automatically provides the two statistics I will now talk about: idle drain and active drain.

Idle drain is battery drain while the screen is off. During screen off, the phone spends most of its time in “deep sleep”. Sometimes, it wakes up to do some background work, like syncing email or checking for updates. These would be examples of the system, apps or services “asking” the kernel to stay awake while they perform their tasks. If all is working correctly, when they finish, the device goes back to sleep. Idle drain should be measured over several hours to get an accurate picture. A good time to measure it is overnight while you aren’t using your device (if you are not a dev and actually get to sleep). On most devices, idle drain ranges from about 0.2% per hour to 0.8% per hour on a stock setup with default options (i.e., with no battery saving measures in place) on a normal WiFi connection. On some devices, kernel optimizations can shave a bit off this number. But only a tiny bit, generally in the range of 0.1% to 0.3% improvement over stock. This is not going to make a huge difference to battery life. As already mentioned, sometimes hardware features like sweep2wake can eat up about the same amount. So as we can see, a kernel offers relatively little improvement here, but then again, every bit counts. Another factor that influences idle drain is your network connection, particularly cellular connection. A poor signal will often result in a bit of extra drain. But this should not cause excessive drain during idle, and will mostly make a difference while you are using the data connection. I should add that many of the battery saving measures people take also make little difference here. As long as your idle drain is below 1% per hour, don’t even worry about it. If it’s more than 1% per hour, look at your apps and services. Occasionally, there will be a big batch of updates that cause a bit of extra drain. It happens.

Active drain is the amount of battery used while the screen is on. That is, while you are using your device. Active drain is obviously much greater than idle drain. The phone is on, the screen is on, and it is doing work using the CPU, GPU, memory, modem, wifi, disk, etc. Active drain varies quite a bit from device to device. A lot of times we hear about “screen-on time”. Active drain, measured in % per hour can be translated easily into screen-on time. Active drain of 12.5% per hour is extremely good and will equate to about 8 hours of screen time. Drain of 25% per hour will get you about 4 hours of screen time. See how that works?

Screen-on time (hours) = 100 / Active drain (% per hour)

This does not take into account the small amount of battery use while the screen is off. Assuming idle drain is about 0.6% per hour, you would lose about 6% in ten hours, or around 14% in a 24 hour period. You can subtract that from 100 in the equation above.

Now we’re getting into the truth of the matter. What influences active drain? Many
things. Network (especially cellular) connection makes a difference. Poor signal means it has to work harder to transmit and receive data. The type of apps you are using makes a difference. Obviously playing a graphics-intensive game will use far more battery than reading some email. Using the camera, especially flash, will cause more drain than texting. The point is, what you do with your device has, by far, the biggest influence on battery life. Something like changing your web browser could have a significant impact on battery life, perhaps a greater impact than any kernel or battery saving tweaks floating around on the Internet. Bottom line: Active drain will vary from user to user, even with the same device!

There is, however, one part of the kernel that has a significant influence on active drain, and therefore can have a big impact on screen-on time. This is the CPU governor. This is why kernel developers spend a lot of time tweaking governors. It’s about frequency usage, which you can measure with an app like CPU Times. The CPU governor controls frequency scaling according to system load. While not busy, the CPU will stay at its lowest frequency, which uses the least energy. When there is work to do, the CPU governor ramps up the frequency so the work can be completed faster and the user can enjoy a smooth experience. A good governor is responsive, quickly responding to changes in system load, to prevent lag, but also quickly returning to the lowest frequency to save energy.


There is an idea called “race to idle” which suggests the governor should immediately ramp up to the highest frequency so tasks can be completed as quickly as possible, and consequently, the CPU can more quickly return to a lower power state. This logic is generally sound, but with modern processors, there may be a negligible time difference for completing a task using the highest frequency available compared to a frequency somewhere in the middle. In other words, it may be a waste of energy to ramp up to the highest frequency when a somewhat lower frequency may complete the task in essentially the same amount of time, and return to an idle state. The highest frequency will use more energy than the moderate frequency, and there may be very real battery savings when this is repeated thousands or millions of times per day. The trick is to find frequencies that are “fast enough” to create a feeling of snappiness for the user, without constantly ramping up to the highest frequency. I could write a whole other essay on governors, so for now I will leave it at that. It will suffice to say that different governors will behave differently, and have different battery use characteristics. Therefore, the kernel really does have an impact on battery life.

There are other aspects of the kernel that impact battery life too. Chief among these is task scheduling, particularly the aspect where tasks are assigned to one CPU core or another. This means a CPU may be “woken up” to perform a task, or tasks may be packed onto the same core. Another is hotplugging. There is an energy cost to put CPU cores on or offline. On many devices, you will hear about the evils of mpdecision, a closed-source binary from Qualcomm that controls hotplugging and often includes a “touchboost” feature that overrides the CPU governor. Many custom kernels disable mpdecision and implement a custom hotplugging driver. My own testing has found that mpdecision and its excessive touchboosting generally do not have a major impact on battery life, and I have left it enabled in most of my kernels. In some recent devices, such as the Nexus 6 and the HTC One m9, there is no hotplugging during normal use. All CPU cores are online. It can’t be said that task scheduling, hotplugging and touchboost have no impact on battery life. They clearly do. It’s just not going to make a huge difference. If we think of the impact of these optimizations in terms of active drain (% per hour), the change will be relatively small, probably less than one percent per hour, which would be measured in minutes of screen-on time over the course of a day. I think the impact of these optimizations is more apparent on older devices that are less power efficient and have smaller batteries.

I will mention quickly one more topic that always comes up in discussions of battery life: undervolting. Again, undervolting probably made a bigger difference on older devices. Devices released in the past year or two have become considerably more power efficient, some even have automatic fine tuning and scaling of voltages. I remember working on msm8960 devices that used the same voltage for every CPU frequency. In a case like that, undervolting could make quite a difference. Recent devices run with much lower voltages, and chips are binned with tighter tolerances, leaving less headroom for undervolting and reducing the battery impact of undervolting. On some devices I offered automatic undervolting, but only for the lowest frequency, which is the most-used frequency.

Much more could be said on this topic, but the main point I wanted to make is that the kernel does, indeed, make a difference in battery life, but the difference is often not as dramatic as some like to think. From the kernel’s perspective, the CPU governor will have the biggest impact on battery life. Many of the things that people obsess about do not make a big difference in battery life. Finally, if you want to judge battery life, take a scientific approach. Try to use the same conditions when making comparisons, measure carefully, and give it some time.

- flar2

This article was originally posted by its author on elementalx.org and Android Revolution blog has been given a permission to re-publish the article.

Do you have any questions or comments? Feel free to share! Also, if you like this article, please use media sharing buttons (Twitter, G+, Facebook) below this post!


For latest news follow Android Revolution HD on popular social platforms:

Read More..

Learn about Vulkan and 3D Graphics Coffee with Shannon Woods

Posted by, Laurence Moroney, Developer Advocate

Vulkan is the new generation, open standard API for efficient access to graphics and compute on modern GPUs. In this episode of Coffee with a Googler, Laurence meets with Shannon Woods, a Technical Program Manager in Google’s rendering teams to talk about plumbing code from your app down to the GPU!

Historically mobile apps have used Open GL ES to communicate with the GPU, but the hardware and API have evolved separately, impacting efficiency. Vulkan has been designed to organize the graphics space in much the same way as the underlying GPU, so it can be more efficient.

Android will support both Open GL ES and Vulkan, so developers can choose which API is right for them — and with Vulkan, precise control over the commands executed by the GPU allows for great optimization, as well as parallelization of code.

We also learn about the famous Utah Teapot, a standard reference object for 3D modellers, and how it is found in popular culture -- such as showing up in most animated movies. Have you spotted it?

Watch this episode for some great guidance from Shannon on what you need to do as a developer to prepare for Vulkan, and how using could be of benefit to your apps!


Read More..

More details about incoming Sense 5 5 update

The dust hasnt settled yet after the first worldwide HTC Sense 5.5 screenshots and here comes the another part of the fresh new details about newest HTC Sense UI. Have fun!


Lock-screen widgets - possibility to place one widget on the lock-screen. You need to swipe left to see the additional screen, where you can place of one these widgets: Gmail, Google+, Calendar, Google Keep (x2), Calculator, Music, Google Now and some widgets from 3rd party applications with support for lock-screen widgets, like Minimalistic Text or SoundHound


Possibility to use entire UI in landscape mode when device is inside car dock. Home screen, phone panel and basically everything else is working very well in landscape mode.


Possibility to use "Automatic brightness" and "Maximum brightness level" at the same time. This allows you to save some battery, because brightness max level can be limited. 


Possibility to edit "Phone" panel. You can rearrange them or even remove unused tabs. This is rather small, but very nice improvement. You dont need to swipe 3 or 4 times any more to access particular tab.


New BlinkFeed settings panel, where you can select the exact content you want to view on your BlinkFeed screen. It seems that HTC really focused on their BlinkFeed child. Lets hope it will still be getting better and better!


Possibility to protect SMS backup with password. I believe that every "security" or "privacy" related update is important, even if most users wont probably use it.


"Stay awake" is finally back in Developer options in Settings. Taken away few months ago and desperately desired by users and developers.


Up to 6 (previously 5) home-screen panels including BlinkFeed screen. In my personal opinion 6 is weird number because this little thin line, also known as screen indicator can never be in the centre. This can be little confusing when using the device.


"Do not disturb" mode accessible via Quick Settings panel. Really great feature if you dont want to be waken up few times during the night!

More details coming soon!

Have any questions or comments? Feel free to share! Also, if you like this article, please use media sharing buttons (Twitter, G+, Facebook) below this post!
Read More..

What you need to know about copying or editing someone else’s music

You might find yourself editing music and wondering, am I allowed to do this? Whether you’re making your own music mashup with the MixPad multi-track mixer, adding a soundtrack to your home videos with VideoPad video editor, or making a new ringtone for your phone with WavePad audio editor, there are some rules you need to know about your music, and how you’re allowed to use it.

What’s mine isn’t yours and what’s yours isn’t mine
What you need to know about copying or editing someone else’s musicThat is the legal stance as far as copying or editing someone else’s music is concerned. With the increased popularity of the MP3 music format in the late 1990s, the sharing of copy written music without authorization became much more prevalent, causing an increase in concerns about copyright infringement. Today, copyright infringement isn’t something to take lightly. If you’re caught copying or editing someone else’s work you may be forced to pay heavy fines. Just ask former Boston University student Joel Tenenbaum - he had to pay $675,000 in fines for illegally downloading music.

Copying Music
According to The Copyright Act of 1976, you are allowed to copy someone else’s work if it falls under fair use. Fair use is described as using limited portions of a work, including quotes, comments, criticism, news reporting, and scholarly reports.

Editing Music
Since it is legal to create software to edit music, shouldn’t editing music be legal? There is a lot of talk about reselling and downloading copyrighted music, but not too much about edited music. The most important thing to know is you can edit music as long as you do not intend to use it for commercial use. Also, once you purchase music you inherit the rights to share that music with your friends, and you are also allowed to edit that music as long as you keep a copy of the original.

For more information see the following articles:
Using Edited Music on YouTube
For quite some time now, posting copyrighted or edited music to original videos on YouTube has been a problem. However, as of June anyone who wishes to put music behind their videos can, you just have to follow these simple rules. First, it is important to know that YouTube has signed a deal with Rumblefish, allowing users access to a library of music. Therefore, if you use music from this library you can edit it any way you like without worrying about YouTube removing your video. All you have to do is purchase the song for $1.99 and you will have a lifetime license to use and edit that song on YouTube.

Basic things to remember
  1. Always purchase music legally either at a music store or online
  2. If it’s not your original music, using it may be violating someone’s copyright
  3. If you arent sure something is copy written, check with the US Copyright Office
  4. Selling or redistributing music without the copyright owners permission is a violation of the owners rights
  5. If you edit or mix song you’ve purchased, you have to keep a copy of the original song
  6. Only the owner of copy written work has the right to prepare or authorize someone else to create a new version of that work
  7. When using someone else’s work, even just a portion of it for a video or any other project, it is always a good idea to credit the original artist(s)
Read More..

Blog Archive

Powered by Blogger.