summaryrefslogtreecommitdiffstats
path: root/wifi/java/android
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2010-03-23 12:24:33 -0700
committerIrfan Sheriff <isheriff@google.com>2010-03-24 17:59:42 -0700
commit3bf504df9fc1971078fdde7eed418a0dd8f601e2 (patch)
tree8b80810bd70ed9346b43a012e9e357b20b038e2f /wifi/java/android
parent69c997a5c603c3cc56cbfdacd72cbe9993c5f053 (diff)
downloadframeworks_base-3bf504df9fc1971078fdde7eed418a0dd8f601e2.zip
frameworks_base-3bf504df9fc1971078fdde7eed418a0dd8f601e2.tar.gz
frameworks_base-3bf504df9fc1971078fdde7eed418a0dd8f601e2.tar.bz2
Fix WakeLock issue for driver stop
Due to message removal, wakelock could be held forever. Do a timer only based wakelock release until we do this more cleanly in ConnectivityService for later release. Also, add an optimization to prevent use of wakelocks when driver is already stopped. Bug: 2529883 Change-Id: Ia1c2ddd44213ef3aa609855613bf155945bef8e4
Diffstat (limited to 'wifi/java/android')
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java45
1 files changed, 21 insertions, 24 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 80b8aed..4f84aab 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -313,8 +313,6 @@ public class WifiStateTracker extends NetworkStateTracker {
private String mInterfaceName;
private static String LS = System.getProperty("line.separator");
- private Runnable mReleaseWakeLockCallback;
-
private static String[] sDnsPropNames;
/**
@@ -615,7 +613,15 @@ public class WifiStateTracker extends NetworkStateTracker {
}
}
- private synchronized boolean isDriverStopped() {
+ /**
+ * TODO: mRunState is not synchronized in some places
+ * address this as part of re-architect.
+ *
+ * TODO: We are exposing an additional public synchronized call
+ * for a wakelock optimization in WifiService. Remove it
+ * when we handle the wakelock in ConnectivityService.
+ */
+ public synchronized boolean isDriverStopped() {
return mRunState == RUN_STATE_STOPPED || mRunState == RUN_STATE_STOPPING;
}
@@ -674,15 +680,20 @@ public class WifiStateTracker extends NetworkStateTracker {
}
}
+ /**
+ * We release the wakelock in WifiService
+ * using a timer.
+ *
+ * TODO:
+ * Releasing wakelock using both timer and
+ * a call from ConnectivityService requires
+ * a rethink. We had problems where WifiService
+ * could keep a wakelock forever if we delete
+ * messages in the asynchronous call
+ * from ConnectivityService
+ */
@Override
public void releaseWakeLock() {
- if (mReleaseWakeLockCallback != null) {
- mReleaseWakeLockCallback.run();
- }
- }
-
- public void setReleaseWakeLockCallback(Runnable callback) {
- mReleaseWakeLockCallback = callback;
}
/**
@@ -1481,20 +1492,6 @@ public class WifiStateTracker extends NetworkStateTracker {
} else {
return disconnect();
}
- } else {
- /*
- * The "driver-stop" wake lock normally is released from the
- * connectivity manager after the mobile data connection has
- * been established, or after a timeout period, if that never
- * happens. Because WifiService.updateWifiState() can get called
- * multiple times, we can end up acquiring the wake lock and calling
- * disconnectAndStop() even when a disconnect or stop operation
- * is already in progress. In that case, we want to ignore the
- * disconnectAndStop request and release the (ref-counted) wake
- * lock, so that eventually, when the mobile data connection is
- * established, the ref count will drop to zero.
- */
- releaseWakeLock();
}
return true;
}