Android 网络优先级调整

android 网络优先级默认为   以太网 --> Wifi --> 移动数据

有一些同学想在多同络情况下   默认使用  wifi 或者 以太网

那么这就涉及到更改系统网络默认优先级,系统的网络优先级是从

frameworks\base\core\res\res\values\config.xml中读取出来的,读取的属性为

    
        "wifi,9,9,9,-1,true"
        "mobile,0,0,0,-1,true"
        "mobile_mms,2,0,2,60000,false"
        "mobile_supl,3,0,2,60000,true"
        "mobile_dun,4,0,2,60000,true"
        "mobile_hipri,5,0,3,60000,true"
        "mobile_fota,10,0,2,60000,true"
        "mobile_ims,11,0,2,60000,true"
        "mobile_cbs,12,0,2,60000,true"

        "bluetooth,7,7,0,-1,true"
        "ethernet,1,1,2,-1,true"

        "pppoe,15,15,5,-1,true"
    

看到上面的 wifi、ethernet 、mobile了吗?    他里面的第三个数字越大,其优先级也就越高

当然,如果你直接跑道 framework目录中去修改 config.xml文件的话,是不会起作用的,

为什么不会起作用,是因为  framework目录下的这个 config.xml文件会被覆盖掉。

你需要跑到 项目根目录的 device/....../config.xml  中去查找   networkAttributes 这个属性

毕竟这个目录下的 config.xml文件很多,所以我在这里将如何查找到 networkAttributes 这个属性的

config.xml文件的方式写出来,

cd  device

find ./ -name "config.xml" | xargs grep -n "networkAttributes"

这条命令执行后,你有可能会看到几个 config.xml文件中包含 networkAttributes这个属性,那就直接将包含

这个属性的几个文件都改了,当然  如果要追踪具体改哪个 config.xml文件的话,需要去查看编译脚步。

你可能感兴趣的:(Android)