[Tasker Tips & Tricks] sundaysfantasy:
Hey, I've been tinkering for a few days with Tasker (begginer here) and I finally managed to do what I wanted when I installed it, that is turning WiFi or mobile data on for a few seconds every few minutes when the screen is off. I tested the battery drain with this task and after a full charge on my Huawei P9 lite, I managed to obtain 48 hours of battery life with 10 hours of usage.

Before anything else, this profile only works with Nougat. Marshmallow apparently doesn't allow apps to wake the device when it enters doze, even If I excluded Tasker and all the other apps I needed from doze. Nougat has a softer doze and it works great.

So, before you start, there are several requirements:

1. Tasker

2. Secure Settings plugin (for gps disabling and other stuff) - optionally

3. Taskkill (for killing processes when you turn the display off) - optionally

3. A rooted Nougat running phone

If you don't know how to root Nougat, there are several tutorials out there. Here's a small one for Huawei P9 Lite(mine runs on VNS-L21C432B370):

1. Revolution Recovery

2. Elite Kernel v5.1

3. PHH's Superuser

4. Adb and Fastboot drivers

5. Bootloader unlock code from huawei site (Tutorial)

6. USB drivers for your phone (just install HiSuite)

How to root Huawei P9 Lite Nougat:

- install adb and faastboot drivers

- use one of the methods to reboot to bootloader (i just reboot the phone with usb connected and hold volume down key)

- shift+right click where you have downloaded the recovery image, click "Open command window here" and type: fastboot oem unlock *insert bootloader unlock code here* and press enter

- after you unlocked your bootloader, from the same command window type: fastboot flash recovery revo_recovery.img

- reboot phone to recovery and install EliteKernel, after that wipe cache

- install PHH's Superuser from playstore and give Tasker, Secure Settings and Taskkill root permisions

Now for the Tasker profiles, small description:

Basically there are three profiles, one activates when the display is off, one after you unlock the display, and the third one does the magic. All the links are below.

Display Off profile with the Locked task does several things after you turn off the display:

- Sets variable LCD to 0 (you will se why in a minute)

- Sets Auto-Sync to off

- Turns off GPS (via Secure Settings plugin)

- several Taskkill actions (you can disable those if you want)

Display On profile with the WiFi On task does:

- Sets variable LCD to 1

- Turns on WiFi

- Waits 10 seconds

- If WiFi isn't connected turns of Mobile Data

- Turns on Auto-Sync

On-Off profile with Do task does the following every 2 minutes (change the value if you want or even set the hours between you want it active)

- If LCD~0 then

- Turn on WiFI

- Turn on Auto-Sync

- Waits 10 seconds

- If WiFi isn't connected then

- Turn on mobile data

- Wait 10 seconds

- Turn Wifi, Mobile Data and Auto-Sync off

Now go to Settings->Battery->Close apps after screen lock and allow Tasker, Secure Settings and maybe Superuser to run after you turn the screen off.

After that go to Settings->Apps press on the Settings icon on the bottom, go to Special Access->Ignore battery optimisation, press on the small arrow and select All apps, find Tasker, Secure Settinsg and maybe Superuser and allow them to stay active after doze.

You can customize the profile and add as many tasks as you like or play with the timers but I recommend not to alter the conditions for the profiles because some things won't work. This works 100%. Also, when I was researching, I found out you can monitor network usage and restrict the task from running if you have downloads in progress. I haven't implemented that, feel free to do the research and post the results.

And that's it. After this, enable all profiles and profit. Like I said, my average battery life is 48 hours and as long as nobody sends me important notifications that can't wait 2 minutes until I receive them, it's the best battery save trick I know.

Tasker profiles&tasks

Extract the archive and paste the files wherever. After that long press the Profiles and Tasks tabs in Tasker and import the XML files.

Let me know if it works for you.

Cheers.