diff options
5 files changed, 38 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 0f84b3dd9..727676880 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -2983,6 +2983,10 @@ public class ClientModeImpl extends StateMachine { mNetworkFactory.handleConnectionAttemptEnded(level2FailureCode, configuration); mWifiNetworkSuggestionsManager.handleConnectionAttemptEnded( level2FailureCode, configuration, getCurrentBSSID()); + ScanResult candidate = configuration.getNetworkSelectionStatus().getCandidate(); + if (candidate != null && !TextUtils.equals(candidate.BSSID, getCurrentBSSID())) { + mWifiMetrics.incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware(); + } } handleConnectionAttemptEndForDiagnostics(level2FailureCode); } diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 621a2fbc8..0559326b1 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -6452,4 +6452,13 @@ public class WifiMetrics { public void noteSoftApClientBlocked(int maxClient) { mSoftApConfigLimitationMetrics.maxClientSettingWhenReachHistogram.increment(maxClient); } + + /** + * Increment number of connection with different BSSID between framework and firmware selection. + */ + public void incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware() { + synchronized (mLock) { + mWifiLogProto.numBssidDifferentSelectionBetweenFrameworkAndFirmware++; + } + } } diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 0c3346bef..8755271f7 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -706,6 +706,9 @@ message WifiLog { // User reaction to the carrier or suggestion app approval UI. optional UserReactionToApprovalUiEvent user_reaction_to_approval_ui_event = 198; + + // Number of connection with different BSSID between framework and firmware selection. + optional int32 num_bssid_different_selection_between_framework_and_firmware = 199; } // Information that gets logged for every WiFi connection. diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 1761b2113..c3829be46 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -2944,6 +2944,8 @@ public class ClientModeImplTest extends WifiBaseTest { */ @Test public void testReportConnectionEventIsCalledAfterAssociationFailure() throws Exception { + mConnectedNetwork.getNetworkSelectionStatus() + .setCandidate(getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult()); // Setup CONNECT_MODE & a WifiConfiguration initializeAndAddNetworkAndVerifySuccess(); mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); @@ -2962,6 +2964,8 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiNetworkSuggestionsManager).handleConnectionAttemptEnded( eq(WifiMetrics.ConnectionEvent.FAILURE_ASSOCIATION_REJECTION), any(WifiConfiguration.class), eq(null)); + verify(mWifiMetrics, never()) + .incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware(); verifyConnectionEventTimeoutDoesNotOccur(); } @@ -2973,6 +2977,8 @@ public class ClientModeImplTest extends WifiBaseTest { */ @Test public void testReportConnectionEventIsCalledAfterAuthenticationFailure() throws Exception { + mConnectedNetwork.getNetworkSelectionStatus() + .setCandidate(getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult()); // Setup CONNECT_MODE & a WifiConfiguration initializeAndAddNetworkAndVerifySuccess(); mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); @@ -2991,6 +2997,8 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiNetworkSuggestionsManager).handleConnectionAttemptEnded( eq(WifiMetrics.ConnectionEvent.FAILURE_AUTHENTICATION_FAILURE), any(WifiConfiguration.class), eq(null)); + verify(mWifiMetrics, never()) + .incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware(); verifyConnectionEventTimeoutDoesNotOccur(); } @@ -3165,6 +3173,8 @@ public class ClientModeImplTest extends WifiBaseTest { */ @Test public void testReportConnectionEventIsCalledAfterDhcpFailure() throws Exception { + mConnectedNetwork.getNetworkSelectionStatus() + .setCandidate(getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult()); testDhcpFailure(); verify(mWifiDiagnostics, atLeastOnce()).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_FAILED)); @@ -3175,6 +3185,8 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiNetworkSuggestionsManager, atLeastOnce()).handleConnectionAttemptEnded( eq(WifiMetrics.ConnectionEvent.FAILURE_DHCP), any(WifiConfiguration.class), any(String.class)); + verify(mWifiMetrics, never()) + .incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware(); verifyConnectionEventTimeoutDoesNotOccur(); } @@ -3186,8 +3198,9 @@ public class ClientModeImplTest extends WifiBaseTest { */ @Test public void testReportConnectionEventIsCalledAfterSuccessfulConnection() throws Exception { + mConnectedNetwork.getNetworkSelectionStatus() + .setCandidate(getGoogleGuestScanDetail(TEST_RSSI, sBSSID1, sFreq).getScanResult()); connect(); - ArgumentCaptor<Messenger> messengerCaptor = ArgumentCaptor.forClass(Messenger.class); verify(mConnectivityManager).registerNetworkAgent(messengerCaptor.capture(), any(NetworkInfo.class), any(LinkProperties.class), any(NetworkCapabilities.class), @@ -3209,6 +3222,8 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mWifiNetworkSuggestionsManager).handleConnectionAttemptEnded( eq(WifiMetrics.ConnectionEvent.FAILURE_NONE), any(WifiConfiguration.class), any(String.class)); + // BSSID different, record this connection. + verify(mWifiMetrics).incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware(); verifyConnectionEventTimeoutDoesNotOccur(); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index e4e58c1df..67d0c82a7 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -440,6 +440,7 @@ public class WifiMetricsTest extends WifiBaseTest { private static final int NUM_NETWORK_ABNORMAL_ASSOC_REJECTION = 2; private static final int NUM_NETWORK_SUFFICIENT_RECENT_STATS_ONLY = 4; private static final int NUM_NETWORK_SUFFICIENT_RECENT_PREV_STATS = 5; + private static final int NUM_BSSID_SELECTION_DIFFERENT_BETWEEN_FRAMEWORK_FIRMWARE = 3; /** Number of notifications per "Connect to Network" notification type. */ private static final int[] NUM_CONNECT_TO_NETWORK_NOTIFICATIONS = {0, 10, 20, 30, 40}; @@ -909,6 +910,9 @@ public class WifiMetricsTest extends WifiBaseTest { for (int i = 0; i < NUM_PNO_FOUND_NETWORK_EVENTS; i++) { mWifiMetrics.incrementPnoFoundNetworkEventCount(); } + for (int i = 0; i < NUM_BSSID_SELECTION_DIFFERENT_BETWEEN_FRAMEWORK_FIRMWARE; i++) { + mWifiMetrics.incrementNumBssidDifferentSelectionBetweenFrameworkAndFirmware(); + } // set and increment "connect to network" notification metrics for (int i = 0; i < NUM_CONNECT_TO_NETWORK_NOTIFICATIONS.length; i++) { @@ -1324,6 +1328,8 @@ public class WifiMetricsTest extends WifiBaseTest { mDecodedProto.numPasspointProviderWithSelfSignedRootCa); assertEquals(NUM_PASSPOINT_PROVIDERS_WITH_EXPIRATION_DATE, mDecodedProto.numPasspointProviderWithSubscriptionExpiration); + assertEquals(NUM_BSSID_SELECTION_DIFFERENT_BETWEEN_FRAMEWORK_FIRMWARE, + mDecodedProto.numBssidDifferentSelectionBetweenFrameworkAndFirmware); assertEquals(NUM_RADIO_MODE_CHANGE_TO_MCC, mDecodedProto.numRadioModeChangeToMcc); assertEquals(NUM_RADIO_MODE_CHANGE_TO_SCC, mDecodedProto.numRadioModeChangeToScc); |