title: When does the device go to sleep?
body: <p>I saw a great speech from Commonsware's Mark about multithreading and using wakeful services yesterday at AppsWorld London. He recommends using <a href="https://github.com/commonsguy/cwac-wakeful" rel="nofollow">WakefulIntentService</a> or <a href="https://developer.android.com/reference/android/support/v4/content/WakefulBroadcastReceiver.html" rel="nofollow">WakeFulBroadcastReceiver</a> in some situations to ensure your app will be able to continue some long processing and prevent the device to go to sleep.</p>
  
  <p>I have an <a href="https://play.google.com/store/apps/details?id=org.gpo.greenpower" rel="nofollow">app</a> that does some background processing regularly when the device screen is off. I use <a href="http://developer.android.com/reference/android/app/AlarmManager.html" rel="nofollow">AlarmManager</a> to have it get the stuff done regularly.
  Since I have a large user base (200.000 active users), I get to see all kind of weird cases when users send me some logfile. Among others I could see that on some devices after the alarm will be triggered, the app starts doing his job and then suddenly just doesn't do anything for many seconds, or even minutes (no entry in the logfile for a while). I assume this is because the phone goes to sleep.
  What bugs me is that this happens only on some devices, for instance it would happen a lot on Samsung SGS2+, but not on SGS2, SGS3 or SGS4. </p>
  
  <p>So what I'm wondering is: what is the policy to decide when to put the phone to sleep? Is it Android deciding or is it lower at the Linux level?
  How much tweaking from the manufacturer is allowed? Shouldn't the sleep policy be part of the <a href="http://source.android.com/compatibility/" rel="nofollow">Android Compatibility</a> definition?
  Extra question: Are there some levels of being asleep, like several levels of CPU speed, or is it just boolean sleeping / not sleeping?</p>