Synchronize calls to updateDoze

And hold a lock when updating doze
screen state and doze brightness changes.

So updates from different threads are always
ordered to ensure the latest information
is sent to DreamManagerService.

This is more robust than volatile because the actual IPC
call to mDreamManager could still be called out of order if
the calls to DreamManager aren't synchronized.

Fixes: 358578071
Flag: EXEMPT bugfix
Test: manually request display and brightness changes
from separate threads; latest requested values get
sent to DreamManagerService

(cherry picked from commit a7b30e3c6aa47b2511f06fd603b55ba43c1bb1d7)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:959dd616056f8f3a1957259f5fd3093eeb514036)
Merged-In: I0377cce2aa4d30db3850ed98b9f5f6aa050fec49
Change-Id: I0377cce2aa4d30db3850ed98b9f5f6aa050fec49
1 file changed