[CM7][GPS][Tasker] Enable/Disable GPS Driver Widget - Vibrant Android Development

Hi all,
Abstract:
I present a way to easily toggle GPS on/off in CM7-based ROMs using Tasker and Locale Execute plugin. It is a little less cumbersome to use than the toggle available in Trigger Redux, and introduces the ability entirely in other CM7 based ROMs. It also leaves a permanent notification on boot if GPS drivers are enabled, so you're not wondering if it worked or not. You can download and import the profiles, tasks, and scripts required in the attached zip, below. See installation instructions.
NOTE: I cannot guarantee that your GPS will get a lock! I can only guarantee that the GPS driver will be correctly loaded/unloaded. Getting a lock is a whole different story!
Overview:
I'm running Trigger Redux build#14 and got a little annoyed with having to go into EDT Tweaks to toggle on/off GPS. There also isn't a naive way to do it in vanilla CM7 (that I know of). However, it's as simple as getting rid of /system/vendor/bin/gpsd (Roman renames it "disabled_gps".) I wanted to write a Tasker widget to do the following:
When I want GPS on:
rename /system/vendor/bin/disabled_gps to [..]/gpsd
Automatically toggle GPS on before reboot
Reboot for me, to reload the GPS driver
Create a permanent notification after reboot
When I want GPS off:
rename /system/vendor/bin/gpsd to [..]/disabled_gps
Automatically toggle GPS off before reboot
Reboot for me; on reboot, phone won't find GPS driver
Using Tasker and the Locale Execute plugin, this is all pretty easy. I wanted to share this with you all because I know how annoying the GPS battery drain is, and toggling the driver on and off isn't natively available in CM7.
Installation Instructions
In the attached zip file, there are 6 files:
CM7_GPS.sh <---- used to only have to approve one Superuser request, rather than several; renames GPS driver correctly and causes a hard reboot
CM7_GPS.tsk.xml <---- toggle widget, this lives on the home screen
CM7_GPS_su.tsk.xml <---- get superuser request - run one time, then you can delete it if you really wanted to
CM7_GPSToggle.tsk.xml <---- toggles GPS on/off, runs CM7_GPS.sh to rename the GPS driver
CM7_GPSNotify.prf.xml <---- leaves a permanent notification that CM7 GPS is enabled on boot
CM7_GPSNotifyClick.prf.xml <---- allows you to click the previously set permanent notification to disable CM7 GPS
You'll need Tasker 1.1 (latest version) and the free Locale Execute Plugin.[/color]
Open the zip and place all *.prf.xml in /mnt/sdcard/Tasker/profiles . Place all *.tsk.xml in /mnt/sdcard/Tasker/tasks . Place CM7_GPS.sh in /mnt/sdcard .
Open Tasker; hit Menu->Profile Data->Import One Profile. Import all profiles that you just installed.
Same as above step, but with tasks.
Hit Tasks, then open "CM7-GPS_su", and hit "Test". Approve the Superuser request. Exit Tasker.
Create a Tasker widget on your home screen - look for the task "CM7 GPS".
Enjoy the ability to toggle the GPS driver on and off, quickly and easily
THAT'S ALL YOU NEED! Download the profile scheme, and hit the Thanks button
If you ever wonder if the Tasker widget actually worked, just look for the "CM7 GPS Enabled" permanent notification. I explicitly check if the file "/system/vendor/bin/gpsd" exists to create that notification. There have been a *couple* of instances where the notification didn't come when it should have; I put in a Wait 20 seconds before checking for file existence in the CM7-GPSNotify task, and that seems to have fixed my problem.
I've been testing, debugging, and refining this profile scheme all day. I've not always been able to get locks, but I've been able to load/unload the GPS driver every time.
If you have issues, please let me know ASAP so I can fix and re-upload. Like I said though, I've been using this GPS toggler without fail for the better part of a day now.
Changelog
Code:
v1: initial release - should hopefully be the only one!

where you can find TASKER 1.1b4
i only find Version: 1.0.21 in offical website
BTW, why don't just turn off gps, i don't think this can drain battery.

yeah i dont think it does i leave mine on and i get good battery life

