diff options
author | Irfan Sheriff <isheriff@google.com> | 2012-05-02 12:43:05 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2012-05-02 17:51:26 -0700 |
commit | 027828bff7928a125c7150fe7cb4dcbcba113912 (patch) | |
tree | 738ebb466da9941b8f979e53db2dbe6f21512a76 /wifi/java/android | |
parent | faac92942c50b12edada5e92e7c323609b2bdb5f (diff) | |
download | frameworks_base-027828bff7928a125c7150fe7cb4dcbcba113912.zip frameworks_base-027828bff7928a125c7150fe7cb4dcbcba113912.tar.gz frameworks_base-027828bff7928a125c7150fe7cb4dcbcba113912.tar.bz2 |
Report open networks without saved networks
The supplicant stops periodic scans when there are no saved networks.
The framework needs to have a periodic scan to handle this scenario.
We do have an infrequent wake up scan (15 mins), but thats way too
slow to report an open network.
Setup a scan by the supplicant interval when there are no saved
networks
Bug: 5420656
Change-Id: Id3708ecc874b42971643cc747bb9e7f2efc7d1dd
Diffstat (limited to 'wifi/java/android')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index a85083d..fbcb9e2 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -184,6 +184,9 @@ public class WifiStateMachine extends StateMachine { private LinkProperties mLinkProperties; + /* Tracks sequence number on a periodic scan message */ + private int mPeriodicScanToken = 0; + // Wakelock held during wifi start/stop and driver load/unload private PowerManager.WakeLock mWakeLock; @@ -331,6 +334,9 @@ public class WifiStateMachine extends StateMachine { static final int CMD_SET_SUSPEND_OPTIMIZATIONS = BASE + 86; /* Clear suspend mode optimizations in the driver */ static final int CMD_CLEAR_SUSPEND_OPTIMIZATIONS = BASE + 87; + /* When there are no saved networks, we do a periodic scan to notify user of + * an open network */ + static final int CMD_NO_NETWORKS_PERIODIC_SCAN = BASE + 88; /* arg1 values to CMD_STOP_PACKET_FILTERING and CMD_START_PACKET_FILTERING */ static final int MULTICAST_V6 = 1; @@ -385,10 +391,11 @@ public class WifiStateMachine extends StateMachine { private final int mDefaultFrameworkScanIntervalMs; /** - * Default supplicant scan interval in milliseconds. - * {@link Settings.Secure#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} can override this. + * Supplicant scan interval in milliseconds. + * Comes from {@link Settings.Secure#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} or + * from the default config if the setting is not set */ - private final int mDefaultSupplicantScanIntervalMs; + private long mSupplicantScanIntervalMs; /** * Minimum time interval between enabling all networks. @@ -568,9 +575,6 @@ public class WifiStateMachine extends StateMachine { mDefaultFrameworkScanIntervalMs = mContext.getResources().getInteger( com.android.internal.R.integer.config_wifi_framework_scan_interval); - mDefaultSupplicantScanIntervalMs = mContext.getResources().getInteger( - com.android.internal.R.integer.config_wifi_supplicant_scan_interval); - mDriverStopDelayMs = mContext.getResources().getInteger( com.android.internal.R.integer.config_wifi_driver_stop_delay); @@ -1870,6 +1874,7 @@ public class WifiStateMachine extends StateMachine { case WifiWatchdogStateMachine.POOR_LINK_DETECTED: case WifiWatchdogStateMachine.GOOD_LINK_DETECTED: case CMD_CLEAR_SUSPEND_OPTIMIZATIONS: + case CMD_NO_NETWORKS_PERIODIC_SCAN: break; case CMD_SET_SUSPEND_OPTIMIZATIONS: mSuspendWakeLock.release(); @@ -2269,11 +2274,15 @@ public class WifiStateMachine extends StateMachine { mIsScanMode = false; /* Wifi is available as long as we have a connection to supplicant */ mNetworkInfo.setIsAvailable(true); - /* Set scan interval */ - long supplicantScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(), + + int defaultInterval = mContext.getResources().getInteger( + com.android.internal.R.integer.config_wifi_supplicant_scan_interval); + + mSupplicantScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(), Settings.Secure.WIFI_SUPPLICANT_SCAN_INTERVAL_MS, - mDefaultSupplicantScanIntervalMs); - mWifiNative.setScanInterval((int)supplicantScanIntervalMs / 1000); + defaultInterval); + + mWifiNative.setScanInterval((int)mSupplicantScanIntervalMs / 1000); } @Override public boolean processMessage(Message message) { @@ -3270,11 +3279,39 @@ public class WifiStateMachine extends StateMachine { } else { setScanAlarm(true); } + + /** + * If we have no networks saved, the supplicant stops doing the periodic scan. + * The scans are useful to notify the user of the presence of an open network. + * Note that these are not wake up scans. + */ + if (mWifiConfigStore.getConfiguredNetworks().size() == 0) { + sendMessageDelayed(obtainMessage(CMD_NO_NETWORKS_PERIODIC_SCAN, + ++mPeriodicScanToken, 0), mSupplicantScanIntervalMs); + } } @Override public boolean processMessage(Message message) { if (DBG) log(getName() + message.toString() + "\n"); + boolean ret = HANDLED; switch (message.what) { + case CMD_NO_NETWORKS_PERIODIC_SCAN: + if (message.arg1 == mPeriodicScanToken && + mWifiConfigStore.getConfiguredNetworks().size() == 0) { + sendMessage(CMD_START_SCAN); + sendMessageDelayed(obtainMessage(CMD_NO_NETWORKS_PERIODIC_SCAN, + ++mPeriodicScanToken, 0), mSupplicantScanIntervalMs); + } + break; + case WifiManager.FORGET_NETWORK: + case CMD_REMOVE_NETWORK: + // Set up a delayed message here. After the forget/remove is handled + // the handled delayed message will determine if there is a need to + // scan and continue + sendMessageDelayed(obtainMessage(CMD_NO_NETWORKS_PERIODIC_SCAN, + ++mPeriodicScanToken, 0), mSupplicantScanIntervalMs); + ret = NOT_HANDLED; + break; case CMD_SET_SCAN_MODE: if (message.arg1 == SCAN_ONLY_MODE) { mWifiNative.setScanResultHandling(message.arg1); @@ -3301,25 +3338,28 @@ public class WifiStateMachine extends StateMachine { StateChangeResult stateChangeResult = (StateChangeResult) message.obj; setNetworkDetailedState(WifiInfo.getDetailedStateOf(stateChangeResult.state)); /* ConnectModeState does the rest of the handling */ - return NOT_HANDLED; + ret = NOT_HANDLED; + break; case CMD_START_SCAN: /* Disable background scan temporarily during a regular scan */ if (mEnableBackgroundScan) { mWifiNative.enableBackgroundScan(false); } /* Handled in parent state */ - return NOT_HANDLED; + ret = NOT_HANDLED; + break; case WifiMonitor.SCAN_RESULTS_EVENT: /* Re-enable background scan when a pending scan result is received */ if (mEnableBackgroundScan && mScanResultIsPending) { mWifiNative.enableBackgroundScan(true); } /* Handled in parent state */ - return NOT_HANDLED; + ret = NOT_HANDLED; + break; default: - return NOT_HANDLED; + ret = NOT_HANDLED; } - return HANDLED; + return ret; } @Override |