[Android Software/Hacking General [Developers Only]] ziddey:
Preface

This guide only deals with VoIP calling over wifi. You can experiment with calling over a data connection as well; just make sure to use only the speex or GSM codecs. I have had pretty good success with VoHSPA calls with T-Mobile. However, this would require manually switching call forwarding to the cell number on and off. I am looking into creating an app to automate this (as well as combine features of all the accessory apps used in this guide). However, I have limited programming experience and no Android experience yet, so it's a long term project.

Apps

Sipdroid

https://play.google.com/store/apps/details?id=org.sipdroid.sipua

Google Voice

https://play.google.com/store/apps/details?id=com.google.android.apps.googlevoice

Y5 - Battery Saver

https://play.google.com/store/apps/details?id=pl.polidea.y5

Plane Mode Tweaker

https://play.google.com/store/apps/details?id=com.wordpress.chislonchow.airplanemodetweak

AutoAir

https://play.google.com/store/apps/details?id=Com.YangSoft.AutoAir

GV SMS Integration Free

https://play.google.com/store/apps/details?id=com.mdrtools.apps.gvintegration.free

Guide

Free VoIP is a great addition to plans with low airtime minutes, such as T-Mobile's contract-free $30 100 minute, 5GB 4G plan. An activation kit can be purchased for $0.99 shipped from http://prepaid-phones.t-mobile.com/prepaid-phone/T-Mobile-Prepaid-SIM-Activation-Kit.

This guide assumes that your primary number is with Google Voice, http://www.google.com/voice. You can port your number from one of the major carriers (Verizon, AT&T, T-Mobile, Sprint) to Google Voice for $20. Do note that porting your number will terminate service with your provider, and you will be responsible for any ETF. If your number is currently with an MVNO or other carrier, you should be able to use a prepaid T-Mobile account as the middleman. Simply pick up an extra kit (if you will be using the T-Mobile $30 plan) to use for the number porting. Kits come with an initial value of $3.34, more than enough for the process.

If you are not attached to your current number enough to spend the $20 port fee, you can pick a new number when signing up for Google Voice. You can specify desired characters or numbers, and it will attempt to find a match.

Once you have created an account, add your cell number and enable call forwarding from your Google Voice number. Most prepaid accounts, including the $30 T-Mobile one, do not allow call forwarding, so you will not be able to "Activate Google voicemail on this phone." However, this shouldn't be an issue since people shouldn't be calling your cell number directly anyway.

Also enable call forwarding to Google chat. This is critical for receiving VoIP calls. It may be necessary to first place a call within GMail to ensure that Google chat calling works as it should.

Now it's time to download and setup the apps listed above.

Sipdroid

When first starting Sipdroid, you will find a button on the bottom of the screen to create a new account with PBXes.com linked to your Google Voice account. Use the same password as used with your Google Voice account. After signing up with Sipdroid, you have a week or so to login to the pbxes.com website and fill out some personal information. This must be completed, or your account will be deleted.

As far as configuring Sipdroid itself, you may want to go into Audio/Video and adjust Earpiece Gain to Highest. Adjust as necessary if echo is a problem.

Under Audio Codecs, set G722, PCMA, PCMU, GSM, and BV16 to Never. Speex is the only codec we want to use due to its ability to compensate for packet loss and jitter and its low bandwidth consumption. However, it can be quite CPU intensive, and if you have a slower phone, GSM may be a better option. Experiment with the two and find what works best for you. Snapdragon and faster CPUs will have no problems with speex.

Under Wireless, you can experiment with the Control Wi-Fi Power option. It may save you some battery life, but disable it if it cause otherwise slow wifi or disconnects. If not using this setting, you will need to set Android to keep the wireless connection on all the time. You can access this from Android's Wi-Fi settings page, where it lists the wireless connections. Hit the menu button and choose Advanced. Change Keep Wi-Fi on during sleep to Always.

Enable Bluetooh (experimental) if you will be using a bluetooth headset to make VoIP calls.

Finally, in PBXes Features, enable Improve Audio. In the event packet loss / jitter is detected, all data will be transmitted/received twice, effectively decreasing packet loss considerably (ideally).

Google Voice

Setup should be fairly straight forward. You may run into issues setting up call forwarding for voicemail, but this shouldn't be an issue. Set it to Use Google Voice to make all calls. This way, all non-VoIP outgoing calls will still have your Google Voice caller id.

This will also be the app you use for text messaging. Unfortunately, Google Voice is still working on implementing MMS. As of now, receiving MMS messages from certain providers is functional, although they will be sent to your email.

