summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-10-23 17:30:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-10-23 17:30:50 +0000
commitda89bc3fd7aba15cf808d80c8254b022599ba416 (patch)
treeec6260905eb16ca4b6c4697a0fea09fc96956e48
parent3358131b39a85aee27c3e1e0ffbc1dfc1468bd2c (diff)
parent317ade534d1e97ddfa2870a5e93b9e24c92c36e4 (diff)
Merge "WifiLastResortWatchdog: Use injector to get SelfRecovery"
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
-rw-r--r--service/java/com/android/server/wifi/WifiLastResortWatchdog.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java4
3 files changed, 8 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index bb0a37176..7dd6beacc 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -526,7 +526,7 @@ public class WifiInjector {
mWifiCoreHandlerThread.getLooper(), mFrameworkFacade, mClock, mWifiMetrics,
mWifiConfigManager, mWifiConfigStore, clientModeImpl,
new ConnectToNetworkNotificationBuilder(mContext, mFrameworkFacade));
- mWifiLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mClock,
+ mWifiLastResortWatchdog = new WifiLastResortWatchdog(this, mClock,
mWifiMetrics, clientModeImpl, clientModeImpl.getHandler().getLooper());
return new WifiConnectivityManager(mContext, getScoringParams(),
clientModeImpl, this,
diff --git a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
index 6a9b2f825..87d060d9b 100644
--- a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
+++ b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
@@ -87,7 +87,7 @@ public class WifiLastResortWatchdog {
private boolean mWatchdogAllowedToTrigger = true;
private long mTimeLastTrigger;
- private SelfRecovery mSelfRecovery;
+ private WifiInjector mWifiInjector;
private WifiMetrics mWifiMetrics;
private ClientModeImpl mClientModeImpl;
private Looper mClientModeImplLooper;
@@ -97,9 +97,9 @@ public class WifiLastResortWatchdog {
// did not fix the problem
private boolean mWatchdogFixedWifi = true;
- WifiLastResortWatchdog(SelfRecovery selfRecovery, Clock clock, WifiMetrics wifiMetrics,
+ WifiLastResortWatchdog(WifiInjector wifiInjector, Clock clock, WifiMetrics wifiMetrics,
ClientModeImpl clientModeImpl, Looper clientModeImplLooper) {
- mSelfRecovery = selfRecovery;
+ mWifiInjector = wifiInjector;
mClock = clock;
mWifiMetrics = wifiMetrics;
mClientModeImpl = clientModeImpl;
@@ -225,8 +225,7 @@ public class WifiLastResortWatchdog {
mWatchdogFixedWifi = true;
Log.e(TAG, "Watchdog triggering recovery");
mTimeLastTrigger = mClock.getElapsedSinceBootMillis();
- mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
- // increment various watchdog trigger count stats
+ mWifiInjector.getSelfRecovery().trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG);
incrementWifiMetricsTriggerCounts();
clearAllFailureCounts();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
index eb6af0f86..e9351258f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
@@ -41,6 +41,7 @@ import java.util.List;
@SmallTest
public class WifiLastResortWatchdogTest {
WifiLastResortWatchdog mLastResortWatchdog;
+ @Mock WifiInjector mWifiInjector;
@Mock WifiMetrics mWifiMetrics;
@Mock SelfRecovery mSelfRecovery;
@Mock ClientModeImpl mClientModeImpl;
@@ -61,7 +62,8 @@ public class WifiLastResortWatchdogTest {
public void setUp() throws Exception {
initMocks(this);
mLooper = new TestLooper();
- mLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mClock, mWifiMetrics,
+ when(mWifiInjector.getSelfRecovery()).thenReturn(mSelfRecovery);
+ mLastResortWatchdog = new WifiLastResortWatchdog(mWifiInjector, mClock, mWifiMetrics,
mClientModeImpl, mLooper.getLooper());
mLastResortWatchdog.setBugReportProbability(1);
}