[MTCD Software Development] SomebodySysop:
Using Tasker and AutoVoice to Voice Automate BT App Calls

OK, I finally figured this out. It's clunky, kludgy and not for the faint at heart, but it works and it works with Google Now. I'm using only Tasker and AutoVoice. It doesn't actually call the contact, but using voice only commands, you can bring up the Bluetooth phone app with contacts which match your request. Select the one you want and click dial.

I am actually using Skype to place and receive most of my calls. I'm posting this for two reasons:

a. To help other newbies, like myself, to better understand how Tasker works with an example of real code.

b. Hopefully, someone who knows a lot more than me about Tasker and AutoVoice might see it and offer suggestions on how to make it faster, more efficient and better overall.

Example of how it works here: https://youtu.be/g9fjHtBcf10

Tasker Profile BT Call

Event: AutoVoice Recognized [ Configuration:Command: "bluetooth call (regex)"

Variable Names: %name

Variable Values: %avcommnofilter ]

Essentially followed the guidance here to create a custom Google Now Voice Trigger “bluetooth call”: http://lifehacker.com/how-to-create-custom-voice-commands-with-tasker-and-aut-1282209195

This creates AutoVoice Recognized event when OK, Google gets voice command beginning with “bluetooth call”. I used “The Hard Way” and clicked “regex” which includes the AutoVoice variables %avcomm and %avcommnofilter (which I use). I created %name variable, but do not use it.
​

Enter: Start Phone App (3)

A1: Launch App [ App:Bluetooth Data: Exclude From Recent Apps: Off Always Start New Copy: Off ]

I launch the Bluetooth phone app with the profile command.​

A2: Run Shell [ Command:sh /system/bin/BTContactsButtonPress.sh Timeout (Seconds):15 Use Root: On Store Output In:%Temp Store Errors In:%Temp02 Store Result In: Continue Task After Error: On ]

I created a shell script which, when ran, executes the “Contacts” button press from the Bluetooth phone app default screen. First, I manually captured the results of this button press using “getevent”. Then, I took that code, which is in hexadecimal, and reformatted it to “sendevent” code in decimal. That’s the hex_to_dec.py script explained here: https://qatesttech.wordpress.com/20...nt-into-something-something-that-can-be-used/

Running this script gets me to the BT phone app Contacts screen. The execution of this script takes several seconds, hence the timeout.​

A3: Run Shell [ Command:input text %avcommnofilter Timeout (Seconds):10 Use Root: On Store Output In: Store Errors In: Store Result In: ]

I execute this command to send the name I wish to call to the BT app Contacts screen. The AutoVoice variable %avcommnofilter will contain this name as it is the entire voice command sent minus the command filter “bluetooth call”.​

A4: Run Shell [ Command:dumpsys window InputMethod | grep "mHasSurface" Timeout (Seconds):0 Use Root: On Store Output In:%Keyboard Store Errors In: Store Result In: ]

I use this command to check if the virtual keyboard is displayed on the screen. I store the results of this check in %Keyboard variable.​

A5: Run Shell [ Command:input keyevent 111 Timeout (Seconds):10 Use Root: On Store Output In: Store Errors In: Store Result In: ] If [ %Keyboard ~R .+true.+ ]

If %Keyboard variable contains the word “true”, then keyboard is on screen and I then execute this command which sends the BACK key signal to the screen, effectively hiding the keyboard. If I send this command without first checking if the keyboard is there, then it would move me away from this screen I wrote all this code to get to in the first place!
​