Loading services/java/com/android/server/WifiService.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -171,6 +171,7 @@ public class WifiService extends IWifiManager.Stub { WifiService(Context context, WifiStateTracker tracker) { WifiService(Context context, WifiStateTracker tracker) { mContext = context; mContext = context; mWifiStateTracker = tracker; mWifiStateTracker = tracker; mWifiStateTracker.enableRssiPolling(true); mBatteryStats = BatteryStatsService.getService(); mBatteryStats = BatteryStatsService.getService(); mScanResultCache = new LinkedHashMap<String, ScanResult>( mScanResultCache = new LinkedHashMap<String, ScanResult>( Loading Loading @@ -1367,9 +1368,11 @@ public class WifiService extends IWifiManager.Stub { mAlarmManager.cancel(mIdleIntent); mAlarmManager.cancel(mIdleIntent); mDeviceIdle = false; mDeviceIdle = false; mScreenOff = false; mScreenOff = false; mWifiStateTracker.enableRssiPolling(true); } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { Log.d(TAG, "ACTION_SCREEN_OFF"); Log.d(TAG, "ACTION_SCREEN_OFF"); mScreenOff = true; mScreenOff = true; mWifiStateTracker.enableRssiPolling(false); /* /* * Set a timer to put Wi-Fi to sleep, but only if the screen is off * Set a timer to put Wi-Fi to sleep, but only if the screen is off * AND the "stay on while plugged in" setting doesn't match the * AND the "stay on while plugged in" setting doesn't match the Loading wifi/java/android/net/wifi/WifiStateTracker.java +16 −6 Original line number Original line Diff line number Diff line Loading @@ -242,6 +242,7 @@ public class WifiStateTracker extends NetworkStateTracker { private SettingsObserver mSettingsObserver; private SettingsObserver mSettingsObserver; private boolean mIsScanModeActive; private boolean mIsScanModeActive; private boolean mEnableRssiPolling; // Wi-Fi run states: // Wi-Fi run states: private static final int RUN_STATE_STARTING = 1; private static final int RUN_STATE_STARTING = 1; Loading Loading @@ -340,6 +341,7 @@ public class WifiStateTracker extends NetworkStateTracker { private void setSupplicantState(SupplicantState state) { private void setSupplicantState(SupplicantState state) { mWifiInfo.setSupplicantState(state); mWifiInfo.setSupplicantState(state); updateNetworkInfo(); updateNetworkInfo(); checkPollTimer(); } } public SupplicantState getSupplicantState() { public SupplicantState getSupplicantState() { Loading @@ -354,6 +356,7 @@ public class WifiStateTracker extends NetworkStateTracker { private void setSupplicantState(String stateName) { private void setSupplicantState(String stateName) { mWifiInfo.setSupplicantState(stateName); mWifiInfo.setSupplicantState(stateName); updateNetworkInfo(); updateNetworkInfo(); checkPollTimer(); } } /** /** Loading Loading @@ -550,8 +553,10 @@ public class WifiStateTracker extends NetworkStateTracker { * Set the interval timer for polling connection information * Set the interval timer for polling connection information * that is not delivered asynchronously. * that is not delivered asynchronously. */ */ private synchronized void setPollTimer () { private synchronized void checkPollTimer() { if (!hasMessages(EVENT_POLL_INTERVAL)) { if (mEnableRssiPolling && mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED && !hasMessages(EVENT_POLL_INTERVAL)) { sendEmptyMessageDelayed(EVENT_POLL_INTERVAL, POLL_STATUS_INTERVAL_MSECS); sendEmptyMessageDelayed(EVENT_POLL_INTERVAL, POLL_STATUS_INTERVAL_MSECS); } } } } Loading Loading @@ -651,6 +656,13 @@ public class WifiStateTracker extends NetworkStateTracker { setBluetoothScanMode(isBluetoothPlaying); setBluetoothScanMode(isBluetoothPlaying); } } public void enableRssiPolling(boolean enable) { if (mEnableRssiPolling != enable) { mEnableRssiPolling = enable; checkPollTimer(); } } @Override @Override public void releaseWakeLock() { public void releaseWakeLock() { if (mReleaseWakeLockCallback != null) { if (mReleaseWakeLockCallback != null) { Loading Loading @@ -1031,9 +1043,7 @@ public class WifiStateTracker extends NetworkStateTracker { case EVENT_POLL_INTERVAL: case EVENT_POLL_INTERVAL: if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) { if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) { requestPolledInfo(mWifiInfo, true); requestPolledInfo(mWifiInfo, true); if (mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED) { checkPollTimer(); setPollTimer(); } } } break; break; Loading Loading @@ -1170,7 +1180,7 @@ public class WifiStateTracker extends NetworkStateTracker { } } private void configureInterface() { private void configureInterface() { setPollTimer(); checkPollTimer(); mLastSignalLevel = -1; mLastSignalLevel = -1; if (!mUseStaticIp) { if (!mUseStaticIp) { if (!mHaveIpAddress && !mObtainingIpAddress) { if (!mHaveIpAddress && !mObtainingIpAddress) { Loading Loading
services/java/com/android/server/WifiService.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -171,6 +171,7 @@ public class WifiService extends IWifiManager.Stub { WifiService(Context context, WifiStateTracker tracker) { WifiService(Context context, WifiStateTracker tracker) { mContext = context; mContext = context; mWifiStateTracker = tracker; mWifiStateTracker = tracker; mWifiStateTracker.enableRssiPolling(true); mBatteryStats = BatteryStatsService.getService(); mBatteryStats = BatteryStatsService.getService(); mScanResultCache = new LinkedHashMap<String, ScanResult>( mScanResultCache = new LinkedHashMap<String, ScanResult>( Loading Loading @@ -1367,9 +1368,11 @@ public class WifiService extends IWifiManager.Stub { mAlarmManager.cancel(mIdleIntent); mAlarmManager.cancel(mIdleIntent); mDeviceIdle = false; mDeviceIdle = false; mScreenOff = false; mScreenOff = false; mWifiStateTracker.enableRssiPolling(true); } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { Log.d(TAG, "ACTION_SCREEN_OFF"); Log.d(TAG, "ACTION_SCREEN_OFF"); mScreenOff = true; mScreenOff = true; mWifiStateTracker.enableRssiPolling(false); /* /* * Set a timer to put Wi-Fi to sleep, but only if the screen is off * Set a timer to put Wi-Fi to sleep, but only if the screen is off * AND the "stay on while plugged in" setting doesn't match the * AND the "stay on while plugged in" setting doesn't match the Loading
wifi/java/android/net/wifi/WifiStateTracker.java +16 −6 Original line number Original line Diff line number Diff line Loading @@ -242,6 +242,7 @@ public class WifiStateTracker extends NetworkStateTracker { private SettingsObserver mSettingsObserver; private SettingsObserver mSettingsObserver; private boolean mIsScanModeActive; private boolean mIsScanModeActive; private boolean mEnableRssiPolling; // Wi-Fi run states: // Wi-Fi run states: private static final int RUN_STATE_STARTING = 1; private static final int RUN_STATE_STARTING = 1; Loading Loading @@ -340,6 +341,7 @@ public class WifiStateTracker extends NetworkStateTracker { private void setSupplicantState(SupplicantState state) { private void setSupplicantState(SupplicantState state) { mWifiInfo.setSupplicantState(state); mWifiInfo.setSupplicantState(state); updateNetworkInfo(); updateNetworkInfo(); checkPollTimer(); } } public SupplicantState getSupplicantState() { public SupplicantState getSupplicantState() { Loading @@ -354,6 +356,7 @@ public class WifiStateTracker extends NetworkStateTracker { private void setSupplicantState(String stateName) { private void setSupplicantState(String stateName) { mWifiInfo.setSupplicantState(stateName); mWifiInfo.setSupplicantState(stateName); updateNetworkInfo(); updateNetworkInfo(); checkPollTimer(); } } /** /** Loading Loading @@ -550,8 +553,10 @@ public class WifiStateTracker extends NetworkStateTracker { * Set the interval timer for polling connection information * Set the interval timer for polling connection information * that is not delivered asynchronously. * that is not delivered asynchronously. */ */ private synchronized void setPollTimer () { private synchronized void checkPollTimer() { if (!hasMessages(EVENT_POLL_INTERVAL)) { if (mEnableRssiPolling && mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED && !hasMessages(EVENT_POLL_INTERVAL)) { sendEmptyMessageDelayed(EVENT_POLL_INTERVAL, POLL_STATUS_INTERVAL_MSECS); sendEmptyMessageDelayed(EVENT_POLL_INTERVAL, POLL_STATUS_INTERVAL_MSECS); } } } } Loading Loading @@ -651,6 +656,13 @@ public class WifiStateTracker extends NetworkStateTracker { setBluetoothScanMode(isBluetoothPlaying); setBluetoothScanMode(isBluetoothPlaying); } } public void enableRssiPolling(boolean enable) { if (mEnableRssiPolling != enable) { mEnableRssiPolling = enable; checkPollTimer(); } } @Override @Override public void releaseWakeLock() { public void releaseWakeLock() { if (mReleaseWakeLockCallback != null) { if (mReleaseWakeLockCallback != null) { Loading Loading @@ -1031,9 +1043,7 @@ public class WifiStateTracker extends NetworkStateTracker { case EVENT_POLL_INTERVAL: case EVENT_POLL_INTERVAL: if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) { if (mWifiInfo.getSupplicantState() != SupplicantState.UNINITIALIZED) { requestPolledInfo(mWifiInfo, true); requestPolledInfo(mWifiInfo, true); if (mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED) { checkPollTimer(); setPollTimer(); } } } break; break; Loading Loading @@ -1170,7 +1180,7 @@ public class WifiStateTracker extends NetworkStateTracker { } } private void configureInterface() { private void configureInterface() { setPollTimer(); checkPollTimer(); mLastSignalLevel = -1; mLastSignalLevel = -1; if (!mUseStaticIp) { if (!mUseStaticIp) { if (!mHaveIpAddress && !mObtainingIpAddress) { if (!mHaveIpAddress && !mObtainingIpAddress) { Loading