Reset draw state after notifying invisible to activity window

This moves the concept of I69f893a19d6426710bb0b8b0e18f3d2664cb6412
to a more suitable place. Instead of resetting draw state when the
app becomes visible, it is more general when setting app window to
be invisible.

There are 2 cases that could benefit from this:
1. The computation ActivityRecord#updateReportedVisibilityLocked
depends on w.isDrawn(). So ActivityRecord#isReportedDrawn() won't
get stale draw state.

2. ActivityRecord#addStartingWindow checks w.isDrawn() to skip
adding starting window. So it can avoid missing starting window
when launching app again in a short time, e.g. return to home
and click the same app immediately.

Bug: 373023636
Test: atest ActivityRecordTests#testSetVisibility_visibleToInvisible
Flag: com.android.window.flags.reset_draw_state_on_client_invisible

Change-Id: I91ffbd5ce4d014feb667383fda404df23759be89
4 files changed