diff options
5 files changed, 27 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/BaseWifiDiagnostics.java b/service/java/com/android/server/wifi/BaseWifiDiagnostics.java index 3b4c72bf7..85fdb6b0d 100644 --- a/service/java/com/android/server/wifi/BaseWifiDiagnostics.java +++ b/service/java/com/android/server/wifi/BaseWifiDiagnostics.java @@ -11,6 +11,7 @@ public class BaseWifiDiagnostics { public static final byte CONNECTION_EVENT_STARTED = 0; public static final byte CONNECTION_EVENT_SUCCEEDED = 1; public static final byte CONNECTION_EVENT_FAILED = 2; + public static final byte CONNECTION_EVENT_TIMEOUT = 3; protected final WifiNative mWifiNative; diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 23e3f4755..3742079f2 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -3588,7 +3588,7 @@ public class ClientModeImpl extends StateMachine { break; case CMD_DIAGS_CONNECT_TIMEOUT: mWifiDiagnostics.reportConnectionEvent( - (Long) message.obj, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + (Long) message.obj, 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 670923a70..35ce73677 100644 --- a/service/java/com/android/server/wifi/LastMileLogger.java +++ b/service/java/com/android/server/wifi/LastMileLogger.java @@ -64,10 +64,14 @@ public class LastMileLogger { disableTracing(); return; case BaseWifiDiagnostics.CONNECTION_EVENT_FAILED: + mPendingConnectionId = -1; + disableTracing(); + mLastMileLogForLastFailure = readTrace(); + return; + case BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT: if (connectionId >= mPendingConnectionId) { mPendingConnectionId = -1; disableTracing(); - mLastMileLogForLastFailure = readTrace(); return; } else { // Spurious failure message. Here's one scenario where this might happen: @@ -88,7 +92,6 @@ public class LastMileLogger { public void dump(PrintWriter pw) { dumpInternal(pw, "Last failed last-mile log", mLastMileLogForLastFailure); dumpInternal(pw, "Latest last-mile log", readTrace()); - mLastMileLogForLastFailure = null; } private static final String TAG = "LastMileLogger"; diff --git a/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java index bb26d01f1..769d67e34 100644 --- a/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/LastMileLoggerTest.java @@ -168,24 +168,24 @@ public class LastMileLoggerTest { } @Test - public void connectionEventFailedDoesNotDisableTracingOnFailureOfStaleConnection() + public void connectionEventTimeoutDoesNotDisableTracingOnFailureOfStaleConnection() throws Exception { mLastMileLogger.reportConnectionEvent( FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); mLastMileLogger.reportConnectionEvent( FAKE_CONNECTION_ID + 1, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT); assertEquals("1", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } @Test - public void connectionEventFailedDisablesTracingOnFailureOfFutureConnection() + public void connectionEventTimeoutDisablesTracingOnFailureOfFutureConnection() throws Exception { mLastMileLogger.reportConnectionEvent( FAKE_CONNECTION_ID, BaseWifiDiagnostics.CONNECTION_EVENT_STARTED); mLastMileLogger.reportConnectionEvent( - FAKE_CONNECTION_ID + 1, BaseWifiDiagnostics.CONNECTION_EVENT_FAILED); + FAKE_CONNECTION_ID + 1, BaseWifiDiagnostics.CONNECTION_EVENT_TIMEOUT); assertEquals("0", IoUtils.readFileAsString(mTraceEnableFile.getPath())); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index 52cf65e93..7d0f2f196 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -391,6 +391,22 @@ public class WifiDiagnosticsTest { verify(mWifiNative).getRxPktFates(any(), anyObject()); } + /** + * Verifies that we are not fetching packet fates for a CONNECTION_EVENT_TIMEOUT event + * and propagating it to LastMileLogger instead. + */ + @Test + public void loggerSimplyPropagateEventTimeoutToLastMileLogger() { + 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); + verify(mWifiNative, never()).getTxPktFates(any(), anyObject()); + verify(mWifiNative, never()).getRxPktFates(any(), anyObject()); + } + /** Verifies that dump() fetches the latest fates. */ @Test public void dumpFetchesFates() { |