device/generic/common
Revision | 8ac9fea0db77ce1ace33e04a0da9def54a92ac55 (tree) |
---|---|
Zeit | 2019-06-13 18:08:41 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
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.
@@ -44,6 +44,20 @@ function init_misc() | ||
44 | 44 | wifi=$(basename `readlink /sys/class/net/wlan0/device/driver`) |
45 | 45 | [ "$wifi" != "wl" ] && rmmod_if_exist wl |
46 | 46 | fi |
47 | + | |
48 | + # enable virt_wifi if needed | |
49 | + local eth=`getprop net.virt_wifi eth0` | |
50 | + if [ -d /sys/class/net/$eth -a "$VIRT_WIFI" != "0" ]; then | |
51 | + if [ -n "$wifi" -a "$VIRT_WIFI" = "1" ]; then | |
52 | + rmmod_if_exist iwlmvm $wifi | |
53 | + fi | |
54 | + if [ ! -d /sys/class/net/wlan0 ]; then | |
55 | + ifconfig $eth down | |
56 | + ip link set $eth name wifi_eth | |
57 | + ifconfig wifi_eth up | |
58 | + ip link add link wifi_eth name wlan0 type virt_wifi | |
59 | + fi | |
60 | + fi | |
47 | 61 | } |
48 | 62 | |
49 | 63 | function init_hal_audio() |