Wakelock acquisition can fail if suspend service is not available.
Make this clear by returning an optional value that client must
check before entering wakelock critical sections.
Bug: b/179229598
Test: Boot test on Pixel 4 device
Change-Id: Ied00fa919c20d8a30f1c40ee34a91a2a7e240689
For verification of blocked suspend or other unit testing, the spinloop
is fine. However, making it sleep so that it is more viable to assist
with power testing or for any other test where avoiding changes to
device performance is important.
Bug: N/A
Test: run, and ps:
root 4179 4168 18720 4724 __se_sys_nanosleep_time32 0 S block_suspend
Change-Id: I81545ae7db1c1fad2cb94d00456d1a6773868111
Bug: 143284916
Test: ./block_suspend; dumpsys suspend_control shows that wakelocks are
created as expected
Change-Id: Ifacb4f476632e0c36f7ec4f59164f91e89faf1f1