summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-11-12 12:36:48 -0800
committerRoshan Pius <rpius@google.com>2019-11-13 06:08:08 -0800
commit77f8ce94b89bae2a15ee1e7aab6d8c4fac19fcbd (patch)
tree580c3c9bb5fb9cf0f89ad7a17cef2f2255db5825 /tests
parent90503be8f907d90977cce9e3baf3b0de0436e71d (diff)
WifiDiagnostics: Use shell command to trigger bugreport
a) Move bugreport collection by WifiDiagnostics behind an OEM specific overlay. b) Use the shell intent to trigger the bugreport instead of using the @hide API in ActivityManagerService. Note: This is not using a formal API, discussions ongoing on whether we can use a formal API instead in the linked bug. This unblocks to get feedback on wifi issues from early dogfooders in R. Bug: 143494985 Test: atest com.android.server.wifi.WifiDiagnosticsTest Test: Verified bugreport taking using the new mechanism. Change-Id: I4e44d61d33e456fd0252dba7e382e0feb87de544
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java43
1 files changed, 29 insertions, 14 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index 711930912..b85e540c5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -36,6 +36,8 @@ import static org.mockito.Mockito.when;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
import android.content.Context;
+import android.content.Intent;
+import android.os.UserHandle;
import androidx.test.filters.SmallTest;
@@ -71,6 +73,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
@Mock ActivityManagerService mActivityManagerService;
@Mock WifiMetrics mWifiMetrics;
@Mock Clock mClock;
+ MockResources mResources;
WifiDiagnostics mWifiDiagnostics;
private static final String FAKE_RING_BUFFER_NAME = "fake-ring-buffer";
@@ -118,14 +121,15 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
when(mExternalProcess.getErrorStream()).thenReturn(new ByteArrayInputStream(new byte[0]));
when(mJavaRuntime.exec(anyString())).thenReturn(mExternalProcess);
- MockResources resources = new MockResources();
- resources.setInteger(R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb,
+ mResources = new MockResources();
+ mResources.setInteger(R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb,
SMALL_RING_BUFFER_SIZE_KB);
- resources.setInteger(R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb,
+ mResources.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,
+ mResources.setIntArray(R.array.config_wifi_fatal_firmware_alert_error_code_list,
FATAL_FW_ALERT_LIST);
- when(mContext.getResources()).thenReturn(resources);
+ mResources.setBoolean(R.bool.config_wifi_diagnostics_bugreport_enabled, true);
+ when(mContext.getResources()).thenReturn(mResources);
when(mWifiInjector.makeLog(anyString())).thenReturn(mLog);
when(mWifiInjector.getJavaRuntime()).thenReturn(mJavaRuntime);
when(mWifiInjector.getActivityManagerService()).thenReturn(mActivityManagerService);
@@ -857,30 +861,41 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
}
@Test
- @Ignore("TODO(b/143494985): re-enabled this @Test")
public void takeBugReportCallsActivityManagerOnUserDebug() {
when(mBuildProperties.isUserBuild()).thenReturn(false);
mWifiDiagnostics.takeBugReport("", "");
- verify(mActivityManagerService, times(1)).requestWifiBugReport(
- anyString(), anyString());
+ verify(mContext, times(1)).sendBroadcastAsUser(
+ any(Intent.class), any(UserHandle.class));
}
@Test
- @Ignore("TODO(b/143494985): re-enabled this @Test")
public void takeBugReportSwallowsExceptions() {
when(mBuildProperties.isUserBuild()).thenReturn(false);
- doThrow(new RuntimeException()).when(mActivityManagerService).requestWifiBugReport(
- anyString(), anyString());
+ doThrow(new RuntimeException()).when(mContext).sendBroadcastAsUser(
+ any(Intent.class), any(UserHandle.class));
mWifiDiagnostics.takeBugReport("", "");
- verify(mActivityManagerService, times(1)).requestWifiBugReport(
- anyString(), anyString());
+ verify(mContext, times(1)).sendBroadcastAsUser(
+ any(Intent.class), any(UserHandle.class));
}
@Test
public void takeBugReportDoesNothingOnUserBuild() {
when(mBuildProperties.isUserBuild()).thenReturn(true);
mWifiDiagnostics.takeBugReport("", "");
- verify(mActivityManagerService, never()).requestWifiBugReport(anyString(), anyString());
+ verify(mContext, never()).sendBroadcastAsUser(
+ any(Intent.class), any(UserHandle.class));
+ }
+
+ @Test
+ public void takeBugReportDoesNothingWhenConfigOverlayDisabled() {
+ when(mBuildProperties.isUserBuild()).thenReturn(false);
+ mResources.setBoolean(R.bool.config_wifi_diagnostics_bugreport_enabled, false);
+ mWifiDiagnostics = new WifiDiagnostics(
+ mContext, mWifiInjector, mWifiNative, mBuildProperties, mLastMileLogger, mClock);
+
+ mWifiDiagnostics.takeBugReport("", "");
+ verify(mContext, never()).sendBroadcastAsUser(
+ any(Intent.class), any(UserHandle.class));
}
/** Verifies that we flush HAL ringbuffer when capture bugreport. */