android的快捷操作关闭WIFI是怎么实现的?是否类似Linux的ifconfig xxx0 down ?
- 0次
- 2021-07-21 06:02:41
- idczone
有没有可能是像linux关闭一个网卡那样,
使用ifconfig wlan0 down 关闭一个网络设备,
在使用的时候再ifconfig wlan0 up ?
源码都在那,看看就明白了
Android有API来给应用用的,普通应用也用不了ifconfig...
root权限下:
service call wifi 14 | grep "0 00000001"
if [ "$?" -eq "0" ]; then
service call wifi 13 i32 1
else
service call wifi 13 i32 0
fi
有CHANGE_WIFI_STATE权限就不要root。
service就行