Wednesday, April 17, 2013

Tasker to auto record incoming or outgoing call


Tasker to auto record incoming or outgoing call



most of time, i was thinking of tasker can do the job like callrecorder? if yes, how to do?
well, after done some homework, i have figured out the method below to share with you guys. via this method, tasker is able to auto record incoming
call and outgoing call, unwanted callee and unreached call will be excluded from recording.

before everything, you should create 1 folder named with english characters, eg. Voice, then create 3 separate folders inside this folder, named it as "Incoming", "Outgoing" and "Temp".

NB. if you are currently using some kind of caller location app, please make sure if it would change the call logs combined phone number and location info with symbol like angle brackets? if yes, tasker would fail to create the new file for outgoing call recording.



Profile 1: (incoming call) 
 
Context 1: Event- Phone- Offhook

Context 2: State: Incoming Call

Task: 

Action 1: variable-Variable Set [ Name:%Oncall To:0] 

Action 2: media-Record Audio [ File: Voice/Incoming/%CNAME_%CDATE_%CTIME  Source: incoming Call/Mic, Code: arm narrowband, format: raw_arm  ]  

Action 3: alert-Notify [Title:Recording Call Icon:(any icon)]

PS. you may put action 2 and 3 together as a separate task, then make it as a pop up alert positive button right after action 1, asking if you wanna
record.


Profile 2: (outgoing Temp)

Context: State: outgoing Call


Task:

Action 1: task-If, %CONUM !~ XXXXX       # XXXX stands for the phone number which you don't wish to record

Action 2: variable-Variable Set [ Name:%Oncall To:1] 

Action 3: media-Record Audio [ File: Voice/Temp/    Source:ouggoing Call/Mic Code: arm narrowband, format: raw_arm  ]   

Action 4: alert-Notify [Title:Recording Call Icon:(any icon)]


PS. you may put action 2 and 3 together as a separate task, then make it as a pop up alert positive button right after action 1, asking if you wanna
record.



Profile 3: (stop recording)

Context: Event-phone-Phone Idle

Task:

Action 1: media-Record Audio Stop

Action 2: alert-Notify Cancel, title: Recording Call

Action 3: task-If %Oncall ~ 1

Action 4: 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 %COUNT

# this step is very important, cause we may know, tasker even sl4a script could not detect if the callee has picked up the phone. if duration is 0, i guess you don't wish to waste storage to record the ringtone, right? this shell command would extract the value of duration for the last phone call
you have made.

Action 5: File--Move [ From: Voice/Temp/.amr  To: Voice/Outgoing/%CONAME_%CODATE_%COTIME.amr  If,  %COUNT > 0 ]        # Based on action 4 run result,
tasker may detect and exclude the unreached outgoing phone call. so it would not waste storage space at all. cause the recording would just start
right from the moment while dialing.

Action 6: task-end if

Action 7: variable-variable clear, name: %Oncall




##  duration counting  via sqlit 3 command

if we look into the calllogs within android default call database, we will see some significant columns, which are very useful for us to get this job done.

type: (numberic)

3: incoming missed call,  2: outgoing call(reached or unreached)  1: incoming call(offhook)

duration: (seconds)

order by date desc limit 1: this is to identify and select the last one in record.

