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

Updated WiFiConfigStore.xml is applied only after reboot #7

Closed milan-fabian closed 1 year ago

milan-fabian commented 1 year ago

Hello,

First of all, thank you for providing this tool. I am having a slight issue with the change applied only after the Android device is rebooted, not right after the WiFi is enabled again.

Steps to reproduce (tested on a box with Android 9):

  1. Prepare WiFiConfigStore.xml with new WiFi networks on a computer
  2. Disable WiFi on Android device
  3. Push WiFiConfigStore.xml
  4. Enable WiFi on Android device
  5. Check Saved WiFi networks - Android doesn't display any
  6. Reboot the Android device
  7. Check Saved WiFi networks - Android shows the networks from uploaded WiFiConfigStore.xml

Is there a way to apply the changes without rebooting the entire device?

mnalis commented 1 year ago

Well, that is how it is supposed to work (that' why there is adb reboot in the README.md, which should've rebooted your phone).

As I needed to do that only after upgrading or changing to a new phone, one extra reboot was not a problem, and it wasn't working without it IIRC, so I've put it into instructions.

However, if your needs are different and that reboot is an big issue (I'm curious now why?), probably there are other ways to accomplish it. Perhaps just going to airplane mode and back might reload wifi passwords instead if you're lucky?

If not, I'd try (in root adb shell) using lsof | grep -i wifi and ps -ef | grep -i wifi and see if I can spot which process is responsible for Wifi, and that try to kill that PID to see if it restarts by itself. Unfortunately I currently lack a phone to try that.

milan-fabian commented 1 year ago

Sorry for missing the adb reboot command. I am trying to automate the process and rebooting the device makes the entire workflow more difficult.

I tried using ps -ef | grep -i wifi and then killing all processes:

rk3399_mid:/ # ps -ef | grep -i wifi
wifi           275     1 0 11:22:41 ?     00:00:00 android.hardware.wifi@1.0-service
wifi           302     1 1 11:22:42 ?     00:02:54 wificond
wifi           803     1 0 11:22:48 ?     00:00:02 wpa_supplicant /vendor/etc/wifi/wpa_config.txt
root          3612  3553 0 14:59:45 pts/0 00:00:00 grep -i wifi

android.hardware.wifi@1.0-service and wificond restarted automatically, but wpa_supplicant did not and WiFi setting UI was entirely frozen until I rebooted the device.

mnalis commented 1 year ago

if it doesn't restart by its own, you should be able to restart it manually.

milan-fabian commented 1 year ago

Figured out how to restart WiFi services so they start up again correctly:

svc wifi disable
ps -efwww | grep -i wifi
kill {PIDs from previous command}
svc wifi enable

After this, I can access WiFi Settings UI just fine.

The problem is that this sequence of commands doesn't force Android to reload WiFiConfigStore.xml. The file on the file system is with the new entries, but I can still see only the old entries in the list of saved WiFi networks on UI. If I reboot the device, I can then see the new entries in UI.

mnalis commented 1 year ago

Well, I'm out of ideas. If you do find a solution, do write it here so it can help others.

Another place you can ask is https://forum.xda-developers.com/