History log of /frameworks/base/core/java/android/os/MessageQueue.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3f6405259aab3d9d5bd0a1f6dec98ad27e774f69 15-May-2015 Jeff Brown <jeffbrown@google.com> Rename file descriptor listener API.

Bug: 21039493
Change-Id: I506c429e99528eb04dbda5b28da2ad000d10b467
/frameworks/base/core/java/android/os/MessageQueue.java
dc3eb4bf91d37ce6b8b000a59625a496b64b36fb 06-Mar-2015 Jeff Brown <jeffbrown@google.com> Add support for non-blocking I/O with Looper.

Bug: 10349083
Change-Id: I4a94b1eac53df57c05103913bd593d92b1e062d7
/frameworks/base/core/java/android/os/MessageQueue.java
3d4e7efe37a4b0dfc5807444e8c3b98a28953377 27-Feb-2015 Jeff Brown <jeffbrown@google.com> Move sync barrier methods into MessageQueue.

The methods were previously defined on Looper but on reflection
they actually make more sense on the MessageQueue instead since
the Looper class is primarily concerned with thread lifecycle
rather than the actual messages themselves.

Change-Id: Iff356b94754fc9960774fa17e3eec9604229cba6
/frameworks/base/core/java/android/os/MessageQueue.java
6c7b41adf9e937a66880b8906389760f3fc82a08 26-Feb-2015 Jeff Brown <jeffbrown@google.com> Rename Looper::isIdling() to isPolling() to resolve confusion.

The loop isn't technically idle at this time, it's just checking
whether any file descriptors have pending events. However it's
still a good signal as to whether the loop is alive.

Added a real isIdle() function.

Bug: 19532373
Change-Id: Idd273e8774f469ccafb00d560818cf279dfd6ba6
/frameworks/base/core/java/android/os/MessageQueue.java
9867ed7aa98f5a719db4b50c39a290bc0ef38123 28-Feb-2014 Jeff Brown <jeffbrown@google.com> Detect invalid uses of Message.

Throw an exception when an application attempts to recycle or
resend messages that are still in-use.

Change-Id: I7096e8b7bd5bec41b7b8ef0c798c55ce3db6827e
/frameworks/base/core/java/android/os/MessageQueue.java
ab8643452adcf91781991bce03be26f072311d89 16-Jan-2014 Narayan Kamath <narayan@google.com> Track AArch64 changes from AOSP.

mPtr is now long, not int.

Change-Id: I75297cbef3571f8f0cc02a35a06c1bc1f4fbe416
/frameworks/base/core/java/android/os/MessageQueue.java
5875c94c591e3e10011509cd6a059844316b7f85 16-Jan-2014 Narayan Kamath <narayan@google.com> am 275586aa: am 7471dfc4: am 42defa02: am faa62aac: am 84ee7930: Merge "AArch64: Use long for pointers in android/os/MessageQueue"

* commit '275586aa53889a851e0b739e408896861d76e3a8':
AArch64: Use long for pointers in android/os/MessageQueue
63a37153238d95cf8897939e6d6e8fbc56e9ec7f 10-Jan-2014 Ashok Bhat <ashok.bhat@arm.com> AArch64: Use long for pointers in android/os/MessageQueue

Long is used in android/os/MessageQueue class to store
pointers as native pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: I7e901b8515a5b5e3afe1dadaaf3e5c186955c2a0
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
/frameworks/base/core/java/android/os/MessageQueue.java
b1eb620219de034b28a0130b07ca05140c4ff830 18-Oct-2013 Jeff Brown <jeffbrown@google.com> am 83bf4404: am 3e3296e5: am 82f31701: Merge "Log view root, input and looper state in bug reports." into klp-dev

* commit '83bf440440309a394f792e3d8a6acb98197d9d7c':
Log view root, input and looper state in bug reports.
5182c780a8b42acd46a06d693ab63a0dd78c6d70 16-Oct-2013 Jeff Brown <jeffbrown@google.com> Log view root, input and looper state in bug reports.

Bug: 10948648
Change-Id: I956cce2a0fb516c02f9bbbc021f6238bcb226891
/frameworks/base/core/java/android/os/MessageQueue.java
605839066af9a5825c074e54e3db90cf88a2220a 10-Sep-2013 Jeff Brown <jeffbrown@google.com> Fix crash when Looper used after quit.

Calling Looper.loop() after quit() isn't supported but it shouldn't
crash either.

Bug: 8808624
Change-Id: I73ea54444ed908c2e8964645f4a8cd08b842baac
/frameworks/base/core/java/android/os/MessageQueue.java
013cf847bcfd2828d34dced60adf2d3dd98021dc 07-Sep-2013 Jeff Brown <jeffbrown@google.com> Fix native crash when message queue quits.

