Modify the configuration of hot calls back WifiTetherSettings.java in the
onTetherConfigUpdated () method, this method was invoked stopTether ().
Consuming mainly getWifiApState method called hot spots before closing
211 if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {
212 Log.d("TetheringSettings",
213 "Wifi AP config changed while enabled, stop and restart");
214 mRestartWifiApAfterConfigChange = true;
215 mSwitchBarController.stopTether();
216 }
Reason for closing Hotspot time-consuming in the WifiserviceImpl, with the function Q getWifiApEnabledState 1000ms, only the P 20ms.
P code
/android/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
mClientHandler.runWithScissors(() -> {
Q code
/android/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiServiceImpl.java
mWifiInjector.getClientModeImplHandler().runWithScissors(() -> {
After local authentication, using a P-Q in the notation can solve the problem of time-consuming off hot.
The difference between points P and Q:
the P mClientHandler wifiServiceHandlerThread thread working in
this command is processed (mWifiCoreHandlerThread) corresponds ClientModeImpl mWifiStateMachineHandlerThread thread on the P Q
Since the opening / closing process, ClientModeImpl thread (mWifiCoreHandlerThread) busy in a hotspot, resulting getWifiApEnabledState after treatment by comparison.
The reason being busy is SoftAP startup / shutdown
At the same time, switch wifi hotspots and will cause them to switch calls getWifiApEnabledState slow, but it should also consider the performance of your phone, this problem usually occurs under low performance situations.