diff options
author | David Su <dysu@google.com> | 2019-03-07 17:33:02 -0800 |
---|---|---|
committer | David Su <dysu@google.com> | 2019-03-15 15:27:34 -0700 |
commit | f76cf1112e78a03ec60b999a5d7d931588c89c48 (patch) | |
tree | 3e5a78eb6b9196699bfbf6dff2a4382431d9f9db /tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | |
parent | dca46d9f86d7a78ca84903137e73e5f9f9ba6929 (diff) | |
download | android_frameworks_opt_net_wifi-f76cf1112e78a03ec60b999a5d7d931588c89c48.tar.gz android_frameworks_opt_net_wifi-f76cf1112e78a03ec60b999a5d7d931588c89c48.tar.bz2 android_frameworks_opt_net_wifi-f76cf1112e78a03ec60b999a5d7d931588c89c48.zip |
Dump RSSI and Link Layer Stats in Bug Report when screen off
Always poll RSSI and link layer stats during a bug report, even when the screen
is off. The RSSI and link layer stats will be shown in the "WifiScoreReport"
section of the bug report.
Bug: 119727583
Test: ran `adb bugreport` when screen is on, verify that it does not crash
Test: ran `adb bugreport` when screen is off, verify link layer stats show in BR
Test: ran `adb bugreport` when the device is disconnected from Wifi, verify that
it does not crash
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I9aa47225f109751fbae68fd28c68b358fe67fef6
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 48efb51a6..a69679482 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -115,6 +115,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatcher; +import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.Spy; @@ -233,6 +234,7 @@ public class WifiServiceImplTest { @Mock TelephonyManager mTelephonyManager; @Mock IOnWifiUsabilityStatsListener mOnWifiUsabilityStatsListener; @Mock WifiConfigManager mWifiConfigManager; + @Mock WifiScoreReport mWifiScoreReport; @Spy FakeWifiLog mLog; @@ -357,6 +359,7 @@ public class WifiServiceImplTest { .thenReturn(mWifiNetworkSuggestionsManager); when(mWifiInjector.makeTelephonyManager()).thenReturn(mTelephonyManager); when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager); + when(mClientModeImpl.getWifiScoreReport()).thenReturn(mWifiScoreReport); when(mClientModeImpl.syncStartSubscriptionProvisioning(anyInt(), any(OsuProvider.class), any(IProvisioningCallback.class), any())).thenReturn(true); when(mPackageManager.hasSystemFeature( @@ -439,6 +442,35 @@ public class WifiServiceImplTest { } /** + * Ensure that WifiServiceImpl.dump() calls + * {@link ClientModeImpl#updateLinkLayerStatsRssiAndScoreReport()}, then calls + * mWifiInjector.getClientModeImplHandler().runWithScissors() at least once before calling + * {@link WifiScoreReport#dump(FileDescriptor, PrintWriter, String[])}. + * + * runWithScissors() needs to be called at least once so that we know that the async call + * {@link ClientModeImpl#updateLinkLayerStatsRssiAndScoreReport()} has completed, since + * runWithScissors() blocks the current thread until the call completes, which includes all + * previous calls posted to that thread. + * + * This ensures that WifiScoreReport will always get updated RSSI and link layer stats before + * dumping during a bug report, no matter if the screen is on or not. + */ + @Test + public void testWifiScoreReportDump() { + setupClientModeImplHandlerForRunWithScissors(); + + mWifiServiceImpl.dump(new FileDescriptor(), new PrintWriter(new StringWriter()), null); + + InOrder inOrder = inOrder(mClientModeImpl, mHandlerSpyForCmiRunWithScissors, + mWifiScoreReport); + + inOrder.verify(mClientModeImpl).updateLinkLayerStatsRssiAndScoreReport(); + inOrder.verify(mHandlerSpyForCmiRunWithScissors, atLeastOnce()) + .runWithScissors(any(), anyLong()); + inOrder.verify(mWifiScoreReport).dump(any(), any(), any()); + } + + /** * Verify that wifi can be enabled by a caller with NETWORK_SETTINGS permission. */ @Test |