diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-09-14 16:54:08 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-14 16:54:09 -0700 |
commit | 424968261fb346859a7ac796703527f2e34c0a84 (patch) | |
tree | 64555a51c4f2c7fa5b5c99968e639b9ddc982df9 /wifi | |
parent | 9ceede6d7e250922e63b0d2c90403089f8736e0c (diff) | |
parent | 633fe60b78665979109d4796ba22430b7b1cd758 (diff) | |
download | frameworks_base-424968261fb346859a7ac796703527f2e34c0a84.zip frameworks_base-424968261fb346859a7ac796703527f2e34c0a84.tar.gz frameworks_base-424968261fb346859a7ac796703527f2e34c0a84.tar.bz2 |
Merge "Fix suspend bugs" into jb-mr1-dev
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 3 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 18 |
2 files changed, 10 insertions, 11 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 805faa6..4c5fc5d 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -49,6 +49,7 @@ public class WifiNative { static final int BLUETOOTH_COEXISTENCE_MODE_SENSE = 2; String mInterface = ""; + private boolean mSuspendOptEnabled = false; public native static boolean loadDriver(); @@ -349,6 +350,8 @@ public class WifiNative { } public boolean setSuspendOptimizations(boolean enabled) { + if (mSuspendOptEnabled == enabled) return true; + mSuspendOptEnabled = enabled; if (enabled) { return doBooleanCommand("DRIVER SETSUSPENDMODE 1"); } else { diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 4cbb824..5e69482 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -141,8 +141,6 @@ public class WifiStateMachine extends StateMachine { private boolean mBluetoothConnectionActive = false; - private BroadcastReceiver mScreenReceiver; - private IntentFilter mScreenFilter; private PowerManager.WakeLock mSuspendWakeLock; /** @@ -628,15 +626,16 @@ public class WifiStateMachine extends StateMachine { }, new IntentFilter(ACTION_START_SCAN)); - mScreenFilter = new IntentFilter(); - mScreenFilter.addAction(Intent.ACTION_SCREEN_ON); - mScreenFilter.addAction(Intent.ACTION_SCREEN_OFF); - mScreenReceiver = new BroadcastReceiver() { + IntentFilter screenFilter = new IntentFilter(); + screenFilter.addAction(Intent.ACTION_SCREEN_ON); + screenFilter.addAction(Intent.ACTION_SCREEN_OFF); + BroadcastReceiver screenReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(Intent.ACTION_SCREEN_ON)) { + if (DBG) log("ACTION_SCREEN_ON"); enableRssiPolling(true); if (mBackgroundScanSupported) { enableBackgroundScanCommand(false); @@ -647,6 +646,7 @@ public class WifiStateMachine extends StateMachine { sendMessage(obtainMessage(CMD_SET_SUSPEND_OPT_ENABLED, 0, 0)); } } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { + if (DBG) log("ACTION_SCREEN_OFF"); enableRssiPolling(false); if (mBackgroundScanSupported) { enableBackgroundScanCommand(true); @@ -660,6 +660,7 @@ public class WifiStateMachine extends StateMachine { } } }; + mContext.registerReceiver(screenReceiver, screenFilter); mContext.registerReceiver( new BroadcastReceiver() { @@ -1335,12 +1336,10 @@ public class WifiStateMachine extends StateMachine { /* None of dhcp, screen or highperf need it disabled and user wants it enabled */ if (mSuspendOptNeedsDisabled == 0 && mUserWantsSuspendOpt.get()) { mWifiNative.setSuspendOptimizations(true); - if (DBG) log("Enabled, mSuspendOptNeedsDisabled " + mSuspendOptNeedsDisabled); } } else { mSuspendOptNeedsDisabled |= reason; mWifiNative.setSuspendOptimizations(false); - if (DBG) log("Disabled, mSuspendOptNeedsDisabled " + mSuspendOptNeedsDisabled); } } @@ -2723,8 +2722,6 @@ public class WifiStateMachine extends StateMachine { } if (mP2pSupported) mWifiP2pChannel.sendMessage(WifiStateMachine.CMD_ENABLE_P2P); - - mContext.registerReceiver(mScreenReceiver, mScreenFilter); } @Override public boolean processMessage(Message message) { @@ -2861,7 +2858,6 @@ public class WifiStateMachine extends StateMachine { mScanResults = new ArrayList<ScanResult>(); if (mP2pSupported) mWifiP2pChannel.sendMessage(WifiStateMachine.CMD_DISABLE_P2P); - mContext.unregisterReceiver(mScreenReceiver); } } |