[Vibrant Android Development] strictlyrude27:
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

v1: initial release - should hopefully be the only one!