am af2d3c7c: Merge "DO NOT MERGE Remove wifistatetracker lock access in BroadcastReceiver" into gingerbread
* commit 'af2d3c7ccebb009f31a92c1a87b0925a2891e1c4': DO NOT MERGE Remove wifistatetracker lock access in BroadcastReceiver
This commit is contained in:
@@ -174,6 +174,8 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
private static final int MESSAGE_SET_CHANNELS = 8;
|
private static final int MESSAGE_SET_CHANNELS = 8;
|
||||||
private static final int MESSAGE_ENABLE_NETWORKS = 9;
|
private static final int MESSAGE_ENABLE_NETWORKS = 9;
|
||||||
private static final int MESSAGE_START_SCAN = 10;
|
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;
|
private final WifiHandler mWifiHandler;
|
||||||
@@ -1664,8 +1666,8 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
mScreenOff = false;
|
mScreenOff = false;
|
||||||
// Once the screen is on, we are not keeping WIFI running
|
// Once the screen is on, we are not keeping WIFI running
|
||||||
// because of any locks so clear that tracking immediately.
|
// because of any locks so clear that tracking immediately.
|
||||||
reportStartWorkSource();
|
sendReportWorkSourceMessage();
|
||||||
mWifiStateTracker.enableRssiPolling(true);
|
sendEnableRssiPollingMessage(true);
|
||||||
/* DHCP or other temporary failures in the past can prevent
|
/* DHCP or other temporary failures in the past can prevent
|
||||||
* a disabled network from being connected to, enable on screen on
|
* 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");
|
Slog.d(TAG, "ACTION_SCREEN_OFF");
|
||||||
}
|
}
|
||||||
mScreenOff = true;
|
mScreenOff = true;
|
||||||
mWifiStateTracker.enableRssiPolling(false);
|
sendEnableRssiPollingMessage(false);
|
||||||
/*
|
/*
|
||||||
* Set a timer to put Wi-Fi to sleep, but only if the screen is off
|
* 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
|
* 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");
|
Slog.d(TAG, "got ACTION_DEVICE_IDLE");
|
||||||
}
|
}
|
||||||
mDeviceIdle = true;
|
mDeviceIdle = true;
|
||||||
reportStartWorkSource();
|
sendReportWorkSourceMessage();
|
||||||
} else if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
} else if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
||||||
/*
|
/*
|
||||||
* Set a timer to put Wi-Fi to sleep, but only if the screen is off
|
* 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();
|
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() {
|
private void reportStartWorkSource() {
|
||||||
synchronized (mWifiStateTracker) {
|
synchronized (mWifiStateTracker) {
|
||||||
mTmpWorkSource.clear();
|
mTmpWorkSource.clear();
|
||||||
@@ -2021,6 +2032,12 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
}
|
}
|
||||||
mWifiStateTracker.scan(forceActive);
|
mWifiStateTracker.scan(forceActive);
|
||||||
break;
|
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...
|
// Be aggressive about adding new locks into the accounted state...
|
||||||
// we want to over-report rather than under-report.
|
// we want to over-report rather than under-report.
|
||||||
reportStartWorkSource();
|
sendReportWorkSourceMessage();
|
||||||
|
|
||||||
updateWifiState();
|
updateWifiState();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user