roffee said:
where you can find TASKER 1.1b4
i only find Version: 1.0.21 in offical website
BTW, why don't just turn off gps, i don't think this can drain battery.
Click to expand...
Click to collapse
Check the link I posted.
Disable/enable for the GPS driver itself was based on a conversation in the CM7 nightlies thread (can't find it because there are WAY too many posts in that thread). In Trigger Redux#13, Roman introduced an "Enable GPS" checkbox in his EDT Tweaks that loads or unloads the GPS driver. This Tasker widget just emulates that functionality, but with a few more bells and whistles.
It may or may not impact battery life; I haven't run enough tests to truly understand the impact of leaving the GPS driver enabled, but GPS functionality disabled. I do know that at the time of the original fix (nightly #54 or thereabouts?) it was, correctly or incorrectly, associated with moderate to heavy battery drain. I've always used EDT Tweaks to load/unload the driver ever since; I just wanted to share something that made my life easier, and might make others' lives easier too.

Yes I confirm, GPS enabled does not actually waste your baterry life, it only uses it when the gps icon is blinking. I keep my gps on all the time, but this is a nice profile nevertheless.

Related

Shortcuts to enable/disable Wi-Fi?

Forgive me if this has been asked before, but are there any shortcuts to enable/disable wifi on the Raphael? I picked up the AT&T Fuze earlier this week and I love it, but I use the wifi fairly often and it is rather tedious to have to go to Settings > Communications > Wi-Fi (from TouchFlo) every time I want to either enable or disable it. Thanks in advance.
I use AEWifitrigger and it works great. Check my signature out for the download.
You could also disable PTT, and then set the PTT button to pop up the CommManager (now pseudo-renamed as Wireless Manager) as a quick way to enable/disable everything.
My XIAMultitheme theme - SaFF has BT and WiFi icons that can be used to start/stop bt or wifi and also show the state.
It is currently a clock plugin (Time - links to alarms, date - links to calendar, email/sms/voicemail/missed calls counters/buttons, BT and WiFi) Feel free to rip my code if all you want is the BT/WiFi buttons in a today plugin.
There are also more states than I have supplied icons for. See the images\common\wifi folder, it has a number of PNGs in it, each one represents a state code (eg 5.png is what shows if the wifi reg key says state 5), so if you find that the icon does not change when you connect to something for example, if we find what state code that is (Which is easy, just add another tag to the XML file to tell it to print the number), we can add a new icon easily.
I am in the process of doing a new VGA version for the raphael - all that needs changing is coordinates doubling in the XML file and double size images need to be supplied.
It currently requires mortscript if you want to hear a sound when you click a button, if you don't require that, all you need is XIAMultiTheme.

Widget for turning off location awareness? (in addition to GPS)

(caveat: this is for Sprint Hero)
Does anyone know of a widget that will turn off ALL location based settings? Obviously there's the builtin widget from HTC for GPS.. but heres what I mean - follow this into the settings..
Settings>Location
There's checkboxes in here for
-Wireless Networks
-Location Setting
-GPS
The builtin widget only turns off the GPS checkbox. I want to turn on/off all three of these settings at once, or even via separate widgets is acceptable.
I can't seem to find anything that will allow me to do this. Anyone know of anything?
Just trying to turn off anything I can to help conserve battery. I'm not a big location-based user so I can live without these features. If I want mapping or location stuff I want to be able to turn all of it on/off without menu diving.
Can't wait for Seidio or whomever to release a big battery for this phone. I can't get a full day, presumably because of things keeping radios/connections alive.

Atomatically enable data when screen is off periodically (enormous battery save)

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!

[Trick] Make AOD useful again

So you tried AOD (Always On Display) on your favorite Port ROM, you like it but you don't use it anymore because of battery issue.
A way to avoid this would be, like application bases AOD do, to enable this feature only if the phone is on charge. Unfortunatly, this settings is not available. I found a way (somewhere, by somebody else, all credit to him) using Tasker to do it:
Once you have Tasker and Secure Settings (paid apps, but in my opinion, really worth it if you like customizing your device), open Tasker and do the following :
1. On the Tasks tab, create a new task called for example ‘AOD On’
2. In that new task, add an action (Category = Plugin, then Secure Settings)
3. Edit the configuration in the new screen and select Actions => Device Setting
4. In that screen, the Setting Table should stay at ‘system’, and the Setting Name should be ‘aod_mode’. The Setting Value should be set to ’1′.
5. Save the task and create another task with the same steps but call it ‘AOD Off’ and set the Setting Value to ’0′.
6. Once both tasks have been created, go to the Profiles Tab and create a new profile and select ‘State’.
7. Select state category => Power => Power
8. Leave Source as Any, and Invert unchecked.
9. Save the profile, choose the correct task (‘AOD On’), call it ‘Charging’ for example
10. Create a second profile called ‘Not Charging’ exactly the same way but with the ‘Invert’ of step 8 checked, and select the task ‘AOD Off’.
UPDATE : Solution No2 (+ disable AOD when battery is low)
1. Download this app (paid),
2. Don't forget to select the features you want to enable,
3. Thanks @erghetto in post #2 !
4. Voila !
Both solutions works fine on my S8 port. AOD becomes useful again !!!
Or simply use this:
https://play.google.com/store/apps/details?id=com.roei.aodplus
erghetto said:
Or simply use this:
https://play.google.com/store/apps/details?id=com.roei.aodplus
Click to expand...
Click to collapse
Well honestly I tried all app based AOD and it's like lock screen app : more features, nice looking but not so well implemented that stock (security, look and feel, Speed...).
But if you are ok with it...
nmeuret said:
Well honestly I tried all app based AOD and it's like lock screen app : more features, nice looking but not so well implemented that stock (security, look and feel, Speed...).
But if you are ok with it...
Click to expand...
Click to collapse
Maybe you didn't even open that link.
It is an app that simply activates aod only when phone is in charge (plus another feature)
So no need to download tasker or any other app.
It is paid, but also one app you suggests need be payed, so this one is simpler and doesn't require any configuration with tasker or similar
erghetto said:
Maybe you didn't even open that link.
It is an app that simply activates aod only when phone is in charge (plus another feature)
So no need to download tasker or any other app.
It is paid, but also one app you suggests need be payed, so this one is simpler and doesn't require any configuration with tasker or similar
Click to expand...
Click to collapse
Ok, ok, I see, you're right, it's a good alternative. Now it depends if you already use Tasker or not, but for people who don't and don't want to bother with all Tasker settings, that's a nice app I didn't know !
nmeuret said:
Ok, ok, I see, you're right, it's a good alternative. Now it depends if you already use Tasker or not, but for people who don't and don't want to bother with all Tasker settings, that's a nice app I didn't know !
Click to expand...
Click to collapse
Happy of having helped ^^
And thanks also to you, because you however provided a guide which i'm sure is interesting for many users
macrodroid is better

Can Tasker create an icon to set the volume to a specific value...

...and to set the brightness to a specific value? I can do this easily in Windows, but not in Android.
Perhaps you figured it out by now, but just in case, the answer is definitely yes, I use that very functionality for brightness on my phone:
1. Create a new task
2. Add a "Display Brightness" action to this task (the value in this action doesn't represent percentage, so you might need to experiment with the number to get the desired brightness)
3. Add a "Tasker Shortcut" widget to your home screen. It will lead you to select the name of the task you created.
-It will also require you to select an icon for the widget, which you will do with the 9 squares at the bottom of the task edit screen (I already selected an Android robot icon in the picture).
-When adding the widget, you may also encounter an error message requiring you to open Tasker and exit with the back button to close it out properly in order for the widget to work.
There would be a similar process for volume, but you'd have to choose the appropriate action for which volume you want to adjust: ringer/system/media, etc.
Yes, I did figure it out, but thanks for posting that clear explanation, which is rare. It will probably help someone.
My most interesting program so far is a reliable way to turn the display off and on automatically to save battery power and, more importantly, to extend the lifetime of the power button.
Even with a reliable program, though, Tasker sometimes delays responding when it is closed and the display is off, so I've found that Tasker must be left running all the time. This is easy to arrange: in Android task viewing mode, click the lock icon at the top right of the screen view pane so that it becomes solid.
Such locks persist forever, I think, and are therefore quite confusing to newcomers to Adenoid, I mean Android.
You're welcome. Hopefully it might. I sympathize with the new user, since often it's difficult to get a solid, helpful answer from an advanced user regarding a beginner's topic.
As for Tasker being killed on occasion, unfortunately the circumstances surrounding that vary dramatically between devices. For example, whatever lock icon you're talking about to fix the issue on your device is not on my phone at all, so it would not work as a solution for me.
Do you have the option to "Use reliable alarms" in Tasker? I'm not sure if its presence varies between Android versions. I have that option set to "always"*, and I've never had a single time where Tasker fired late or was killed. It uses a persistent system alarm to keep tasker "in mind" all the time.
*And battery optimization for Tasker turned off, of course
david0001 said:
Yes, I did figure it out, but thanks for posting that clear explanation, which is rare. It will probably help someone.
My most interesting program so far is a reliable way to turn the display off and on automatically to save battery power and, more importantly, to extend the lifetime of the power button.
Even with a reliable program, though, Tasker sometimes delays responding when it is closed and the display is off, so I've found that Tasker must be left running all the time. This is easy to arrange: in Android task viewing mode, click the lock icon at the top right of the screen view pane so that it becomes solid.
Such locks persist forever, I think, and are therefore quite confusing to newcomers to Adenoid, I mean Android.
Click to expand...
Click to collapse
Enabling Use Reliable Alarms doesn't help. I think at this point I would say that getting Tasker to work when the display is locked is not obvious. Perhaps it is documented somewhere.
Basically, the bad symptom is as follows: after the display has been locked for a few minutes, moving the device fails to turn the display on again. Something kicks or locks Tasker out, but only after more than just a few seconds.
Sorry about not realizing that locking an app in memory is not part of Android. I'm using an inexpensive TCL A3 device sold by Tracfone. Locking is nice when you want to avoid startup delays for a task.

Categories

Resources