Merge "Report open networks without saved networks" into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
531522c7fe
@ -184,6 +184,9 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
|
|
||||||
private LinkProperties mLinkProperties;
|
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
|
// Wakelock held during wifi start/stop and driver load/unload
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
@ -331,6 +334,9 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
static final int CMD_SET_SUSPEND_OPTIMIZATIONS = BASE + 86;
|
static final int CMD_SET_SUSPEND_OPTIMIZATIONS = BASE + 86;
|
||||||
/* Clear suspend mode optimizations in the driver */
|
/* Clear suspend mode optimizations in the driver */
|
||||||
static final int CMD_CLEAR_SUSPEND_OPTIMIZATIONS = BASE + 87;
|
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 */
|
/* arg1 values to CMD_STOP_PACKET_FILTERING and CMD_START_PACKET_FILTERING */
|
||||||
static final int MULTICAST_V6 = 1;
|
static final int MULTICAST_V6 = 1;
|
||||||
@ -385,10 +391,11 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
private final int mDefaultFrameworkScanIntervalMs;
|
private final int mDefaultFrameworkScanIntervalMs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default supplicant scan interval in milliseconds.
|
* Supplicant scan interval in milliseconds.
|
||||||
* {@link Settings.Secure#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} can override this.
|
* 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.
|
* Minimum time interval between enabling all networks.
|
||||||
@ -568,9 +575,6 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
mDefaultFrameworkScanIntervalMs = mContext.getResources().getInteger(
|
mDefaultFrameworkScanIntervalMs = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_wifi_framework_scan_interval);
|
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(
|
mDriverStopDelayMs = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_wifi_driver_stop_delay);
|
com.android.internal.R.integer.config_wifi_driver_stop_delay);
|
||||||
|
|
||||||
@ -1869,6 +1873,7 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
case WifiWatchdogStateMachine.POOR_LINK_DETECTED:
|
case WifiWatchdogStateMachine.POOR_LINK_DETECTED:
|
||||||
case WifiWatchdogStateMachine.GOOD_LINK_DETECTED:
|
case WifiWatchdogStateMachine.GOOD_LINK_DETECTED:
|
||||||
case CMD_CLEAR_SUSPEND_OPTIMIZATIONS:
|
case CMD_CLEAR_SUSPEND_OPTIMIZATIONS:
|
||||||
|
case CMD_NO_NETWORKS_PERIODIC_SCAN:
|
||||||
break;
|
break;
|
||||||
case CMD_SET_SUSPEND_OPTIMIZATIONS:
|
case CMD_SET_SUSPEND_OPTIMIZATIONS:
|
||||||
mSuspendWakeLock.release();
|
mSuspendWakeLock.release();
|
||||||
@ -2268,11 +2273,15 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
mIsScanMode = false;
|
mIsScanMode = false;
|
||||||
/* Wifi is available as long as we have a connection to supplicant */
|
/* Wifi is available as long as we have a connection to supplicant */
|
||||||
mNetworkInfo.setIsAvailable(true);
|
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,
|
Settings.Secure.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
|
||||||
mDefaultSupplicantScanIntervalMs);
|
defaultInterval);
|
||||||
mWifiNative.setScanInterval((int)supplicantScanIntervalMs / 1000);
|
|
||||||
|
mWifiNative.setScanInterval((int)mSupplicantScanIntervalMs / 1000);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
@ -3273,11 +3282,39 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
} else {
|
} else {
|
||||||
setScanAlarm(true);
|
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
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DBG) log(getName() + message.toString() + "\n");
|
if (DBG) log(getName() + message.toString() + "\n");
|
||||||
|
boolean ret = HANDLED;
|
||||||
switch (message.what) {
|
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:
|
case CMD_SET_SCAN_MODE:
|
||||||
if (message.arg1 == SCAN_ONLY_MODE) {
|
if (message.arg1 == SCAN_ONLY_MODE) {
|
||||||
mWifiNative.setScanResultHandling(message.arg1);
|
mWifiNative.setScanResultHandling(message.arg1);
|
||||||
@ -3304,25 +3341,28 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
|
StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
|
||||||
setNetworkDetailedState(WifiInfo.getDetailedStateOf(stateChangeResult.state));
|
setNetworkDetailedState(WifiInfo.getDetailedStateOf(stateChangeResult.state));
|
||||||
/* ConnectModeState does the rest of the handling */
|
/* ConnectModeState does the rest of the handling */
|
||||||
return NOT_HANDLED;
|
ret = NOT_HANDLED;
|
||||||
|
break;
|
||||||
case CMD_START_SCAN:
|
case CMD_START_SCAN:
|
||||||
/* Disable background scan temporarily during a regular scan */
|
/* Disable background scan temporarily during a regular scan */
|
||||||
if (mEnableBackgroundScan) {
|
if (mEnableBackgroundScan) {
|
||||||
mWifiNative.enableBackgroundScan(false);
|
mWifiNative.enableBackgroundScan(false);
|
||||||
}
|
}
|
||||||
/* Handled in parent state */
|
/* Handled in parent state */
|
||||||
return NOT_HANDLED;
|
ret = NOT_HANDLED;
|
||||||
|
break;
|
||||||
case WifiMonitor.SCAN_RESULTS_EVENT:
|
case WifiMonitor.SCAN_RESULTS_EVENT:
|
||||||
/* Re-enable background scan when a pending scan result is received */
|
/* Re-enable background scan when a pending scan result is received */
|
||||||
if (mEnableBackgroundScan && mScanResultIsPending) {
|
if (mEnableBackgroundScan && mScanResultIsPending) {
|
||||||
mWifiNative.enableBackgroundScan(true);
|
mWifiNative.enableBackgroundScan(true);
|
||||||
}
|
}
|
||||||
/* Handled in parent state */
|
/* Handled in parent state */
|
||||||
return NOT_HANDLED;
|
ret = NOT_HANDLED;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return NOT_HANDLED;
|
ret = NOT_HANDLED;
|
||||||
}
|
}
|
||||||
return HANDLED;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user