Programmatically add wifi networks on Android I have a list of about 100 WiFi SSIDs and passwords that I've extracted from my old phone and I want to add them to the new phone that runs Android 10 and I couldn't find any useful information on the net as everything seems outdated and not working.

A bit about my phone: it's a OnePlus 7 with OxygenOS 10.0.1, rooted with TWRP and Magisk. The wifi networks come from an old OnePlus One with Cyanogenmod wich is not rooted. I obtained the passwords following https://www.reddit.com/r/Android/comments/86zkzf/restoring_wifi_passwords_from_old_device/

The closest thing I've found is this: https://github.com/steinwurf/adb-join-wifi but it works only one network at the time and it doesn't work very well, often passwords aren't added and I have problem escaping the SSID and passwords.

I've also tried to look for wpa_supplicant.conf but apparently it's not used anymore, instead I've found a file called WifiConfigStore.xml but I'm not sure if it can be edited manually or it needs a program, I tried to use wpa_cli but I get an error at startup, I looked for apps but nothing like I need.

I believe the way to go is through WifiConfigStore.xml but its format looks non trivial so that I'm not confident to update it manually plus there's the change it's managed by a service and any change I make will be erased.

How can I add programmatically my networks? Is there an adb command, a file I could edit on the phone or an app that can help me with this?
I've also had the same problem with losing all WiFi networks when upgrading LineageOS, so I've written a tool which will convert your old wpa_supplicant.conf to new WifiConfigStore.xml (and I'm not using Google accounts or other "upload all my stuff to some cloud" privacy nightmares)

You can find it here: https://github.com/mnalis/android-wifi-upgrade

Even with just SSID/passwords list and without original wpa_supplicant.conf file, file format for WifiConfigStore.xml is not really complex (it is just very verbose). With minimal programming you can use template in my code used for filling it to replace $SSID and other variables in order to generate it from your list).

Note that it will require root (or recovery rom with full adb or filemanager access) on your new android device in order to actually upload newly created WifiConfigStore.xml to the phone.