Turn off synthetic VSYNC when adjusting thread scheduling for performance

* This CL explicitly sets synthetic VSYNC state based on the new power state. Before, the synthetic VSYNC state was assumed based on the previous power state and in some cases was not set explicitly.
* The previous behaviour of enabling synthetic VSYNC if the only display is DOZE_SUSPEND is preserved.
* This also fixes a hypothetical gap where it would not optimise for performance if there were a display that needed it, while the primary display was DOZE_SUSPEND.

setPhysicalDisplayPowerMode now applies optimiation policy for any
internal display power mode change (external displays are out of scope
in this CL). This is necessary for foldables since the active display
has not always been updated at that point.

(This includes undoing commit 92bf32ae411fe7bc124e891e1fd9efe18b019742,
fixing the issue it caused, and adding an additional flag)

Bug: 406147398

Bug: 342681202

Bug: 404073995

Flag: android.companion.virtualdevice.flags.correct_virtual_display_power_state

Flag: com.android.graphics.surfaceflinger.flags.disable_synthetic_vsync_for_performance

Test: ran failing tests (https://android-build.corp.google.com/builds/abtd/run/L41000030010571741) and SurfaceFlinger unit tests. Also verified logs include the call to applyOptimizationPolicy and SurfaceFlinger dumpsys not showing display in synthetic VSYNC when powered on.

Change-Id: I4ffcb42379fa97546ad307f8077455495382e878
8 files changed