AnalogClock






Tuesday, September 9, 2008

iPhone Gurgling Water Noises and Dropped Calls

Updated 2008-10-08:
I traced the source of the problem back to smsnotify. The daemon shell script runs through a tight loop repeatedly checking the voicemail and sms sqlite databases using the sqlite3 command. I edited the script and put some bigger time delays between queries to the databases and a growing delay between vibrating alerts. The smsnotify default time delays can be a little disconcerting when you get a voicemail or SMS while on a call. It also creates a problem when you put down your phone and leave it for an hour. A single voicemail or sms will run down your battery and wake you from your sleep with incessant vibration alerts every 10 seconds.

Here is my version of the smsnotify.sh script. The original post follows it.:

#!/bin/bash

#set -Tvx

SMSNOTIFY_PATH=/usr/local/smsnotify
SMSNOTIFY_SECONDS=30
SMSNOTIFY_COUNT=0
VMNOTIFY_SECONDS=30
VMNOTIFY_COUNT=0

while test 1
do
if [ `echo 'select count(*) from message where \
flags=0;' | sqlite3 \
/var/mobile/Library/SMS/sms.db` -gt 0 ]
then
if [ $SMSNOTIFY_COUNT -lt 2 ]
then
SMSNOTIFY_SECONDS=10
elif [ $SMSNOTIFY_COUNT -lt 4 ]
then
SMSNOTIFY_SECONDS=100
elif [ $SMSNOTIFY_COUNT -lt 5 ]
then
SMSNOTIFY_SECONDS=1000
elif [ $SMSNOTIFY_COUNT -lt 6 ]
then
SMSNOTIFY_SECONDS=2000
else
SMSNOTIFY_SECONDS=9000
fi
#Each parameter to vibrate is 1 more
#vibration, so vibrate 3 times
$SMSNOTIFY_PATH/vibrate 1 1
let SMSNOTIFY_COUNT+=1
else
SMSNOTIFY_SECONDS=30
SMSNOTIFY_COUNT=0
fi
/bin/sleep $SMSNOTIFY_SECONDS

if [ `echo 'select count(*) from voicemail \
where flags & 1 == 0;' | sqlite3 \
/var/mobile/Library/Voicemail/voicemail.db` -gt 0 ]
then
if [ $VMNOTIFY_COUNT -lt 2 ]
then
VMNOTIFY_SECONDS=10
elif [ $VMNOTIFY_COUNT -lt 4 ]
then
VMNOTIFY_SECONDS=100
elif [ $VMNOTIFY_COUNT -lt 5 ]
then
VMNOTIFY_SECONDS=1000
elif [ $VMNOTIFY_COUNT -lt 6 ]
then
VMNOTIFY_SECONDS=2000
else
VMNOTIFY_SECONDS=9000
fi
#vibrate 2 times
$SMSNOTIFY_PATH/vibrate 1
let VMNOTIFY_COUNT++
else
VMNOTIFY_SECONDS=30
VMNOTIFY_COUNT=0
fi
/bin/sleep $VMNOTIFY_SECONDS

#This program sleeps for 5 seconds then checks
#how long it's been sleeping. If it's been more
#than 10 seconds the phone has slept and it exits,
#allowing the loop to continue
#$SMSNOTIFY_PATH/waitforsleep
done

# vim:ai:et:sw=4:sts=4:


I've been having all kinds of iPhone trouble acquiring signal, dropping calls, and the signal going in and out. My voice sounded incoherent and was always accompanied by the gurgling sound of electronic water.

The problem was of my own creation. I had jail broken my phone and installed all kinds of apps that had launched many server processes. Most of the server processes failed to stop with a simple:

su -c 'launchctl stop com.sourceforge.netatalk.afpd'

I ended up having to do a:

su -c 'for i in /Library/LaunchDaemons/*;
do launchctl unload $i;done'

I did the same for the ones installed in /System/Library/LaunchDaemons. I just limited the file glob expression to the services I wanted to unload as a plain * would probably force me to have to restore my iPhone. i.e. I used com.apple.mDNS* and other more specific file globbing expressions.

Since all of my calls had garbled audio quality my first phone call verified that I had fixed the problem. Also the fact that I had a crystal clear conversation with only one bar was the proof I needed. As I hadn't been able to get my iPhone to dial most of the time with 3 bars.

The only caveat is that inorder to renable these services you have to load the profiles again rather than doing a simple stop and then start. I'll have to look into how those .plist files should be written so that the start and stop work properly and maybe even have launchd do the listening for some of the services rather than having all of those services running unnecessarily.

Hope this helps. It saved me from carrying a separate phone just for conversations.