Friday, May 27, 2011

More Tasker tricks

Continuing the theme of automation with Tasker, I've come up with a couple of new things to share...

Damn you, autorotate!

For the most part, I use my phone in portrait mode. It's just the most comfortable way to hold such a device. I think that might have something to do with why they made it that way. :) But, there are a lot of times landscape's a better fit for what you're doing...like Angry Birds. And, maybe some web sites.

Now, if you're a portrait kind of guy like me, you might find the phone's auto-rotation feature to be a bit of a hassle at times. Like, when I'm using Navigation and it switches because I put the phone down on the seat next to me and now I can't tell where I'm supposed to turn because the damn thing's too narrow to display the road far enough ahead. I could turn off auto-rotate, sure. But, then I lose the functionality in those few apps where I actually want it. Oh, the quandary!

Then, the other day, I came across an app called Smart Rotator which provides a solution: it toggles auto-rotate on an app-by-app basis. Nice! And, it works pretty well. Unfortunately, it's yet another thing I need to have running, so I decided to do some poking to see if I could mimic the features using Tasker. Fortunately, it couldn't be easier.

First, I created a new Tasker profile in the App Launch context (the little rocket ship icon). I chose Dolphin Browser HD and Calculator as the apps to watch for. Then, create a new task called "Turn On Rotate" and select Display - > Display Rotation -> Set to On. Save it. Create an Exit Task called "Turn Off Rotate" and repeat except change it to Set to Off. Then, tap the Menu button, then Settings -> Display and uncheck Auto-rotate screen.

Now, auto-rotate is off by default, but when I launch my browser or calculator it's available. When they close, it goes back to off. I chose Calculator just to show you could configure multiple apps with just one profile. If I find another app that I want to be able to auto-rotate, I just go in and edit the profile.

Don't Track On Me!

Recently, I switched over to CyanogenMOD 7 on my Evo (love it!). There is, however, a bigish bug on the Evo in the version I'm using: GPS can't keep a lock properly. There are workarounds and a solution that worked when I put CM7 on my wife's phone, but not on mine. For the time being, I've found my own workaround:

Create a new profile in the Event context (the orange triangle) and call it Display Unlocked. Then, Display -> Display Unlocked. I set the priority to Normal and haven't had any issue. Create a new task called Display Unlocked (I like originality). Misc -> GPS -> Set to On. Create a second profile in the same context, but call it Display Off. Then, Display -> Display Off. I'll leave it as an exercise to figure out what to do for a task. :)

So, now, when I unlock my phone, it turns GPS on automatically and turns it off when I've turned the screen off. This has actually worked quite nicely and I haven't had any complaints about GPS since. The one drawback is Google Latitude doesn't work as well. However, as I'm constantly checking my phone anyway, it seems to keep me mostly up to date. Plus, no tracking by the feds! Double-win!

My Dynamic DNS Hack

