test_wifi

#!/system/bin/sh

#Load driver
echo "ASD WIFI TESTING..."

AP_NAME="default"
num=0
FLAG=0

busybox cp /system/etc/wifi/pre_supplicant.conf /data/misc/wifi/wpa_supplicant.conf
busybox chmod 666 /data/misc/wifi/pre_supplicant.conf
busybox chmod 666 /data/misc/wifi/wpa_supplicant.conf
busybox chmod 777 /dev/rfkill

#insmod /system/lib/dhd.ko firmware_path=/system/etc/wifi/40183/ nvram_path=/system/etc/wifi/40183/nvram.txt
insmod /system/lib/dhd.ko firmware_path=/etc/wifi/40181/fw_bcm40181a2.bin nvram_path=/etc/wifi/40181/nvram.txt

sleep 5 

busybox ifconfig wlan0 up
sleep 5 
#/system/bin/wpa_supplicant_ye -Dwext -C/data/misc/wifi/wlan0 -iwlan0 -c/data/misc/wifi/pre_supplicant.conf & 
wpa_supplicant -Dnl80211 -C/data/misc/wifi/wlan0 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf &

sleep 2

while busybox test $num -lt 5        # Test num with test command
    do
       #Scan
       /system/bin/wpa_cli_ye -p/data/misc/wifi/wlan0 -iwlan0 scan

       sleep 2

       /system/bin/wpa_cli_ye -p/data/misc/wifi/wlan0 -iwlan0 scan_results | busybox grep '[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]:[0-9a-zA-Z][0-9a-zA-Z]'


       if busybox test $? -eq 0
       then
		busybox sed -i "s/wifi_state = [0-9],[0-9]/wifi_state = 1,1/g" /system/bin/pretest_state
		echo "WIFI OK"
		FLAG=1
		break
       else
           	busybox sed -i "s/wifi_state = [0-9],[0-9]/wifi_state = 0,2/g" /system/bin/pretest_state
           	echo "scanning..."
       fi
          	num=`busybox expr  $num + 1`     # Increment num
    done

if busybox test $num = 5
then
    busybox sed -i "s/wifi_state = [0-9],[0-9]/wifi_state = 0,0/g" /system/bin/pretest_state
    echo "WIFI FAILED"
    exit 0
fi
busybox rm /data/misc/wifi/pre_supplicant.conf
rmmod /system/lib/dhd.ko
exit 0


你可能感兴趣的:(shell,Android)