Fix a race when quitting the looper's message queue that could
cause the mPtr field to be zeroed out and the native object to
be destroyed while still in use.

This happened due to an optimization that was intended to release
the native looper's file descriptor as soon as the last message
was processed rather than waiting for the finalizer to run.

Bug: 9726217
Change-Id: I695a9a657acfdb3ce65a5737ff20cd11113d15fa
/frameworks/base/core/java/android/os/MessageQueue.java
efa92b2182ab581873aa8e75d596e2e363bd5e6d 03-May-2013 Dianne Hackborn <hackbod@google.com> Cleanup some of the thread merging.

Adds an optimization for checking whether a looper is stuck,
with a new Looper method to see if its thread is currently
idle. This will allow us to put a large number of loopers
in the monitor efficiently, since we generally won't have to
do a context switch on each of them (since most looper threads
spend most of their time idle waiting for work).

Also change things so the system process's main thread
is actually running on the main thread. Because Jeff
asked for this, and who am I to argue? :)

Change-Id: I12999e6f9c4b056c22dd652cb78c2453c391061f
/frameworks/base/core/java/android/os/MessageQueue.java
8b60e4514702edd1eb4b6f2bfc027e04a94369c0 19-Apr-2013 Jeff Brown <jeffbrown@google.com> Fix change of behavior in Looper.quit().

It seems some applications rely on Looper.quit() terminating the
loop immediately without processing all messages. Rather than
risk breaking them, make the safer behavior optional.

Also take care to properly drain the message queue before quitting
so that all of the Message instances are recycled. This may
help release storage sooner in case the Looper doesn't get GC'd
promptly and its remaining queue of undelivered messages sticks
around.

Improve docs on runWithScissors.

Bug: 8596303
Change-Id: I8cbeb6f7a5f6b8e618b5109f87a03defc1486b9f
/frameworks/base/core/java/android/os/MessageQueue.java
024136f57e5f8b4c11a4fe0fd83061eb6d372d26 12-Apr-2013 Jeff Brown <jeffbrown@google.com> Ensure looper quits after all other messages are handled.

Bug: 8596303
Change-Id: Ie8bfbbe810f5ade2afd870c8e675ce1353a80e5d
/frameworks/base/core/java/android/os/MessageQueue.java
67fc67cf3e1dba17b0eae4f3923f3e93a78c7575 01-Apr-2013 Jeff Brown <jeffbrown@google.com> Make MessageQueue and Looper final.

Applications already cannot subclass these classes because
their constructors are not visible.

Change-Id: Id979d86dd05f7bcc888fe4ea499ab9b95d3d5dde
/frameworks/base/core/java/android/os/MessageQueue.java
864693461b6223a995038847591b17abe2de647e 28-Jan-2013 Jeff Brown <jeffbrown@google.com> Optimize Looper JNI code.

Use static native methods.

Release the native looper objects as soon as the Looper quits
instead of waiting until the GC finalizer to take care of it.

Change-Id: I02783e48782a8f972ec2138862f700ade33d8e78
/frameworks/base/core/java/android/os/MessageQueue.java
ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47 24-Apr-2012 Romain Guy <romainguy@google.com> Prevent WebView from crashing when detached from the window
Bug #6365056

WebView enqueues a functor in the hardware renderer to handle
animations and this functor is called at a later time by the
hardware renderer. However, the functor was not removed from
the queue when WebView was removed from the window. This could
cause the hardware renderer to attempt to execute an invalid
functor and lead to a crash.

Change-Id: I9d38e80f3fdc5e29d4d0cdfa1e893c251a954508
/frameworks/base/core/java/android/os/MessageQueue.java
0f85ce3837633a03460a61405087a5d28a4bf955 16-Feb-2012 Jeff Brown <jeffbrown@google.com> Improve MessageQueue sync barrier implementation.

Instead of acquiring and releasing a barrier using an up/down
counter, we post a message to the queue that represents the
barrier. This is a more natural representation of the barrier
and better matches what we want to do with it: stall messages
behind the barrier in the queue while allowing messages earlier
in the queue to run as usual.

Refactored the MessageQueue a little bit to simplify the quit
logic and to better encapsulate the invariant that all
messages within the queue must have a valid target. Messages
without targets are used to represent barriers.

Bug: 5721047
Change-Id: Id297d9995474b5e3f17d24e302c58168e0a00394
/frameworks/base/core/java/android/os/MessageQueue.java
e799cb78b4be61d3882e71c6812fa62c9a83fd5d 14-Feb-2012 Jeff Brown <jeffbrown@google.com> Add a barrier mechanism to the MessageQueue.

The synchronization barrier enables selectively blocking
execution of synchronous messages until the barrier is released.
Asynchronous messages may continue running in the meantime.

