diff options
Diffstat (limited to 'service')
3 files changed, 34 insertions, 18 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java index 681cf3a3e..f21c75490 100644 --- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java +++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java @@ -43,6 +43,7 @@ import android.hidl.manager.V1_0.IServiceNotification; import android.net.IpConfiguration; import android.net.wifi.SupplicantState; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiManager; import android.net.wifi.WifiSsid; import android.os.HwRemoteBinder; import android.os.RemoteException; @@ -1919,7 +1920,7 @@ public class SupplicantStaIfaceHal { if (mStateIsFourway && (!locallyGenerated || reasonCode != WLAN_REASON_IE_IN_4WAY_DIFFERS)) { mWifiMonitor.broadcastAuthenticationFailureEvent( - mIfaceName, WifiMonitor.AUTHENTICATION_FAILURE_REASON_WRONG_PSWD); + mIfaceName, WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD); } mWifiMonitor.broadcastNetworkDisconnectionEvent( mIfaceName, locallyGenerated ? 1 : 0, reasonCode, @@ -1941,7 +1942,7 @@ public class SupplicantStaIfaceHal { logCallback("onAuthenticationTimeout"); synchronized (mLock) { mWifiMonitor.broadcastAuthenticationFailureEvent( - mIfaceName, WifiMonitor.AUTHENTICATION_FAILURE_REASON_TIMEOUT); + mIfaceName, WifiManager.ERROR_AUTH_FAILURE_TIMEOUT); } } @@ -1964,7 +1965,7 @@ public class SupplicantStaIfaceHal { logCallback("onEapFailure"); synchronized (mLock) { mWifiMonitor.broadcastAuthenticationFailureEvent( - mIfaceName, WifiMonitor.AUTHENTICATION_FAILURE_REASON_EAP_FAILURE); + mIfaceName, WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE); } } diff --git a/service/java/com/android/server/wifi/SupplicantStateTracker.java b/service/java/com/android/server/wifi/SupplicantStateTracker.java index 9ba64b9bc..cac7f06df 100644 --- a/service/java/com/android/server/wifi/SupplicantStateTracker.java +++ b/service/java/com/android/server/wifi/SupplicantStateTracker.java @@ -55,6 +55,14 @@ public class SupplicantStateTracker extends StateMachine { * for all type of failures: EAP, WPS & WPA networks */ private boolean mAuthFailureInSupplicantBroadcast = false; + /* Authentication failure reason + * see {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_NONE}, + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_TIMEOUT}, + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_WRONG_PSWD}, + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_EAP_FAILURE} + */ + private int mAuthFailureReason; + /* Maximum retries on a authentication failure notification */ private static final int MAX_RETRIES_ON_AUTHENTICATION_FAILURE = 2; @@ -171,6 +179,11 @@ public class SupplicantStateTracker extends StateMachine { } private void sendSupplicantStateChangedBroadcast(SupplicantState state, boolean failedAuth) { + sendSupplicantStateChangedBroadcast(state, failedAuth, WifiManager.ERROR_AUTH_FAILURE_NONE); + } + + private void sendSupplicantStateChangedBroadcast(SupplicantState state, boolean failedAuth, + int reasonCode) { int supplState; switch (state) { case DISCONNECTED: supplState = BatteryStats.WIFI_SUPPL_STATE_DISCONNECTED; break; @@ -204,8 +217,11 @@ public class SupplicantStateTracker extends StateMachine { intent.putExtra(WifiManager.EXTRA_NEW_STATE, (Parcelable) state); if (failedAuth) { intent.putExtra( - WifiManager.EXTRA_SUPPLICANT_ERROR, - WifiManager.ERROR_AUTHENTICATING); + WifiManager.EXTRA_SUPPLICANT_ERROR, + WifiManager.ERROR_AUTHENTICATING); + intent.putExtra( + WifiManager.EXTRA_SUPPLICANT_ERROR_REASON, + reasonCode); } mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); } @@ -225,12 +241,15 @@ public class SupplicantStateTracker extends StateMachine { switch (message.what) { case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: mAuthFailureInSupplicantBroadcast = true; + mAuthFailureReason = message.arg2; break; case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: StateChangeResult stateChangeResult = (StateChangeResult) message.obj; SupplicantState state = stateChangeResult.state; - sendSupplicantStateChangedBroadcast(state, mAuthFailureInSupplicantBroadcast); + sendSupplicantStateChangedBroadcast(state, mAuthFailureInSupplicantBroadcast, + mAuthFailureReason); mAuthFailureInSupplicantBroadcast = false; + mAuthFailureReason = WifiManager.ERROR_AUTH_FAILURE_NONE; transitionOnSupplicantStateChange(stateChangeResult); break; case WifiStateMachine.CMD_RESET_SUPPLICANT_STATE: @@ -332,7 +351,7 @@ public class SupplicantStateTracker extends StateMachine { } mLoopDetectIndex = state.ordinal(); sendSupplicantStateChangedBroadcast(state, - mAuthFailureInSupplicantBroadcast); + mAuthFailureInSupplicantBroadcast, mAuthFailureReason); } else { //Have the DefaultState handle the transition return NOT_HANDLED; @@ -361,7 +380,8 @@ public class SupplicantStateTracker extends StateMachine { case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: StateChangeResult stateChangeResult = (StateChangeResult) message.obj; SupplicantState state = stateChangeResult.state; - sendSupplicantStateChangedBroadcast(state, mAuthFailureInSupplicantBroadcast); + sendSupplicantStateChangedBroadcast(state, mAuthFailureInSupplicantBroadcast, + mAuthFailureReason); /* Ignore any connecting state in completed state. Group re-keying * events and other auth events that do not affect connectivity are * ignored @@ -390,6 +410,7 @@ public class SupplicantStateTracker extends StateMachine { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { super.dump(fd, pw, args); pw.println("mAuthFailureInSupplicantBroadcast " + mAuthFailureInSupplicantBroadcast); + pw.println("mAuthFailureReason " + mAuthFailureReason); pw.println("mNetworksDisabledDuringConnect " + mNetworksDisabledDuringConnect); pw.println(); } diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java index 6c8ac813f..d1903a0de 100644 --- a/service/java/com/android/server/wifi/WifiMonitor.java +++ b/service/java/com/android/server/wifi/WifiMonitor.java @@ -96,15 +96,6 @@ public class WifiMonitor { /* hotspot 2.0 events */ public static final int HS20_REMEDIATION_EVENT = BASE + 61; - /** - * Authentication Failure reasonCode, used internally by WifiStateMachine - * @hide - */ - public static final int AUTHENTICATION_FAILURE_REASON_DEFAULT = 0; - public static final int AUTHENTICATION_FAILURE_REASON_TIMEOUT = 1; - public static final int AUTHENTICATION_FAILURE_REASON_WRONG_PSWD = 2; - public static final int AUTHENTICATION_FAILURE_REASON_EAP_FAILURE = 3; - /* WPS config errrors */ private static final int CONFIG_MULTIPLE_PBC_DETECTED = 12; private static final int CONFIG_AUTH_FAILURE = 18; @@ -480,7 +471,10 @@ public class WifiMonitor { * * @param iface Name of iface on which this occurred. * @param reason Reason for authentication failure. This has to be one of the - * |AUTHENTICATION_FAILURE_REASON_*| reason codes. + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_NONE}, + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_TIMEOUT}, + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_WRONG_PSWD}, + * {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_EAP_FAILURE} */ public void broadcastAuthenticationFailureEvent(String iface, int reason) { sendMessage(iface, AUTHENTICATION_FAILURE_EVENT, 0, reason); |