Commit graph

10 commits

Author SHA1 Message Date
Tri Vo
934f175a42 libpower: RAII wake lock implementation
Main motivation is to prevent wake lock leaks, e.g. b/133175847.

Changing power.h header breaks downstream vendor code that does C
linkage to that header b/135730848. Introduce new wakelock.h header.

Bug: 133175847
Test: boot blueline
Test: device suspends if left alone
Change-Id: I477123938ab20e954ce4d55b8588c0a116ed3882
2019-06-26 13:01:39 -07:00
Ruslan Tkhakokhov
acf23a23e7 Merged-In Revert "libpower: RAII wake lock implementation"
This reverts commit 23009bb199.

Reason for revert: Breaks the build

Change-Id: I347928c4d444f4b1ce9d79f855c171626c0214c0
2019-06-21 10:32:57 +00:00
Tri Vo
23009bb199 libpower: RAII wake lock implementation
Bug: 133175847
Test: boot blueline
Test: device suspends if left alone
Change-Id: I5a63fedabb18a9dcd510ca76303f54ec6c0b7f8c
2019-06-20 09:02:16 -07:00
Tri Vo
3714b98cf5 libpower: add error logs
Bug: 134078730
Test: libpower_test
Change-Id: I35ac20c3f075bb83e61d5fad5bcfd8a1876b0c30
2019-05-31 11:48:17 -07:00
Tri Vo
631215c63a libpower: handle SystemSuspend shutdown on client side.
On device shutdown, it's possible for SystemSuspend to have exited
before its clients. We change libpower to handle this case by checking
DEAD_OBJECT transaction error, so that client can shutdown cleanly.

Fixes: 120292523
Test: libpower_test
Change-Id: Ie43b72f2c326a9dcdc48371c03b4d97d7fd4e12a
2018-12-04 16:22:28 -08:00
Tri Vo
ca0b45a15e Handle concurrent exit and wake lock acquisition.
We use "-Wexit-time-destructors" and "-fno-c++-static-destructors" flags
to make sure that no static variables are destroyed at exit time.

We do this to avoid the race condition between process exit and use of
static vars when calling acquire/release_wake_lock().

Bug: 117575503
Test: libpower_test
Change-Id: I16acfeb2412685e376d8bd1069c86f60f56d215a
2018-11-28 16:04:12 -08:00
Tri Vo
a8742d6851 libpower: try detect memory corruption and abort
Bug: 117575503
Test: device boots
Change-Id: Idf81ad5591c675473624dc4d0a057ae715ed748f
2018-11-16 14:35:13 -08:00
Tri Vo
e1a9a6337f libpower: pass static-duration strong pointer as const reference.
With this change:
1. We avoid constructing a strong pointer on every call to
getSystemSuspendServiceOnce().
2. In case the function static pointer is corrupted, the error
propagates to the API call where we're able to handle the errors instead
of the compiler-generated code in the return statement of
getSystemSuspendServiceOnce().

Bug: 117575503
Test: device builds/boots
Change-Id: I85b5616efca25063c876b242529e2bf561f5b834
2018-10-22 13:29:30 -07:00
Tri Vo
8eb59a0050 Simplify libpower
Changed:
- simplified getting system suspend service
- added isOk() check when releasing a wake lock

Bug: 117575503
Test: presubmit
Change-Id: I78f1f50a7670e7df88e59999c35f99a6df06e8ef
2018-10-16 13:30:58 -07:00
Tri Vo
e0a9c90bf5 libpower: acquire wake locks from SystemSuspend service.
This change routes libpower and libhardware_legacy to SystemSuspend service for
wake locks instead of /sys/power/wake_[un]lock.

Bug: 78888165
Bug: 115946999
Test: /sys/kernel/debug/suspend_stats shows that device suspends if left alone
Change-Id: Id4d392e13d06be6d86e3112dedeb6a57bb24c06f
2018-10-05 17:45:00 -07:00