LRWD: Remove obsolete snapshot grabbing check

No longer need this because we are enforcing something even more strict.

Bug: 77655949
Test: compile, unit test
Change-Id: Ic48999b4b0dcb633085afb66bcc63400c143b4c8
diff --git a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
index 562af1d..b83963e 100644
--- a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
+++ b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
@@ -26,11 +26,9 @@
 import com.android.internal.annotations.VisibleForTesting;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * This Class is a Work-In-Progress, intended behavior is as follows:
@@ -82,9 +80,6 @@
     private Map<String, Pair<AvailableNetworkFailureCount, Integer>> mSsidFailureCount =
             new HashMap<>();
 
-    // Set of SSIDs that watchdog tried to connect to before finally triggering a restart
-    private Set<String> mSsidAvailableAtFailure = new HashSet<>();
-
     // Tracks: if WifiStateMachine is in ConnectedState
     private boolean mWifiIsConnected = false;
     // Is Watchdog allowed to trigger now? Set to false after triggering. Set to true after
@@ -229,8 +224,6 @@
             setWatchdogTriggerEnabled(false);
             mWatchdogFixedWifi = true;
             Log.e(TAG, "Watchdog triggering recovery");
-            mSsidAvailableAtFailure.clear();
-            mSsidAvailableAtFailure.addAll(mSsidFailureCount.keySet());
             mTimeLastTrigger = mClock.getElapsedSinceBootMillis();
             mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
             // increment various watchdog trigger count stats
@@ -244,9 +237,8 @@
      * Handles transitions entering and exiting WifiStateMachine ConnectedState
      * Used to track wifistate, and perform watchdog count resetting
      * @param isEntering true if called from ConnectedState.enter(), false for exit()
-     * @param ssid the ssid of the network doing the transition
      */
-    public void connectedStateTransition(boolean isEntering, String ssid) {
+    public void connectedStateTransition(boolean isEntering) {
         if (mVerboseLoggingEnabled) {
             Log.v(TAG, "connectedStateTransition: isEntering = " + isEntering);
         }
@@ -255,10 +247,7 @@
             return;
         }
         if (!mWatchdogAllowedToTrigger && mWatchdogFixedWifi
-                && checkIfAtleastOneNetworkHasEverConnected()
-                && mSsidAvailableAtFailure.contains(ssid)) {
-            Log.e(TAG, "Wifi failed to connect on " + mSsidAvailableAtFailure.size()
-                    + " networks but was able to reconnect to one of them after a restart.");
+                && checkIfAtleastOneNetworkHasEverConnected()) {
             takeBugReportWithCurrentProbability("Wifi fixed after restart");
             // WiFi has connected after a Watchdog trigger, without any new networks becoming
             // available, log a Watchdog success in wifi metrics
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 32427c9..907cd28 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -5339,9 +5339,8 @@
             }
 
             mLastDriverRoamAttempt = 0;
-            String curSsid = getTargetSsid();
             mTargetNetworkId = WifiConfiguration.INVALID_NETWORK_ID;
-            mWifiInjector.getWifiLastResortWatchdog().connectedStateTransition(true, curSsid);
+            mWifiInjector.getWifiLastResortWatchdog().connectedStateTransition(true);
             mWifiStateTracker.updateState(WifiStateTracker.CONNECTED);
         }
         @Override
@@ -5496,8 +5495,7 @@
                      WifiConnectivityManager.WIFI_STATE_TRANSITIONING);
 
             mLastDriverRoamAttempt = 0;
-            mWifiInjector.getWifiLastResortWatchdog().connectedStateTransition(false,
-                    getTargetSsid());
+            mWifiInjector.getWifiLastResortWatchdog().connectedStateTransition(false);
         }
     }
 
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
index 0647892..3809c7f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
@@ -901,7 +901,7 @@
         int dhcpFailures = 11;
 
         // Set Watchdogs internal wifi state tracking to 'connected'
