line

The Smart Watch Project

MAKING THE SOFTWARE PERFECT

by Dalibor Lanik

line



    As I said in my U8 clone watch review, the problem this and probably all Bluetooth watches have is ability to switch, or better, select, where you will receive incoming/outgoing calls on the fly.

THE PROBLEM

First, we need to understand how Bluetooth works. And why. Because of security, BT devices need to pair. This is no problem, and once devices are paired, or allowed to access each other, they stay that way. There are several "protocols" Bluetooth can use over this connection. One of these protocols is, for example connecting your mouse and keyboard, but in this case it needs, and automatcally connects BT call audio and BT media audio.

BT SETTINGS

BT call audio is needed to transfer voice calls from your handset to your Bluetooth device, in our case, smart watch. Or it could be BT earpiece. BT speaker, etc.

BT media audio is used to transfer other sounds your handset makes, i.e. music. So when you connect BT speaker, you can play music to it from your phone. And this works fairly well for speakers, as the other protocol works well for BT headsets.

BT AUDIO

But it doesn't work well for smart watches.

First of all, when you connect call audio, all audio during calls is transfered to your Bluetooth device, that is - watch. There is no way to change it on the fly, once the call arrives. You would have to go to settings and turn off call audio, or turn off Bluetooth altogether, which is not practical and takes a lot of time. By the time you (let's take simpler and quicker task) manage to turn off Bluetooth, the caller would probably hang up :) Or you would press something wrong in haste and panic while the phone is ringing (could be your boss calling!!) :) And after you finish the call, you would again have to turn Bluetooth on and connect the devices. Too much operations, for a single call. So either leave your audio on the watch (good luck in hearing anything) or untick this option altogether.

That leaves us with media audio. Once this item is ticked, all audio (excluding calls) from your phone will be transfered to your smartwatch. All audio. Not just music, when you play it from your favorite player or audio from Youtube and such. All audio. Get it? Button clicks, alerts, sounds apps make when you like, post, send... everything. First of all, this is terribly annoying, you typing and sound coming from elsewhere, and second thing - this drains battery terribly. Both your phone and your watch, because Bluetooth is constantly transfering audio. And third thing - the speaker on the watch is greatly inferior to the one on your phone :)

So why just not disconnect/uncheck both options? Well.. you can, but then you wouldn't be able to accept phone calls from your watch, listen to music on your watch, and use the remote camera function. Only thing that would work would be notifications. If that is enough for you - the you don't have a problem. But that would be using only like 50% of your watch.

In order to have calls and remote camera, you need at least one service active, either call audio or media audio. Since media audio does greater "damage" to the battery and is more annoying, I have decided to turn it off and have only call audio active. This way, everything works, except the media player (listening music from your phone on your watch).

THE SOLUTION

The solution would be in something that would enable you to switch the bluetooth (or call audio) off quickly and easily when you dial or receive a call. The presumption is that you want this functionality because sometimes you will answer calls on your phone and sometimes on your watch, so you would want to preserve both options.

The solution I came up with is done with my favorite app on Android - Tasker. and one plugin for tasker called Secure Settings.


HOW IT WORKS

The idea is as following: Detect when there is incoming call and display an overlay button. By clicking this button, Bluetooth connection will be terminated, and as a result, your incoming call will be taken on your handset (phone) - or rather, your audio will be routed back to your phone. If you don't press the button, the call will be transfered to your watch. You can see the red Bluetooth button on the screenshot below.

DIALING

Also, you need to detect outgoing calls, so you can do the same. Mind you that these are two different things, technically - incoming call rings, and you have option to answer. Outgoing calls go directly to "in call" screen.

Ofcourse, there has to be something to turn the Bluetooth back on, after the call has finished. But if you think this is all, you're wrong. By turning Bluetooth on, you don't automatically connect to the watch. So that is another step needed - conect to the watch again.

IMPLEMENTING THE SOLUTION

The best tool for Android automation and interface building is Tasker. We will use it together with one plugin for a complete solution, nothing else is needed. First of all, we need to create an scene - that is a overlay which contains the button that will be displayes when there is a call. Give it a name BT, it should be something like this:

SCENE

Make an overlay that is the size of the button, and a button that fills the whole overlay. Select it's position so it is not covering any other buttons in incall screens.

Then, let's make events that will trigger the action.

First event is Phone Ringing. So in Tasker, under profiles:

PROFILES

create new event like this:

RINGING
 
This event runs only when the "Phone Ringing" and "BT Connected to Smartwatch" are true. You can setup smart watch name and MAC adress.The BT_PopupRing task runs following:

POPUP RING

Variable set, sets variable BTon so we know whether we're in a call. And it displays scene, that is overlay button.

The second event is Call.

ИНЦОМИНГ ЦАЛЛж

Тhis runs the event on any call, incoming and outgoing when smart watch is connected. The reason we have 2 diferent events is because we want to display the overlay on incoming call, when the phone is ringing, before we answer the call. This displays the overlay when we accept the call or dial out. BT_Popup is very similar to BT_PopopRing and does the following:

POPUP

First it checks variable BTon. If it was setup to 1 by previous event (BT_PopupRing) while the phone was ringing, there is no need to display the overlay, since BT_PopupRing already displayed it. This is (logically) an outgoing call. Then display the overlay, and that's it.

Now, we want to create a task that is executed when we press the Bluetooth overlay. Under tasks, make a task called BT_OFF as follows:

BT OFF

This turns off Bluetooth and hides the scene (overlay) since we pressed it, and don't need it anymore.

This task will be executed from a scene (overlay) so go to your scene and add tap action like this:

SCENE TAP

OK, this is almost done. Now just to add event and task which will turn Bluetooth back once the call has ended. Back to profiles, make an event that will run when phone is idle, that means ends the call:

IDLE

When phone is idle (that event is run when call is ended) will run BT_ON task, which will be set like this:

BT ON

First it checks whether we were in a call, by checking BTon variable. If it is 1, set it back to zero (reset it). Then run plugin Secure Settings and from it set it to auto-connect to the watch, and turn the Bluetooth on as well:

SECURE SETTINGS

So, just to make things a bit easier, we will create another profile, which will be activated on phone shake if Bluetooth is not connected to smart watch:

SHAKE

The BT_CONNECT task will do the following:

SHAKE DETAIL

So when you want to manualy connect your watch to the phone, all you have to do is shake your phone a couple of times from left to right :)


That is all, folks :)

BUY ME A BEER!

    I already spent many days and nights to develop this software and write this tutorial and am offering it for free. So, if you like it and feel it is usefull to you, buy me a beer or two! Donate 2-3 or $ or whatever you think appropriate. Cheers!


U8 clone smart watch review



line