-1

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.

bugfreerammohan
  • 1,471
  • 1
  • 7
  • 22
Suban Dhyako
  • 2,436
  • 4
  • 16
  • 38

2 Answers2

3

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
Suban Dhyako
  • 2,436
  • 4
  • 16
  • 38
  • Doesn't work for me. This yields the error message: "Failed to connect to non-global ctrl_ifname: (nil) error: Operation not permitted", So I tried to do it as a super user (ran "su", then the list snippet), and got the error weird message: "Failed to connect to non-global ctrl_ifname: (nil) error: Success" – MahNas92 Jan 16 '20 at 09:44
  • On a rooted Android Q device the error is instead: wpa_cli: inaccessible or not found, so seems like this is gone or something. – MahNas92 Jan 17 '20 at 15:17
  • Not working. Here is my code `val command = "adb shell wpa_cli remove_network $netId" ; val process = Runtime.getRuntime().exec(arrayOf("su", "-c", command))` – Muhammad Babar May 28 '20 at 12:48
0

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.

Mritunjay Gupta
  • 311
  • 2
  • 8