diff options
| author | Robert Greenwalt <rgreenwalt@google.com> | 2011-05-18 16:31:01 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-18 16:31:01 -0700 |
| commit | 4a76d154e4d6ca532321e6f6dc9cdad3263affa3 (patch) | |
| tree | 5f11358d700987edfd9de302dfa98dc9517d0bec /apps | |
| parent | d143387d72e502d5d00ce12163edc40fcfaf9d2d (diff) | |
| parent | 82cdc8cc426fa73b49412245b1c826d4acd29140 (diff) | |
| download | android_development-4a76d154e4d6ca532321e6f6dc9cdad3263affa3.tar.gz android_development-4a76d154e4d6ca532321e6f6dc9cdad3263affa3.tar.bz2 android_development-4a76d154e4d6ca532321e6f6dc9cdad3263affa3.zip | |
am 82cdc8cc: Merge "Fix Development app to use netd for routes" into honeycomb-LTE
* commit '82cdc8cc426fa73b49412245b1c826d4acd29140':
Fix Development app to use netd for routes
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/Development/src/com/android/development/Connectivity.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/apps/Development/src/com/android/development/Connectivity.java b/apps/Development/src/com/android/development/Connectivity.java index c7029ecc7..c62d9b59b 100644 --- a/apps/Development/src/com/android/development/Connectivity.java +++ b/apps/Development/src/com/android/development/Connectivity.java @@ -29,11 +29,13 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ConnectivityManager; import android.net.NetworkUtils; +import android.net.RouteInfo; import android.net.wifi.WifiManager; import android.os.RemoteException; import android.os.Handler; import android.os.Message; import android.os.IBinder; +import android.os.INetworkManagementService; import android.os.Parcel; import android.os.PowerManager; import android.os.PowerManager.WakeLock; @@ -99,6 +101,7 @@ public class Connectivity extends Activity { private WifiManager mWm; private PowerManager mPm; private ConnectivityManager mCm; + private INetworkManagementService mNetd; private WakeLock mWakeLock = null; private WakeLock mScreenonWakeLock = null; @@ -191,6 +194,8 @@ public class Connectivity extends Activity { mWm = (WifiManager)getSystemService(Context.WIFI_SERVICE); mPm = (PowerManager)getSystemService(Context.POWER_SERVICE); mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); + mNetd = INetworkManagementService.Stub.asInterface(b); findViewById(R.id.enableWifi).setOnClickListener(mClickListener); findViewById(R.id.disableWifi).setOnClickListener(mClickListener); @@ -372,12 +377,20 @@ public class Connectivity extends Activity { private void onAddDefaultRoute() { try { - NetworkUtils.addRoute("eth0", "0.0.0.0", 0, "8.8.8.8"); - } catch (Exception e) { } + mNetd.addRoute("eth0", new RouteInfo(null, + NetworkUtils.numericToInetAddress("8.8.8.8"))); + } catch (Exception e) { + Log.e(TAG, "onAddDefaultRoute got exception: " + e.toString()); + } } private void onRemoveDefaultRoute() { - Log.e(TAG, "removeDefaultRoute returned "+NetworkUtils.removeDefaultRoute("eth0")); + try { + mNetd.removeRoute("eth0", new RouteInfo(null, + NetworkUtils.numericToInetAddress("8.8.8.8"))); + } catch (Exception e) { + Log.e(TAG, "onRemoveDefaultRoute got exception: " + e.toString()); + } } private void onRoutedHttpRequest() { |
