命令开关wifibluetooth-Android-svc命令与自动化压力测试
目录
命令开关wifi/bluetooth – Android svc命令与自动化/压力测试
svc指令可用于电源控制, 无线业务控制(modem/wifi/nfc/bt, etc), 等等.
可以不适用按键,触控设备, 而通过使用svc命令实现这些模块的功能操作,比如wifi的开关:
svc wifi enable //打开wifi
svc wifi disable //关闭wifi
因此, 对于涉及到这些模块的自动化测试和压力测试, 都可以使用svc命令, 来解放双手.
svc位于/system/bin/svc
# which svc
/system/bin/svc
# svc help
Available commands:
help Show information about the subcommands
power Control the power manager
data Control mobile data connectivity
wifi Control the Wi-Fi manager
usb Control Usb state
nfc Control NFC functions
feedback Control feedback state
ebensecure Control ebensecure state
opt Control the operation monitor manager
bluetooth Control Bluetooth service
# svc wifi
Control the Wi-Fi manager
usage: svc wifi [enable|disable]
Turn Wi-Fi on or off.
svc可用于power/data/wifi/usb/nfc/bt等的自动化测试和压力测试.
下面通过wifi开关/自动重连的压力测试举例说明svc的好用之处.
wifi开关/自动重连的压力测试脚本:
#!/bin/sh
count_success=0
count_err=0
while true
do
svc wifi disable
sleep 5
svc wifi enable
sleep 20
wlan_status=`wpa_cli -i wlan0 status`
tmp=${wlan_status#*wpa_state=}
wpa_state=${tmp:0:9}
echo "STA status is: $wpa_state"
if [ $wpa_state = "COMPLETED" ];then
count_success=$(($count_success+1))
else
count_err=$(($count_err+1))
fi
echo "====== SUCCESS: $count_success, FAIL: $count_err ========"
done