Thursday, April 25, 2013

Tasker to detect and vibrate once the ougoing call is being answered

Tasker to detect and vibrate once the ougoing call is being answered
as far as we may know, many 3rd party apps have the option for vibrating while the outgoing call is being answer. and this profile below is made for anyone who might not want to install any 3rd party apps and wish to use tasker to make it instead.

I happen to find that for GSM standard phone, call duration would be created into sql database only if the outgoing call is being answered, or after hanging up if it is not being answered.

So i guess this method is meant for CDMA android phone only. cause we could not detect if outgoing call is offhook by the callee via tasker or sl4a.

Java code would be the solution i think, by monitoring the phone state.
If you are interested, please follow my profile instruction below and run some test, please further advise me if it is working or any issues. many thanks!
NB.: to run sqlite 3 command, you must make sure your phone has installed the proper sqlite3 file and you must root your phone first to run sqlite3 command.
Tips:
download the sqlite3 file via the links below and renane it as "sqlite3" if it is not, then put it under the phone root directory /system/bin folder, and don't forget to modify the permission for the sqlite3 file to be
rwxr-xr-x
android 4.0 or earlier: http://bit.ly/sqlite3
profile:

context: state-phone-call, type:outgoing
task:
action 1: script-run shell,
command: sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db "select duration from calls where type <= 2 order by date desc limit 1;"
use root checked, store result in %VIBRATING
action 2: alert-vibrate, 200ms, if %VIBRATING  ~   1
action 3: task-goto, action number 2, if %VIBRATING    !~   1
Action 4: task-stop, if %VIBRATING  ~   1

 

11 comments:

  1. JB : The database entry is created only after the call is endeed :(

    ReplyDelete
  2. I think I have mentioned about that in my posts already .

    Outgoing call For GSM standard cellphones, the call duration would be created after the recipient answers the call.

    Not at the time call is ended ,cause I actually did test about this a couple times.

    ReplyDelete
  3. After a few test I can confirm that the database entry is created after the call ENDEED and not after the recipient answers the call.

    ReplyDelete
    Replies
    1. hi,

      1st, i was wondering what specific testings you did? how?

      2nd, what specific database entry are you talking about? call duration colom?

      3rd, what specific ROM and phone model are your cellphone?

      seriously, you have got my interest in this issue.

      i just need some more information to figure it out.

      Cathy

      Delete
    2. Wiko Cink Slim, Stock ROM Android 4.1.1 + TWRP 2 + root

      sqlite3 /data/data/com/android.providers.contacts/databases/contacts2.db "select duration from calls where date = (select max(date) from calls);"

      This request return the last call entry duration.

      -I make a call of 10 seconds and hang up. After,it return 10.
      -I make a new call.
      -While the outgoing call is ringing it return 10.
      -after the call is answered and ongoing it return 10.
      -I wait 15 seconds and then end the call
      -After the call ended it return 15.

      Delete
    3. /data/data/com.android.providers.contacts/databases/contacts2.db
      not
      /data/data/com/android.providers.contacts/databases/contacts2.db
      :)

      Delete
    4. Hi,

      1st, regarding run shell action for sqlite3 command, i have already explained clearly in my posts that it usally runs slowly and would get stuck if runs with any error.(not always, it just would) you may search on google to see if i am telling you the truth.
      that means one thing, 10 seocnds a cycle as an interval, you probably get none/null or even stderr(standard error) as result in return, cause accoording to the tasker run shell action help file, run shell action would stop only after it is done.(of course you may set up a specific timeout for it, but i am afraid it makes no difference.)

      2nd, concerning your given sqlite3 command, i was wondering if "where date = (select max(date) from calls)" would work.
      cause based on the standard sqlite3 syntax, select the last item from a specific colom should be "order by date desc limit 1", which you may find it in my posts description.


      you may try to use python script to get your will done, which you may find out details in my other posts.

      i sincerely hope my explanation is clear enough and would be any helpful for you.

      Cathy

      Delete
  4. Hi,
    The sqlite3 request take around 1000ms to complete. And I monitor error output. No stuck, no time out.
    I use "where date = (select max(date) from calls)" because it's more efficient than "order by date desc limit 1"
    Order by is slooooooow

    So again, the entry is created only after hang up.

    What phone/rom are you using ?

    ReplyDelete
    Replies
    1. Hi,

      are you using tasker outgoing call context to test it?

      in addition, did you try python sl4a script as i suggested previously?

      my phone is HTC desire s, stock android 4.04+sense 3.5

      Cathy

      Delete
    2. Hi,
      every way lead to the same result. I tried tasker, sl4a and even directly in an android console.

      Delete
    3. Hi,

      i am not so sure what is going on for your phone, maybe you could get other android smartphone to test if possible.

      in addition, are you using tasker outgoing call context to test it?

      Cheers!

      Cathy

      Delete