On quiescent boot, report screenTurningOff, skip screenTurningOn

Fixes an issue where ActivityStacks were resumed while the screen was
off and PowerManager wakefulness was asleep after a quiescent boot.

To keep ActivityStacks paused, PhoneWindowManager acquires a "sleep
token". In #screenTurningOff, this token is acquired, and
in #screenTurningOn it is released.

Before, PhoneWindowManager#systemBooted always called #screenTurningOn.
In a quiescent boot, this led to the sleep token being released and
ActivityStacks being resumed, even though the screen did not actually
turn on.

With this change, DisplayPowerController calls #screenTurningOff during
a quiescent boot, acquiring the sleep token, and #systemBooted skips
calling #screenTurningOn, preventing the sleep token from being released
again.
To finish up boot, #enableScreen is called (last part
of #finishScreenTurningOn), which stops the boot animation process,
signals SurfaceFlinger and ActivityManager that boot has completed.

Bug: 171827143
Test: atest QuiescentBootTests#testQuiescentBoot_activitiesNotResumedAfterBoot
Test: adb reboot quiescent
      adb shell dumpsys power: Verify wakefulness asleep
      adb shell dumpsys activity activities:
        Verify stack is sleeping (isSleeping=true),
        state is STOPPED (state=STOPPED)
Change-Id: Ieb0b805c33b3da4261856b724f32412c2660f4c9
2 files changed