這個是對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");
要是改成這樣無線網絡就用不了,所以我稍微改了下
[java]
/* 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中加上這個服務:
[html]
service dhcpcd_eth0 /system/bin/dhcpcd -o domain_name_servers -dd -ABKL eth0
class main
disabled
oneshot
現在有線和無線就都能正常連接了。