Fix window manager policy state when waking from doze.
Once upon a time when the world was fresh and new, the heavens had an easy rhythm. Day and night. Night and day. In the day, the pixel fairies would cavort and play in the bright gardens with narry a mark of shadow or gloom. In the night, they would rest peacefully, dreaming no dreams and knowing no fear. Then one night a fairy dreamed the first dream. At first the dream was peaceful, full of colors and delight, hopes and memories. Then all at once, jarringly, it awoke in bright daylight. The pixel fairy knew fear, for the world had changed and it was unprepared. Time passed and the pixel fairies grew accustomed to their fate, day and night, night and day, sometimes dreaming, until there came a night when a fairy did not sleep. It roamed the land in a dreamless doze, lost and afraid amid a grim haze of grey and darkness. The fairy despaired. It wanted no part of this place. It pretended for a time to be awake but the bright daylight would not come. It pretended for a time to be dreaming but the colors and memories would not come. That is when the fairy wished for oblivion. Then just as suddenly, it awoke in the daylight. It fell to the ground, stunned as if it had forgotten how to walk in the too bright daylight. Though the world again grew softer and kinder in time, the pixel fairies were never the same. For the night is dark and full of terrors. --- It used to be easy. Screen on and screen off could explain almost everything about the state of the device but it's different now with ambient display. We need to be able to wait for all windows to be drawn even in the case where the device is still nominally asleep. In truth, the window manager policy which drives a lot of these interactions is a thicket of outdated assumptions. Added a new method to tell the window manager policy when the screen is being turned off so that it can correctly account for changes to the interactive state (wakeUp and goingToSleep) and screen state (screenTurningOn and screenTurnedOff). Now we can independently poke keyguard during interactive state changes and we can apply screen on blocking during screen state changes. Moved the code which manages screen on blocking (which is what ensures the UI has fully drawn before revealing screen contents) from the power manager to the display manager since the display manager is in a better position to accurately track the state of the screen, particularly when the screen is being turned off. Fixed a bunch of synchronization issues. Previously some work had been moved to a handler without considering what might happen if it became reordered relative to other work happening elsewhere. Documented the desired behavior in the code to prevent this from happening again. There's still a bunch of stuff in here that isn't quite right, particularly the assumption that there's only one screen, but it's good enough for now. Hopefully there aren't too many bugs. Bug: 17605802 Change-Id: Ic7319e09948c8a3cda014d7e169c964a3ad86f14
Loading
Please register or sign in to comment