[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)
2 files changed