am f897b443: Fix driver stop check

Merge commit 'f897b443fed5c88c6b12e3fa1da72f231db67673' into gingerbread-plus-aosp

* commit 'f897b443fed5c88c6b12e3fa1da72f231db67673':
  Fix driver stop check
This commit is contained in:
Irfan Sheriff
2010-06-16 14:31:54 -07:00
committed by Android Git Automerger

View File

@@ -1483,18 +1483,19 @@ public class WifiStateTracker extends NetworkStateTracker {
* disconnect or stop command was initiated.
*/
public synchronized boolean disconnectAndStop() {
boolean ret = true;;
if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
// Take down any open network notifications
setNotificationVisible(false, 0, false, 0);
mRunState = RUN_STATE_STOPPING;
if (mWifiInfo.getSupplicantState() == SupplicantState.DORMANT) {
return stopDriver();
ret = stopDriver();
} else {
return disconnect();
ret = disconnect();
}
mRunState = RUN_STATE_STOPPING;
}
return true;
return ret;
}
public synchronized boolean restart() {
@@ -1605,7 +1606,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean scan(boolean forceActive) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.scanCommand(forceActive);
@@ -1621,7 +1622,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setScanResultHandling(int mode) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED) {
return false;
}
return WifiNative.setScanResultHandlingCommand(mode);
@@ -1635,7 +1636,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* 00:bb:cc:dd:cc:ff 2412 165 [WPA-EAP-TKIP][WPA2-EAP-CCMP] Net2
*/
public synchronized String scanResults() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return null;
}
return WifiNative.scanResultsCommand();
@@ -1647,7 +1648,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setScanMode(boolean isScanModeActive) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
if (mIsScanModeActive != isScanModeActive) {
@@ -1662,7 +1663,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean disconnect() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.disconnectCommand();
@@ -1674,7 +1675,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean reconnectCommand() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.reconnectCommand();
@@ -1738,7 +1739,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean reassociate() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.reassociateCommand();
@@ -1837,7 +1838,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return RSSI value, -1 on failure
*/
public synchronized int getRssi() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getRssiApproxCommand();
@@ -1849,7 +1850,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return RSSI value, -1 on failure
*/
public synchronized int getRssiApprox() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getRssiApproxCommand();
@@ -1861,7 +1862,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return link speed, -1 on failure
*/
public synchronized int getLinkSpeed() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getLinkSpeedCommand();
@@ -1873,7 +1874,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return MAC address, null on failure
*/
public synchronized String getMacAddress() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return null;
}
return WifiNative.getMacAddressCommand();
@@ -1897,7 +1898,9 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean stopDriver() {
if (mWifiState.get() != WIFI_STATE_ENABLED) {
/* Driver stop should not happen only when supplicant event
* DRIVER_STOPPED has already been handled */
if (mWifiState.get() != WIFI_STATE_ENABLED || mRunState == RUN_STATE_STOPPED) {
return false;
}
return WifiNative.stopDriverCommand();
@@ -1909,7 +1912,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean startPacketFiltering() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.startPacketFiltering();
@@ -1921,7 +1924,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean stopPacketFiltering() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.stopPacketFiltering();
@@ -1946,7 +1949,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setPowerMode(int mode) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.setPowerModeCommand(mode);
@@ -1959,7 +1962,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* the number of channels is invalid.
*/
public synchronized boolean setNumAllowedChannels() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
try {
@@ -1984,7 +1987,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* {@code numChannels} is outside the valid range.
*/
public synchronized boolean setNumAllowedChannels(int numChannels) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
mNumAllowedChannels = numChannels;
@@ -1997,7 +2000,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return channel count, -1 on failure
*/
public synchronized int getNumAllowedChannels() {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getNumAllowedChannelsCommand();
@@ -2013,7 +2016,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setBluetoothCoexistenceMode(int mode) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.setBluetoothCoexistenceModeCommand(mode);
@@ -2027,7 +2030,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @param isBluetoothPlaying whether to enable or disable this mode
*/
public synchronized void setBluetoothScanMode(boolean isBluetoothPlaying) {
if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return;
}
WifiNative.setBluetoothCoexistenceScanModeCommand(isBluetoothPlaying);