Thursday, September 8, 2011

Re: [android-developers] What is wavelock in PowerManager API

copied Wakelock documentation below.

Wakelocks
=========

A locked wakelock, depending on its type, prevents the system from entering
suspend or other low-power states. When creating a wakelock, you can select
if it prevents suspend or low-power idle states. If the type is set to
WAKE_LOCK_SUSPEND, the wakelock prevents a full system suspend. If the type
is WAKE_LOCK_IDLE, low-power states that cause large interrupt latencies, or
that disable a set of interrupts, will not be entered from idle until the
wakelocks are released. Unless the type is specified, this document refers
to wakelocks with the type set to WAKE_LOCK_SUSPEND.

If the suspend operation has already started when locking a wakelock, it will
abort the suspend operation as long it has not already reached the suspend_late
stage. This means that locking a wakelock from an interrupt handler or a
freezeable thread always works, but if you lock a wakelock from a suspend_late
handler you must also return an error from that handler to abort suspend.

Wakelocks can be used to allow user-space to decide which keys should wake the
full system up and turn the screen on. Use set_irq_wake or a platform specific
api to make sure the keypad interrupt wakes up the cpu. Once the keypad driver
has resumed, the sequence of events can look like this:
- The Keypad driver gets an interrupt. It then locks the keypad-scan wakelock
and starts scanning the keypad matrix.
- The keypad-scan code detects a key change and reports it to the input-event
driver.
- The input-event driver sees the key change, enqueues an event, and locks
the input-event-queue wakelock.
- The keypad-scan code detects that no keys are held and unlocks the
keypad-scan wakelock.
- The user-space input-event thread returns from select/poll, locks the
process-input-events wakelock and then calls read in the input-event device.
- The input-event driver dequeues the key-event and, since the queue is now
empty, it unlocks the input-event-queue wakelock.
- The user-space input-event thread returns from read. It determines that the
key should not wake up the full system, releases the process-input-events
wakelock and calls select or poll.

Key pressed Key released
| |
keypad-scan ++++++++++++++++++
input-event-queue +++ +++


process-input-events +++ +++


On Thu, Sep 8, 2011 at 3:45 PM, Mark Murphy <mmurphy@commonsware.com> wrote:
On Thu, Sep 8, 2011 at 5:42 PM, Sarath Krishna
<sarathkrishna99@gmail.com> wrote:
> I was reading about PowerManager API . But, I couldn't understand the
> term wavelock.  What is a wavelock? What does it exactly do?

There is no wavelock. There is WakeLock. An acquired WakeLock keeps
the device awake (e.g., CPU powered on), until it is later released.

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

Android Training in NYC: http://marakana.com/training/android/

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Kind Regards,
Pratik Prajapati



--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment

Post a Comment