Protects query pulse reason exception

Checks the machine is currently in one of the pulse states before
query the current pulse reason. Avoid incorrect undocked event cause
DozeService crash. And refines test case and javadoc.

Bug: 120464108
Test: atest SystemUITests
Test: manual
Change-Id: I3595217984ec7982de1f0f53765e7ae0a9d80fcf
3 files changed