20 comments:

  1. Cathy,通话记录在通话期间(尚未结束通话)是不能得到更新的,怎么办啊?

    ReplyDelete
  2. Not like that you thought so. It is certainly getting updated. It is mainly because of the run shell action reacts not that much rapidly. Sometimes it gets error then fails to exit.

    Check my other posts to get more information.

    ReplyDelete
  3. 好吧,希望如此。我再试试。

    ReplyDelete
  4. 试了。我试着取到值后就显示,结果还是那样,电话挂断之前,一直显示的是上次通话的分钟数(若上次未接通,就是0,接通了就是上次的通话时长)。电话一挂断,马上得到更新。可能我手机的个例吧。motolola的双模机,不是标准的联系人库。/data/data/com.motorola.blur.providers.contacts/contacts2.db
    顺便说一句,华为mate上的这个库是标准的路径 /data/data/com.android.providers.contacts/databases/contacts2.db 。但是也未能即时更新,只有在电话挂断后才得到更新。

    ReplyDelete
    Replies
    1. huh?

      may i know what method did you test on getting the duration for outgoing call? via run shell command? how exactly did you implement?

      you are always talking about outgoing call, right?

      if via run shell command, i already told you why earlier.

      by the way, i am not familiar about the database structure for dual standard cellphones.

      Cathy

      Delete
  5. 是的Cathy,抱歉没说清楚误导你了。其实,我是想参照你这个例子,来实现在通话过程中(电话挂断之前)判断本次通话时长,但是很遗憾试了几个机型都失败了(有双模的motolola XT882,有单卡的huawei的mate,有单卡的samsung的N7100,在通话过程中,无论是用sqlite editer,还是通过run shell sqlite3的查询,都没办法看到尚在通话过程中的本次通话进行的时长。
    BTW,你的这个教程的例子中,本来就是在通话过程结束后才查询通话时长的。所以我并不是说你的这个例子不对。别误会啊Cathy。
    顺祝安好。

    ReplyDelete
  6. Cathy,你退出qq群了,失去了向你请教和你沟通的渠道,借你的博客吧。如果介意就请删掉以免影响你博客版面整洁。
    我是想在motorolaXT882上实现通话过程中自动录音。此机型原生自带通话过程中录音的按钮,效果也很好,真正的内录。我是想参照你的博客中的相关教程,来判断通话是否开始(无论是呼出,还是呼入,抱歉上面的留言只提到了呼出)。如果通话开始了(进行中的通话时长>0),就模拟点击屏幕上的通话录音按钮(模拟点击操作用run shell实现了)。否则就等待后再尝试。我注意到你提到了两种方法:run shell ,以及py脚本。可是,在py脚本中,查到相关记录后,我不会进一步调用run shell操作,所以只好用run shell sqlite3的方法来判断是否开始了实际通话。
    上面提到的几个机型都不是在通话过程中即时更新本次通话时长的(事实上连本次通话记录都没有),Cathy请教你有好的建议来实现我上面提到的这个功能么?就是判断通话过程实际开始了,然后模拟点击操作。
    给你带来困扰,抱歉了。

    ReplyDelete
    Replies
    1. Hi,

      i think i have explained sorta clearly that run shell action runs slowly and it might even get error in return and cause stuck.

      so it didn't mean "未能即时更新,只有在电话挂断后才得到更新",although you get none/null as result.

      please try to use python script in instead of run shell command, which you may find out how in my other posts.

      and regarding your another concern, "在py脚本中,查到相关记录后,我不会进一步调用run shell操作", it is no problem at all.

      after you done get the right string value in return via python script, you may send variable intent to tasker, which you may set up relevant variable value context to link the run shell action.

      in addtion, it would be better if you leave me message in english only, cause it took me quite some time to understand what you mean, especfically that kind of long sentences.

      or you may send directly to my qq email box with full details, which would save me quite some time.

      I guess you are Fantasy, right?

      Cheers!

      Cathy

      Delete
  7. Hey Cathy,

    Interesting stuff. I'm a web developer over in Dublin Ireland. Just started playing round with SL4A this past week with python and enjoying it. Been playing with RSS feed consumption using the feedparser package and with Twitter search and streaming API's using Tweepy, both packages work very well though the docs on Tweepy are a little out of date.

    I've added a call record button to my phone using Wanam Exposed but the option to have it all automated is appealing so I'll try out your solution and let you know how it goes.

    In the meantime, keep up the good work. I've posted the URL to your blog on the Google Plus Tasker group as I really think more people should see the nice work you've done here.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. So I set this up today on my rooted Samsung Galaxy Note 2 (International version) and discovered a couple of things that might help someone else.

    On the Note 2 and maybe other Samsung models, I found the best balance between caller and callee voices was obtained by setting the audio source to 'default' for both incoming and outgoing - call incoming and call outgoing sources were not available to me and threw errors.

    To check the call duration I found that my '/data/data/com.android.providers.contacts/databases/contacts2.db' calls table was empty. After some hunting round I discovered that Samsung save this data in '/data/data/com.sec.android.provider.logsprovider/databases/logs.db' so you just need to update your duration collection action to take account of that.

    Otherwise everything seems to work great.

    Want to look now at automatically moving the recordings over to my external SD card (didn't want to record them there as it is obviously slower than the internal SD) - maybe on a nightly basis. Would be also nice if I can throw them up on Dropbox for archiving there - if i make progress with that I'll add it here.

    ReplyDelete
  10. Hi Cathy, amazing task!!
    I need your help: I have a Note 2 with 4.4.2, and when I finish an outgoing call the registration is not renamed and moved from Temp folder to Outgoing folder, so at the end of the call I found a recorded file without name in Temp folder such as Voice/Outgoing/.amr

    I have already checked and in the path '/data/data/com.android.providers.contacts/databases/contacts2.db' is present a file (about 1.3mb size), so I think is correct.
    Any suggest?

    ReplyDelete
  11. record all incoming or outgoing calls auto http://androidcallrecorder.blogspot.in/

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Dont miss any call record all incoming and outgoing calls automatic.Download android premium call recorders for FREE . Download From Here: Android call Recorder

    ReplyDelete
  15. Hello, this is a good auto recorder. Well, i have a Total Recall call recorder android app installed on my device allowing you to record both sided conversation with clarity.

    ReplyDelete
    Replies
    1. Hey tani..i have installed this Total Recall application. I have no words to explain how good this app works. Also, one unique feature of this which i discovered is it does not produce any sound while recording. Thanks!

      Delete

  16. Check Samsung call recorder App for Samsung MOBILE phone user , Best recording App for samsung user,
    Install call recorder in your phone.

    ReplyDelete