summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-09-14 19:58:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-09-14 19:58:48 +0000
commit21130f070cd84f847b2efd59c099b86068733347 (patch)
tree9e2be2b758ac3b2598f6aae4509b9ae468ef4883
parent90b8c690138228ae755a68dd11b6c6d102eeb824 (diff)
parentbac7430bc9de3779b078da596a2ef1badfc7fd54 (diff)
Merge "SupplicantStaIfaceCallback: Refactor FILS connection event handling" into rvc-qpr-dev
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java13
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceCallbackImpl.java16
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_1Impl.java10
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_2Impl.java10
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_3Impl.java47
-rw-r--r--service/java/com/android/server/wifi/WifiMonitor.java20
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java11
9 files changed, 50 insertions, 87 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index e7371a9f1..f4e3ed5f3 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -910,8 +910,6 @@ public class ClientModeImpl extends StateMachine {
getHandler());
mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.NETWORK_CONNECTION_EVENT,
getHandler());
- mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.FILS_NETWORK_CONNECTION_EVENT,
- getHandler());
mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.NETWORK_DISCONNECTION_EVENT,
getHandler());
mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.RX_HS20_ANQP_ICON_EVENT,
@@ -1998,7 +1996,6 @@ public class ClientModeImpl extends StateMachine {
}
sb.append(" blacklist=" + Boolean.toString(mDidBlackListBSSID));
break;
- case WifiMonitor.FILS_NETWORK_CONNECTION_EVENT:
case WifiMonitor.NETWORK_CONNECTION_EVENT:
sb.append(" ");
sb.append(Integer.toString(msg.arg1));
@@ -2264,9 +2261,6 @@ public class ClientModeImpl extends StateMachine {
case WifiMonitor.NETWORK_CONNECTION_EVENT:
s = "NETWORK_CONNECTION_EVENT";
break;
- case WifiMonitor.FILS_NETWORK_CONNECTION_EVENT:
- s = "FILS_NETWORK_CONNECTION_EVENT";
- break;
case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
s = "NETWORK_DISCONNECTION_EVENT";
break;
@@ -3456,7 +3450,6 @@ public class ClientModeImpl extends StateMachine {
case CMD_RECONNECT:
case CMD_REASSOCIATE:
case WifiMonitor.NETWORK_CONNECTION_EVENT:
- case WifiMonitor.FILS_NETWORK_CONNECTION_EVENT:
case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
@@ -4213,12 +4206,11 @@ public class ClientModeImpl extends StateMachine {
}
handleStatus = NOT_HANDLED;
break;
- case WifiMonitor.FILS_NETWORK_CONNECTION_EVENT:
- mWifiMetrics.incrementL2ConnectionThroughFilsAuthCount();
- mSentHLPs = true;
case WifiMonitor.NETWORK_CONNECTION_EVENT:
if (mVerboseLoggingEnabled) log("Network connection established");
mLastNetworkId = message.arg1;
+ mSentHLPs = message.arg2 == 1;
+ if (mSentHLPs) mWifiMetrics.incrementL2ConnectionThroughFilsAuthCount();
mWifiConfigManager.clearRecentFailureReason(mLastNetworkId);
mLastBssid = (String) message.obj;
reasonCode = message.arg2;
@@ -4908,7 +4900,6 @@ public class ClientModeImpl extends StateMachine {
}
break;
case WifiMonitor.NETWORK_CONNECTION_EVENT:
- case WifiMonitor.FILS_NETWORK_CONNECTION_EVENT:
mWifiInfo.setBSSID((String) message.obj);
mLastNetworkId = message.arg1;
mWifiInfo.setNetworkId(mLastNetworkId);
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackImpl.java b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackImpl.java
index 9d69003cf..0e2189ba0 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackImpl.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackImpl.java
@@ -157,9 +157,11 @@ abstract class SupplicantStaIfaceCallbackImpl extends ISupplicantStaIfaceCallbac
}
}
- @Override
- public void onStateChanged(int newState, byte[/* 6 */] bssid, int id,
- ArrayList<Byte> ssid) {
+ /**
+ * Added to plumb the new {@code filsHlpSent} param from the V1.3 callback version.
+ */
+ public void onStateChanged(int newState, byte[/* 6 */] bssid, int id, ArrayList<Byte> ssid,
+ boolean filsHlpSent) {
synchronized (mLock) {
mStaIfaceHal.logCallback("onStateChanged");
SupplicantState newSupplicantState =
@@ -174,7 +176,8 @@ abstract class SupplicantStaIfaceCallbackImpl extends ISupplicantStaIfaceCallbac
}
if (newState == State.COMPLETED) {
mWifiMonitor.broadcastNetworkConnectionEvent(
- mIfaceName, mStaIfaceHal.getCurrentNetworkId(mIfaceName), bssidStr);
+ mIfaceName, mStaIfaceHal.getCurrentNetworkId(mIfaceName), filsHlpSent,
+ bssidStr);
}
mWifiMonitor.broadcastSupplicantStateChangeEvent(
mIfaceName, mStaIfaceHal.getCurrentNetworkId(mIfaceName), wifiSsid,
@@ -183,6 +186,11 @@ abstract class SupplicantStaIfaceCallbackImpl extends ISupplicantStaIfaceCallbac
}
@Override
+ public void onStateChanged(int newState, byte[/* 6 */] bssid, int id, ArrayList<Byte> ssid) {
+ onStateChanged(newState, bssid, id, ssid, false);
+ }
+
+ @Override
public void onAnqpQueryDone(byte[/* 6 */] bssid,
ISupplicantStaIfaceCallback.AnqpData data,
ISupplicantStaIfaceCallback.Hs20AnqpData hs20Data) {
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_1Impl.java b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_1Impl.java
index 12e025e69..c4a3dda16 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_1Impl.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_1Impl.java
@@ -53,10 +53,18 @@ abstract class SupplicantStaIfaceCallbackV1_1Impl extends
mCallbackV10.onNetworkRemoved(id);
}
+ /**
+ * Added to plumb the new {@code filsHlpSent} param from the V1.3 callback version.
+ */
+ public void onStateChanged(int newState, byte[/* 6 */] bssid, int id, ArrayList<Byte> ssid,
+ boolean filsHlpSent) {
+ mCallbackV10.onStateChanged(newState, bssid, id, ssid, filsHlpSent);
+ }
+
@Override
public void onStateChanged(int newState, byte[/* 6 */] bssid, int id,
ArrayList<Byte> ssid) {
- mCallbackV10.onStateChanged(newState, bssid, id, ssid);
+ onStateChanged(newState, bssid, id, ssid, false);
}
@Override
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_2Impl.java b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_2Impl.java
index 89e66d22c..973e11a4a 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_2Impl.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_2Impl.java
@@ -59,10 +59,18 @@ abstract class SupplicantStaIfaceCallbackV1_2Impl extends
mCallbackV11.onNetworkRemoved(id);
}
+ /**
+ * Added to plumb the new {@code filsHlpSent} param from the V1.3 callback version.
+ */
+ public void onStateChanged(int newState, byte[/* 6 */] bssid, int id, ArrayList<Byte> ssid,
+ boolean filsHlpSent) {
+ mCallbackV11.onStateChanged(newState, bssid, id, ssid, filsHlpSent);
+ }
+
@Override
public void onStateChanged(int newState, byte[/* 6 */] bssid, int id,
ArrayList<Byte> ssid) {
- mCallbackV11.onStateChanged(newState, bssid, id, ssid);
+ onStateChanged(newState, bssid, id, ssid, false);
}
@Override
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_3Impl.java b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_3Impl.java
index f293b9d7c..154fde40b 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_3Impl.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceCallbackV1_3Impl.java
@@ -15,19 +15,13 @@
*/
package com.android.server.wifi;
-import static com.android.server.wifi.SupplicantStaIfaceCallbackImpl.supplicantHidlStateToFrameworkState;
import android.annotation.NonNull;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback;
-import android.hardware.wifi.supplicant.V1_3.ISupplicantStaIfaceCallback.BssTmData;
-import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiSsid;
import android.util.Log;
-import com.android.server.wifi.util.NativeUtil;
-
import java.util.ArrayList;
abstract class SupplicantStaIfaceCallbackV1_3Impl extends
@@ -37,7 +31,6 @@ abstract class SupplicantStaIfaceCallbackV1_3Impl extends
private final String mIfaceName;
private final WifiMonitor mWifiMonitor;
private final SupplicantStaIfaceHal.SupplicantStaIfaceHalCallbackV1_2 mCallbackV12;
- private boolean mStateIsFourwayV13 = false; // Used to help check for PSK password mismatch
SupplicantStaIfaceCallbackV1_3Impl(@NonNull SupplicantStaIfaceHal staIfaceHal,
@NonNull String ifaceName,
@@ -57,9 +50,7 @@ abstract class SupplicantStaIfaceCallbackV1_3Impl extends
@Override
public void onNetworkRemoved(int id) {
- mStaIfaceHal.logCallback("onNetworkRemoved");
- // Reset 4way handshake state since network has been removed.
- mStateIsFourwayV13 = false;
+ mCallbackV12.onNetworkRemoved(id);
}
@Override
@@ -96,20 +87,7 @@ abstract class SupplicantStaIfaceCallbackV1_3Impl extends
@Override
public void onDisconnected(byte[/* 6 */] bssid, boolean locallyGenerated,
int reasonCode) {
- mStaIfaceHal.logCallback("onDisconnected");
- if (mStaIfaceHal.isVerboseLoggingEnabled()) {
- Log.e(TAG, "onDisconnected 4way=" + mStateIsFourwayV13
- + " locallyGenerated=" + locallyGenerated
- + " reasonCode=" + reasonCode);
- }
- if (mStateIsFourwayV13
- && (!locallyGenerated || reasonCode != ReasonCode.IE_IN_4WAY_DIFFERS)) {
- mWifiMonitor.broadcastAuthenticationFailureEvent(
- mIfaceName, WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD, -1);
- }
- mWifiMonitor.broadcastNetworkDisconnectionEvent(
- mIfaceName, locallyGenerated ? 1 : 0, reasonCode,
- NativeUtil.macAddressFromByteArray(bssid));
+ mCallbackV12.onDisconnected(bssid, locallyGenerated, reasonCode);
}
@Override
@@ -365,25 +343,6 @@ abstract class SupplicantStaIfaceCallbackV1_3Impl extends
@Override
public void onStateChanged_1_3(int newState, byte[/* 6 */] bssid, int id,
ArrayList<Byte> ssid, boolean filsHlpSent) {
- mStaIfaceHal.logCallback("onStateChanged_1_3");
- SupplicantState newSupplicantState =
- supplicantHidlStateToFrameworkState(newState);
- WifiSsid wifiSsid =
- WifiSsid.createFromByteArray(NativeUtil.byteArrayFromArrayList(ssid));
- String bssidStr = NativeUtil.macAddressFromByteArray(bssid);
- mStateIsFourwayV13 =
- (newState == ISupplicantStaIfaceCallback.State.FOURWAY_HANDSHAKE);
- if (newSupplicantState == SupplicantState.COMPLETED) {
- if (filsHlpSent) {
- mWifiMonitor.broadcastFilsNetworkConnectionEvent(
- mIfaceName, mStaIfaceHal.getCurrentNetworkId(mIfaceName), bssidStr);
- } else {
- mWifiMonitor.broadcastNetworkConnectionEvent(
- mIfaceName, mStaIfaceHal.getCurrentNetworkId(mIfaceName), bssidStr);
- }
- }
- mWifiMonitor.broadcastSupplicantStateChangeEvent(
- mIfaceName, mStaIfaceHal.getCurrentNetworkId(mIfaceName),
- wifiSsid, bssidStr, newSupplicantState);
+ mCallbackV12.onStateChanged(newState, bssid, id, ssid, filsHlpSent);
}
}
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java
index 7f620851d..32a96d0eb 100644
--- a/service/java/com/android/server/wifi/WifiMonitor.java
+++ b/service/java/com/android/server/wifi/WifiMonitor.java
@@ -100,9 +100,6 @@ public class WifiMonitor {
/* MBO/OCE events */
public static final int MBO_OCE_BSS_TM_HANDLING_DONE = BASE + 71;
- /* Fils network connection completed */
- public static final int FILS_NETWORK_CONNECTION_EVENT = BASE + 62;
-
/* WPS config errrors */
private static final int CONFIG_MULTIPLE_PBC_DETECTED = 12;
private static final int CONFIG_AUTH_FAILURE = 18;
@@ -500,21 +497,12 @@ public class WifiMonitor {
*
* @param iface Name of iface on which this occurred.
* @param networkId ID of the network in wpa_supplicant.
+ * @param filsHlpSent Whether the connection used FILS.
* @param bssid BSSID of the access point.
*/
- public void broadcastNetworkConnectionEvent(String iface, int networkId, String bssid) {
- sendMessage(iface, NETWORK_CONNECTION_EVENT, networkId, 0, bssid);
- }
-
- /**
- * Broadcast the fils network connection event to all the handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param networkId ID of the network in wpa_supplicant.
- * @param bssid BSSID of the access point.
- */
- public void broadcastFilsNetworkConnectionEvent(String iface, int networkId, String bssid) {
- sendMessage(iface, FILS_NETWORK_CONNECTION_EVENT, networkId, 0, bssid);
+ public void broadcastNetworkConnectionEvent(String iface, int networkId, boolean filsHlpSent,
+ String bssid) {
+ sendMessage(iface, NETWORK_CONNECTION_EVENT, networkId, filsHlpSent ? 1 : 0, bssid);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index fd1ef1718..d4af7ecac 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -4986,7 +4986,7 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWifiMetrics, times(1)).incrementConnectRequestWithFilsAkmCount();
- mCmi.sendMessage(WifiMonitor.FILS_NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
+ mCmi.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 1, sBSSID);
mLooper.dispatchAll();
verify(mWifiMetrics, times(1)).incrementL2ConnectionThroughFilsAuthCount();
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 762691184..7e0c20faf 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -1010,7 +1010,7 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest {
NativeUtil.decodeSsid(SUPPLICANT_SSID));
wifiMonitorInOrder.verify(mWifiMonitor).broadcastNetworkConnectionEvent(
- eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(BSSID));
+ eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(false), eq(BSSID));
wifiMonitorInOrder.verify(mWifiMonitor).broadcastSupplicantStateChangeEvent(
eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId),
any(WifiSsid.class), eq(BSSID), eq(SupplicantState.COMPLETED));
@@ -2824,7 +2824,7 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest {
NativeUtil.decodeSsid(SUPPLICANT_SSID), false);
wifiMonitorInOrder.verify(mWifiMonitor).broadcastNetworkConnectionEvent(
- eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(BSSID));
+ eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(false), eq(BSSID));
wifiMonitorInOrder.verify(mWifiMonitor).broadcastSupplicantStateChangeEvent(
eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId),
any(WifiSsid.class), eq(BSSID), eq(SupplicantState.COMPLETED));
@@ -2904,8 +2904,8 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest {
NativeUtil.macAddressToByteArray(BSSID), SUPPLICANT_NETWORK_ID,
NativeUtil.decodeSsid(SUPPLICANT_SSID), true);
- wifiMonitorInOrder.verify(mWifiMonitor).broadcastFilsNetworkConnectionEvent(
- eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(BSSID));
+ wifiMonitorInOrder.verify(mWifiMonitor).broadcastNetworkConnectionEvent(
+ eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId), eq(true), eq(BSSID));
wifiMonitorInOrder.verify(mWifiMonitor).broadcastSupplicantStateChangeEvent(
eq(WLAN0_IFACE_NAME), eq(frameworkNetworkId),
any(WifiSsid.class), eq(BSSID), eq(SupplicantState.COMPLETED));
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
index 24bb968a5..c4acd73c2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
@@ -423,13 +423,14 @@ public class WifiMonitorTest extends WifiBaseTest {
WLAN_IFACE_NAME, WifiMonitor.NETWORK_CONNECTION_EVENT, mHandlerSpy);
int networkId = NETWORK_ID;
String bssid = BSSID;
- mWifiMonitor.broadcastNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, bssid);
+ mWifiMonitor.broadcastNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, false, bssid);
mLooper.dispatchAll();
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
verify(mHandlerSpy).handleMessage(messageCaptor.capture());
assertEquals(WifiMonitor.NETWORK_CONNECTION_EVENT, messageCaptor.getValue().what);
assertEquals(networkId, messageCaptor.getValue().arg1);
+ assertEquals(0, messageCaptor.getValue().arg2);
assertEquals(bssid, (String) messageCaptor.getValue().obj);
}
@@ -607,17 +608,17 @@ public class WifiMonitorTest extends WifiBaseTest {
@Test
public void testBroadcastFilsNetworkConnectionEvent() {
mWifiMonitor.registerHandler(
- WLAN_IFACE_NAME, WifiMonitor.FILS_NETWORK_CONNECTION_EVENT, mHandlerSpy);
+ WLAN_IFACE_NAME, WifiMonitor.NETWORK_CONNECTION_EVENT, mHandlerSpy);
int networkId = NETWORK_ID;
String bssid = BSSID;
- mWifiMonitor.broadcastFilsNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, bssid);
+ mWifiMonitor.broadcastNetworkConnectionEvent(WLAN_IFACE_NAME, networkId, true, bssid);
mLooper.dispatchAll();
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
verify(mHandlerSpy).handleMessage(messageCaptor.capture());
- assertEquals(WifiMonitor.FILS_NETWORK_CONNECTION_EVENT, messageCaptor.getValue().what);
+ assertEquals(WifiMonitor.NETWORK_CONNECTION_EVENT, messageCaptor.getValue().what);
assertEquals(networkId, messageCaptor.getValue().arg1);
+ assertEquals(1, messageCaptor.getValue().arg2);
assertEquals(bssid, (String) messageCaptor.getValue().obj);
}
-
}