Making tech work for me (smartphone automation with Tasker)

I’ve made a few mentions of my fondness for MortScript during my time in the Windows Mobile world.  It was most useful when it came time to automate in-car tasks – resolve Bluetooth connectivity drops, dis/connect A2DP, keep the screen alive.  Other things were more general in nature, like emulating a Bluetooth “timed discoverable” feature and restoring the Normal ring profile after Silent had been active for a period of time.

All useful additions, features or fixes.  And I’m sure that I’ve given a shout-out to Tasker as my go-to-guy for giving me the same sort of hacking pleasure on Android.

Fortunately, my Tasker experience to-date has been more about adding functionality than fixing O/S problems.  And I’ve extended the functions I mentioned in this post to the point that I’m tickled pink (not literally, of course) over the added convenience that has been bestowed on my Android phone.

The aforementioned post has a section aptly named “Tasker” that basically talked about things which happen automagically when the phone is in the car.  Basically, when the car’s Bluetooth is detected, the phone can be in one of two states which we’ll call “Car In” and “Car Docked”.  It’s the latter which is of most interest, and it becomes active – as mentioned in that previous post – when external power is connected.

(it would be possible to sense the presence of an actual “car mode” cradle, but the Desire Z doesn’t have the requisite hardware.  I find it acceptable to consider the phone in a “car docked” mode if the car’s bluetooth is detected and the phone is plugged in – which pretty much means that the phone is sitting in a cradle)

Gone are the days of auto-launching Google Navigation – more on that later.  I definitely wanted a 3-foot user interface to come up when the phone entered Car Docked mode, but Google chose to deny access to the actual Car Home app on my phone.  So, I relied on Vlingo‘s “InCar” feature to emulate the Car Home app.  And this was… acceptable.  Vlingo’s usefulness as a Siri-like assistant was questionable, but I was digging the convenience of the InCar interface so I told Tasker to fire up this interface when Car Docked mode became active.  From there, I could launch Navigation or Maps or – if Vlingo was cooperative and background noise was low enough – speak a command to open any app of my choosing.

Vlingo’s usefulness fell significantly once it stopped being able to hear anything I tried to yell at it.  I think this happened shortly after I rooted the phone, but no matter; it was the kick in the pants that I needed to convince me that it was time to rid myself of this dysfunctional relationship with Vlingo.  Away it went.

It was subsequently replaced with a pure-Tasker solution, in which I could hold down the search key and up would pop a custom menu containing all of my useful in-car shortcuts.  So there was a link to Navigation, Opera Mobile, XiiaLive for streaming audio, and some other useful apps.  And this was… acceptable… but it was just wasn’t integrated enough.  What I really wanted was to hit the home key and have a real 3-ft interface appear.  What I really wanted was Google’s Car Home app.

My decision to root the phone was actually the ticket I needed to get Car Home installed, as it involves booting into recovery and installing a signed package file containing Car Home.  Anyhow, that was done, and so we arrive at the point where I am today – getting in the car and putting the phone in its cradle and connecting power automagically brings up the 3-ft interface of the Car Home app.

It may seem to you like I’ve spent a lot of time to get something going that’s trivial.  And on the face of it I’d agree with that perception.  But you have to keep in mind the how and why of it all.

The “how”, in this case, is Tasker.  And the “why”, in this case, is Tasker’s flexibility and power.  Car Home has the ability to launch itself whenever it detects a certain Bluetooth device – ie, the car – and that’s great.  But I want more to happen when my phone is “docked” in the car.  And this is why Tasker is important, and why I’d rather have Tasker launch Car Home at the appropriate time.  In actual fact, Tasker sets the phone’s “Car Mode” setting to true, which is a global setting which may have other (desired) ramifications.

