diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-03-26 14:56:07 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-03-29 12:02:44 -0700 |
commit | b99fe5e622aa5419d80c02e3fab614372f44bc2a (patch) | |
tree | 55017e13c16a4ebe0958af0ce0fc56caff1b2165 | |
parent | ab924c909a516eb71fef7c238a20c7755f8170ed (diff) | |
download | frameworks_base-b99fe5e622aa5419d80c02e3fab614372f44bc2a.zip frameworks_base-b99fe5e622aa5419d80c02e3fab614372f44bc2a.tar.gz frameworks_base-b99fe5e622aa5419d80c02e3fab614372f44bc2a.tar.bz2 |
cherry-pick 288b4ac94571e6f77036831708e7bb7c31874688 into froyo
Killing the WifiWatchdogService thread from
WifiService can cause messages to be handled on
a dead thread. Quit the thread on the broadcast
instead.
A couple of more fixes:
- Do an asynchronous bring up of Wifi. This will
allow WifiWatchdogServiceThread to be immediately
brought up, instead of relying on an update.
- There is no need to listen on supplicant connection
in wifiwatchdog anymore. We kill the thread when
supplicant connection is no more.
Bug: 2546756
Change-Id: I15a188e031bc79856c55aabdd271287b0df0377d
-rw-r--r-- | services/java/com/android/server/WifiService.java | 9 | ||||
-rw-r--r-- | services/java/com/android/server/WifiWatchdogService.java | 14 |
2 files changed, 5 insertions, 18 deletions
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index e4d7623..76e0d74 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -268,7 +268,7 @@ public class WifiService extends IWifiManager.Stub { boolean wifiEnabled = getPersistedWifiEnabled() || testAndClearWifiSavedState(); Slog.i(TAG, "WifiService starting up with Wi-Fi " + (wifiEnabled ? "enabled" : "disabled")); - setWifiEnabledBlocking(wifiEnabled, true, Process.myUid()); + setWifiEnabled(wifiEnabled); } private void updateTetherState(ArrayList<String> available, ArrayList<String> tethered) { @@ -1857,10 +1857,10 @@ public class WifiService extends IWifiManager.Stub { switch (msg.what) { case MESSAGE_ENABLE_WIFI: + setWifiEnabledBlocking(true, msg.arg1 == 1, msg.arg2); if (mWifiWatchdogService == null) { mWifiWatchdogService = new WifiWatchdogService(mContext, mWifiStateTracker); } - setWifiEnabledBlocking(true, msg.arg1 == 1, msg.arg2); sWakeLock.release(); break; @@ -1878,10 +1878,7 @@ public class WifiService extends IWifiManager.Stub { // a non-zero msg.arg1 value means the "enabled" setting // should be persisted setWifiEnabledBlocking(false, msg.arg1 == 1, msg.arg2); - if (mWifiWatchdogService != null) { - mWifiWatchdogService.quit(); - mWifiWatchdogService = null; - } + mWifiWatchdogService = null; sWakeLock.release(); break; diff --git a/services/java/com/android/server/WifiWatchdogService.java b/services/java/com/android/server/WifiWatchdogService.java index e2c523d..87f8a6e 100644 --- a/services/java/com/android/server/WifiWatchdogService.java +++ b/services/java/com/android/server/WifiWatchdogService.java @@ -251,7 +251,6 @@ public class WifiWatchdogService { private void registerForWifiBroadcasts() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); - intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); mContext.registerReceiver(mReceiver, intentFilter); } @@ -276,7 +275,7 @@ public class WifiWatchdogService { /** * Unregister broadcasts and quit the watchdog thread */ - public void quit() { + private void quit() { unregisterForWifiBroadcasts(); mContext.getContentResolver().unregisterContentObserver(mContentObserver); mHandler.removeAllActions(); @@ -1117,9 +1116,6 @@ public class WifiWatchdogService { if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { handleNetworkStateChanged( (NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO)); - } else if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) { - handleSupplicantConnectionChanged( - intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); } else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { handleWifiStateChanged(intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN)); @@ -1153,15 +1149,9 @@ public class WifiWatchdogService { } } - private void handleSupplicantConnectionChanged(boolean connected) { - if (!connected) { - onDisconnected(); - } - } - private void handleWifiStateChanged(int wifiState) { if (wifiState == WifiManager.WIFI_STATE_DISABLED) { - onDisconnected(); + quit(); } else if (wifiState == WifiManager.WIFI_STATE_ENABLED) { onEnabled(); } |