之所以4G无法上网的根本原因是4G的ppp拨号没有设置指定路由导致的,只需在rk3188_5.1_mid\frameworks\base\services\core\java\com\android\server\ConnectivityService.java加入指定路由即可从根本上解决问题,分析详情见博客https://blog.youkuaiyun.com/u012246195/article/details/53427111
添加4G路由:
for (RouteInfo route : routeDiff.added) {
if (route.hasGateway() == false) continue;
if (DBG) log("Adding Route [" + route + "] to network " + netId);
try {
/**add by shihao for 4G start*/
if (route.getInterface().equals("ppp0")) {
RouteInfo xroute = RouteInfo.makeHostRoute(route.getGateway(),
route.getInterface()); // make host route for nexthop
mNetd.addRoute(netId, xroute); //add nexthop(getGateway()) for table ppp0
if (DBG) log("Adding Route [" + xroute + "] to network " + netId);
}
/**add by shihao for 4G end*/
mNetd.addRoute(netId, route);
} catch (Exception e) {
if ((route.getGateway() instanceof Inet4Address) || VDBG) {
loge("Exception in addRoute for gateway: " + e);
}
}
}