Now… recall that I mentioned Tasker’s previous duty of starting Google Navigation whenever the Car Docked state became active.  I could tell you that it’s nice to have Navigation up when you’re driving, and to some extent that’s true, but my car has navigation built-in – and that screen is 2x the size of my phone’s screen.  I could tell you that Google Navigation shows semi-reliable traffic information, and that’s true too, but I don’t need that info for the entire drive.  Plus, I can always get there with two taps: one tap on the Home button to bring up the Car Home launcher, one tap on the Navigation icon to bring up navigation.

So why did I ever have Tasker launch Navigation as soon as the phone was docked in the car?

One word: Latitude.  Click the link.  Honestly, do it.  Then you’ll know why Latitude is important for me.  With Navigation active, GPS is also active, and when GPS is active the phone is aware of movement with more precision than it is when using WiFi and/or cell towers.

So Navigation was a useful means to a GPS-enabled end.  And while I still find Navigation useful, it’s really the Latitude updates that I wanted to occur while the phone is docked in the car.

Most obvious solution: tell Tasker to turn on GPS, and Bob’s your uncle.  Well, not so fast – even if Tasker can just turn on the GPS module and leave it turned on (which I doubt), you get into trouble with the opposite action: turning GPS off.  Suppose somebody is trying to use GPS when Tasker turns it off?

So my solution is somewhat more creative.  And this goes back to the “how” and “why” of using Tasker at all when Car Home seems suited to fulfilling your 3ft-interface needs.

Something else that I’ve had Tasker do is adjust my phone’s brightness dynamically.  And yes, the phone has an auto-brightness setting, but believe me when I say that the lowest brightness setting is still way too bright when you’re driving in darkness.  When the phone is docked, Tasker runs a task that loops and constantly measures the light-sensor’s reported ambient light level.  Then, in conjunction with the Screen Filter plugin, it is able to dim the screen to levels that would be un-achievable otherwise.  It can even take sunset/sunrise times into account, as those tend to be the trickiest times of day when it comes to suitable lighting.  This logic recently underwent a rewrite, and it’s not as straightforward as following the sensor’s (somewhat finicky and fluctuating) reported level.

Anyhow, this task is great because it’s an active loop that I can use to call other tasks.  And the lastest task is… one which attempts to get a GPS fix.  So every 60 seconds or so, Tasker asks the Android system for the most accurate location info possible.  Android dutifully obliges by determing which location services are permitted – GPS and/or “net” – and uses the most accurate one to get the requested information.  The beauty here is that it’s now Android which is determining what needs to be done to get the location data.  If Navigation is active and using GPS, then the location data is known and returned to Tasker.  Okay, Tasker doesn’t actually do anything with that information.  BUT… if GPS is not active, then Android will turn on GPS, get a fix, return the location data to Tasker, then turn off GPS if nobody else is using it.  Which completely solves Tasker’s  problem of determining when/if GPS should be active.

This is good news, because Latitude seems to be hooked into a system event notification that goes something like this: “if the phone determines that its location has changed, let me know.”  Well, because Tasker is asking for updated location info every minute, and its asking for the most accurate location info available, it’s necessarily the case that Latitude will get notified every minute if the phone has moved.  Meaning…

…all of my Latitude-dependent services will have precise, up-to-date location info.

I know what you’re thinking – what happens if I’m moving around and I’m not driving?  This is entirely possible.  And the short-answer is – nothing.  We’ll get the same old imprecise Latitude info and it may not be terribly relevant either.  BUT… and this is important… everything I’ve done re: Tasker and the “Car Docked” mode means that the special use case of having the phone docked in the car will result in precise, relevant Latitude info.  Period.  Even if I only drive one day a week, it’s now the case that the driving scenario is handled in a seamless, extensible, straightforward manner.  It requires no special user intervention that wouldn’t occur otherwise.  It doesn’t even require that Navigation is active.

And that’s the design philosophy that I aim for.  Look at a problem, find an elegant and workable solution.  Refine the solution.  And hopefully, extend the solution to resolve related problems.  If you can extend the solution, then you know you’ve come up with a solid foundation or approach.

That’s why I’m tickled pink.  I love to solve worthwhile problems 🙂