The barrier is intended to be used to implement more sophisticated
scheduling policies related to view hierarchy traversals. While
traversals are pending, most messages posted to the message queue
must be held up. This is to satisfy the invariant that traversals
will occur before subsequently posted messages are handled.

The exception to this rule are "asynchronous" messages that represent
external events or interrupts that come from other components such
as VSYNC pulses, input events or sensor events. Because these messages
are typically delivered at arbitrary times, they are independent of
traversals or other typical synchronization boundaries.

Messages can now be flagged as asynchronous to indicate that they
are weakly ordered.

Bug: 5721047
Change-Id: I1446dcfbc896f33b48355adc28967ace8c8c9b9b
/frameworks/base/core/java/android/os/MessageQueue.java
43a17654cf4bfe7f1ec22bd8b7b32daccdf27c09 07-Apr-2011 Joe Onorato <joeo@google.com> Remove the deprecated things from Config.java. These haven't been working since before 1.0.

Change-Id: Ic2e8fa68797ea9d486f4117f3d82c98233cdab1e
/frameworks/base/core/java/android/os/MessageQueue.java
d5da367024c36b317b101fc066a7a4cf992c7d58 10-Oct-2010 Jeff Brown <jeffbrown@google.com> am 22cb4ef8: am d577cfd7: Merge "Switch Looper back to using poll() instead of epoll()." into gingerbread

Merge commit '22cb4ef8ce9c4d5536ac5cee5c40b82bfa56ccc5'

* commit '22cb4ef8ce9c4d5536ac5cee5c40b82bfa56ccc5':
Switch Looper back to using poll() instead of epoll().
415d8c38199e258dfce92cdb0c69e056b3b51ef8 06-Oct-2010 Jeff Brown <jeffbrown@google.com> Switch Looper back to using poll() instead of epoll().

Added a couple of micro-optimizations to avoid calling wake() unnecessarily
and reduce JNI overhead slightly.

Fixed a minor issue where we were not clearing the "next" field of Messages
returned by the MessageQueue so the Message would hold on to its successor
and potentially prevent the GC from collecting it if the message were leaked
somehow.

Change-Id: I488d29417ce0cdd7d0e447cda76ec978ef7f811c
/frameworks/base/core/java/android/os/MessageQueue.java
85c3fe443f7bd06ae0aae6074f4cf2960892cdc0 22-Sep-2010 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of aa522ac8 to master

Change-Id: Ib17ff201e770abc6b9edb58e01f3bb483dc8fa56
ed7393274af2f268fcdede5f1a3d72c9af842b8e 22-Sep-2010 Jeff Brown <jeffbrown@google.com> Simplify and optimize MessageQueue loop.

Avoids allocating new idle handler arrays on each iteration since
we only need one to copy into.
Coalesced the synchronized blocks.
Hoisted the call to Binder.flushPendingCommands() outside of the
synchronized block.

Change-Id: Iabb6b633627954564bdd5d09e696663223407f47
/frameworks/base/core/java/android/os/MessageQueue.java
b3787d57fffbb898f4767f7a94031cafe974a0b0 13-Sep-2010 Jeff Brown <jeffbrown@google.com> am 0f0541e4: am b88102f5: Input dispatcher ANR handling enhancements.

Merge commit '0f0541e40cfef51eb5c3769e53c1aa853b53aaf6'

* commit '0f0541e40cfef51eb5c3769e53c1aa853b53aaf6':
Input dispatcher ANR handling enhancements.
b88102f5b7e51552a3576cf197b4c8cf96f193d1 08-Sep-2010 Jeff Brown <jeffbrown@google.com> Input dispatcher ANR handling enhancements.

This change is essentially a rewrite of the main input dispatcher loop
with the target identification folded in. Since the input dispatcher now
has all of the window state, it can make better decisions about
when to ANR.

Added a .5 second deadline for processing app switch keys. This behavior
predates Gingerbread but had not previously been ported.

Fixed some timing inaccuracies in the ANR accounting that could cause
applications to ANR sooner than they should have.

Added a mechanism for tracking key and motion events that have been
dispatched to a window so that appropriate cancelation events can be
synthesized when recovering from ANR. This change helps to keep
applications in sync so they don't end up with stuck buttons upon
recovery from ANRs.

Added more comments to describe the tricky parts of PollLoop.

Change-Id: I13dffca27acb436fc383980db536abc4d8b9e6f1
/frameworks/base/core/java/android/os/MessageQueue.java
a334e7c72408c4e2805f2427a35d841a60adefc4 24-Aug-2010 Wink Saville <wink@google.com> Allow reliable detection of a message that is in use.

Because the standard Looper.loop code calls Message#recycle it is
imperative that Handler#handleMessage code not attempt to resue
a message it receives. If allowed to do so it will cause bugs that
could be difficult to diagnois.

