describe:
As the question is, online devices are likely to experience WIFI reconnection, and this will not happen if they are rebooted without power off mode.
analyze:
After analysis, this is related to Linux's file system storage mechanism. When the user layer writes files, the system first stores the files in memory and then writes data to flash after the CPU is idle. This is a caching mechanism, which aims to improve the read and write efficiency of files. But it brings the risk of losing data when the machine suddenly loses power.
Solution:
There is a command sync in Linux system, which aims to force the data to be written in memory to flash. Going back to our question, we just call the sync command after saving the WIFI password.
Add fileSync(); in the file frameworks/opt/net/wifi/service/java/com/android/server/wifi/ as shown below;
private void fileSync(){ Runtime runtime = (); try { ("sync"); } catch (IOException e) { (); (TAG, "fileSync"); } } public boolean saveConfig() { boolean ret; ret = doBooleanCommand("SAVE_CONFIG"); fileSync();//Newly added return ret; }
Summarize
The above is the bug that the editor introduced to you that WIFI cannot be automatically reconnected after the Android device is powered off and restarted. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!