OSDN Git Service

Fix bad merge.
authorRobert Greenwalt <rgreenwalt@google.com>
Fri, 1 Apr 2011 21:11:30 +0000 (14:11 -0700)
committerRobert Greenwalt <rgreenwalt@google.com>
Fri, 1 Apr 2011 21:11:30 +0000 (14:11 -0700)
Add host route for a default gateway before adding the default route.
Also fixing bug were "already active" condtion of APN failed to
propagate the default gateway info, resulting in a loss of that address.

bug:4175328
Change-Id: I38f9d108693382a43e6605d56ca3963adf4eb6f4

core/java/android/net/MobileDataStateTracker.java
core/java/android/net/NetworkStateTracker.java

index 32c2d64..04b0f12 100644 (file)
@@ -247,6 +247,9 @@ public class MobileDataStateTracker extends NetworkStateTracker {
                                     Log.d(TAG, "CONNECTED event did not supply interface name.");
                                 }
                                 mDefaultGatewayAddr = intent.getIntExtra(Phone.DATA_GATEWAY_KEY, 0);
+                                if (mDefaultGatewayAddr == 0) {
+                                    Log.d(TAG, "CONNECTED event did not supply a default gateway.");
+                                }
                                 setDetailedState(DetailedState.CONNECTED, reason, apnName);
                                 break;
                         }
@@ -385,6 +388,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
                 intent.putExtra(Phone.DATA_APN_KEY, mApnName);
                 intent.putExtra(Phone.DATA_IFACE_NAME_KEY, mInterfaceName);
                 intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, false);
+                intent.putExtra(Phone.DATA_GATEWAY_KEY, mDefaultGatewayAddr);
                 if (mStateReceiver != null) mStateReceiver.onReceive(mContext, intent);
                 break;
             case Phone.APN_REQUEST_STARTED:
index 1e8dedc..233ad21 100644 (file)
@@ -172,6 +172,7 @@ public abstract class NetworkStateTracker extends Handler {
             if (inetAddress == null) {
                 if (DBG) Log.d(TAG, " Unable to add default route. mDefaultGatewayAddr Error");
             } else {
+                NetworkUtils.addHostRoute(mInterfaceName, inetAddress, null);
                 if (!NetworkUtils.addDefaultRoute(mInterfaceName, inetAddress) && DBG) {
                     Log.d(TAG, "  Unable to add default route.");
                 }