How can I remove the saved wi-fi network from my rooted android device?
I have tried copying the custom wpa_supplicant.conf file to /data/misc/wifi/
>adb push wpa_supplicant.conf /data/misc/wifi/wpa_supplicant.conf
The file copied successfully but it won't remove the saved wi-fi network.
I have following content in the custom wpa_supplicant.conf
ctrl_interface=/data/misc/wifi/sockets
disable_scan_offload=1
driver_param=use_p2p_group_interface=1p2p_device=1use_multi_chan_concurrent=1
update_config=1
device_name=Tablet
manufacturer=MSI
model_name=550-18900(MiniTouch)
model_number=550-18900(MiniTouch)
serial_number=0123456789ABCDEF
device_type=10-0050F204-5
config_methods=physical_display virtual_push_button
pmf=1
external_sim=1
I also tried removing wpa_supplicant.conf file.
I also tried turning off wifi and then pushing custom wpa_supplicant.conf file. I am not able to a removed the saved wifi network.
I found the alternative way to remove the saved network from rooted device. This can be achieved using wpa_cli command.
$adb shell wpa_cli list_networks
//this will show the list like following
network id / ssid / bssid / flags
0 worldink_wifi any [CURRENT]
//now you can remove the network using its network id
Then you can remove network using
$adb shell wpa_cli remove_network 0
//0 is network id
Install adb, and connect your device and execute the following command :
adb shell am start -n 'com.adbwifisettingsmanager/.WifiSettingsManagerActivity' --esn remove -e ssid <ssid_name>
Replace the <ssid_name> with the name of the wifi network.
Related
Android device: How to connect wifi by "Adb shell cmd wifi" command?
I tried to connect wifi by adb to avoid tedious click and verification operations by appium. And i found that the "adb shell cmd wifi" have a keyword "connect-network", but i cant connect the wifi by this way. Does anyone know how to use it? Thank a lot guys!
Here is the usage of the "Adb shell cmd wifi connect-network":Wi-Fi (wifi) commands:
connect-network <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-m] [-d] [-b <bssid>]
Connect to a network with provided params and add to saved networks list
<ssid> - SSID of the network
open|owe|wpa2|wpa3 - Security type of the network.
- Use 'open' or 'owe' for networks with no passphrase
- 'open' - Open networks (Most prevalent)
- 'owe' - Enhanced open networks
- Use 'wpa2' or 'wpa3' for networks with passphrase
- 'wpa2' - WPA-2 PSK networks (Most prevalent)
- 'wpa3' - WPA-3 PSK networks
-m - Mark the network metered.
-d - Mark the network autojoin disabled.
-b <bssid> - Set specific BSSID.
And my input is adb shell cmd wifi connect-network WIFIName open wpa2 Loginpassword, it return me a Connection initiated, But the connect is not successful. Why this happen? Should i input the wifi login account? And what the whole command should be?
Hey I think that you should use either 'open' or 'wpa2' not both. But If we assume that wifi is secured by a wpa2 password so proper command would be:
adb shell cmd wifi connect-network WIFIName wpa2 password
Also, take into consideration that only the root user can invoke wifi commands, and root access is not available in most cases.
I understand we could turn off Wifi through the "adb shell svc wifi disable" command but I don't want to completely turn off Wifi. I want to disconnect from a particular ssid through adb. Is it possible?
Edit: I got a notification saying this question is identified as a dupe of this question: How to turn off Wifi via ADB?. It actually is not. As mentioned clearly in the first paragraph, I don't want to turn off wifi but want to simply disconnect from a particular network. This is like long pressing a network and tapping "Forget network". Essentially I want to simulate a condition of the user moving out of a wifi network without having to turn off wifi.
If you have root access, you can make it by using wpa_cli.
First, you can use the wpa_cli`s list_networks to get the network id of the network that you want to disconnect
$ adb shell
# wpa_cli
> list_networks
**network id** / ssid / bssid / flags
0 001aLinksys14081-2G any [CURRENT]
and then you just need to run the wpa_cli remove_network {network id}, where the {network id} parameter is the one that you got on the list_networks method.
One option is to use cmd wifi. For disconnecting from a Wi-Fi network, you can "forget" it like so:
adb shell cmd wifi list-networks
adb shell cmd wifi forget-network <networkId from list-networks>
You can view the help documentation for cmd wifi with:
adb shell cmd wifi -h
This command did it for me
docker exec -it $container_id /bin/bash -c "cd /root//shared-tools/android-sdk/platform-tools; ./adb shell 'svc wifi disable'"
You cannot. But, this will not be enough to satisfying your question, there is tricky way to connect to "other wifi". (Yes, it is not disconnect)
Install an app, and send command to the app via adb.
See this: https://stackoverflow.com/a/37303412/850347
I already build an app which does so and it's available here: https://github.com/steinwurf/adb-join-wifi
Once the app is installed, a wifi access point can be joined using the following ADB command:
adb shell am start -n com.steinwurf.adbjoinwifi/com.steinwurf.adbjoinwifi.MainActivity -e ssid [SSID] -e password_type [PASSWORD_TYPE] -e password [WIFI PASSWORD]
See this: https://stackoverflow.com/a/37303412/850347
Is there a way to get the configured WiFi-SSIDS from an Android (not rooted) device via ADB? This should be working independant from the WiFi on/off state.
Thank you
generally all the configured WIFIs with their passwords are stored in wpa_supplicant.conf which saved in
/data/misc/wifi/wpa_supplicant.conf
but you cant access it unless you have root permission.
you can pull the file by this command
if using windows
adb pull /data/misc/wifi/wpa_supplicant.conf c:\
if using ubuntu
adb pull /data/misc/wifi/wpa_supplicant.conf ~/
Finally found out that
adb shell dumpsys wifi | grep -i ssid
gives the configured wifis
Edit: Only if wifi is enabled
Not possible. WifiManager.getConfiguredNetworks() only works when WiFi is on.
adb pull does work on unrooted devices. u need to run the command as root first. try the following:
in the same command prompt box,
-type [adb root] to restart adb as root. click enter.
-Now type [adb shell], click enter. makes sure the prompt shows [root#[device]: ]
-At the # prompt type [cd /data/misc/wifi] click enter.
-Lastly type [cat wpa_supplicant.conf] click enter.
this should dump data of WiFi you've previously connected to on your phone, to your pc screen.
*type in without brackets []
these command works on my unrooted device after running into the “remote object does not exist” issue.
Does anyone know how to make a device adb another device.
i.e
Device1 I create a folder apks and copy and paste 5 apk files.
then I use micro usb to micro usb to connect to another device.
then from device1 i adb all these 5 apk files to device2
using something like this a guess ?
adb install 1.apk & adb install 2apk & adb install 3.apk & adb install 4.apk & adb install 5.apk
I know this is possible as I know someone who does it. But their won't reveal how it is done. Thank you
AFAIK, connecting two android devices via USB is meaningless.
You can use adb over tcpip (over WiFi) in order to accomplish this.
Here is what you need to do:
Make sure both devices are on the same network. This can be done by connecting them to the same AP, by peering them together using WiFi direct or
by setting one of the devices as a hotspot and connecting the second to it.
Configure device 2 adbd to work over tcpip (this is done from your desktop shell):
adb tcpip <port number>
From device 1 shell run:
adb connect <device 2 ip>:<port number>
adb install 1.apk
adb install 2.apk2
and so forth...
I have an android device connected through adb over wifi. Now, due to some reason, the adb server is killed using command
'adb kill-server'.
Once I restart the server or issue the command
'adb devices', I would like the devices that were connected over wifi to appear in the list of devices, Just like the devices connected by usb appear in the list.
How can this be achieved? Can I put the ipaddresses of the devices in some file and they get connected automatically when the adb server restarts?
I have made batch scripts for automatically setting up a device for Wifi adb bridge, getting the IP and connecting to it. You just plug your device in, run the script and then unplug the device again.
Windows batch (wifi-connect.bat):
#echo off
echo Disconnecting old connections...
adb disconnect
echo Setting up connected device
adb tcpip 5555
echo Waiting for device to initialize
timeout 3
FOR /F "tokens=2" %%G IN ('adb shell ip addr show wlan0 ^|find "inet "') DO set ipfull=%%G
FOR /F "tokens=1 delims=/" %%G in ("%ipfull%") DO set ip=%%G
echo Connecting to device with IP %ip%...
adb connect %ip%
pause
Unix / Mac (wifi-connect.sh)
#!/bin/sh
adb disconnect
adb tcpip 5555
sleep 3
IP=$(adb shell ip addr show wlan0 | grep 'inet ' | cut -d' ' -f6| cut -d/ -f1)
echo "${IP}"
adb connect $IP
Both scripts requires adb to be in your path or in the same folder as the script.
You cannot automatically connect your device over WiFi if it that DEVICE is not connected using a USB cable first, because you need to config the device to listen a port and open a connection. What you can do is try to run these commands using a script.
From a computer, if you have USB access already (NO root required)
1. For Linux and MAC User:
Step 1:
Open terminal and install adb using
sudo apt-get install android-tools-adb android-tools-fastboot
Step 2:
Connect your phone via USB cable to the PC. Type following command in terminal to get the device ID:
$ adb devices
List of devices attached
LGV498b9cacc1 device
192.168.1.187:5558 device
192.168.1.184:5557 device
192.168.1.186:5556 device
192.168.1.143:5555 device
Step 3:
Using the device name listed above, get the IP of your Android device (if you know you can skip this step)
$ adb -s LGV498b9cacc1 shell ip -f inet addr show wlan0
22: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
inet 192.168.1.185/24 brd 192.168.1.255 scope global wlan0
Step 4:
Setup the communication port using this command:
$ adb -s LGV498b9cacc1 tcpip 5559
restarting in TCP mode port: 5559
Step 5:
Connect to your Android device IP address.
$ adb -s LGV498b9cacc1 connect 192.168.1.185:5559
connected to 192.168.1.185:5559
Step 6:
Verify if the device was added to the list:
$ adb devices
List of devices attached
192.168.1.185:5559 device
LGV498b9cacc1 device
192.168.1.187:5558 device
192.168.1.184:5557 device
192.168.1.186:5556 device
192.168.1.143:5555 device
If you are using Windows operating system, you could create a batch file and add
adb connect 192.168.1.179
please replace 192.168.1.179 with your own device ip address.
Then save the bat file and put it in startup folder.
You can't automatically connect your device over wifi if it's not connected using a USB cable. I've developed an open source IntelliJ Plugin do this as fast as possible. Here you have de code https://github.com/pedrovgs/AndroidWiFiADB and here the plugin https://plugins.jetbrains.com/plugin/7983
No you can't do that because once connection to adb server is killed you have to make connection again . If you still want to connect automatically and don't have to write command again and again than You can create a batch/Script file with all the command and make it run at time of reconnecting to adb devices .