From 1590c968d37b78b8dfcd3cf21a80f380b7613166 Mon Sep 17 00:00:00 2001 From: zhujiatai Date: Wed, 6 Jan 2021 13:41:03 +0800 Subject: Fix abnormal wake up caused by WifiConnectivityManager When wifi is toggled off when disconnected, the Watchdog Timer will still work after at most 20mins, this will wake up the phone from sleep. Signed-off-by: zhujiatai Change-Id: I73333041932d3240783cd3a2ceb2f6243ccde2d6 --- .../java/com/android/server/wifi/WifiConnectivityManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index 77af65400..12c64b542 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -175,6 +175,7 @@ public class WifiConnectivityManager { private boolean mPnoScanStarted = false; private boolean mPeriodicScanTimerSet = false; private boolean mDelayedPartialScanTimerSet = false; + private boolean mWatchdogScanTimerSet = false; // Used for Initial Scan metrics private boolean mFailedInitialPartialScan = false; @@ -1466,6 +1467,15 @@ public class WifiConnectivityManager { mClock.getElapsedSinceBootMillis() + WATCHDOG_INTERVAL_MS, WATCHDOG_TIMER_TAG, mWatchdogListener, mEventHandler); + mWatchdogScanTimerSet = true; + } + + // Cancel the watchdog scan timer. + private void cancelWatchdogScan() { + if (mWatchdogScanTimerSet) { + mAlarmManager.cancel(mWatchdogListener); + mWatchdogScanTimerSet = false; + } } // Schedules a delayed partial scan, which will scan the frequencies in mCachedWifiCandidates. @@ -1893,6 +1903,7 @@ public class WifiConnectivityManager { if (!mRunning) return; mRunning = false; stopConnectivityScan(); + cancelWatchdogScan(); resetLastPeriodicSingleScanTimeStamp(); mOpenNetworkNotifier.clearPendingNotification(true /* resetRepeatDelay */); mLastConnectionAttemptBssid = null; -- cgit v1.2.3