mnalis / android-wifi-upgrade

convert WiFi passwords from old Android wpa_supplicant.conf to newer (post-Oreo) WifiConfigStore.xml
Apache License 2.0
17 stars 8 forks source link

cannot use output for Android 11 ? #9

Open rregn opened 4 weeks ago

rregn commented 4 weeks ago

This works fine from Android 6 to an Samsung A7 with Android 10

But now i have another movement from Android 6 (Sony Z3) to Android 11 (Realme X2). The script produces around 800 KB . Then i copy the output to /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml with wifi off and reboot

But when i now enable Wifi, i can see in the total commander, how the file shrinks down to about 50kB. Nearly all entries are lost. S

Couldn't it be because the Android 11 doesn't fit the format?

In the native wificonfigstore the 3rd line says version value=3 while the version generated by this script is version=1

mnalis commented 3 weeks ago

Its hard to tell @rregn, but I'd guess from what you wrote that some of the wireless networks got transferred successfully. My (blind) guess would be that phone accepted networks from start of the file up to some point where it stumbled upon something it couldn't understand, and then import aborted and all wifi networks after that line did not get processed.

Then it saved new (version3) file over (with just the information that it managed to import so far, thus losing most of the networks).

You could verify that theory by comparing wifi networks that did manage to get imported with original file. If the theory is correct, you should be able to find network which cased import to abort (i.e. the first network that didn't get imported). My guess is that something will be special about that network - some custom parameters, different authentication types, strange (non-ASCII) name etc. When you have found it, then you could:

rregn commented 3 weeks ago

thank you for the fast reply and the ideas. So I had a closer look to the networks which are finally on the phone. It comes out, that it was the last 20 of the list in the wpa_supplicant. So i thought, there is a problem with the entry just before. I removed the last 22 entries in the wpa_supplicant. and tried again. Again just the last 20 (and my home network) remain Also I could see - after switching wifi on again - with the total commander how the file in ...apexdata/com.android.wifi shrinks and from time to time there is a wpa_supplicant.conf.new - so some process does a copy for rewriting. I did this a 3rd time, cut again 22 entries from wpa_supplicant.conf, and again: the last 20 entries survive + my network. i really like to attach the file here (bt you need an Adroid 11 or somewhat phone to test the import

rregn commented 3 weeks ago

wpa_supplicant.conf_8_24_era.txt here my wpa_supplicant.conf - note: whereever key_mgmt is "WPA-PSK .... " i cut after WPA_PSK, otherwise the script stops with error

rregn commented 3 weeks ago

I have come one step further - a problem was the cut of the characters behind WPA-PSK! i removed the "$" in line 58 of the script, now i have many Networks in the new phone. But the xml file has 383 ssids

after restart the 826k wpa_supplicant file shrinks to 372k , switching wifi on - i count around 155 networks BUT after adding one more network, the shrinking process start again (with the .new file) and 21 networks are remaining!!

mnalis commented 2 weeks ago

It comes out, that it was the last 20 of the list in the wpa_supplicant

That is strange that those are last 20 entries; it would mean my guess was probably wrong and something else is at work. Unfortunately, I don't know what :shrug:. Is your wifi on or off when you try doing the import?

Could you try keeping only first 30 entries and removing all other, and trying to import that? What is on the phone then (can you list exact network names that remain on the phone)?

i really like to attach the file here (bt you need an Adroid 11 or somewhat phone to test the import

Unfortunately I don't have rooted Android 11 device, sorry.

mnalis commented 2 weeks ago

here my wpa_supplicant.conf - note: whereever key_mgmt is "WPA-PSK .... " i cut after WPA_PSK, otherwise the script stops with error

I've just made some changes to avoid problems with that. Can you try that new version?

rregn commented 2 weeks ago

i tried, (again wifi is off, when i insert the file, and after i reboot quickly) but the result is the same. shrinking takes around 10 sec, and i could see the .new file agein. i think, the problem is in the xml file.

Now i found out that ALL "surviving entries" are open wifis - without key!

rregn commented 2 weeks ago

I added here WifiConfigStore_realme_xml.txt a entry in the final xml "made" by my realme

mnalis commented 2 weeks ago

Now i found out that ALL "surviving entries" are open wifis - without key!

Aha, that is very useful information!

Can you manually create one password-protected entry via normal Android UI, and extract from WifiConfigStore.xml (with replaced password with dummy value) how that correct & working entry looks on your Android?

Then we can compare how it looks compared to the output that script generates...

rregn commented 2 weeks ago

WifiConfigStore_realme_xml.txt

here