This change adds Message#flags and uses one bit to reliably detect
a message is in use and throws an error in MessageQueue#enqueueMessage.
This allows early detection of this bug.

Note: This is not new functionality, but the current implementation does
not detect messages that are in use because it uses Message#when != 0
as the detection mechanism. The problem is that a Message#when value of 0
is valid value used to place a message at the front of the queue and is
thus unreliable.

Another option is to change the setting of Message#when in Message#enqueueMessage
so that it is never 0, although that does change subtly a publicly accessible
field.

Yet another option would be to use other fields but all candidates have
similar problems as when in that they are publicly accessible or even
settable such as Message#target.

Change-Id: I040d6e546376f7b1ed1e4daa0d5644cce8bf333a
/frameworks/base/core/java/android/os/MessageQueue.java
ddb2bfeb6e5a383306159672fe81333bf8520776 24-Aug-2010 Jaikumar Ganesh <jaikumar@google.com> Revert "Allow reliable detection of a message that is in use."

This reverts commit 6083d81ce4d67ec632962270fda64ebb9db0d5b1.
Reverting this because it causes runtime to reboot in a loop
if connected to a Bluetooth Headset.

copyFrom() needs to check for the introduced bit too.
/frameworks/base/core/java/android/os/MessageQueue.java
6083d81ce4d67ec632962270fda64ebb9db0d5b1 22-Aug-2010 Wink Saville <wink@google.com> Allow reliable detection of a message that is in use.

Because the standard Looper.loop code calls Message#recycle it is
imperative that Handler#handleMessage code not attempt to resue
a message it receives. If allowed to do so it will cause bugs that
could be difficult to diagnois.

This change adds Message#flags and uses one bit to reliably detect
a message is in use and throws an error in MessageQueue#enqueueMessage.
This allows early detection of this bug.

Note: This is not new functionality, but the current implementation does
not detect messages that are in use because it uses Message#when != 0
as the detection mechanism. The problem is that a Message#when value of 0
is valid value used to place a message at the front of the queue and is
thus unreliable.

Another option is to change the setting of Message#when in Message#enqueueMessage
so that it is never 0, although that does change subtly a publicly accessible
field.

Yet another option would be to use other fields but all candidates have
similar problems as when in that they are publicly accessible or even
settable such as Message#target.

Change-Id: I2df600537700a3fe206678f38bcae7329751c4e5
/frameworks/base/core/java/android/os/MessageQueue.java
7fbdc84e87dd3a0e196b9803bb04495d11e9cb8a 18-Jun-2010 Jeff Brown <jeffbrown@google.com> More native input event dispatching.

Added ANRs handling.
Added event injection.
Fixed a NPE ActivityManagerServer writing ANRs to the drop box.
Fixed HOME key interception.
Fixed trackball reporting.
Fixed pointer rotation in landscape mode.

Change-Id: I50340f559f22899ab924e220a78119ffc79469b7
/frameworks/base/core/java/android/os/MessageQueue.java
46b9ac0ae2162309774a7478cd9d4e578747bfc2 23-Apr-2010 Jeff Brown <jeffbrown@google.com> Native input dispatch rewrite work in progress.

The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.

Includes part of the new input event NDK API. Some details TBD.

To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.

There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.

End-to-end event dispatch mostly works!

To do: event injection, rate limiting, ANRs, testing, optimization, etc.

Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
/frameworks/base/core/java/android/os/MessageQueue.java
fa9e7c05c7be6891a6cf85a11dc635a6e6853078 06-May-2010 Christopher Tate <ctate@google.com> Sketch of Native input for MessageQueue / Looper / ViewRoot

MessageQueue now uses a socket for internal signalling, and is prepared
to also handle any number of event input pipes, once the plumbing is
set up with ViewRoot / Looper to tell it about them as appropriate.

Change-Id: If9eda174a6c26887dc51b12b14b390e724e73ab3
/frameworks/base/core/java/android/os/MessageQueue.java
60d8762413e8daba5f73559786312a9ec5e3b827 17-Dec-2009 Dan Egnor <egnor@google.com> DropBox logging of app & system server crashes.

The crashes are also reported to the event log (and of course the
main logcat, like they always have been). Ordinary Log.e(t,m,e) isn't dropboxed
but there's a new Log.wtf() which always is. (Still @pending in this change.)

Add a hook to IPowerManager to crash the system server on demand
(only for apps with REBOOT permission, since it's basically a restart).
This is not exposed in PowerManager, must be invoked directly -- mostly
this is there so "Bad Behavior" in dev tools can do it.
/frameworks/base/core/java/android/os/MessageQueue.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/os/MessageQueue.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/os/MessageQueue.java
54b6cfa9a9e5b861a9930af873580d6dc20f773c 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/base/core/java/android/os/MessageQueue.java