Skip to content

Commit 9bf3bb2

Browse files
szymJean-Baptiste Queru
authored andcommitted
- updates NetUtils to use new libnetutils headers
- updates WifiStateTracker to track net.XXX.dnsX properties for name servers - removes dhcp from WifiNative (use NetworkUtils instead) Change-Id: Ic69ff253e8784cad34e9291e7970ee38bfa235b9
1 parent 77dcdc9 commit 9bf3bb2

File tree

4 files changed

+5
-97
lines changed

4 files changed

+5
-97
lines changed

core/jni/android_net_NetUtils.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,8 @@
2222
#include <utils/Log.h>
2323
#include <arpa/inet.h>
2424

25-
extern "C" {
26-
int ifc_enable(const char *ifname);
27-
int ifc_disable(const char *ifname);
28-
int ifc_add_host_route(const char *ifname, uint32_t addr);
29-
int ifc_remove_host_routes(const char *ifname);
30-
int ifc_set_default_route(const char *ifname, uint32_t gateway);
31-
int ifc_get_default_route(const char *ifname);
32-
int ifc_remove_default_route(const char *ifname);
33-
int ifc_reset_connections(const char *ifname);
34-
int ifc_configure(const char *ifname, in_addr_t ipaddr, in_addr_t netmask, in_addr_t gateway, in_addr_t dns1, in_addr_t dns2);
35-
36-
int dhcp_do_request(const char *ifname,
37-
in_addr_t *ipaddr,
38-
in_addr_t *gateway,
39-
in_addr_t *mask,
40-
in_addr_t *dns1,
41-
in_addr_t *dns2,
42-
in_addr_t *server,
43-
uint32_t *lease);
44-
int dhcp_stop(const char *ifname);
45-
int dhcp_release_lease(const char *ifname);
46-
char *dhcp_get_errmsg();
47-
}
25+
#include <netutils/ifc.h>
26+
#include <netutils/dhcp.h>
4827

4928
#define NETUTILS_PKG_NAME "android/net/NetworkUtils"
5029

