summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-02-13 14:24:59 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-02-15 00:30:09 +0000
commit4815d6e5a658bb1b301f7724c8e8fff6bc764bba (patch)
tree66f6e6484d239545197d73bcca8ad2505246c981 /wifi
parenteaa7d1835c8691dd656fea99ae3d61b039ebe1b7 (diff)
parent763ef60466ac752a3031719fb86b08486c9946b1 (diff)
downloadframeworks_base-4815d6e5a658bb1b301f7724c8e8fff6bc764bba.zip
frameworks_base-4815d6e5a658bb1b301f7724c8e8fff6bc764bba.tar.gz
frameworks_base-4815d6e5a658bb1b301f7724c8e8fff6bc764bba.tar.bz2
Merge commit 'android-4.2.2_r1' into mr1.1-staging
Conflicts: core/java/android/os/Trace.java core/java/android/widget/Toast.java core/res/res/values-cs/strings.xml core/res/res/values-el/strings.xml core/res/res/values-iw/strings.xml core/res/res/values/config.xml core/res/res/values/symbols.xml media/java/android/media/AudioService.java packages/SystemUI/res/values-sv/strings.xml packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java services/java/com/android/server/NotificationManagerService.java services/java/com/android/server/power/ElectronBeam.java Change-Id: I60b8ddf20a1d7bcf9dc7b1a4ed841aaa4d953294
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java21
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java2
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java16
3 files changed, 29 insertions, 10 deletions
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 5e4f117..e3ef913 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -508,6 +508,10 @@ public class WifiManager {
private Messenger mWifiServiceMessenger;
private final CountDownLatch mConnected = new CountDownLatch(1);
+ private static Object sThreadRefLock = new Object();
+ private static int sThreadRefCount;
+ private static HandlerThread sHandlerThread;
+
/**
* Create a new WifiManager instance.
* Applications will almost always want to use
@@ -1377,9 +1381,14 @@ public class WifiManager {
return;
}
- HandlerThread t = new HandlerThread("WifiManager");
- t.start();
- mHandler = new ServiceHandler(t.getLooper());
+ synchronized (sThreadRefLock) {
+ if (++sThreadRefCount == 1) {
+ sHandlerThread = new HandlerThread("WifiManager");
+ sHandlerThread.start();
+ }
+ }
+
+ mHandler = new ServiceHandler(sHandlerThread.getLooper());
mAsyncChannel.connect(mContext, mHandler, mWifiServiceMessenger);
try {
mConnected.await();
@@ -1995,8 +2004,10 @@ public class WifiManager {
protected void finalize() throws Throwable {
try {
- if (mHandler != null && mHandler.getLooper() != null) {
- mHandler.getLooper().quit();
+ synchronized (sThreadRefLock) {
+ if (--sThreadRefCount == 0 && sHandlerThread != null) {
+ sHandlerThread.getLooper().quit();
+ }
}
} finally {
super.finalize();
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 54b758a..733fb91 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -61,7 +61,7 @@ public class WifiNative {
/* Sends a kill signal to supplicant. To be used when we have lost connection
or when the supplicant is hung */
- public native static boolean killSupplicant();
+ public native static boolean killSupplicant(boolean p2pSupported);
private native boolean connectToSupplicant(String iface);
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 06a8562..67e8ac9 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1964,6 +1964,7 @@ public class WifiStateMachine extends StateMachine {
case CMD_STOP_DRIVER:
case CMD_DELAYED_STOP_DRIVER:
case CMD_DRIVER_START_TIMED_OUT:
+ case CMD_CAPTIVE_CHECK_COMPLETE:
case CMD_START_AP:
case CMD_START_AP_SUCCESS:
case CMD_START_AP_FAILURE:
@@ -2209,6 +2210,13 @@ public class WifiStateMachine extends StateMachine {
loge("Unable to change interface settings: " + ie);
}
+ /* Stop a running supplicant after a runtime restart
+ * Avoids issues with drivers that do not handle interface down
+ * on a running supplicant properly.
+ */
+ if (DBG) log("Kill any running supplicant");
+ mWifiNative.killSupplicant(mP2pSupported);
+
if(mWifiNative.startSupplicant(mP2pSupported)) {
if (DBG) log("Supplicant start successful");
mWifiMonitor.startMonitoring();
@@ -2404,7 +2412,7 @@ public class WifiStateMachine extends StateMachine {
case WifiMonitor.SUP_DISCONNECTION_EVENT:
if (++mSupplicantRestartCount <= SUPPLICANT_RESTART_TRIES) {
loge("Failed to setup control channel, restart supplicant");
- mWifiNative.killSupplicant();
+ mWifiNative.killSupplicant(mP2pSupported);
transitionTo(mDriverLoadedState);
sendMessageDelayed(CMD_START_SUPPLICANT, SUPPLICANT_RESTART_INTERVAL_MSECS);
} else {
@@ -2471,7 +2479,7 @@ public class WifiStateMachine extends StateMachine {
break;
case WifiMonitor.SUP_DISCONNECTION_EVENT: /* Supplicant connection lost */
loge("Connection lost, restart supplicant");
- mWifiNative.killSupplicant();
+ mWifiNative.killSupplicant(mP2pSupported);
mWifiNative.closeSupplicantConnection();
mNetworkInfo.setIsAvailable(false);
handleNetworkDisconnect();
@@ -2625,14 +2633,14 @@ public class WifiStateMachine extends StateMachine {
/* Socket connection can be lost when we do a graceful shutdown
* or when the driver is hung. Ensure supplicant is stopped here.
*/
- mWifiNative.killSupplicant();
+ mWifiNative.killSupplicant(mP2pSupported);
mWifiNative.closeSupplicantConnection();
transitionTo(mDriverLoadedState);
break;
case CMD_STOP_SUPPLICANT_FAILED:
if (message.arg1 == mSupplicantStopFailureToken) {
loge("Timed out on a supplicant stop, kill and proceed");
- mWifiNative.killSupplicant();
+ mWifiNative.killSupplicant(mP2pSupported);
mWifiNative.closeSupplicantConnection();
transitionTo(mDriverLoadedState);
}