[android-developers] Re: Sleep mode

2012-04-02 Thread Chris Stratton
On Tuesday, April 3, 2012 12:03:02 AM UTC-4, Put_tiMe wrote:
>
> So according to Dianne's post, CPU is indeed completely switched off.
> And in Android, there is no CPU under clock mode.
> And it can be woken up only by external interrupts. Got that.
>  
> But then how does Alarm-manager timers work?
> Is it some kind of delayed interrupt or something like that? i.e an 
> interrupt that will be raised after some time???
> I thought at least the alarm-manager will need the CPU running.
>

Most embedded chips, especially those intended for battery powered systems, 
have various peripherals such as timers external to the cpu core which can 
continue to operate even when the cpu core is powered down.

In the chips used in most contemporary smartphones, one of those 
"peripherals" is actually an entire additional arm processor core, charged 
with running the radio and other things such as low level audio and button 
I/O.  The power state of that processor is quite independent of the power 
state of the application arm processor which runs the Linux kernal, android 
stack, and SDK apps, so checking in with the mobile network infrastructure 
does not involve waking up the application processor.  (Depending on your 
perspective, the argument could be made that the radio processor is 
actually the heart of the system, with the application processor just being 
a fancy peripheral charged with entertaining the user...)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Sleep mode

2012-04-02 Thread Chris Stratton
On Monday, April 2, 2012 9:35:28 AM UTC-4, Dan wrote:
>
> the question is what do you do to get the device to try to go to a 
> state 
> of CPU/SCREEN/KEYBOARD all Off. 
>

You (as an application developer) don't.  You merely insure that your code 
isn't what is keeping it from doing so.   

You have no control over what other installed apps might be doing, or how 
rapidly the particular system software will descend into suspend states 
once no application is preventing it from doing so.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Sleep mode

2012-04-02 Thread Put_tiMe
Sorry, I missed Dianne's post above.
 
So according to Dianne's post, CPU is indeed completely switched off.
And in Android, there is no CPU under clock mode.
And it can be woken up only by external interrupts. Got that.
 
But then how does Alarm-manager timers work?
Is it some kind of delayed interrupt or something like that? i.e an 
interrupt that will be raised after some time???
I thought at least the alarm-manager will need the CPU running.
 
 
 

On Tuesday, April 3, 2012 9:19:12 AM UTC+5:30, Put_tiMe wrote:

