CSipSimple icon indicating copy to clipboard operation
CSipSimple copied to clipboard

[FIX] make the phone vibrate and ring in the same time (related to google code issue 2458)

Open oneacl opened this issue 9 years ago • 1 comments

As that google code issue 2458 said, it's currently not possible to have it ring and vibrate at the same time (can be either one but not both). I've solved this by creating a tasker profile that looks for the application csipsimple putting a notification: "call in progress" and variable SILENT !~ on - run a shell script:

[code]

!/system/xbin/bash

while [ $(logcat -d -s libpjsip |tail -1|grep "180 Ringing"|wc -l) -eq 1 ] ; do echo 500 > /sys/devices/virtual/timed_output/vibrator/enable sleep 1 done [/code]

I'm not sure if the "echo" command will run without root privileges though as mine runs as root.

Looking at logcat that "180 Ringing" line is displayed while the phone is ringing and another line will get put afterwards as soon as the call is either connected or disconnected (rejected).

A bit of a nasty hack but it seems to work.

oneacl avatar Aug 23 '15 21:08 oneacl

To do this, CSipSimple's log level should be set to 4 and not log to a file (using logcat), of course.

In my install, much more than just the SIP/2.0 state is apparently being logged to logcat at DEBUG level, so I had to be more selective in the grep expressions. I also didn't want to activate the script when the system was set to vibrate mode (it's already vibrating as-is in that mode, just not when the ringer is audible).

Create a script containing the following, which should work on all ROMs regardless of what is installed (it uses only standard-install commands such as /system/bin/sh):

#!/system/bin/sh
while logcat -d -s libpjsip | grep 'SIP/2.0 ' | tail -1 | grep '180 Ringing' >/dev/null 2>&1; do
    echo 750 >/sys/devices/virtual/timed_output/vibrator/enable
    sleep 1
done

Pay special attention to the space at the end of the first grep command; it's very important that it bve there to avoid extra debug lines like "SIP/2.0/UDP blahblah...".

Make this script executable with chmod +x scriptname.sh. If you put it on a sdcard or other FAT partition, you may not be able to do this and might have to make the tasker Run Shell action below include "/system/bin/sh" in front of the script path.

In Tasker, create task with action Code -> Run Shell, set path to the script saved above, and enable Use Root (required on most ROMs).

Next, create a profile for Event -> Notification -> Owner Application CSipSimple, Title "Call in Progress". Set the task to the one created above. Add another context Variables -> Variable Value, %SILENT, Like (~), off.

This should make the action happen only when the ringer is audible, leaving the normal vibrate profile behavior when the ringer is off. Adjust the 750 (milliseconds) value in the script as desired; that works better for me on my device. If you need it to be longer than 1000, you'll need to make the sleep value longer than 1 second.

tvierling avatar Oct 29 '15 00:10 tvierling