在s5pv210+android4.0.3上移植realtek的wifi,根据以前的经验,从realtek网站下载
rtl8188cus的驱动,编译完驱动,移植到4.0.3中,出现一个现象,可以连接上wifi,而且
有获取到ip地址,但就是上不了外网,用IP的方式访问局域网服务器是可以的。
获取一些log:
I/SystemServer( 2119): NetworkStats Service
I/SystemServer( 2119): NetworkPolicy Service
I/SystemServer( 2119): Wi-Fi P2pService
I/SystemServer( 2119): Wi-Fi Service
E/CommandListener( 2025): Failed to open /proc/sys/net/ipv6/conf/wlan0/disable_ipv6: No such file or directory
E/WifiStateMachine( 2119): Failed to disable IPv6: java.lang.IllegalStateException: Unable to communicate to native daemon for disabling ipv6
I/SystemServer( 2119): Connectivity Service
D/ConnectivityService( 2119): ConnectivityService starting up
E/Ethernet( 2119): runDhcp() iface:
D/NetUtils( 2119): android_net_utils_runDhcpCommon in env=0x17584c8 clazz=0x1d300001 iface= renew=0
I/WifiService( 2119): WifiService starting up with Wi-Fi enabled
D/NetUtils( 2119): android_net_utils_runDhcpCommon in env=0x17bea08 clazz=0x1e100001 iface=wlan0 renew=0
I//system/bin/dhcpcd( 2450): dhcpcd[2451]: version 5.2.10 starting
I//system/bin/dhcpcd( 2450): dhcpcd[2451]: host does not support a monotonic clock - timing can skew
I//system/bin/dhcpcd( 2450): dhcpcd[2451]: wlan0: rebinding lease of 192.168.1.105
I//system/bin/dhcpcd( 2450): dhcpcd[2451]: wlan0: acknowledged 192.168.1.105 from 192.168.1.1
I//system/bin/dhcpcd( 2450): dhcpcd[2451]: wlan0: leased 192.168.1.105 for 7200 seconds
D/NetUtils( 2119): android_net_utils_runDhcpCommon dhcp_do_request() return 0, iface=wlan0
D/NetUtils( 2119): android_net_utils_runDhcpCommon dhcp_do_request() return -1, iface=
E/Ethernet( 2119): DHCP request error:Timed out waiting for init.svc.dhcpcd_ to start,interface:
可以见到,实际上是有一个Ethernet的dhcp请求interface为空,怀疑是这个问题造成,
于是追踪:
frameworks/base/core/jni/android_net_NetUtils.cpp
static jboolean android_net_utils_runDhcpCommon(JNIEnv* env, jobject clazz, jstring ifname,
jobject info, bool renew)
static jboolean android_net_utils_runDhcp(JNIEnv* env, jobject clazz, jstring ifname, jobject info)
{ "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpInfoInternal;)Z", (void *)android_net_utils_runDhcp },
frameworks/base/core/java/android/net/EthernetDataTracker.java
Log.d(TAG, "Adding " + iface);
Log.d(TAG, "Removing " + iface);
public void startMonitoring(Context context, Handler target) {
sIfaceMatch = context.getResources().getString(
com.android.internal.R.string.config_ethernet_iface_regex);
case ConnectivityManager.TYPE_ETHERNET:
mNetTrackers[netType] = EthernetDataTracker.getInstance();
mNetTrackers[netType].startMonitoring(context, mHandler);
break;
跟踪了startMonitoring()中对reconnect()的调用情况,发现不是这里,
而是下面一点:
mCurrentLinkProperties[netType] = null;
if (mNetTrackers[netType] != null && mNetConfigs[netType].isDefault()) {
mNetTrackers[netType].reconnect();
}
于是trace mNetConfigs,找到关键
String[] naStrings = context.getResources().getStringArray(
com.android.internal.R.array.networkAttributes);
发现在
device/samsung/smdkv210/overlay/frameworks/base/core/res/res/values/config.xml中的networkAttributes只有设置ethernet,而没有wifi。补上:
- "wifi,1,1,1,-1,true"
- "ethernet,9,9,1,-1,true"
修改后重新编译,wifi就可以上外网了。还是看guide不够仔细造成的。