[RESTRICT AUTOMERGE] Update the visibility of activities on sleeping display

Activity with showWhenLocked flag is visible when screen is off and
leads to activity restart called.

This CL update the visibility condition for showWhenLocked and
dismisskeyguard activities and refer the keyguard visibility to
ensure the function works as expected.

Bug: 161036653
Test: atest ActivityRecordTests
      atest CtsWindowManagerDeviceTestCases:KeyguardTests
      atest CtsWindowManagerDeviceTestCases:KeyguardLockedTests

Change-Id: I9d56e40de964e9d11193fec7008f8d880028ac50
(cherry picked from commit 73d6c7926d2cdc39de617f7213fc85f303501f37)
(cherry picked from commit 31fc73a70719ed9a07a9a865c71b602e2fd0c53e)
(cherry picked from commit 1e8e7a94872de70aa6e661fe960854e01447b1c0)
2 files changed