summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-04-22 11:12:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-22 11:12:02 +0000
commit15c46a1e03c203ee6bf2886d6058dec9d9895440 (patch)
tree07306f2dc573ced848095fb4f99bb21008a873b1
parentedea5f52d7ceb19117d8c5ff2a28d1b0657fdae3 (diff)
parente1ebbceea0832f2b6e4e30e84ec4ea1ff84762e4 (diff)
Merge "WifiDiagnostics: Collect logs when detecting fatal firmware alert" into qt-dev
-rw-r--r--service/java/com/android/server/wifi/WifiDiagnostics.java13
-rw-r--r--service/java/com/android/server/wifi/WifiLoggerHal.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/MockResources.java15
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java26
4 files changed, 57 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java
index b288ccb24..52a787adb 100644
--- a/service/java/com/android/server/wifi/WifiDiagnostics.java
+++ b/service/java/com/android/server/wifi/WifiDiagnostics.java
@@ -34,10 +34,13 @@ import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
import java.util.zip.Deflater;
/**
@@ -81,6 +84,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
public static final int REPORT_REASON_USER_ACTION = 7;
public static final int REPORT_REASON_WIFINATIVE_FAILURE = 8;
public static final int REPORT_REASON_REACHABILITY_LOST = 9;
+ public static final int REPORT_REASON_FATAL_FW_ALERT = 10;
/** number of bug reports to hold */
public static final int MAX_BUG_REPORTS = 4;
@@ -116,6 +120,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
private final Runtime mJavaRuntime;
private final WifiMetrics mWifiMetrics;
private int mMaxRingBufferSizeBytes;
+ private final List<Integer> mFatalFirmwareAlertErrorCodeList;
private WifiInjector mWifiInjector;
private Clock mClock;
@@ -127,10 +132,14 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb) * 1024;
RING_BUFFER_BYTE_LIMIT_LARGE = context.getResources().getInteger(
R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb) * 1024;
+ int[] fatalFirmwareAlertErrorCodeArray = context.getResources().getIntArray(
+ R.array.config_wifi_fatal_firmware_alert_error_code_list);
mBuildProperties = buildProperties;
mIsLoggingEventHandlerRegistered = false;
mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_SMALL;
+ mFatalFirmwareAlertErrorCodeList = Arrays.stream(fatalFirmwareAlertErrorCodeArray)
+ .boxed().collect(Collectors.toList());
mLog = wifiInjector.makeLog(TAG);
mLastMileLogger = lastMileLogger;
mJavaRuntime = wifiInjector.getJavaRuntime();
@@ -232,6 +241,10 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
BugReport report = captureBugreport(errorCode, isVerboseLoggingEnabled());
report.alertData = alertData;
mLastAlerts.addLast(report);
+ /* Flush HAL ring buffer when detecting data stall */
+ if (mFatalFirmwareAlertErrorCodeList.contains(errorCode)) {
+ flushDump(REPORT_REASON_FATAL_FW_ALERT);
+ }
}
@Override
diff --git a/service/java/com/android/server/wifi/WifiLoggerHal.java b/service/java/com/android/server/wifi/WifiLoggerHal.java
index 0294e9bf7..5e2635f13 100644
--- a/service/java/com/android/server/wifi/WifiLoggerHal.java
+++ b/service/java/com/android/server/wifi/WifiLoggerHal.java
@@ -48,7 +48,7 @@ public class WifiLoggerHal {
public static final byte RX_PKT_FATE_DRV_DROP_OTHER = 10;
/** These aren't formally part of the HAL. But they probably should be, eventually. */
- public static final byte WIFI_ALERT_REASON_RESERVED = 0;
- public static final byte WIFI_ALERT_REASON_MIN = 0;
- public static final byte WIFI_ALERT_REASON_MAX = 64;
+ public static final int WIFI_ALERT_REASON_RESERVED = 0;
+ public static final int WIFI_ALERT_REASON_MIN = 0;
+ public static final int WIFI_ALERT_REASON_MAX = 1024;
}
diff --git a/tests/wifitests/src/com/android/server/wifi/MockResources.java b/tests/wifitests/src/com/android/server/wifi/MockResources.java
index 1a061e22a..dd4413228 100644
--- a/tests/wifitests/src/com/android/server/wifi/MockResources.java
+++ b/tests/wifitests/src/com/android/server/wifi/MockResources.java
@@ -24,12 +24,14 @@ public class MockResources extends android.test.mock.MockResources {
private HashMap<Integer, Integer> mIntegerValues;
private HashMap<Integer, String> mStringValues;
private HashMap<Integer, CharSequence> mTextValues;
+ private HashMap<Integer, int[]> mIntArrayValues;
public MockResources() {
mBooleanValues = new HashMap<Integer, Boolean>();
mIntegerValues = new HashMap<Integer, Integer>();
mStringValues = new HashMap<Integer, String>();
mTextValues = new HashMap<Integer, CharSequence>();
+ mIntArrayValues = new HashMap<Integer, int[]>();
}
@Override
@@ -68,6 +70,15 @@ public class MockResources extends android.test.mock.MockResources {
}
}
+ @Override
+ public int[] getIntArray(int id) {
+ if (mIntArrayValues.containsKey(id)) {
+ return mIntArrayValues.get(id);
+ } else {
+ return null;
+ }
+ }
+
public void setBoolean(int id, boolean value) {
mBooleanValues.put(id, value);
}
@@ -83,4 +94,8 @@ public class MockResources extends android.test.mock.MockResources {
public void setText(int id, CharSequence value) {
mTextValues.put(id, value);
}
+
+ public void setIntArray(int id, int[] value) {
+ mIntArrayValues.put(id, value);
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index 1c33d3920..6b63137a2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -79,6 +79,10 @@ public class WifiDiagnosticsTest {
private static final int BYTES_PER_KBYTE = 1024;
private static final int ALERT_REASON_CODE = 1;
private static final byte[] ALERT_DATA = {0 , 4, 5};
+ /** Mock resource for fatal firmware alert list */
+ private static final int[] FATAL_FW_ALART_LIST = {256, 257, 258};
+ /** Mock a non fatal firmware alert */
+ private static final int NON_FATAL_FW_ALART = 0;
private WifiNative.RingBufferStatus mFakeRbs;
/**
@@ -117,6 +121,8 @@ public class WifiDiagnosticsTest {
SMALL_RING_BUFFER_SIZE_KB);
resources.setInteger(R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb,
LARGE_RING_BUFFER_SIZE_KB);
+ resources.setIntArray(R.array.config_wifi_fatal_firmware_alert_error_code_list,
+ FATAL_FW_ALART_LIST);
when(mContext.getResources()).thenReturn(resources);
when(mWifiInjector.makeLog(anyString())).thenReturn(mLog);
when(mWifiInjector.getJavaRuntime()).thenReturn(mJavaRuntime);
@@ -864,4 +870,24 @@ public class WifiDiagnosticsTest {
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).flushRingBufferData();
}
+
+ /** Verifies that we flush HAL ringbuffer when detecting fatal firmware alert. */
+ @Test
+ public void captureAlertFlushRingBufferData() {
+ when(mBuildProperties.isUserBuild()).thenReturn(false);
+ when(mWifiNative.flushRingBufferData()).thenReturn(true);
+ /** captureAlertData with mock fatal firmware alert*/
+ mWifiDiagnostics.captureAlertData(FATAL_FW_ALART_LIST[0], ALERT_DATA);
+ verify(mWifiNative).flushRingBufferData();
+ }
+
+ /** Verifies that we don't flush HAL ringbuffer when detecting non fatal firmware alert. */
+ @Test
+ public void captureNonAlertFlushRingBufferData() {
+ when(mBuildProperties.isUserBuild()).thenReturn(false);
+ when(mWifiNative.flushRingBufferData()).thenReturn(true);
+ /** captureAlertData with mock non fatal firmware alert*/
+ mWifiDiagnostics.captureAlertData(NON_FATAL_FW_ALART, ALERT_DATA);
+ verify(mWifiNative, never()).flushRingBufferData();
+ }
}