-        mLastResortWatchdog.connectedStateTransition(true, "");
+        mLastResortWatchdog.connectedStateTransition(true);
 
         // Buffer potential candidates 1,2,3 & 4
         List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(mSsids,
@@ -980,7 +980,7 @@
         assertFailureCountEquals(mBssids[2], 0, 0, dhcpFailures);
 
         // Transition to 'ConnectedState'
-        mLastResortWatchdog.connectedStateTransition(true, "");
+        mLastResortWatchdog.connectedStateTransition(true);
 
         // Check that we have no failures
         for (int i = 0; i < mSsids.length; i++) {
@@ -1234,7 +1234,7 @@
         mLastResortWatchdog.updateAvailableNetworks(candidates);
 
         // Set Watchdogs internal wifi state tracking to 'connected'
-        mLastResortWatchdog.connectedStateTransition(true, "");
+        mLastResortWatchdog.connectedStateTransition(true);
 
         // Count failures on all 4 networks until all of them are over the failure threshold
         boolean watchdogTriggered = false;
@@ -1349,8 +1349,8 @@
         }
 
         // transition Watchdog wifi state tracking to 'connected' then back to 'disconnected'
-        mLastResortWatchdog.connectedStateTransition(true, "");
-        mLastResortWatchdog.connectedStateTransition(false, "");
+        mLastResortWatchdog.connectedStateTransition(true);
+        mLastResortWatchdog.connectedStateTransition(false);
 
         // Fail 3/4 networks until they're over threshold
         for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD + 1; i++) {
@@ -1492,7 +1492,7 @@
         verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggersWithBadDhcp();
 
         // Simulate wifi connecting after triggering
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
+        mLastResortWatchdog.connectedStateTransition(true);
 
         // Verify that WifiMetrics counted this as a Watchdog success
         verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses();
@@ -1503,7 +1503,7 @@
         verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString());
 
         // Simulate wifi disconnecting
-        mLastResortWatchdog.connectedStateTransition(false, "\"test1\"");
+        mLastResortWatchdog.connectedStateTransition(false);
 
         // Verify that WifiMetrics has still only counted one success
         verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses();
@@ -1546,7 +1546,7 @@
         mLastResortWatchdog.updateAvailableNetworks(candidates);
 
         // Simulate wifi connecting
-        mLastResortWatchdog.connectedStateTransition(true, "");
+        mLastResortWatchdog.connectedStateTransition(true);
 
         // Verify that WifiMetrics did not count another success, as the connection could be due
         // to the newly available network #5
