Monthly Archives: October 2015

Introducing No Wakelock

Hi, No Wakelock is a new Android app I developed. It gives user the ability to disable wakelocks of specified apps, which are usually the root cause of battery drain. It requires Xposed to function normally.

How it works?

Android allows apps to use partial WAKE_LOCK to keep devices awake while screen is off. However, this mechanism is often abused as some Android developers introduced it into network related operations. As a matter of fact, network events will wake devices up automatically and only pure CPU operations require wakelocks to prevent device from falling asleep.

Disabling partial WAKE_LOCK is usually safe and has little impact on the functionality of Android apps, except if you are doing CPU intensive work like video rendering, π calculation etc.

How to use it?

First of all, enable the Xposed module.

Screenshot_2015-10-01-09-40-52

It is recommended to use No Wakelock with other apps like Greenify. If you do not wish to have an app running in the background while screen is off, simply greenify it. If you have an app that you wish to have it running in the background, but at the same time want to minimize its battery usage, then do not greenify it. Instead, use No Wakelock to restrict its access to wakelocks.

It is recommended to identify the apps that use excess wakelocks first. Tools that can help you with that include Wakelock Detector.

Screenshot_2015-10-01-08-51-56

Then open No Wakelock, locate the app you want to disable.

Screenshot_2015-10-01-09-08-38

Then, choose the types of wakelocks you want to disable.

What to disable?

Partial Wakelock: This is the wakelock that prevents your CPU from falling into sleep while screen is off.

All Other Wakelocks: This is the wakelock that prevents your screen from turning off.

Sync Adapters: Sync Adapters can also keep devices awake. If you do not need synchronisation, you can disable it.

Align AlarmManager Wake-ups: (>= Android 4.4 only) Use this option to force align all wakeups caused by AlarmManager so that the CPU can keep asleep for as long as possible. Please be reminded that this option might postpone or break push notifications of apps that are improperly designed.

These four options should be enough for 99% of the users. However, if you wish to have more precise control over your phone’s wakelocks, you can enable this option:

Apply Custom Black/Whitelist: This is an advance option. Common users usually do not need to touch this unless you are clear what you are doing. If you wish to enable it, please edit the custom black/whitelist first. For more information about black/whitelist, read the next session.

  • Setup Example: Google Play Services

If you are using Google Play Services, it may be consuming too much battery. So you checked the battery usage of Google Play Services, and it turned out that Google Play Services is keeping your device awake even when you are not using it. To save your battery, open “No Wakelock”, navigate to Google Play Services (Enable system apps first in No Wakelock settings), disable partial wakelock and leave everything unchanged. Restart your device to make this effective.

Google Play Services will now no longer consume too much battery. The best part is that GCM notifications & Google Account Sync are all working as normal. Woohoo!

Screenshot_2015-10-01-09-08-48

Force stop the app(if you only change the settings of one app) or reboot your devices(if you changed the settings of a lot of apps) to make all settings effective.

Screenshot_2016-02-14-00-06-48

That’s all. Your device can have a good night’s sleep now.

Advanced Option: Black/WhiteList

Please be reminded that this is only for advanced users.

If you decide to enable it, the priority of wakelock matching becomes: blacklist > whitelist > other settings for the app.

To edit your black/whitelist, click the “Edit” button on the top right and fill in the black/whitelist in corresponding columns.

Black/Whitelist works in the way that matches wakelocks’ names. You can write regular expressions on each line. For instance, if you saw a wakelock named WakeLock:12345 & a wakelock named WakeLock:abcde are keeping your device awake, you can fill in these content in your blacklist:

WakeLock:\d+
WakeLock:[a-zA-Z]+

Please be reminded that one and only one regular expression should appear on each line. Do not insert extra new lines as this will invalidate all settings for this app.

Get it now!

Download No Wakelock at Google Play: https://play.google.com/store/apps/details?id=com.linangran.nowakelock

Purchase Donation Pack at Google Play: https://play.google.com/store/apps/details?id=com.linangran.nowakelock.donation

关于禁止唤醒

禁止唤醒是我开发的一款应用, 它允许用户禁用掉特定应用的唤醒锁. 可以在不影响推送的情况下, 大大降低应用的耗电量. 唤醒锁在 Android 中的滥用十分普遍, 特别是在国内, 各路应用纷纷使用唤醒锁来上传下载资料, 既泄露隐私又耗费电量.

禁止唤醒需要 Xposed 模块以正常工作.

