So what about 3G on sholes?

So a lot of people are probably wondering why I haven't updated in awhile. I actually am hoping to start updating this blog more often but with shorter blog posts in order to try and keep up with all of the crazy stuff I'm up to lately!

Well I'll get right into it!

Sholes 3G

So my main focus right now has been trying to fix the sholes 3G bug. I have recently modified some of the NetworkStateTracker code and submitted it to the Cyanogen Gerrit for review.

So what does this fix do? Well essentially it's laid out below:

     public void addDefaultRoute() {
         if (mInterfaceName != null) {
             if (DBG) {
                 Log.d(TAG, "addDefaultRoute for " + mNetworkInfo.getTypeName() +
                         " (" + mInterfaceName + "), GatewayAddr=" + mDefaultGatewayAddr +
                         ", CachedGatewayAddr=" + mCachedGatewayAddr);
             }
 
             if (mDefaultGatewayAddr != 0) {
+                NetworkUtils.addHostRoute(mInterfaceName, mDefaultGatewayAddr);
                 NetworkUtils.setDefaultRoute(mInterfaceName, mDefaultGatewayAddr);
             } else if (mCachedGatewayAddr != 0) {
                 /*
                  * We don't have a default gateway set, so check if we have one cached due to
                  * a previous suspension.  If we do, then restore that one
                  */
-                NetworkUtils.setDefaultRoute(mInterfaceName, mCachedGatewayAddr);
+                if (DBG) {
+                    Log.d(TAG, "addDefaultRoute: no default gateway, attempting to use cached gateway");
+                }
+                int r1 = NetworkUtils.addHostRoute(mInterfaceName, mCachedGatewayAddr);
+                int r2 = NetworkUtils.setDefaultRoute(mInterfaceName, mCachedGatewayAddr);
+                if (r1 < 0 || r2 < 0) {
+                    // something went wrong... restart the network
+                    if (DBG) {
+                        Log.d(TAG, "addDefaultRoute: something went terribly wrong... restart the network");
+                    }
+                    teardown();
+                    reconnect();
+                }
             }
 
             /*
              * Clear our cached value regardless of which of the above two situations
              * were hit.
              */
             mCachedGatewayAddr = 0;
-            NetworkUtils.addHostRoute(mInterfaceName, mDefaultGatewayAddr);
-            NetworkUtils.setDefaultRoute(mInterfaceName, mDefaultGatewayAddr);
         }
     }
 
     public void removeDefaultRoute() {
         if (mInterfaceName != null) {
             if (DBG) {
                 Log.d(TAG, "removeDefaultRoute for " + mNetworkInfo.getTypeName() + " (" +
                         mInterfaceName + ")");
             }

There's a few things happening there. First, we make sure that the settings for the original default route are where they're supposed to be. After the merger of 2.3.4, apparently an extra addHostRoute as well as an addDefaultRoute were appended to the end of the method, so we fix that.

Secondly, we set up a fallback which calls teardown() and reconnect() in the event of a cached route restore failing. This isn't necessarily the most elegant way to fix this, but from what I can tell, Motorola's RIL is attempting to handle routing on its own, so without an updated RIL for sholes, we may be stuck with this solution.

On another note, it was brought to my attention recently that we were actually building for sholes as if it were a GSM device, so that's been modified to reflect that it is actually CDMA, though I haven't noticed any difference.

The good news? In my testing I haven't seen any data connectivity problems anymore yet, but that's just me, so we'll hope for the best.

Wrap-up and a look of things to come!

As mentioned above, I hope to start doing more blog posts but to make them shorter so as to more easily keep up with all of the things I will be doing over the summer months! Here's a brief list of topics I intend to cover coming up as well as what I'm presently working on:

I'll talk to you next time! If any of the above topics sound the most interesting to you, mention it in the comments and I'll take that into consideration for my next write-up!

tl;dr

Sholes 3g has a potential fix, waiting on more extensive testing via the nightlies.

Blog posts will be shorter and more succinct in their topics from now on. Read above for a list of topics I'll be covering in upcoming posts.