Y5 - Battery Saver

This app remembers wifi APs that you have associated with and switches wifi on when you are in the area. When out of area, it will be disable wifi. It requires both the cell radio and wireless to be connected to determine location. Therefore, airplane mode must not be enabled during this step.

The only setup required is to enable the app. It will then run in the background automatically.

Plane Mode Tweaker

Enabling airplane mode on most phones will disable the cell radio, wifi, and bluetooth. While in Airplane Mode, wifi is allowed to be re-enabled, while bluetooth usually is not. Make the appropriate changes with this app to prevent wifi/bt from turning off when entering airplane mode, and to allow wifi/bt.

AutoAir

AutoAir polls the wireless state in the background. When connected, it enables airplane mode; when the connection is lost, it disables airplane mode. Hit the power button in the app to enable initially. Set it to Start Service on system up and Start Service on application start up. To disable the icon in the notification bar, uncheck Show message on status bar. This serves to save battery by disabling the cell radio and to prevent double ringing, since Google Voice is forwarding to both your cell number and Sipdroid.

GV SMS Integration Free

While not related to VoIP, a lot of users would prefer the native SMS client over the GV app for text messages. Google Voice can forward texts, but it will obviously be encapsulated in a forwarded message from a shortcode instead of the actual sender's number. Not exactly clean by any means, but it is the only solution when in an area without data (i.e. roaming). Otherwise, this app will work alongside the GV app to offer seamless integration with the native SMS app (or GoSMS). You must enter your credentials in the app again for it to be able to send messages. Upon enabling integration, the phone will reboot. There looks to be three types of integration: standard, root user, and airplane mode. I've only used root user, which seems to work just fine in airplane mode.

Since I never use my cell number for texting, I have it set to send all text messages via Google Voice account. It does have the option to allow replying to texts from the number it was received from, which can be useful. There's some warning about hiding the notification bar, but I haven't had any issues yet.

Going after strictly GV SMS integration, and nothing else, I've disabled the send/receive text signatures, turning the screen on when there's a new notification, and showing popups when there's a new text.

Be sure to disable text notifications in the Google Voice app.

Do note the warning when you first enable integration-- if you decide to uninstall the app, DISABLE INTEGRATION FIRST.

That should be it! When you are home, the phone should automatically switch wifi on, connect to Google Voice (PBXes to be accurate), and enable airplane mode to disable the cell radio. Incoming calls should ring through Sipdroid. Outgoing calls are made through the native dialer as usual, and will be intercepted by Sipdroid.

When you leave home and lose wifi, airplane mode will be disabled, re-enabling the cell radio, and wifi should be disabled (saving battery by not constantly searching for APs). Inbound calls will be forward to your cell number, ringing through the native dialer. Calls made with the native dialer will dial through Google Voice (still uses airtime) and allow your Google Voice caller id to be shown.

Messaging is not a problem in airplane mode since you will be using the Google Voice app (and GV SMS Integration). The only downside is that a data connection is required for messaging while on the go. You can enable forwarding messages to your cell number if this is an issue.

Notes

It would have been nice to use the native SIP client, but it simply lacks too many features. Even over a strong wifi connection, a high(er) bandwidth codec like PCMA/PCMU may not be feasible, because of the lack of packet loss/jitter compensation. Many people prefer CSIPSimple over Sipdroid, but it does not play nicely with the Google Voice app, and does not support PBXes' proprietary features.

The main advantage of using the Sipdroid/PBXes combo over GrooVeIP is the ability to use speex/GSM codecs. GrooVeIP connects directly to Google Voice, which only supports PCMA/PCMU.

If you want to experiment with other SIP clients, do make sure to connect using TCP. UDP is a battery pig.

I've experimented with a few Android phones and have to say that some of the lower end ones are simply plagued with call quality issues, especially with regards to echo. Other issues may involve wifi quality with the screen off, so play with those settings as necessary.

Some phones have issues maintaining a wifi connection. Check for any ROMs that may address this issue. The plus side is that AutoAir will disable airplane mode if the wifi connection is lost, so there shouldn't be any missed calls. Specific to HTC Sense, there is a bug (feature) that causes the wifi connection to be dropped between midnight and 7am. The app SmartSync Disabler attempts to address this issue: https://play.google.com/store/apps/details?id=com.j4n87.smartsyncdisabler.

I am using this setup with good success on an HTC Sensation running ICS. I'm at the end of my current billing period and haven't even used half of my allotted minutes. In comparison, I've clocked over 500 minutes over VoIP.

I hope this guide saves you some minutes and battery life.