OSDN Git Service

Merge remote-tracking branch 'x86/nougat-x86' into oreo-x86 android-x86-8.1-r2
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 13 Jun 2019 09:09:26 +0000 (17:09 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 13 Jun 2019 09:09:26 +0000 (17:09 +0800)
init.sh

diff --git a/init.sh b/init.sh
index a73721a..ab7f50d 100644 (file)
--- a/init.sh
+++ b/init.sh
@@ -15,6 +15,13 @@ function set_prop_if_empty()
        [ -z "$(getprop $1)" ] && set_property "$1" "$2"
 }
 
+function rmmod_if_exist()
+{
+       for m in $*; do
+               [ -d /sys/module/$m ] && rmmod $m
+       done
+}
+
 function init_misc()
 {
        # device information
@@ -30,6 +37,27 @@ function init_misc()
        # enable sdcardfs if /data is not mounted on tmpfs or 9p
        mount | grep /data\ | grep -qE 'tmpfs|9p'
        [ $? -ne 0 ] && modprobe sdcardfs
+
+       # remove wl if it's not used
+       local wifi
+       if [ -d /sys/class/net/wlan0 ]; then
+               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()