1.连上wifi时同步保存wifi密码,避免连上wifi后马上断电重启由于密码没保存导致不能自动重连wifi
packages/modules/Wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -66,6 +66,7 @@ import com.android.server.wifi.WifiNative.SupplicantDeathEventHandler;
import com.android.server.wifi.util.GeneralUtil.Mutable;
import com.android.server.wifi.util.NativeUtil;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
@@ -977,10 +978,22 @@ public class SupplicantStaIfaceHal {
}
return null;
}
+ fileSync();
return new Pair(network, new WifiConfiguration(config));
}
}
+ private void fileSync() {
+ Runtime runtime = Runtime.getRuntime();
+ try {
+ runtime.exec("sync");
+ Log.i(TAG, "saveConfig fileSync() successfully!");
+ } catch (IOException e) {
+ e.printStackTrace();
+ Log.e(TAG, "fileSync exception");
+ }
+ }
+
/**
* Add the provided network configuration to wpa_supplicant and initiate connection to it.
* This method does the following:
2.解决已连接过的wifi重启后低概率不能自动重连
diff --git a/packages/modules/Wifi/service/java/com/android/server/wifi/WifiConnectivityManager.java b/packages/modules/Wifi/service/java/com/android/server/wifi/WifiConnectivityManager.java
index e8507ce..2373c3f 100644
--- a/packages/modules/Wifi/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/packages/modules/Wifi/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -169,7 +169,7 @@ public class WifiConnectivityManager {
private boolean mDbg = false;
private boolean mVerboseLoggingEnabled = false;
private boolean mWifiEnabled = false;
- private boolean mAutoJoinEnabled = false; // disabled by default, enabled by external triggers
+ private boolean mAutoJoinEnabled = true; // disabled by default, enabled by external triggers
private boolean mRunning = false;
private boolean mScreenOn = false;
private int mWifiState = WIFI_STATE_UNKNOWN;