OSDN Git Service

Clean up certain state transitions in DreamService.
authorJeff Brown <jeffbrown@google.com>
Thu, 3 Apr 2014 03:00:36 +0000 (20:00 -0700)
committerJeff Brown <jeffbrown@google.com>
Thu, 3 Apr 2014 03:17:32 +0000 (20:17 -0700)
commit344812d2f3a9e56cc53a86a8825fb73b16d3c0dd
tree2bb29339748a4071e81b370b6f1590e9788309e9
parentc013eaad574bcb40152d90105d6fbc82293cbb11
Clean up certain state transitions in DreamService.

Instead of posting onDreamingStarted() to a handler from attach(), do
the work immediately.  This ensures that the dream is actually in the
expected state when the callback runs.  Previously it was possible
for the callback to run after detach() occurred which could cause
exceptions and unexpected behavior.  As it happens, there's no need
to post this callback since attach() already runs on the UI thread.

Handle certain races involving the window token lifecycle a little
better.  When the dream manager shuts down a dream, it removes the
window token.  This can happen before the dream completes its attach()
phase in which case a BadTokenException is thrown.  We now handle this
exception and abort the dream in anticipation of receiving a request
to finish it immediately.

Add a safeguard to getDozeHardware() to handle the case where it
might inadvertently be called at the wrong point in the lifecycle.

Bug: 13475612
Bug: 13760290
Change-Id: I9bc9c154370d08d7727b568d398c460a38592099
core/java/android/service/dreams/DreamService.java