Atomatically enable data when screen is off periodically (enormous battery save) - Tasker Tips & Tricks

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.

Hey man, I'm going to tell you right now, this was a great post. The content was ok, but your style, your step by step instructions WITH reasons... remarkable.
Keep it up and you will be the tasker man, just based on your dedication.
Now if I may tweak your content?
Adding wait actions inside tasks is a battery destroyer and is bad taskering in general. Plus doing checks, waiting, checking etc... just hard to debug, hard to enjoy when you're leaving battery juice you could be saving.
Set a time context DO profile that runs every.... switch to variable . And the variable...name it something like %synccheck
Then on your screen off profile, set %synccheck to %TIMES+360 (the current time in secs, plus 5 min) this only runs on screen off.
Create a SCREEN ON profile, set %synccheck to %TIMES+120 (the current time in secs, plus 2 min) this only runs on screen on. SO 2 MIN IF SCREEN ON. 5 MIN IF SCREEN OFF.
(NOTE: I WOULDN'T put too much effort into checking whether on data or Wi-Fi. Under Wi-Fi settings, just disable "keep wifi on during sleep " and that lets the system handle disabling and reenabling when the screen comes on.
(Build a tasker task that enables Wi-Fi based on location and disables on it when you leave the Wi-Fi area...)
he current time is %synccheck. Since the current time can never be null, it will never run if the variable was cleared
Since in this example, it's set 5 min from now, the timing profile will run. The timing profile is the one that enables auto sync and whatever else you want to at a given time.
So there's no checking at all. If we clear the variable %synccheck then the profile never runs. The profile is only enabling auto sync and disabling on the exit task.

Hey, thanks for the reply. I am aware that my tasker knowledge is limited. I will take your tips into consideration and update my guide.
Cheers!

Related

keep active program?

Is there a program to keep my screen active when i am using a 3rd party GPS program? with TomTom it keeps staying active, but with for instance GPS Performance, it will go inactive after a while, and then my screen turns off..
Can't help you with that, my only idea is set the "screen turn off if not used for x min" to lots of minutes before entering app, and set it back after you exit the app
yeah, but that is a crappy way..
Unless I'm mistaken, MortScript is free. Install that and write a script to:
1. Change backlight setting.
2. Launch GPS Performance.
3. Change one of the hardware keys to execute the application's exit routine (if it's not simply hiting "X" in the corner - some aren't).
4. Reset the backlight settings.

[GUIDE] How to turn on your phone without using your hands [S8/S8+][Other devices]

[UPDATED]
Hello guys,
A little introduction:
I'm an XDA user for quite a while now, but never started an own thread. As I like playing with mods like Xposed, magisk or, in this case Tasker, I'd like to share my profile with those who find it handy too. Also I think there're way more advanced tasker guides and tricks and this is rather easy, but I'd love to share it anyways with you
What does this profile do?
It's pretty simple and basic. This profile lets you magically wake your phone with holding your hand (for example) close to the approximity sensor, but also (only on S8/S8+) trigger the Iris scanner, which would usually need to be tapped on, since Samsung doesn't allow 3rd-party apps to wake the phone! But we'll get this anyways But here's a video. You will see what I mean:
Click here for YT video (XDA embedding doesn't seem to work here)
Requirements:
Magisk (root) (*note: If you have rooted your phone with another method Secure Settings won't work, due to lack of development)
Secure Settings (*note: If you know another tasker plug-in, which can wake the device feel free to take that)
Tasker of course
Within Tasker you need to set proximity sensor (Under UI) to "yes". This ensures, that the sensor won't be killed from doze or anything else
And of course you need a working Secure Settings App. Make sure System+ module is active and granted root (Works very well with Magisk). Because it's enabled by default, it might be necessary to disable and re-enable it
If you meet all the requirements: Let's start
So step 1 : Create a new profile in Tasker with 3 status:
Sensor -> Proximity sensor
Display [Turned off]
Variable -> Variable value = %ONLYONCE to Undone (This is important, so the screen will be woken up only once after you turned off your device and not every time you put your hands to the sensor)
Name the executed task "Wake device" for example and let it run: (Go on in step 2)
Step 2: The executing task of the profile you just created should run this:
Task -> Wait = 350ms (adjustable to your needs)
Plug-In -> Secure Settings -> Configuration -> Wake device = Screen dim 15 seconds (adjustable)
Variable -> Set variable -> %ONLYONCE to Done
Code -> Run shell -> Command = "input tap 840 190" (No quotation marks) [Use root = yes] (*note: this creates a tap input, as if you were tapping on that specific spot, and triggers the Iris scanner. Also make sure that tasker has root privileges)
Step 3: Create a 2nd profile with the event Display -> Device unlocked
The executed task to this profile should be:
Task -> Wait = 3 seconds
Variable -> Set Variable -> %ONLYONCE to Undone
And that's about it Any time you wave your hand over the proximity sensor now or let's say pull it out of your pocket the screen goes on, the Iris scanner is triggered and your phone unlocks
Please hit the thanks button if you could find any benefit of this Guide and the profile and please feel free to leave some feedback You can also import the profile to your tasker. I attached it at the bottom
*Note: All iris scanner related tasks and profiles can be adjusted to devices without Iris scanners, but this profile isn't that handy on other devices apparently

Background app GPS recorder getting killed, howto keep it running?

Hi
My P20Pro has latest firmware and I did set battery to manage the apps manually and keep them running in background, power saving mode is off.
But it does not change anything.
e.g. app Mapillary, which takes a picture every second, is killed after 20 sec
or oruxmaps to record a gps track, is killed after 1 min max, no gps track on device.
Anyone knows a way howto run a gps logger in background all the time without the need to keep the display on with this "no display off" apps?
echelon
echeloni2p said:
Hi
My P20Pro has latest firmware and I did set battery to manage the apps manually and keep them running in background, power saving mode is off.
But it does not change anything.
e.g. app Mapillary, which takes a picture every second, is killed after 20 sec
or oruxmaps to record a gps track, is killed after 1 min max, no gps track on device.
Anyone knows a way howto run a gps logger in background all the time without the need to keep the display on with this "no display off" apps?
echelon
Click to expand...
Click to collapse
Having similar issue with Strava tracker. Latest EMUI version 8.1.0.131.
Tracking is killed after aprox 3 km of bike ride and it's unable to use tracking app. Not sure what is reason but I suspect Huawei to be killing that app without proper reason.
Already tried all settings, nothing helped yet
--
Edit: I found one setting which looks promising: Settings > Apps & Notifications > Apps > Settings (bottom menu) > Special Access > Ignore Battery optimizations > STRAVA (Or your tracking app) > "Allow"
Going to test this setting tomorrow.

Game mode profile

So I think just about every game on my oneplus 7 pro triggers a built in thing called gaming mode. Is it possible to create a profile that begins when that gaming mode starts and ends when that gaming mode ends. In this way I adjust things like volume levels and screen on time along with what the gaming mode does. And once for all of them instead of a profile for every game.
My guess is there is a custom setting that defines the status of the gaming mode. That's only a guess since I don't have a One plus.
You could use the native tasker settings -> custom setting action to see if you can identify what changes when the game mode turns on. Tapping the magnifying icon [emoji361] will bring up an assistant. Once you identify the setting, it can be used in a profile context (system -> custom setting).
From some online reading, I also think that the games that trigger game mode are entered in a list by a user. You could use an app context with each of those games selected so your profile activates whenever the game is in the foreground.
Hitting the gear/cog icon when the profile is selected will bring up settings for the profile. One of those settings is a toggle for restoring settings when the profile exits. In the case of an app trigger, when a different app is in the foreground, the settings made in your entry task will revert.
ktmom said:
My guess is there is a custom setting that defines the status of the gaming mode. That's only a guess since I don't have a One plus.
You could use the native tasker settings -> custom setting action to see if you can identify what changes when the game mode turns on. Tapping the magnifying icon [emoji361] will bring up an assistant. Once you identify the setting, it can be used in a profile context (system -> custom setting).
Click to expand...
Click to collapse
Upon starting a game that starts game mode the only thing that this method finds is a screen brightness change. when used from state. And nothing when used from event. Strange because if a game is triggering a system setting or something there should be something for tasker to see get triggered so a profile could tie into running while it is active. Much like a profile that would trigger upon phone charging for example and end when not plugged in to charge any more. Any other idea how i can identify what is triggered (for game mode on/off) to set a profile to run along with it?
ktmom said:
From some online reading, I also think that the games that trigger game mode are entered in a list by a user. You could use an app context with each of those games selected so your profile activates whenever the game is in the foreground.
Hitting the gear/cog icon when the profile is selected will bring up settings for the profile. One of those settings is a toggle for restoring settings when the profile exits. In the case of an app trigger, when a different app is in the foreground, the settings made in your entry task will revert.
Click to expand...
Click to collapse
Yes in game mode you add whatever games you want to trigger the mode. On my LG G4 I had a profile for each game but the profiles were problematic. Some of them would turn on and off while the game was still running. If I can have a profile that runs when game mode is active and ends when game mode is not then I would completely avoid having a new profile for every game.
I was suggesting using the custom setting action in a task to determine the setting. Then use that information in a profile to monitor it.
You can attempt to manually identify the custom setting (if that's what is controlling game mode). See here.
I'm thinking the mode reverts as soon as you leave the game to return to Tasker, so the built in assistant may not catch the change. Grabbing the settings via ADB and running a diff on the before and after may be the only way to go.
Otherwise, someone in the device forums might have insight how this mode is monitored.
As far as the app trigger approach, sometimes you can stabilize the task by putting a wait action at the start of an exit task and then stop the exit task of the calling profile is active (%PACTIVE).
Thanks for the reply with a method to identify the setting. Assuming that it is a setting. Using the custom setting action is a task when tapping on the icon it says to toggle the setting and return to tasker to find out what it is the results ended the same as attempting to use it by the other ways. It returned nothing or brightness found. I'll have to give the method in the link a try and see what happens. Will report back, might be a couple days.
I finally was able to identify the setting for making the profile, thanks much for the help.

Tasker keep screen on Android 12 issue

Hi,
I have set up the display timeout option with the settings below but it doesn't seem to work. I am using an oppo phone on Android 12.
Create a new task. Select the “+” button. Select “Display” followed by “Display timeout” Select the time span you want to set and then save. Now select “Profile” and click “+” and then “Applications” Mark the applications for which you want to activate this Tasker profile.
Then I open the app but after 15 seconds the screen turns off which is the default device screen timeout.
Is there no way to override this? Maybe get tasker to somehow keep interacting with the screen to keep it on?
I've tried this on a few apps and have got two different messages..
One says screen will stay on for 15 seconds which is the system screen time out.
Other says tasker will keep screen on but still times out after 15 seconds.
Really want this to work as some apps like games I don't want timing out after 15 seconds and I don't want to increase the system time to couple of mins for every app.
Hi,
I have the same problem on my OPPO A74 with Android 11 ((ColorOS Version V11.1). It seems impossible to create a task to change the screen time out; not in connection with a profile, shortcut or widget. The amazing thing, though - when you test the task in Tasker it works perfectly fine.
Media Volume, I think, also doesn't work. Other app connected profiles like autorotate or display brightness work well. I wanted to test more but I can't find the time.
I really miss the screen timeout though. It drains the battery too much to set it constantly to 15 minutes or so, but for some apps less simply is annoying.
The developer created some apk to help with some OPPO related problems, unfortunately, it didn't help with this one (sorry, I can't remember exactly what it was).
A kind of workaround: Once you've activated the Developer Options an your phone you can enable "Keep screen on while charging". When you need longer screen time, just plug into a charger.
But using a Tasker Profile would be much nicer.
Hope somebody knows a better trick.
Not sure if following could help your situation ( only for your gaming situation )
Create a new Profile, choose > apps > add your game apps in it. click left top arrow when finisning add gaming apps.
Tasker will pops-up task list > creat new task > Screen > Turn on.
** when above profile is complete , click the task when you are still in Profile list. Hold the task, it should pops-up with option exit task. Choose this as exit task.
Play around to see if this profile is working when gaming apps in foreground, screen never turn off.
EDIT: Try first not move the task as exit task. ( make the task as normal entry task )
eeeemc said:
Not sure if following could help your situation ( only for your gaming situation )
Create a new Profile, choose > apps > add your game apps in it. click left top arrow when finisning add gaming apps.
Tasker will pops-up task list > creat new task > Screen > Turn on.
** when above profile is complete , click the task when you are still in Profile list. Hold the task, it should pops-up with option exit task. Choose this as exit task.
Play around to see if this profile is working when gaming apps in foreground, screen never turn off.
Click to expand...
Click to collapse
Thanks for your reply.
Creating the profile is not the problem. It just seems that Tasker cannot change the system's setting. As mentioned, there is no problem when you create a profile allowing the screen to rotate using a speciffic app (and others as well ) I have no idea, why it does not work for the screen timeout.
Dreamcatcher0664 said:
Thanks for your reply.
Creating the profile is not the problem. It just seems that Tasker cannot change the system's setting. As mentioned, there is no problem when you create a profile allowing the screen to rotate using a speciffic app (and others as well ) I have no idea, why it does not work for the screen timeout.
Click to expand...
Click to collapse
I use no screen timeout, I use "screen turn on" in your situation as my op., enough I've not tried it on my Samsung A71.
eeeemc said:
I use no screen timeout, I use "screen turn on" in your situation as my op., enough I've not tried it on my Samsung A71.
Click to expand...
Click to collapse
"Display / turn on" works fine when I want the screen to turn on with a notification. But the screen turns dark after the system timeout has passed. I've also tried "Display / Stay On / with Wireless, AC or USB Power" and with the AutoInput Plugin "Screen Off Or On: Turn On / Timeout Never" but the screen always turns dark.
Those Profiles always worked on my other Smartphones (LG -D405, LG-K10 and Moto G6). I believe, it's the ColorOs that's causing the trouble.
Dreamcatcher0664 said:
"Display / turn on" works fine when I want the screen to turn on with a notification. But the screen turns dark after the system timeout has passed. I've also tried "Display / Stay On / with Wireless, AC or USB Power" and with the AutoInput Plugin "Screen Off Or On: Turn On / Timeout Never" but the screen always turns dark.
Those Profiles always worked on my other Smartphones (LG -D405, LG-K10 and Moto G6). I believe, it's the ColorOs that's causing the trouble.
Click to expand...
Click to collapse
below is a task ONLY FOR ROOTED DEVICE., no harm to try even if your's not root.
New task , run shell command , in the command input
there is a button 'use root' , check that button also.
settings put system screen_off_timeout 200000
** 200000 I'm not sure sure equals to how many second., just give it a try and if you get a longer screen on time from your issue it means it is working.
also, make another separate task, search for 'custom setting'. look up from there I thingk it is in system something about screen timeout.
EDIT: run shell command task suggest you run it manually., than see if it works. if not, restart device to check if it requires a restart in order to accept new timeout settings.
eeeemc said:
below is a task ONLY FOR ROOTED DEVICE., no harm to try even if your's not root.
New task , run shell command , in the command input
there is a button 'use root' , check that button also.
settings put system screen_off_timeout 200000
** 200000 I'm not sure sure equals to how many second., just give it a try and if you get a longer screen on time from your issue it means it is working.
also, make another separate task, search for 'custom setting'. look up from there I thingk it is in system something about screen timeout.
EDIT: run shell command task suggest you run it manually., than see if it works. if not, restart device to check if it requires a restart in order to accept new timeout settings.
Click to expand...
Click to collapse
I feel like I'm in Star Trek - "To boldly go, where no one has gone before" XD
When I try your suggestion, I only receive the message that my device isn't rooted.
Btw, for some tasks it is necessary to enable the Write Secure Setting Permission (f.e. Set Assistant), where xou have to setup ADB on your PC. Would such a procedure be registered by the phone as rooting? Anyway, I don't think I would dare to do something I know so little of.
Another solution I was thinking of, is it possible to create a tasker quick tile/ quick setting to change the system screen timeout.
So instead of having it change for certain apps which isn't working at the moment.
Maybe if we can change it from the system so will be for all apps. You can create two separate quick tiles to toggle between different screen timeout settings.
The newest version of Tasker (6.0.9) comes with Tasky.
Tasky offers the possibility to activate premade profiles. One of them is "Keep Display Awake For Apps". And that one works with my OPPO Phone.
I also tried "Auto-Mute Apps", another profile I couldn't get working. It also works fine.
To switch between Tasker and Tasky you just have to click on the "Three-Dots-Button" in the right top corner. It's not like switching apps but using different user interfaces.
Good luck!
- Sorry to say, but this seems to work for some apps and not for others. But at least sometimes it does work.
Thanks for replying back to this thread to inform me. I tried it and it works for the app I was trying to make it work for which is good! Makes it so much easier now.

Categories

Resources