@@ -1729,100 +1729,6 @@
     }
 
     /**
-     * Case 29: Test connection success after wifi restart with an unexpected SSID
-     * Setup 1 network. Fail the network until watchcdog triggers. Trigger a connection success on
-     * a network which has a different SSID than the network that has been failing.
-     * Expected behavior: bugreport is not triggered
-     */
-    @Test
-    public void testConnectionSuccessWithUnexpectedSsidDoesNotTriggerBugreport() {
-        String[] ssids = {"\"test1\""};
-        String[] bssids = {"6c:f3:7f:ae:8c:f3"};
-        int[] frequencies = {2437};
-        String[] caps = {"[WPA2-EAP-CCMP][ESS]"};
-        int[] levels = {-60};
-        boolean[] isEphemeral = {false};
-        boolean[] hasEverConnected = {true};
-        List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(ssids,
-                bssids, frequencies, caps, levels, isEphemeral, hasEverConnected);
-        mLastResortWatchdog.updateAvailableNetworks(candidates);
-
-        // Ensure new networks have zero'ed failure counts
-        for (int i = 0; i < ssids.length; i++) {
-            assertFailureCountEquals(bssids[i], 0, 0, 0);
-        }
-
-        //Increment failure counts
-        for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) {
-            mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
-                    ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION);
-        }
-
-        // Verify relevant WifiMetrics calls were made once with appropriate arguments
-        verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggers();
-
-        // Simulate wifi connecting after triggering on a unexpected SSID
-        mLastResortWatchdog.connectedStateTransition(true, "blahssss");
-        // Verify takeBugReport is not called
-        mLooper.dispatchAll();
-        verify(mWifiStateMachine, times(0)).takeBugReport(anyString(), anyString());
-
-        // Simulate wifi connecting after triggering is the expected SSID, which should be ignored
-        // because watchdog state should already be reset to detect for failures
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
-        // Verify takeBugReport is not called
-        mLooper.dispatchAll();
-        verify(mWifiStateMachine, times(0)).takeBugReport(anyString(), anyString());
-    }
-
-    /**
-     * Case 30: Test connection success after wifi restart with a previously failing SSID
-     * Setup 1 network. Fail the network until watchcdog triggers. Trigger a connection success on
-     * a network which has the same SSID than the network that has been failing.
-     * Expected behavior: bugreport is triggered
-     */
-    @Test
-    public void testConnectionSuccessWithPreviouslyFailingSsidTriggersBugreport() {
-        String[] ssids = {"\"test1\""};
-        String[] bssids = {"6c:f3:7f:ae:8c:f3"};
-        int[] frequencies = {2437};
-        String[] caps = {"[WPA2-EAP-CCMP][ESS]"};
-        int[] levels = {-60};
-        boolean[] isEphemeral = {false};
-        boolean[] hasEverConnected = {true};
-        List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(ssids,
-                bssids, frequencies, caps, levels, isEphemeral, hasEverConnected);
-        mLastResortWatchdog.updateAvailableNetworks(candidates);
-
-        // Ensure new networks have zero'ed failure counts
-        for (int i = 0; i < ssids.length; i++) {
-            assertFailureCountEquals(bssids[i], 0, 0, 0);
-        }
-
-        //Increment failure counts
-        for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) {
-            mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
-                    ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION);
-        }
-
-        // Verify relevant WifiMetrics calls were made once with appropriate arguments
-        verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggers();
-
-        // Simulate wifi connecting after triggering
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
-        // Verify takeBugReport is called
-        mLooper.dispatchAll();
-        verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString());
-
-        // Simulate wifi connecting after triggering
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
-        // Verify takeBugReport is not called again
-        mLooper.dispatchAll();
-        verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString());
-    }
-
-
-    /**
      * Test metrics incrementing connection failure count after watchdog has already been triggered
      */
     @Test
@@ -1902,14 +1808,14 @@
                 ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION);
 
         // Simulate wifi connecting after triggering
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
+        mLastResortWatchdog.connectedStateTransition(true);
         // Verify takeBugReport is not called again
         mLooper.dispatchAll();
         verify(mWifiStateMachine, never()).takeBugReport(anyString(), anyString());
         verify(mWifiMetrics, never()).incrementNumLastResortWatchdogSuccesses();
 
         // Simulate wifi disconnecting
-        mLastResortWatchdog.connectedStateTransition(false, "\"test1\"");
+        mLastResortWatchdog.connectedStateTransition(false);
 
         // Test another round, and this time successfully connect after restart trigger
         for (int i = 0; i < ssids.length; i++) {
@@ -1923,7 +1829,7 @@
         // Verify watchdog has triggered a restart
         verify(mWifiMetrics, times(2)).incrementNumLastResortWatchdogTriggers();
         // Simulate wifi connecting after triggering
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
+        mLastResortWatchdog.connectedStateTransition(true);
         // Verify takeBugReport is not called again
         mLooper.dispatchAll();
         verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString());
@@ -1970,7 +1876,7 @@
         when(candidates.get(0).second.getNetworkSelectionStatus().getHasEverConnected())
                 .thenReturn(false);
 
-        mLastResortWatchdog.connectedStateTransition(true, "\"test1\"");
+        mLastResortWatchdog.connectedStateTransition(true);
         // Verify takeBugReport is not called again
         mLooper.dispatchAll();
         verify(mWifiStateMachine, never()).takeBugReport(anyString(), anyString());