> Ok, to clear some confusion, does CPU off means that CPU is completely 
> switched off, or is it run at a low clock rate?
>  
> If CPU is completely off, then how does the AlarmManager even work, and 
> how does the phone receive an incoming call or an SMS?
>  
> I'm sure CPU will be required to run some basic OS services, right? Like 
> the phone and SMS, and the alarm-manager itself.
>  
>  
>
> On Monday, April 2, 2012 7:05:28 PM UTC+5:30, Dan wrote:
>
>>
>>
>> On Mar 30, 10:06 pm, Dianne Hackborn  wrote: 
>> > On Android "sleep mode" is the screen being off.  What do you mean by 
>> > "sleep mode"? 
>>
>> Given the nice chart of CPU/Screen/Keyboard states at: 
>>
>> http://developer.android.com/reference/android/os/PowerManager.html 
>>
>> If having PARTIAL_WAKE_LOCK held allows the screen to go off (and you 
>> want to say 'On Android "sleep mode" is the screen being off'), what 
>> do you call the state that device will go into if PARTIAL_WAKE_LOCK 
>> is not held? 
>>
>> Once we have the name agreed upon (for conversation, since it can only 
>> be reached if some form of WAKE_LOCK is not held, let's say "not 
>> awake") 
>> the question is what do you do to get the device to try to go to a 
>> state 
>> of CPU/SCREEN/KEYBOARD all Off. 
>>
>> Dan Schmitt
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Sleep mode

2012-04-02 Thread Put_tiMe
Ok, to clear some confusion, does CPU off means that CPU is completely 
switched off, or is it run at a low clock rate?
 
If CPU is completely off, then how does the AlarmManager even work, and how 
does the phone receive an incoming call or an SMS?
 
I'm sure CPU will be required to run some basic OS services, right? Like 
the phone and SMS, and the alarm-manager itself.
 
 

On Monday, April 2, 2012 7:05:28 PM UTC+5:30, Dan wrote:

>
>
> On Mar 30, 10:06 pm, Dianne Hackborn  wrote: 
> > On Android "sleep mode" is the screen being off.  What do you mean by 
> > "sleep mode"? 
>
> Given the nice chart of CPU/Screen/Keyboard states at: 
>
> http://developer.android.com/reference/android/os/PowerManager.html 
>
> If having PARTIAL_WAKE_LOCK held allows the screen to go off (and you 
> want to say 'On Android "sleep mode" is the screen being off'), what 
> do you call the state that device will go into if PARTIAL_WAKE_LOCK 
> is not held? 
>
> Once we have the name agreed upon (for conversation, since it can only 
> be reached if some form of WAKE_LOCK is not held, let's say "not 
> awake") 
> the question is what do you do to get the device to try to go to a 
> state 
> of CPU/SCREEN/KEYBOARD all Off. 
>
> Dan Schmitt

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Sleep mode

2012-04-02 Thread Dianne Hackborn
If you want to talk about anything you explicitly go into as a low-power
"sleep mode" state, that would be turning off the screen.

Once you are in this state (the screen is off), then the CPU *may* no
longer need to run, but Android does not have an explicit switch to go into
a lower-power "CPU not running" mode.

Holding a wake lock tells the system that you need to keep the CPU running.
 Once no more wake locks are held, the CPU is stopped; at that point, the
only way it can be restarted is by an external interrupt such as from
incoming network data, a timer going of (typically scheduled by the
AlarmManager), certain hardware buttons being pressed, etc.

There are of course all kinds of power management levels going on within
these states -- for example CPU stepping levels depending on the amount of
work the CPU needs to do, many CPUs can go into a "power collapse" state
when there is a wake lock held but the CPU is waiting for work to do, etc.

On Mon, Apr 2, 2012 at 3:16 PM, Dan  wrote:

>
>
> On Apr 2, 9:56 am, Mark Murphy  wrote:
> > On Mon, Apr 2, 2012 at 9:50 AM, Dan  wrote:
> > >> > On screen-off, i.e. when it hits the sleep mode, are the wifi
> radios and CPU
> > >> > disabled/switched-off?
> >
> > >> The CPU stops running.
> >
> > > This is demonstrably wrong, as you can have a PARTIAL_WAKE_LOCK held
> > > and not have the screen on (or even just have ADB gathering logs even
> > > after the short/long power button press to turn the screen off.)
> >
> > The question was "when it hits the sleep mode", and a
> > PARTIAL_WAKE_LOCK prohibits the device from reaching sleep mode.
>
> Note that even without the PARTIAL_WAKE_LOCK held, on many devices
> there is a period where the CPU is still active after the screen goes
> blank (call it PARTIAL_WAKE without the lock held) which makes
> defining
> a test case to be sure that a particular device will "do the right
> thing when an alarm goes off while the CPU is not running" difficult.
>
> > That being said, I neglected to correct the OP on equating "screen
> > off" with "hits the sleep mode", and for that I apologize.
>
> Given Dianne's view of:
>
> > On Android "sleep mode" is the screen being off.  What do you mean by
> > "sleep mode"?
>
> it's easy to see how the OP might have made that assumption.  I
> apologize
> for my tone as well, I've been fighting with issues on some firmware
> where a PendingIntent fed an Intent that has had the class set with
> Intent.setClass() doesn't make it from the AlarmManager to my receiver
> and was hoping for an answer that would make how to test this sort of
> thing easy instead of "we don't acknowledge any difference between
> screen off and cpu off".
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Sleep mode

2012-04-02 Thread Dan


On Apr 2, 9:56 am, Mark Murphy  wrote:
> On Mon, Apr 2, 2012 at 9:50 AM, Dan  wrote:
> >> > On screen-off, i.e. when it hits the sleep mode, are the wifi radios and 
> >> > CPU
> >> > disabled/switched-off?
>
> >> The CPU stops running.
>
> > This is demonstrably wrong, as you can have a PARTIAL_WAKE_LOCK held
> > and not have the screen on (or even just have ADB gathering logs even
> > after the short/long power button press to turn the screen off.)
>
> The question was "when it hits the sleep mode", and a
> PARTIAL_WAKE_LOCK prohibits the device from reaching sleep mode.

Note that even without the PARTIAL_WAKE_LOCK held, on many devices
there is a period where the CPU is still active after the screen goes
blank (call it PARTIAL_WAKE without the lock held) which makes
defining
a test case to be sure that a particular device will "do the right
thing when an alarm goes off while the CPU is not running" difficult.

> That being said, I neglected to correct the OP on equating "screen
> off" with "hits the sleep mode", and for that I apologize.

Given Dianne's view of:

> On Android "sleep mode" is the screen being off.  What do you mean by
> "sleep mode"?

it's easy to see how the OP might have made that assumption.  I
apologize
for my tone as well, I've been fighting with issues on some firmware
where a PendingIntent fed an Intent that has had the class set with
Intent.setClass() doesn't make it from the AlarmManager to my receiver
and was hoping for an answer that would make how to test this sort of
thing easy instead of "we don't acknowledge any difference between
screen off and cpu off".

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Sleep mode

2012-04-02 Thread Mark Murphy
On Mon, Apr 2, 2012 at 9:50 AM, Dan  wrote:
>> > On screen-off, i.e. when it hits the sleep mode, are the wifi radios and 
>> > CPU
>> > disabled/switched-off?
>>
>> The CPU stops running.
>
> This is demonstrably wrong, as you can have a PARTIAL_WAKE_LOCK held
> and not have the screen on (or even just have ADB gathering logs even
> after the short/long power button press to turn the screen off.)

The question was "when it hits the sleep mode", and a
PARTIAL_WAKE_LOCK prohibits the device from reaching sleep mode.

That being said, I neglected to correct the OP on equating "screen
off" with "hits the sleep mode", and for that I apologize.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.7 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Sleep mode

2012-04-02 Thread Dan


On Mar 31, 10:29 am, Mark Murphy  wrote:
> On Sat, Mar 31, 2012 at 10:18 AM, Put_tiMe  wrote:
> > On some devices, like the Sony Erricson Experia, if I long press the power
> > button, I get a UI menu, with a sleep mode option.
>
> > What would be the difference between that sleep mode and the screen-off
> > sleep mode?
>
> Nothing. That option is in the menu in case you accidentally
> long-pressed the power button instead just pressing it.
>
> > On screen-off, i.e. when it hits the sleep mode, are the wifi radios and CPU
> > disabled/switched-off?
>
> The CPU stops running.

This is demonstrably wrong, as you can have a PARTIAL_WAKE_LOCK held
and not have the screen on (or even just have ADB gathering logs even
after the short/long power button press to turn the screen off.)

The only thoughts I've had on being able to reliably say "I've tested
my AlarmManager/Wake Lock code across Screen/CPU states for device X"
is to have a non wake lock holding thread that stores a heart beat
value somewhere and compares that to the last one (and if the distance
is more than expected, you can guess that the OS let the CPU stop.)

If your alarm code repeatedly works during a period where the heart
beat was not running, it's probably good.  You should probably test
on a clean device in airplane mode, with all the "background update"
options that you can find set to never, and check the output of
"adb shell dumpsys alarm" to see if your test case just got lucky
and somebody else had an alarm that went off and let you do your
things for a few cycles, or if your alarm code really did wake you
up when you wanted.  If it was production code I'd really want to
test against each of the OEM flavoring (Sense/Blur/Touch etc) because
things like HTC's fast-boot power saving modes won't act the same
as a stock Nexus S on AOSP.

> WiFi behavior will vary by device and user preference. This was
> discussed recently:

And the Radio processor can be a different story as well.

   Dan Schmitt

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Sleep mode

2012-04-02 Thread Dan


On Mar 30, 10:06 pm, Dianne Hackborn  wrote:
> On Android "sleep mode" is the screen being off.  What do you mean by
> "sleep mode"?

Given the nice chart of CPU/Screen/Keyboard states at:

http://developer.android.com/reference/android/os/PowerManager.html

If having PARTIAL_WAKE_LOCK held allows the screen to go off (and you
want to say 'On Android "sleep mode" is the screen being off'), what
do you call the state that device will go into if PARTIAL_WAKE_LOCK
is not held?

Once we have the name agreed upon (for conversation, since it can only
be reached if some form of WAKE_LOCK is not held, let's say "not
awake")
the question is what do you do to get the device to try to go to a
state
of CPU/SCREEN/KEYBOARD all Off.

Dan Schmitt

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Sleep mode

2009-10-31 Thread Anders Feder
Anyone? If it can't be done in any other way, is there by any chance any way
to emulate that the 'end call' button has been pressed? (I've tried with
dispatchKeyEvent() to my own activity, but that didn't do anything.)

Thanks,
Anders Feder

2009/10/24 Anders Feder 

> Hello,
>
> Is it possible to programmaticly send the device into sleep mode (i.e. like
> when pressing the [end call] button once so screen the turns off and locks)?
>
> Thanks in advance,
> Anders Feder
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Sleep mode in emulator

2009-04-06 Thread David Turner
no, it can't really do that right now.

On Mon, Apr 6, 2009 at 6:15 PM, samurai00...@gmail.com <
samurai00...@gmail.com> wrote:

>
> Is the actual version of the emulator able to reproduce the sleep
> mode? (Android 1.1 SDK r_1)
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Sleep mode in emulator

2009-04-06 Thread samurai00...@gmail.com

Sorry, I meant 'current version' instead of 'actual version'. My poor
English skills...

On 6 abr, 18:15, "samurai00...@gmail.com" 
wrote:
> Is the actual version of the emulator able to reproduce the sleep
> mode? (Android 1.1 SDK r_1)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---