Android What is difference between device state after screen timeout vs. sleep? - android

What is the exact effect of a screen timeout? Does the device go into sleep mode? What exact state is the device in during screen timeout? If I do Settings.System.putInt(contentResolver, Settings.System.SCREEN_OFF_TIMEOUT, 1); set to one second will this put the device in sleep mode in 1 second? Thanks

First thing of all, you should know that "turning off the screen" != "sleep mode". Since you may listen to some music or download some games with large size while the screen is off, but the CPU is still running to do these jobs, therefore it's not in "sleep mode."
As a result, sleep mode is defined as a mode that the CPU is idle. While the system is in sleep mode, the time spent in this mode is not counted in the device uptime (the device uptime can be obtained by calling SystemClock.uptimeMillis()). Let's answer the questions:
1) Turning off the screen.
2) No.
3) A state that the screen is off.
4) No. Setting screen timeout to one second means that if no action is taken on the device for one second, the device will turn off the screen automatically. Even the screen is turned off, the device is also not in sleep mode.

Related

Android ACTION_SCREEN_OFF intent meaning

In Google documentation about ACTION_SCREEN_OFF they write:
This broadcast is sent when the device becomes non-interactive which may have nothing to do with the screen turning off. To determine the actual state of the screen, use Display.getState().
So I asking when the screen becomes non-interactive and it still turned on.
When you press the power button to lock the screen (or even if the device's screen lights get off, due to inactivity), at that time it goes to a non-interactive state.
And yes, the device will be turned on.

Can't simulate sleep mode on Android emulator

I am trying to put my emulators into sleep mode to test some behavior.
For this, I deactivate the charger, set the battery to "uncharging" and a low battery %. Then I lock the screen over the power button (swipe to unlock is activated).
Then I start some background operation (for example an IntentService) without holding a wake lock and leave the app, but everything just keeps running as if the screen was on.
The emulator seems to not fall into sleep.
Not a duplicate since I am already following these exact steps (as described above)

Does Android have two different sleep modes

When the user presses on the Power button to turn off the screen, at some point Android goes into sleep mode shutting down the CPU. It isn't clear whether this happens immediately or after a period of time. Does the CPU stay fully or partially awake for a duration and then go into a complete sleep mode?
When the user presses the power button, Android goes into screen off mode. Some time after this, the device will go into sleep mode if nothing is kept awake using a Wakelock. The duration of this period is uncertain. See here for more:
https://stackoverflow.com/a/5120225/1369222

Can you programmatically check to determine if your android device is in deep sleep mode?

Can you programmatically check to determine if your android device is in deep sleep mode?
Reason being, if it is, you may obtain a wake lock or a wifi lock... however, is it is not, you wouldn't want to obtain a wifi lock if it is not necessary. Since, I also have a delay created when a wifi lock is obtained in order to allow the device time to connect to the network. If it is not needed, I do not want to get the wifi lock and add a delay.
I got a suggestion for you,
Register to screen off and on, when screen off take a one minute timer, if screen on cancel it, when you got to end of timer do your locks, till screen on again.

Android Sleep/Standby Mode

I have made an app that starts a service, which starts a timer, which fires off a small function after an amount of time. This is working great on the emulator and on the Motorola Droid 1, but it doesn't work on the Droid X when the phone has been put into sleep mode. What I have discovered is that the timer seems to pause when the phone is in sleep. It doesn't seem to do this on the Droid 1, or the emulator. I'm sure the workaround isn't too difficult, so I'm not asking for help(for once) I just want an explanation, to better understand this.
My question is what exactly does "sleep mode" do on android systems? What does it stop, what doesn't it stop, etc. By sleep mode I mean, of course, when you press the power button and the screen goes black. What exactly is happening? Any insight is appreciated.
I'm sure the workaround isn't too difficult
Using AlarmManager is a bit tricky.
My question is what exactly does "sleep mode" do on android systems?
Primarily, it shuts down the CPU. Along the way, non-essential radios (WiFi, GPS) will have been shut down as well.
What does it stop, what doesn't it stop, etc.
About the only thing you can count on not stopping is the GSM or CDMA radio (for incoming calls, SMSes, and IP packets) and AlarmManager.
By sleep mode I mean, of course, when you press the power button and the screen goes black.
Actually, that's not sleep mode, per se. That is the screen turning off.
The device will go into sleep mode shortly thereafter, if nothing is keeping it awake with a WakeLock. However, there is no guarantee that within a millisecond of you pressing that button and the screen turning off that the CPU is off.

Categories

Resources