已经有人在这方面做了研究了请先看这篇博客:点击打开链接
这个是对android4.0.3增加ethernet我是直接拿过来对android4.0.4增加,过程中有些是不同的,错误比较容易解决这里我就不作具体说明了。只是其中有一点需要修改的在这个地方:
2. system\core\libnetutils\dhcp_utils.c的 dhcp_do_request函数中,把
snprintf(daemon_cmd,sizeof(daemon_cmd),"%s","dhcpcd_wlan0");改成
snprintf(daemon_cmd,sizeof(daemon_cmd),"%s","dhcpcd_eth0");
要是改成这样无线网络就用不了,所以我稍微改了下
/* Erase any previous setting of the dhcp result property */ property_set(result_prop_name, ""); #if 0 /* Start the daemon and wait until it's ready */ if (property_get(HOSTNAME_PROP_NAME, prop_value, NULL) && (prop_value[0] != '\0')) snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s:-h %s %s", DAEMON_NAME, daemon_suffix, prop_value, interface); else snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s:%s", DAEMON_NAME, daemon_suffix, interface); /////////// modfiy by dao /////////////////////////////////// //snprintf(daemon_cmd,sizeof(daemon_cmd),"%s","dhcpcd_wlan0"); snprintf(daemon_cmd,sizeof(daemon_cmd),"%s","dhcpcd_wlan0"); ////////////////////////////////////////////////////////////// #else #if 1 /* Start the daemon and wait until it's ready */ if (property_get(HOSTNAME_PROP_NAME, prop_value, NULL) && (prop_value[0] != '\0')) //snprintf(daemon_cmd, sizeof(daemon_cmd), "%s:-h %s %s", DAEMON_NAME, // prop_value, interface); snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s", DAEMON_NAME, interface); else #endif snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s", DAEMON_NAME, interface); #endif memset(prop_value, '\0', PROPERTY_VALUE_MAX);把原来的注释掉,然后改成上面那样。
同时在init.rc中加上这个服务:
service dhcpcd_eth0 /system/bin/dhcpcd -o domain_name_servers -dd -ABKL eth0 class main disabled oneshot现在有线和无线就都能正常连接了。