From: Chih-Wei Huang Date: Thu, 13 Jun 2019 09:08:41 +0000 (+0800) Subject: init.sh: enable virt_wifi if needed X-Git-Tag: android-x86-7.1-r3~6 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fdevice-generic-common.git;a=commitdiff_plain;h=8ac9fea0db77ce1ace33e04a0da9def54a92ac55 init.sh: enable virt_wifi if needed Some Android apps are not interested in ethernet devices and would rather connect to a wireless interface. This patch allows the devices with only ethernet interface to treat one of its network connections as wireless, satisfying Android apps's network connection requirements. The ethernet interface being simulated can be specified by the property net.virt_wifi. The default is eth0. The feature is enabled if wlan0 doesn't exist, or VIRT_WIFI=1 is set in kernel cmdline. To disable it, set VIRT_WIFI=0 kernel cmdline. --- diff --git a/init.sh b/init.sh index aee4614..5f09257 100644 --- a/init.sh +++ b/init.sh @@ -44,6 +44,20 @@ function init_misc() wifi=$(basename `readlink /sys/class/net/wlan0/device/driver`) [ "$wifi" != "wl" ] && rmmod_if_exist wl fi + + # enable virt_wifi if needed + local eth=`getprop net.virt_wifi eth0` + if [ -d /sys/class/net/$eth -a "$VIRT_WIFI" != "0" ]; then + if [ -n "$wifi" -a "$VIRT_WIFI" = "1" ]; then + rmmod_if_exist iwlmvm $wifi + fi + if [ ! -d /sys/class/net/wlan0 ]; then + ifconfig $eth down + ip link set $eth name wifi_eth + ifconfig wifi_eth up + ip link add link wifi_eth name wlan0 type virt_wifi + fi + fi } function init_hal_audio()