省电原理

Android 系统允许应用使用CPU唤醒锁来使设备在息屏时保持唤醒状态. 然而, 这个机制在国内 Android 应用中的滥用十分普遍. 很多 Android 开发者错误的在网络通信中加入唤醒锁, 然而实际上, 这种做法除了白白消耗电池之外没有任何作用.

禁用唤醒锁通常不会有什么副作用, 对应用本身的功能影响也十分有限. 正确设置”禁止唤醒”可以在不影响微信等消息推送的前提下节省大量后台电量消耗.

使用方法

首先, 启用 Xposed 模块.

Screenshot_2015-10-01-09-21-53

禁止唤醒主要用于应对那些你希望在后台运行的应用. 对于那些不需要在后台运行的应用, 推荐使用绿色守护直接干掉. 对于那些你希望在后台运行, 但是又特别耗电的应用, 使用禁止唤醒来限制它们使用CPU唤醒锁, 以让设备可以正常休眠.

开始之前, 建议先使用 Wakelock Detector 之类的应用查看过度使用唤醒锁的应用.

Screenshot_2015-10-01-08-51-56

然后打开禁止唤醒, 找到你希望禁止的应用.

Screenshot_2015-10-01-09-22-21

然后, 选择你希望禁用的唤醒类型.

如何设置?

CPU唤醒锁: 这是在息屏后阻止你的设备进入休眠状态的唤醒锁, 禁用它通常不会有任何问题.

所有其它唤醒锁: 除了CPU唤醒锁之外, 还有一些唤醒锁可以阻止设备休眠, 甚至阻止设备息屏. 开启这个选项以禁用这些唤醒锁.

同步: 同步也可以唤醒设备, 如果你不需要应用的同步功能, 使用这个选项来禁用掉它.

对齐定时器: (>= Android 4.4) AlarmManager可以使用定时器来周期性的唤醒设备, 阻止CPU进入长期休眠状态. 启用这个选项来强制对齐定时器, 让它们尽量在同一时间触发以节省电量. 请注意: 对于设计不良的应用, 启用此选项有可能会引发推送消息延迟.

99%的用户使用以上四项即可完美控制好应用的唤醒问题. 然而, 如果你希望对禁止唤醒的唤醒锁管理有更精细的控制, 您可以启用以下选项.

应用自定义黑/白名单: 这是一个高级选项, 如果您确定您要使用黑/白名单机制, 请先通过右上角的编辑按钮设置黑白名单. 了解更多黑/白名单信息, 请看下一节.

  • 设置示例: 微信

微信在后台运行时消耗大量电量, 在电池设置中查看微信的耗电量, 发现微信在设备息屏时保持设备唤醒而无法进入休眠状态. 要减少微信的电量消耗, 打开禁止唤醒, 找到微信, 禁用CPU唤醒锁和同步, 保持所有其它选项不更改, 重启设备以应用更改.

微信不会再消耗大量的电量. 更好的是, 微信的推送一如既往的及时准确, 没有任何功能被破坏.

Screenshot_2015-10-01-09-22-28

强行停止对应的应用(如果你只修改了一个应用的设置)或者重启设备(如果你更改了大量应用的设置)以让更改生效.

Screenshot_2016-02-14-00-08-14

就是这样了! 你的设备现在可以好好的”睡一觉”了.

高级设置: 黑/白名单

请注意: 此项设置仅供高级用户使用.

当您针对某个应用启用黑/白名单功能后, 唤醒锁匹配的优先级为 黑名单 > 白名单 > 您的其他设置.

要编辑黑/白名单, 请点击右上角的编辑按钮, 然后在黑名单唤醒锁和白名单唤醒锁两栏下, 分别填入您的黑/白名单信息.

黑/白名单针对唤醒锁的名称进行过滤, 每行一个, 支持正则表达式. 例如, 您看到某个应用正在使用名为 WakeLock:12345 的唤醒锁和名为 WakeLock:abcde 的唤醒锁唤醒设备, 您可以这样填入正则表达式:

WakeLock:\d+
WakeLock:[a-zA-Z]+

请注意, 正则表达式每行有且仅有一个. 请不要插入多余的空行, 这会导致针对此应用的设置完全失效.

立即下载

在 Google Play 下载禁止唤醒: https://play.google.com/store/apps/details?id=com.linangran.nowakelock

在 Google Play 购买捐赠包: https://play.google.com/store/apps/details?id=com.linangran.nowakelock.donation