diff options
7 files changed, 69 insertions, 156 deletions
diff --git a/service/java/com/android/server/wifi/BaseWifiDiagnostics.java b/service/java/com/android/server/wifi/BaseWifiDiagnostics.java index b9f138539..2090cac1e 100644 --- a/service/java/com/android/server/wifi/BaseWifiDiagnostics.java +++ b/service/java/com/android/server/wifi/BaseWifiDiagnostics.java @@ -37,10 +37,9 @@ public class BaseWifiDiagnostics { /** * Inform the diagnostics module of a connection event. - * @param connectionId A strictly increasing, non-negative, connection identifier * @param event The type of connection event (see CONNECTION_EVENT_* constants) */ - public synchronized void reportConnectionEvent(long connectionId, byte event) {} + public synchronized void reportConnectionEvent(byte event) {} public synchronized void captureBugReportData(int reason) { } diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index f316b504d..3c5f75ca9 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -2903,22 +2903,18 @@ public class ClientModeImpl extends StateMachine { @VisibleForTesting public static final long DIAGS_CONNECT_TIMEOUT_MILLIS = 60 * 1000; - private long mDiagsConnectionStartMillis = -1; /** * Inform other components that a new connection attempt is starting. */ private void reportConnectionAttemptStart( WifiConfiguration config, String targetBSSID, int roamType) { mWifiMetrics.startConnectionEvent(config, targetBSSID, roamType); - mDiagsConnectionStartMillis = mClock.getElapsedSinceBootMillis(); - mWifiDiagnostics.reportConnectionEvent( - mDiagsConnectionStartMillis, WifiDiagnostics.CONNECTION_EVENT_STARTED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_STARTED); mWrongPasswordNotifier.onNewConnectionAttempt(); // TODO(b/35329124): Remove CMD_DIAGS_CONNECT_TIMEOUT, once ClientModeImpl // grows a proper CONNECTING state. removeMessages(CMD_DIAGS_CONNECT_TIMEOUT); - sendMessageDelayed(CMD_DIAGS_CONNECT_TIMEOUT, - mDiagsConnectionStartMillis, DIAGS_CONNECT_TIMEOUT_MILLIS); + sendMessageDelayed(CMD_DIAGS_CONNECT_TIMEOUT, DIAGS_CONNECT_TIMEOUT_MILLIS); } /** @@ -2940,8 +2936,7 @@ public class ClientModeImpl extends StateMachine { // // TODO(b/34181219): Fix the above. removeMessages(CMD_DIAGS_CONNECT_TIMEOUT); - mWifiDiagnostics.reportConnectionEvent( - mDiagsConnectionStartMillis, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); break; case WifiMetrics.ConnectionEvent.FAILURE_REDUNDANT_CONNECTION_ATTEMPT: case WifiMetrics.ConnectionEvent.FAILURE_CONNECT_NETWORK_FAILED: @@ -2950,10 +2945,8 @@ public class ClientModeImpl extends StateMachine { break; default: removeMessages(CMD_DIAGS_CONNECT_TIMEOUT); - mWifiDiagnostics.reportConnectionEvent( - mDiagsConnectionStartMillis, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); } - mDiagsConnectionStartMillis = -1; } private void handleIPv4Success(DhcpResults dhcpResults) { @@ -3593,7 +3586,7 @@ public class ClientModeImpl extends StateMachine { break; case CMD_DIAGS_CONNECT_TIMEOUT: mWifiDiagnostics.reportConnectionEvent( - (Long) message.obj, BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT); + BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT); break; case CMD_GET_ALL_MATCHING_CONFIGS: replyToMessage(message, message.what, new ArrayList<WifiConfiguration>()); diff --git a/service/java/com/android/server/wifi/LastMileLogger.java b/service/java/com/android/server/wifi/LastMileLogger.java index 12277f412..1269638b3 100644 --- a/service/java/com/android/server/wifi/LastMileLogger.java +++ b/service/java/com/android/server/wifi/LastMileLogger.java @@ -45,31 +45,21 @@ public class LastMileLogger { /** * Informs LastMileLogger that a connection event has occurred. - * @param connectionId A non-negative connection identifier, or -1 to indicate unknown * @param event an event defined in BaseWifiDiagnostics */ - public void reportConnectionEvent(long connectionId, byte event) { - if (connectionId < 0) { - mLog.warn("Ignoring negative connection id: %").c(connectionId).flush(); - return; - } - + public void reportConnectionEvent(byte event) { switch (event) { case BaseWifiDiagnostics.CONNECTION_EVENT_STARTED: - mPendingConnectionId = connectionId; enableTracing(); return; case BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED: - mPendingConnectionId = -1; disableTracing(); return; case BaseWifiDiagnostics.CONNECTION_EVENT_FAILED: - mPendingConnectionId = -1; disableTracing(); mLastMileLogForLastFailure = readTrace(); return; case BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT: - mPendingConnectionId = -1; disableTracing(); mLastMileLogForLastFailure = readTrace(); return; @@ -99,7 +89,6 @@ public class LastMileLogger { private WifiLog mLog; private byte[] mLastMileLogForLastFailure; private FileInputStream mLastMileTraceHandle; - private long mPendingConnectionId = -1; private void enableTracing() { if (!ensureFailSafeIsArmed()) { diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java index 224c7140e..37b02ed79 100644 --- a/service/java/com/android/server/wifi/WifiDiagnostics.java +++ b/service/java/com/android/server/wifi/WifiDiagnostics.java @@ -203,8 +203,8 @@ class WifiDiagnostics extends BaseWifiDiagnostics { } @Override - public synchronized void reportConnectionEvent(long connectionId, byte event) { - mLastMileLogger.reportConnectionEvent(connectionId, event); + public synchronized void reportConnectionEvent(byte event) { + mLastMileLogger.reportConnectionEvent(event); if (event == CONNECTION_EVENT_FAILED || event == CONNECTION_EVENT_TIMEOUT) { mPacketFatesForLastFailure = fetchPacketFates(); } diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 4b04694d6..bd4aea95b 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -2327,10 +2327,10 @@ public class ClientModeImplTest { // Setup CONNECT_MODE & a WifiConfiguration initializeAndAddNetworkAndVerifySuccess(); mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); - verify(mWifiDiagnostics, never()).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics, never()).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_STARTED)); mLooper.dispatchAll(); - verify(mWifiDiagnostics).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_STARTED)); } @@ -2347,7 +2347,7 @@ public class ClientModeImplTest { mLooper.dispatchAll(); mLooper.moveTimeForward(ClientModeImpl.DIAGS_CONNECT_TIMEOUT_MILLIS); mLooper.dispatchAll(); - verify(mWifiDiagnostics).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics).reportConnectionEvent( eq(BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT)); } @@ -2363,14 +2363,14 @@ public class ClientModeImplTest { mLooper.dispatchAll(); mLooper.moveTimeForward(ClientModeImpl.DIAGS_CONNECT_TIMEOUT_MILLIS - 1000); mLooper.dispatchAll(); - verify(mWifiDiagnostics, never()).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics, never()).reportConnectionEvent( eq(BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT)); } private void verifyConnectionEventTimeoutDoesNotOccur() { mLooper.moveTimeForward(ClientModeImpl.DIAGS_CONNECT_TIMEOUT_MILLIS); mLooper.dispatchAll(); - verify(mWifiDiagnostics, never()).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics, never()).reportConnectionEvent( eq(BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT)); } @@ -2386,10 +2386,10 @@ public class ClientModeImplTest { mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); mCmi.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT, 0, ISupplicantStaIfaceCallback.StatusCode.AP_UNABLE_TO_HANDLE_NEW_STA, sBSSID); - verify(mWifiDiagnostics, never()).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics, never()).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_FAILED)); mLooper.dispatchAll(); - verify(mWifiDiagnostics).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_FAILED)); verifyConnectionEventTimeoutDoesNotOccur(); } @@ -2406,10 +2406,10 @@ public class ClientModeImplTest { mCmi.sendMessage(ClientModeImpl.CMD_START_CONNECT, 0, 0, sBSSID); mCmi.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT, WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD); - verify(mWifiDiagnostics, never()).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics, never()).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_FAILED)); mLooper.dispatchAll(); - verify(mWifiDiagnostics).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_FAILED)); verifyConnectionEventTimeoutDoesNotOccur(); @@ -2423,7 +2423,7 @@ public class ClientModeImplTest { @Test public void testReportConnectionEventIsCalledAfterDhcpFailure() throws Exception { testDhcpFailure(); - verify(mWifiDiagnostics, atLeastOnce()).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics, atLeastOnce()).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_FAILED)); verifyConnectionEventTimeoutDoesNotOccur(); } @@ -2436,7 +2436,7 @@ public class ClientModeImplTest { @Test public void testReportConnectionEventIsCalledAfterSuccessfulConnection() throws Exception { connect(); - verify(mWifiDiagnostics).reportConnectionEvent(anyLong(), + verify(mWifiDiagnostics).reportConnectionEvent( eq(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED)); verifyConnectionEventTimeoutDoesNotOccur(); } diff --git a/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java index f27d055b4..75c83e439 100644 --- a/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java @@ -46,7 +46,6 @@ import java.io.StringWriter; public class LastMileLoggerTest { @Mock WifiInjector mWifiInjector; @Spy FakeWifiLog mLog; - private static final long FAKE_CONNECTION_ID = 1; @Before public void setUp() throws Exception { @@ -72,16 +71,14 @@ public class LastMileLoggerTest { @Test public void connectionEventStartedEnablesTracing() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); assertEquals("1", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } @Test public void connectionEventStartedDoesNotCrashIfReleaseFileIsMissing() throws Exception { mTraceReleaseFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); verify(mLog).warn(contains("Failed to open free_buffer")); } @@ -89,15 +86,13 @@ public class LastMileLoggerTest { public void connectionEventStartedDoesNotEnableTracingIfReleaseFileIsMissing() throws Exception { mTraceReleaseFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); assertEquals("0", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } @Test public void connectionEventStartedDoesNotAttemptToReopenReleaseFile() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); // This is a rather round-about way of verifying that we don't attempt to re-open // the file. Namely: if we delete the |release| file, and CONNECTION_EVENT_STARTED @@ -108,123 +103,86 @@ public class LastMileLoggerTest { // A more direct test would require the use of a factory for the creation of the // FileInputStream. mTraceReleaseFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); verifyZeroInteractions(mLog); } @Test - public void connectionEventStartedDoesNotEnableTracingForInvalidConnectionId() - throws Exception { - mLastMileLogger.reportConnectionEvent( - -1, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); - assertEquals("0", IoUtils.readFileAsString(mTraceEnableFile.getPath())); - } - - @Test public void connectionEventStartedDoesNotCrashIfEnableFileIsMissing() throws Exception { mTraceEnableFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); } @Test public void connectionEventStartedDoesNotCrashOnRepeatedCalls() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); } @Test public void connectionEventSucceededDisablesTracing() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); assertEquals("0", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } @Test public void connectionEventSucceededDoesNotCrashIfEnableFileIsMissing() throws Exception { mTraceEnableFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); } @Test public void connectionEventSucceededDoesNotCrashOnRepeatedCalls() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); } @Test public void connectionEventFailedDisablesTracingWhenPendingFails() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); assertEquals("0", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } @Test - public void connectionEventTimeoutDisablesTracingOnFailureOfFutureConnection() + public void connectionEventTimeoutDisablesTracing() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID + 1, BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT); assertEquals("0", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } @Test public void connectionEventFailedDoesNotCrashIfEnableFileIsMissing() throws Exception { mTraceEnableFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); } @Test public void connectionEventFailedDoesNotCrashIfDataFileIsMissing() throws Exception { mTraceDataFile.delete(); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); } @Test public void connectionEventFailedDoesNotCrashOnRepeatedCalls() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); } @Test public void dumpShowsFailureTrace() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect"); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); assertTrue(getDumpString().contains("--- Last failed")); assertTrue(getDumpString().contains("rdev_connect")); } - @Test - public void dumpShowsFailureTraceEvenIfConnectionIdIncreases() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); - FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect"); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID + 1, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); - assertTrue(getDumpString().contains("--- Last failed")); - assertTrue(getDumpString().contains("rdev_connect")); - } @Test public void dumpShowsPendingConnectionTrace() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect"); assertTrue(getDumpString().contains("No last mile log for \"Last failed")); assertTrue(getDumpString().contains("--- Latest")); @@ -233,13 +191,10 @@ public class LastMileLoggerTest { @Test public void dumpShowsLastFailureTraceAndPendingConnectionTrace() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #1"); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #2"); String dumpString = getDumpString(); @@ -249,16 +204,12 @@ public class LastMileLoggerTest { @Test public void dumpShowsLastFailureTraceAndCurrentConnectionTrace() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #1"); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect try #2"); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); String dumpString = getDumpString(); assertTrue(dumpString.contains("rdev_connect try #1")); @@ -267,11 +218,9 @@ public class LastMileLoggerTest { @Test public void dumpDoesNotClearLastFailureData() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect"); - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); getDumpString(); String dumpString = getDumpString(); @@ -280,8 +229,7 @@ public class LastMileLoggerTest { @Test public void dumpDoesNotClearPendingConnectionTrace() throws Exception { - mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); + mLastMileLogger.reportConnectionEvent(BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); FileUtils.stringToFile(mTraceDataFile.getPath(), "rdev_connect"); getDumpString(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index 1635ea086..ed1b59675 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -75,7 +75,6 @@ public class WifiDiagnosticsTest { private static final int SMALL_RING_BUFFER_SIZE_KB = 32; private static final int LARGE_RING_BUFFER_SIZE_KB = 1024; private static final int BYTES_PER_KBYTE = 1024; - private static final long FAKE_CONNECTION_ID = 1; private static final int ALERT_REASON_CODE = 1; private static final byte[] ALERT_DATA = {0 , 4, 5}; @@ -314,8 +313,7 @@ public class WifiDiagnosticsTest { public void reportConnectionFailureIsIgnoredWithoutVerboseMode() { final boolean verbosityToggle = false; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); verify(mWifiNative).getTxPktFates(any(), anyObject()); verify(mWifiNative).getRxPktFates(any(), anyObject()); } @@ -327,8 +325,7 @@ public class WifiDiagnosticsTest { public void reportConnectionFailureFetchesFatesInVerboseMode() { final boolean verbosityToggle = true; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); verify(mWifiNative).getTxPktFates(any(), anyObject()); verify(mWifiNative).getRxPktFates(any(), anyObject()); } @@ -337,30 +334,24 @@ public class WifiDiagnosticsTest { public void reportConnectionEventPropagatesStartToLastMileLogger() { final boolean verbosityToggle = false; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_STARTED); - verify(mLastMileLogger).reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_STARTED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_STARTED); + verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_STARTED); } @Test public void reportConnectionEventPropagatesSuccessToLastMileLogger() { final boolean verbosityToggle = false; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); - verify(mLastMileLogger).reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); + verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED); } @Test public void reportConnectionEventPropagatesFailureToLastMileLogger() { final boolean verbosityToggle = false; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); - verify(mLastMileLogger).reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); + verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); } /** @@ -370,10 +361,8 @@ public class WifiDiagnosticsTest { public void reportConnectionEventPropagatesTimeoutToLastMileLogger() { final boolean verbosityToggle = true; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_TIMEOUT); - verify(mLastMileLogger).reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_TIMEOUT); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_TIMEOUT); + verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_TIMEOUT); } /** @@ -384,8 +373,7 @@ public class WifiDiagnosticsTest { final boolean verbosityToggle = true; when(mWifiNative.getRxPktFates(any(), anyObject())).thenReturn(false); mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); verify(mWifiNative).getTxPktFates(any(), anyObject()); verify(mWifiNative).getRxPktFates(any(), anyObject()); } @@ -398,8 +386,7 @@ public class WifiDiagnosticsTest { final boolean verbosityToggle = true; when(mWifiNative.getTxPktFates(any(), anyObject())).thenReturn(false); mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); verify(mWifiNative).getTxPktFates(any(), anyObject()); verify(mWifiNative).getRxPktFates(any(), anyObject()); } @@ -441,8 +428,7 @@ public class WifiDiagnosticsTest { public void dumpSucceedsWhenFatesHaveBeenFetchedButAreEmpty() { final boolean verbosityToggle = true; mWifiDiagnostics.startLogging(verbosityToggle); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); verify(mWifiNative).getTxPktFates(any(), anyObject()); verify(mWifiNative).getRxPktFates(any(), anyObject()); @@ -486,8 +472,7 @@ public class WifiDiagnosticsTest { return true; } }); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); @@ -612,8 +597,7 @@ public class WifiDiagnosticsTest { return true; } }); - mWifiDiagnostics.reportConnectionEvent( - FAKE_CONNECTION_ID, WifiDiagnostics.CONNECTION_EVENT_FAILED); + mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED); verify(mWifiNative).getTxPktFates(any(), anyObject()); verify(mWifiNative).getRxPktFates(any(), anyObject()); |