diff options
author | Hu Wang <huw@codeaurora.org> | 2015-02-04 19:57:10 +0800 |
---|---|---|
committer | Ethan Chen <intervigil@gmail.com> | 2015-03-24 05:21:04 +0000 |
commit | 67d21c2ce1ce492fb798dbdbef09c99be0422f8c (patch) | |
tree | e64fc83d80b1ae6725b1dfa1a7473d42e9cb5eac | |
parent | 6655e0006ba965530225c72cb8da0acea60e70b0 (diff) | |
download | android_frameworks_opt_net_wifi-67d21c2ce1ce492fb798dbdbef09c99be0422f8c.tar.gz android_frameworks_opt_net_wifi-67d21c2ce1ce492fb798dbdbef09c99be0422f8c.tar.bz2 android_frameworks_opt_net_wifi-67d21c2ce1ce492fb798dbdbef09c99be0422f8c.zip |
Softap: update WifiContoller state on start softap failurestable/cm-12.0-YNG4Nstable/cm-12.0-YNG3Ccm-12.0
If start SoftAp fails due to tethering timeout or improper
ssid config, WifiStateMachine would transition to InitialState,
but WifiController is left stuck in ApEnabledState, which
in turn fails to turn on WLAN again.
Register WifiService to receive WIFI_AP_STATE_CHANGED_ACTION
intent from WifiStateMachine, and if wifiApState is failed,
inform WifiController to transtion to ApStaDisabledState.
Change-Id: Ic54716745a4d8b4e0d6984251260390d452ab889
CRs-Fixed: 781404
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 17 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 52ddbcb3c..d8aa8c694 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1332,6 +1332,22 @@ public final class WifiServiceImpl extends IWifiManager.Stub { } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) { boolean emergencyMode = intent.getBooleanExtra("phoneinECMState", false); mWifiController.sendMessage(CMD_EMERGENCY_MODE_CHANGED, emergencyMode ? 1 : 0, 0); + } else if (action.equals(WifiManager.WIFI_AP_STATE_CHANGED_ACTION)) { + int wifiApState = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_STATE, + WifiManager.WIFI_AP_STATE_FAILED); + Slog.d(TAG, "wifiApState=" + wifiApState); + /* + * If start SoftAp fails, WifiStateMachine would transition to InitialState, + * but WifiController is left stuck in ApEnabledState, which in turn + * fails to turn on WLAN again. + * + * Register WifiService to receive WIFI_AP_STATE_CHANGED_ACTION intent + * from WifiStateMachine, and if wifiApState is failed, inform WifiController + * to transtion to ApStaDisabledState. + */ + if (wifiApState == WifiManager.WIFI_AP_STATE_FAILED) { + setWifiApEnabled(null, false); + } } } }; @@ -1360,6 +1376,7 @@ public final class WifiServiceImpl extends IWifiManager.Stub { intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); + intentFilter.addAction(WifiManager.WIFI_AP_STATE_CHANGED_ACTION); intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); mContext.registerReceiver(mReceiver, intentFilter); diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index e111a62d4..39ccf7b84 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -8177,6 +8177,7 @@ public class WifiStateMachine extends StateMachine { if (message.arg1 == mTetherToken) { loge("Failed to get tether update, shutdown soft access point"); transitionTo(mSoftApStartedState); + setWifiApState(WIFI_AP_STATE_FAILED); // Needs to be first thing handled sendMessageAtFrontOfQueue(CMD_STOP_AP); } |