diff options
author | Mike Lockwood <lockwood@android.com> | 2009-05-18 14:14:15 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-05-18 15:54:16 -0400 |
commit | d9c32bc838cb618dcbc1e48df02a34b6596b8930 (patch) | |
tree | cb7ff7abd7b1c2e99b5fcbfaebc7d19a9b4f5dfc /services/java/com | |
parent | 6342d3936ad8c9e6cf5bba1fc88c4e9338391bb4 (diff) | |
download | frameworks_base-d9c32bc838cb618dcbc1e48df02a34b6596b8930.zip frameworks_base-d9c32bc838cb618dcbc1e48df02a34b6596b8930.tar.gz frameworks_base-d9c32bc838cb618dcbc1e48df02a34b6596b8930.tar.bz2 |
WifiService: Wifi power management change
Put Wifi into an idle state immediately if the screen is turned off and the Wifi interface has no IP address.
We will continue to keep Wifi up for 15 minutes in the case where the screen is turned off when Wifi is fully connected.
This will allow us to go into a low power mode faster when Wifi is not actively being used.
It also avoids bringing up Wifi if the user just turns on the screen for a few seconds to check the clock, etc.
Fixes bug b/1736920
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services/java/com')
-rw-r--r-- | services/java/com/android/server/WifiService.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 348f0a1..90ab270 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -1449,10 +1449,12 @@ public class WifiService extends IWifiManager.Stub { Settings.System.getInt(mContext.getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0); if (action.equals(Intent.ACTION_SCREEN_ON)) { + Log.d(TAG, "ACTION_SCREEN_ON"); mAlarmManager.cancel(mIdleIntent); mDeviceIdle = false; mScreenOff = false; } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { + Log.d(TAG, "ACTION_SCREEN_OFF"); mScreenOff = true; /* * Set a timer to put Wi-Fi to sleep, but only if the screen is off @@ -1461,12 +1463,20 @@ public class WifiService extends IWifiManager.Stub { * or plugged in to AC). */ if (!shouldWifiStayAwake(stayAwakeConditions, mPluggedType)) { - long triggerTime = System.currentTimeMillis() + idleMillis; - mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent); + if (!mWifiStateTracker.hasIpAddress()) { + // do not keep Wifi awake when screen is off if Wifi is not fully active + mDeviceIdle = true; + updateWifiState(); + } else { + long triggerTime = System.currentTimeMillis() + idleMillis; + Log.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis + "ms"); + mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent); + } } /* we can return now -- there's nothing to do until we get the idle intent back */ return; } else if (action.equals(ACTION_DEVICE_IDLE)) { + Log.d(TAG, "got ACTION_DEVICE_IDLE"); mDeviceIdle = true; } else if (action.equals(Intent.ACTION_BATTERY_CHANGED)) { /* @@ -1477,9 +1487,11 @@ public class WifiService extends IWifiManager.Stub { * the already-set timer. */ int pluggedType = intent.getIntExtra("plugged", 0); + Log.d(TAG, "ACTION_BATTERY_CHANGED pluggedType: " + pluggedType); if (mScreenOff && shouldWifiStayAwake(stayAwakeConditions, mPluggedType) && !shouldWifiStayAwake(stayAwakeConditions, pluggedType)) { long triggerTime = System.currentTimeMillis() + idleMillis; + Log.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis + "ms"); mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent); mPluggedType = pluggedType; return; |