6

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?

Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50

1 Answers1

0

As far my information, there is known issue - Some devices are not reliable with combination of PARTIAL_WAKE_LOCK and WifiLock:WIFI_MODE_FULL_HIGH_PERF .

It does not work well when screen is OFF.

You can further check with SCREEN_DIM_WAKE_LOCK on that particular device.

Jambaaz
  • 2,788
  • 1
  • 19
  • 30