core/jni/android_net_wifi_Wifi.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,6 @@ namespace android {
2929

3030
static jboolean sScanModeActive = false;
3131

32-
/*
33-
* The following remembers the jfieldID's of the fields
34-
* of the DhcpInfo Java object, so that we don't have
35-
* to look them up every time.
36-
*/
37-
static struct fieldIds {
38-
jclass dhcpInfoClass;
39-
jmethodID constructorId;
40-
jfieldID ipaddress;
41-
jfieldID gateway;
42-
jfieldID netmask;
43-
jfieldID dns1;
44-
jfieldID dns2;
45-
jfieldID serverAddress;
46-
jfieldID leaseDuration;
47-
} dhcpInfoFieldIds;
48-
4932
static int doCommand(const char *cmd, char *replybuf, int replybuflen)
5033
{
5134
size_t reply_len = replybuflen - 1;
@@ -491,28 +474,6 @@ static jboolean android_net_wifi_clearBlacklistCommand(JNIEnv* env, jobject claz
491474
return doBooleanCommand("BLACKLIST clear", "OK");
492475
}
493476

494-
static jboolean android_net_wifi_doDhcpRequest(JNIEnv* env, jobject clazz, jobject info)
495-
{
496-
jint ipaddr, gateway, mask, dns1, dns2, server, lease;
497-
jboolean succeeded = ((jboolean)::do_dhcp_request(&ipaddr, &gateway, &mask,
498-
&dns1, &dns2, &server, &lease) == 0);
499-
if (succeeded && dhcpInfoFieldIds.dhcpInfoClass != NULL) {
500-
env->SetIntField(info, dhcpInfoFieldIds.ipaddress, ipaddr);
501-
env->SetIntField(info, dhcpInfoFieldIds.gateway, gateway);
502-
env->SetIntField(info, dhcpInfoFieldIds.netmask, mask);
503-
env->SetIntField(info, dhcpInfoFieldIds.dns1, dns1);
504-
env->SetIntField(info, dhcpInfoFieldIds.dns2, dns2);
505-
env->SetIntField(info, dhcpInfoFieldIds.serverAddress, server);
506-
env->SetIntField(info, dhcpInfoFieldIds.leaseDuration, lease);
507-
}
508-
return succeeded;
509-
}
510-
511-
static jstring android_net_wifi_getDhcpError(JNIEnv* env, jobject clazz)
512-
{
513-
return env->NewStringUTF(::get_dhcp_error_string());
514-
}
515-
516477
// ----------------------------------------------------------------------------
517478

518479
/*
@@ -569,28 +530,13 @@ static JNINativeMethod gWifiMethods[] = {
569530
{ "setScanResultHandlingCommand", "(I)Z", (void*) android_net_wifi_setScanResultHandlingCommand },
570531
{ "addToBlacklistCommand", "(Ljava/lang/String;)Z", (void*) android_net_wifi_addToBlacklistCommand },
571532
{ "clearBlacklistCommand", "()Z", (void*) android_net_wifi_clearBlacklistCommand },
572-
573-
{ "doDhcpRequest", "(Landroid/net/DhcpInfo;)Z", (void*) android_net_wifi_doDhcpRequest },
574-
{ "getDhcpError", "()Ljava/lang/String;", (void*) android_net_wifi_getDhcpError },
575533
};
576534

577535
int register_android_net_wifi_WifiManager(JNIEnv* env)
578536
{
579537
jclass wifi = env->FindClass(WIFI_PKG_NAME);
580538
LOG_FATAL_IF(wifi == NULL, "Unable to find class " WIFI_PKG_NAME);
581539

582-
dhcpInfoFieldIds.dhcpInfoClass = env->FindClass("android/net/DhcpInfo");
583-
if (dhcpInfoFieldIds.dhcpInfoClass != NULL) {
584-
dhcpInfoFieldIds.constructorId = env->GetMethodID(dhcpInfoFieldIds.dhcpInfoClass, "<init>", "()V");
585-
dhcpInfoFieldIds.ipaddress = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "ipAddress", "I");
586-
dhcpInfoFieldIds.gateway = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "gateway", "I");
587-
dhcpInfoFieldIds.netmask = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "netmask", "I");
588-
dhcpInfoFieldIds.dns1 = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "dns1", "I");
589-
dhcpInfoFieldIds.dns2 = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "dns2", "I");
590-
dhcpInfoFieldIds.serverAddress = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "serverAddress", "I");
591-
dhcpInfoFieldIds.leaseDuration = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "leaseDuration", "I");
592-
}
593-
594540
return AndroidRuntime::registerNativeMethods(env,
595541
WIFI_PKG_NAME, gWifiMethods, NELEM(gWifiMethods));
596542
}

wifi/java/android/net/wifi/WifiNative.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package android.net.wifi;
1818

19-
import android.net.DhcpInfo;
20-
2119
/**
2220
* Native calls for sending requests to the supplicant daemon, and for
2321
* receiving asynchronous events. All methods of the form "xxxxCommand()"
@@ -142,10 +140,6 @@ public class WifiNative {
142140

143141
public native static boolean clearBlacklistCommand();
144142

145-
public native static boolean doDhcpRequest(DhcpInfo results);
146-
147-
public native static String getDhcpError();
148-
149143
/**
150144
* Wait for the supplicant to send an event, returning the event string.
151145
* @return the event string sent by the supplicant.

wifi/java/android/net/wifi/WifiStateTracker.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,6 @@ public class WifiStateTracker extends NetworkStateTracker {
295295

296296
private Runnable mReleaseWakeLockCallback;
297297

298-
private static String[] sDnsPropNames;
299-
300298
/**
301299
* A structure for supplying information about a supplicant state
302300
* change in the STATE_CHANGE event message that comes from the
@@ -351,9 +349,9 @@ public WifiStateTracker(Context context, Handler target) {
351349
mSettingsObserver = new SettingsObserver(new Handler());
352350

353351
mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0");
354-
sDnsPropNames = new String[] {
355-
"dhcp." + mInterfaceName + ".dns1",
356-
"dhcp." + mInterfaceName + ".dns2"
352+
mDnsPropNames = new String[] {
353+
"net." + mInterfaceName + ".dns1",
354+
"net." + mInterfaceName + ".dns2"
357355
};
358356
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
359357

@@ -397,15 +395,6 @@ private void setTornDownByConnMgr(boolean flag) {
397395
updateNetworkInfo();
398396
}
399397

400-
/**
401-
* Return the IP addresses of the DNS servers available for the WLAN
402-
* network interface.
403-
* @return a list of DNS addresses, with no holes.
404-
*/
405-
public String[] getNameServers() {
406-
return getNameServerList(sDnsPropNames);
407-
}
408-
409398
/**
410399
* Return the name of our WLAN network interface.
411400
* @return the name of our interface.

0 commit comments

Comments
 (0)