From 73ad868e44a0cbfba6eadbd690420e8e5cfcd33e Mon Sep 17 00:00:00 2001 From: Mahesh A Saptasagar Date: Thu, 20 Nov 2014 00:33:48 +0530 Subject: wifi: Address the improper scan behavior on PNO failure This commit takes care of the following behavior on a PNO fail. Trigger a periodic scan on a PNO failure when p2p session is active and there are no configured profiles. There is no point to continue the periodic scan triggered on a PNO fail when p2p session is active.Thus, stall further attempts after a p2p disconnections. Change-Id: I7844dca7fe9dd45b99e71ef04beb19ea2ae5343e CRs-Fixed: 759618 --- .../com/android/server/wifi/WifiStateMachine.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index b0fcb17c1..ea84f3105 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -198,6 +198,9 @@ public class WifiStateMachine extends StateMachine { /* Chipset supports background scan */ private final boolean mBackgroundScanSupported; + /* Flag to verify backgroundScan is configured successfully */ + private boolean mBackgroundScanConfigured = false; + private String mInterfaceName; /* Tethering interface could be separate from wlan interface */ private String mTetherInterfaceName; @@ -7709,9 +7712,9 @@ public class WifiStateMachine extends StateMachine { } break; case CMD_PNO_PERIODIC_SCAN: - if ((message.arg1 == mPnoPeriodicScanToken) && - (mEnableBackgroundScan) && - (mWifiConfigStore.getConfiguredNetworks().size() != 0)) { + if ((mBackgroundScanConfigured == false) && + (message.arg1 == mPnoPeriodicScanToken) && + (mEnableBackgroundScan)) { startScan(UNKNOWN_SCAN_SOURCE, -1, null, null); sendMessageDelayed(obtainMessage(CMD_PNO_PERIODIC_SCAN, ++mPnoPeriodicScanToken, 0), @@ -7794,6 +7797,9 @@ public class WifiStateMachine extends StateMachine { (mWifiConfigStore.getConfiguredNetworks().size() != 0)) { if (!mWifiNative.enableBackgroundScan(true)) { handlePnoFailError(); + } else { + if (DBG) log("Stop periodic scan on PNO success"); + mBackgroundScanConfigured = true; } } case CMD_RECONNECT: @@ -8373,12 +8379,15 @@ public class WifiStateMachine extends StateMachine { } private void handlePnoFailError() { + /* PNO should not fail when P2P is not connected and there are + saved profiles */ if (!mP2pConnected.get() && (mWifiConfigStore.getConfiguredNetworks().size() == 0)) { return; } - if (mEnableBackgroundScan && - (mWifiConfigStore.getConfiguredNetworks().size() != 0)) { + /* Trigger a periodic scan for every 300Sec if PNO fails */ + if (mEnableBackgroundScan) { + mBackgroundScanConfigured = false; sendMessageDelayed(obtainMessage(CMD_PNO_PERIODIC_SCAN, ++mPnoPeriodicScanToken, 0), mDefaultFrameworkScanIntervalMs); -- cgit v1.2.3