summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2010-10-14 17:01:27 -0700
committerIrfan Sheriff <isheriff@google.com>2010-10-20 12:04:21 -0700
commit4f5f7c968339a83b6af98ac8893a1ac33c7aa7bc (patch)
tree1bf9e2f1548ba3db07defb52d38d11ca784fd2ca /wifi
parent92f987a07a0b2d03a769a8b5fc57fe97a7bd7541 (diff)
downloadframeworks_base-4f5f7c968339a83b6af98ac8893a1ac33c7aa7bc.zip
frameworks_base-4f5f7c968339a83b6af98ac8893a1ac33c7aa7bc.tar.gz
frameworks_base-4f5f7c968339a83b6af98ac8893a1ac33c7aa7bc.tar.bz2
Fix wake and scan behavior
- Add wakelock for driver start/stop to ensure a wifilock acquisition kick starts driver. Also cleaned up state machine driver start/stop behavior. - Add periodic scans when driver is started to ensure wifi reconnections when wifilock exists or when user chooses never to sleep - some minor clean up Change-Id: I844eb70491d5aa2f8c8933b3d8dd01ba237ee534
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java50
1 files changed, 28 insertions, 22 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 3a9d272..f2fdbad 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -132,8 +132,8 @@ public class WifiStateMachine extends HierarchicalStateMachine {
private LinkProperties mLinkProperties;
- // Held during driver load and unload
- private static PowerManager.WakeLock sWakeLock;
+ // Wakelock held during wifi start/stop and driver load/unload
+ private PowerManager.WakeLock mWakeLock;
private Context mContext;
@@ -469,7 +469,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
};
PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
- sWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
addState(mDefaultState);
addState(mInitialState, mDefaultState);
@@ -624,11 +624,11 @@ public class WifiStateMachine extends HierarchicalStateMachine {
* TODO: doc
*/
public void setDriverStart(boolean enable) {
- if (enable) {
- sendMessage(CMD_START_DRIVER);
- } else {
- sendMessage(CMD_STOP_DRIVER);
- }
+ if (enable) {
+ sendMessage(CMD_START_DRIVER);
+ } else {
+ sendMessage(CMD_STOP_DRIVER);
+ }
}
/**
@@ -951,6 +951,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
mReportedRunning = false;
}
}
+ mWakeLock.setWorkSource(newSource);
} catch (RemoteException ignore) {
}
}
@@ -1678,7 +1679,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
*/
new Thread(new Runnable() {
public void run() {
- sWakeLock.acquire();
+ mWakeLock.acquire();
//enabling state
switch(message.arg1) {
case WIFI_STATE_ENABLING:
@@ -1704,7 +1705,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
}
sendMessage(CMD_LOAD_DRIVER_FAILURE);
}
- sWakeLock.release();
+ mWakeLock.release();
}
}).start();
}
@@ -1802,7 +1803,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
new Thread(new Runnable() {
public void run() {
if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
- sWakeLock.acquire();
+ mWakeLock.acquire();
if(WifiNative.unloadDriver()) {
Log.d(TAG, "Driver unload successful");
sendMessage(CMD_UNLOAD_DRIVER_SUCCESS);
@@ -1832,7 +1833,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
break;
}
}
- sWakeLock.release();
+ mWakeLock.release();
}
}).start();
}
@@ -1936,7 +1937,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
checkIsBluetoothPlaying();
sendSupplicantConnectionChangedBroadcast(true);
- transitionTo(mDriverSupReadyState);
+ transitionTo(mDriverStartedState);
break;
case SUP_DISCONNECTION_EVENT:
Log.e(TAG, "Failed to setup control channel, restart supplicant");
@@ -2004,11 +2005,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
transitionTo(mDriverLoadedState);
sendMessageAtFrontOfQueue(CMD_START_SUPPLICANT); /* restart */
break;
- case CMD_START_DRIVER:
- EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what);
- WifiNative.startDriverCommand();
- transitionTo(mDriverStartingState);
- break;
case SCAN_RESULTS_EVENT:
setScanResults(WifiNative.scanResultsCommand());
sendScanResultsAvailableBroadcast();
@@ -2185,12 +2181,11 @@ public class WifiStateMachine extends HierarchicalStateMachine {
mNumAllowedChannels = message.arg1;
WifiNative.setNumAllowedChannelsCommand(message.arg1);
break;
- case CMD_START_DRIVER:
- /* Ignore another driver start */
- break;
case CMD_STOP_DRIVER:
+ mWakeLock.acquire();
WifiNative.stopDriverCommand();
transitionTo(mDriverStoppingState);
+ mWakeLock.release();
break;
case CMD_REQUEST_CM_WAKELOCK:
if (mCm == null) {
@@ -2266,7 +2261,18 @@ public class WifiStateMachine extends HierarchicalStateMachine {
@Override
public boolean processMessage(Message message) {
if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
- return NOT_HANDLED;
+ switch (message.what) {
+ case CMD_START_DRIVER:
+ mWakeLock.acquire();
+ WifiNative.startDriverCommand();
+ transitionTo(mDriverStartingState);
+ mWakeLock.release();
+ break;
+ default:
+ return NOT_HANDLED;
+ }
+ EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what);
+ return HANDLED;
}
}