Restrict FLAG_TURN_SCREEN_ON for untrusted virtual displays

A vulnerability exists where a zero-permission background app can
bypass the TURN_SCREEN_ON permission to repeatedly wake the
physical screen. This is achieved by creating a
TYPE_PRIVATE_PRESENTATION window with FLAG_TURN_SCREEN_ON on a
private virtual display.

Previously, in WindowState.prepareWindowToDisplayDuringRelayout(),
the check for whether a window could turn the screen on would
short-circuit to true if `mActivityRecord` was null. This allowed
non-activity windows on zero-permission virtual displays to bypass
the one-shot restriction (`currentLaunchCanTurnScreenOn`). Because
zero-permission virtual displays fall back to the DEFAULT_DISPLAY_GROUP,
this resulted in waking the physical device screen.

This commit resolves the issue by updating the logic so that the
screen can only be turned on trusted displays.

Bug: 527038637
Test: WindowStateTests
Flag: EXEMPT CVE_FIX
This was autogenerated by MendIt (go/androidmendit)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:adc9ad6a28520b2e48d9bb8f886cc7eb602485ec
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:016293ca006d58c3c3c73c2dcf1c80343b1049cc
Merged-In: I7853a16d44f06c7b4dc5d8e85b5839b3779fcdd2
Change-Id: I7853a16d44f06c7b4dc5d8e85b5839b3779fcdd2
1 file changed