HeadsUpManager: escalate via wakefulness lifecycle instead of broadcast

Fixes an issue where heads up notifications were escalated too late,
which caused notifications not to show on ambient display if they came
in after the device started dozing but before the SCREEN_OFF intent came
in.

Instead, we now escalate when we start going to sleep.

Note that SCREEN_OFF is dispatched on the wakefulness lifecycle, not the screen
lifecycle.

Change-Id: Ied73161d1007d1c65c31e8c5a6f660124a1f4385
Fixes: 63992199
Test: Receive notification right when the display turns off. Make sure AOD does not show in a weird state.
1 file changed