From 84612ea6110267928eb159b532d52fa3328d746a Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Wed, 30 Sep 2009 09:04:22 -0700 Subject: [PATCH] Add a delay to wifi driver stop on screen off. We already had a delay if we were associated, but we have some race conditions we think will be masked if we delay the driver stop for the other cases too. Don't wait as long (2 min instead of 15). bug: 2147260 --- services/java/com/android/server/WifiService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index cc1b6977c8061..a3589c79a796a 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -1324,9 +1324,16 @@ public class WifiService extends IWifiManager.Stub { if (!shouldWifiStayAwake(stayAwakeConditions, mPluggedType)) { WifiInfo info = mWifiStateTracker.requestConnectionInfo(); if (info.getSupplicantState() != SupplicantState.COMPLETED) { - // do not keep Wifi awake when screen is off if Wifi is not associated - mDeviceIdle = true; - updateWifiState(); + // we used to go to sleep immediately, but this caused some race conditions + // we don't have time to track down for this release. Delay instead, but not + // as long as we would if connected (below) + // TODO - fix the race conditions and switch back to the immediate turn-off + long triggerTime = System.currentTimeMillis() + (2*60*1000); // 2 min + Log.d(TAG, "setting ACTION_DEVICE_IDLE timer for 120,000 ms"); + mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent); + // // do not keep Wifi awake when screen is off if Wifi is not associated + // mDeviceIdle = true; + // updateWifiState(); } else { long triggerTime = System.currentTimeMillis() + idleMillis; Log.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis + "ms");