After the GoDaddy CEO mercilessly and needlessly slaughtered an elephant for his sick amusement, I decided to take advantage of the offer in that article and switch my domains over to Namecheap.com. Aside from no longer supporting a company whose CEO should have his stepped on by that elephant's mate, I've gained some nifty benefits by switching to NameCheap (Not the least of which is better service at a lower price! Seriously, switch. You won't regret it.) One of them is dynamic DNS.

A little background: dynamic DNS is a service that allows you to assign a host name to an IP address that's constantly changing. A lot of folks use dynamic DNS so they can get to their home machines without having to worry about their ip address changing regularly.

The service I've used for years is No-IP.com, and frankly I have nothing bad to say about them at all. I've always had reliable service from them and have never had to contact them for support. It's a service that just works. That being said, if my registrar is giving me free dynamic DNS service along side my basic registration, well it just makes sense to try and migrate to that!

There are a couple of apps in the Market that will perform as client for your dynamic DNS provider, but none worked directly with Namecheap.com. But, as I thought about it, I realized here was another chance to find my own solution. Unfortunately, it wasn't as elegant as I'd like, but it works more or less the way I want. Perhaps if it becomes irritating enough, I'll fix it up further...

First, a caveat: I'm not sure how much of this would require you to have root access on your phone. I've gone through it again in my head, and I don't think there's anything below that needs special permissions. But, if it doesn't work on your first try, that might just be the reason.

The first piece you'll need is the Scripting Layer 4 Android. The SL4A is a great little project to bring a number of scripting languages to the Android platform to make it easier to develop things like...well, this! At current count, it supports Python, PHP, Ruby, JavaBeans and shell scripting, which we'll be using. Follow the instructions at the link to get it installed. Since my solution just uses a shell script, you don't have to install any other interpreters just yet. Fire up a text editor on your machine and copy in the following:


#!/system/xbin/bash

source /data/local/tmp/ipaddress

test=`netcfg | grep UP | grep -v 127.0.0.1 | awk '{ print $3 }'`

if [ "$test" != "$ipadd" ]; then

domain="domain.com"
username="canbeanything"
apikey="namecheapkey"
hostname="mobile"
hosturl="http://dynamicdns.park-your-domain.com/"
command="update?domain=$domain&username=$username&password=$apikey&host=$hostname&ip=$test"

url="$hosturl$command"

wget -q -O- $url
echo ipadd=$test > /data/local/tmp/ipaddress
fi


If you've been following along with other articles, you know that I've got Tasker profiles which disables the mobile radio when wifi is on and vice versa. As a result, the above script is a bit quick-n-dirty as it assumes there's only one radio on at any given time, and thus "UP". You'll have to do some tweaking if you don't have your phone setup like mine.

So, what does it do? It reads a text file I've created that simply contains the line "ipadd=192.168.1.1" (or whatever the IP was the last time it ran). It runs the netcfg command which is similar to Linux' ifconfig command. It finds the line for the interface that's up and not the loopback connector and snips out the IP address it finds. It then compares it with the one that's in the text file. If they match (which means the current IP at Namecheap.com is most likely what's currently on the phone), it does nothing. If they don't, it builds a url and uses wget to ping it. Namecheap.com will then update their records.

Note: I am specifically pushing the IP to Namecheap because if you don't they use whatever IP the request comes from. As a result, when I'm at home on my NATted network, it'll use the IP of the external interface of my router and not the internal IP I'm using on Wifi. Part of the reason I'm setting this up is to automate some tasks at home to push stuff to the phone, so I need the right address there.

So, what about Tasker? Remember the GPS hack you read about 2 minutes ago? We're going to leverage that. Edit the task for the Display Unlocked profile and add a new item. Plugin -> SL4A. Yes, SL4A has been kind enough to give us a Tasker plugin! Hit the Edit button and select the script above. Done! Now, when you unlock your phone, it'll update your IP if need be. A rockin'ly simple solution that seems to work just spiffy!

Hopefully, these will inspire you to try some new stuff with Tasker you hadn't considered before. If you do, drop me a line below and tell me about 'em!

Thursday, May 5, 2011

Sprint/Google Voice - A match made in hell

Last week, Google & Sprint announced the release of their much anticipated integration of services. Google Voice is a fairly cool service that's been around for a few years. It got its start from another company under the name Grand Central and was eventually snatched up by the Googlemonster for inclusion in their line up. With the service, your phone number becomes a lot more flexible. Some features I was looking forward to:


  1. Multiple receiving phones can be setup to ring when someone calls your Google Voice-based number and can pick up any one to answer. This was a feature I was looking forward to using most. I could setup my desk phone to ring along side my cell when called. So, if I was sitting at my desk and someone called my cell I could pickup the headset for the desk phone and talk to them. It's even possible to setup Gtalk on your desktop as a receiving phone


  2. You can specify which times you would like calls to make it through to your phone. So, you could setup a "quiet" time after 11pm where your physical phone doesn't ring and all calls are shunted through straight to voice mail. You can also specify certain numbers always get through and others never do. Useful for telemarketers or your boss having your number and trying to reach you on the weekend.


  3. Voice mail is transcribed to text (albeit very poorly) and sent right to your e-mail inbox to read.


  4. You can make international calls through GV very inexpensively



Some cool stuff, right? The drawback was you had to get a new phone number from Google that you'd have to give out. Now, if you were in the process of getting a new phone and for some reason needed a new number, no biggie. Just get the GV number, point it at your cell and never give out the actual cell number. This was also useful pre-number porting days as you could always have the same number. But, if you're like me and have had your number for 15 or so years, that wasn't a great option.

The Sprint/Google Voice integration allowed you to simply use the number you already have from Sprint as your Google Number. With a few clicks, everything you already have in place just gets a ton of new features and flexibility. At least, that's the theory...

The first issue I ran into was I simply couldn't do it at all. Apparently, there's a feature called "Google Voice Lite" where you simply forward your voicemail to Google Voice, but don't have any additional features beyond that. I had been using Google Voice Lite when I had my iPhone, but didn't know it was considered a different service. When I went in to activate the integration, I didn't have any of the options the announcement said I should. It showed I was using a Sprint phone, but wouldn't give me the option to integrate it.

So, I figured I'd just delete the phone and re-add it and see what happened. No go. I was told I needed to have at least one physical phone listed. Okay, I'm at my desk, I'll add my desk phone, delete the cell phone and re-add. No go. When I tried to add the desk phone, it showed up, but I couldn't do anything with it. Even the Edit and Delete buttons underneath were non-clickable text. I couldn't even get rid of any phone I added!

After a day or so, the answer finally popped up on the Google forums regarding Google Voice Lite. Apparently, I needed to click the link that said "Get a Google Voice number" (which was right next to what was listed as my Google Voice Number) and I would be asked to upgrade my account to full Google Voice and get it integrated. Google's #1 problem: they really don't seem to have a full grasp of the English language. There were NUMEROUS posts on the forums about this problem, and it was almost a week before someone bravely clicked that link and figured it out.

Great, this seemed to work. I got the options to integrate, followed the process, Google Voice called me to authenticate, I gave the code and seemed to be good to go...until I clicked the Continue button. At that point, I was told there was an error and to try again. Which gave the same error, again and again. You can't even get rid of the error message, you have to close your browser (or the tab) to get back to Google Voice.

In order to be complete and verify what my status was for this article, I decided to call my number and leave a voice mail...nope! I can't even leave myself one. Apparently, now my fiddling with Google Voice has disabled even the Google Voice Lite capabilities. Update: I decided to play around a bit further and requested a new Google Voice number. I was then able to add my cell phone back into the mix as a receiving phone which reenabled using Google Voice on it. Phew!!

This is a huge fiasco. The forums, both at Sprint and Google are rife with complaints from people having these same issues. The biggest problem being faced by folks, it appears, is they're getting some kind of discount on their Sprint plan. That would be consistent with my problem as I get a discount through my employer. What bothers me is *I* pay for my plan, not my employer, so why should it matter?

According to one Sprint employee who's trying to help out, the decision was made to block discounted employees because some employers might not want third parties having access to "their" info. Even if this is true, it's an absurdly stupid reason to unilaterally block all discounted customers. It's an indication of pure laziness on the part of Sprint.

So, if you've tried to setup integration of Google Voice and Sprint, and didn't have any luck, I recommend you stop now before you make things worse. It's one thing to experience issues as an early adopter, but complete showstoppers are the last thing I should expect. At the very least, the error messages should clearly state the reason for the failure and not some generic "oops, broke!" message.

It also points to a significant flaw to using Google as a provider for any critical services: they don't have ANY customer support at all. If it's broke, there's no one you can call to get it fixed. You can call Sprint, of course, but they're just going to blame Google (as they did the first few days of this debacle).

It's sad to see two companies who really seemed to have "gotten it" get it so completely wrong.