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