My background service is sending messages to a local server as fast as possible. Each message takes normally about 30ms. But when the phone is in sleep mode it takes around 400ms-1000ms (screen off with the 'correct' Wifi-policy)
Within my service I'm using the following code to acquire a Wifi-lock and WakeLock.
PowerManager lPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = lPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WakeLockTag");
WifiManager lWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
mWifiLock = lWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "LockTag");
} else {
mWifiLock = lWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "LockTag");
}
mWifiLock.acquire();
mWakeLock.acquire();
Is it possible to get the same performance as when the screen is on?