Merge "DO NOT MERGE Remove wifistatetracker lock access in BroadcastReceiver" into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
af2d3c7cce
@@ -174,6 +174,8 @@ public class WifiService extends IWifiManager.Stub {
|
||||
private static final int MESSAGE_SET_CHANNELS = 8;
|
||||
private static final int MESSAGE_ENABLE_NETWORKS = 9;
|
||||
private static final int MESSAGE_START_SCAN = 10;
|
||||
private static final int MESSAGE_REPORT_WORKSOURCE = 11;
|
||||
private static final int MESSAGE_ENABLE_RSSI_POLLING = 12;
|
||||
|
||||
|
||||
private final WifiHandler mWifiHandler;
|
||||
@@ -1664,8 +1666,8 @@ public class WifiService extends IWifiManager.Stub {
|
||||
mScreenOff = false;
|
||||
// Once the screen is on, we are not keeping WIFI running
|
||||
// because of any locks so clear that tracking immediately.
|
||||
reportStartWorkSource();
|
||||
mWifiStateTracker.enableRssiPolling(true);
|
||||
sendReportWorkSourceMessage();
|
||||
sendEnableRssiPollingMessage(true);
|
||||
/* DHCP or other temporary failures in the past can prevent
|
||||
* a disabled network from being connected to, enable on screen on
|
||||
*/
|
||||
@@ -1677,7 +1679,7 @@ public class WifiService extends IWifiManager.Stub {
|
||||
Slog.d(TAG, "ACTION_SCREEN_OFF");
|
||||
}
|
||||
mScreenOff = true;
|
||||
mWifiStateTracker.enableRssiPolling(false);
|
||||
sendEnableRssiPollingMessage(false);
|
||||
/*
|
||||
* Set a timer to put Wi-Fi to sleep, but only if the screen is off
|
||||
* AND the "stay on while plugged in" setting doesn't match the
|
||||
@@ -1715,7 +1717,7 @@ public class WifiService extends IWifiManager.Stub {
|
||||
Slog.d(TAG, "got ACTION_DEVICE_IDLE");
|
||||
}
|
||||
mDeviceIdle = true;
|
||||
reportStartWorkSource();
|
||||
sendReportWorkSourceMessage();
|
||||
} else if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
||||
/*
|
||||
* Set a timer to put Wi-Fi to sleep, but only if the screen is off
|
||||
@@ -1821,6 +1823,15 @@ public class WifiService extends IWifiManager.Stub {
|
||||
Message.obtain(mWifiHandler, MESSAGE_ENABLE_NETWORKS).sendToTarget();
|
||||
}
|
||||
|
||||
private void sendReportWorkSourceMessage() {
|
||||
Message.obtain(mWifiHandler, MESSAGE_REPORT_WORKSOURCE).sendToTarget();
|
||||
}
|
||||
|
||||
private void sendEnableRssiPollingMessage(boolean enable) {
|
||||
Message.obtain(mWifiHandler, MESSAGE_ENABLE_RSSI_POLLING, enable ? 1 : 0, 0).sendToTarget();
|
||||
}
|
||||
|
||||
|
||||
private void reportStartWorkSource() {
|
||||
synchronized (mWifiStateTracker) {
|
||||
mTmpWorkSource.clear();
|
||||
@@ -2021,6 +2032,12 @@ public class WifiService extends IWifiManager.Stub {
|
||||
}
|
||||
mWifiStateTracker.scan(forceActive);
|
||||
break;
|
||||
case MESSAGE_REPORT_WORKSOURCE:
|
||||
reportStartWorkSource();
|
||||
break;
|
||||
case MESSAGE_ENABLE_RSSI_POLLING:
|
||||
mWifiStateTracker.enableRssiPolling(msg.arg1 == 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2245,7 +2262,7 @@ public class WifiService extends IWifiManager.Stub {
|
||||
|
||||
// Be aggressive about adding new locks into the accounted state...
|
||||
// we want to over-report rather than under-report.
|
||||
reportStartWorkSource();
|
||||
sendReportWorkSourceMessage();
|
||||
|
||||
updateWifiState();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user