• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/hardware/interfaces


Commit MetaInfo

Revisão0dbe3f326dec3d8378c27b19892d681a89a848e4 (tree)
Hora2018-12-21 06:11:35
AutorTri Vo <trong@goog...>
CommiterTri Vo

Mensagem de Log

Handle /sys/power/* interfaces not being available.

If either /sys/power/wakeup_count or /sys/power/state fail to open, we
construct SystemSuspend with blocking fds. This way this process will
keep running, handle wake lock requests, collect stats, but won't
suspend the device.

We want this behavior on devices (hosts) where system suspend should not
be handles by Android platform e.g. ARC++, Android virtual devices.

Bug: 118637369
Test: Remove system.suspend access to /sys/power/{ wakeup_count state }
using SELinux. Device still boots and doesn't suspend.
Change-Id: I068a584ada6968520219ee5288f598a53aa48c68

Mudança Sumário

Diff

--- a/suspend/1.0/default/main.cpp
+++ b/suspend/1.0/default/main.cpp
@@ -4,6 +4,7 @@
44 #include <cutils/native_handle.h>
55 #include <hidl/HidlTransportSupport.h>
66
7+#include <sys/socket.h>
78 #include <sys/stat.h>
89 #include <sys/types.h>
910
@@ -12,6 +13,7 @@
1213
1314 using android::sp;
1415 using android::status_t;
16+using android::base::Socketpair;
1517 using android::base::unique_fd;
1618 using android::hardware::configureRpcThreadpool;
1719 using android::hardware::joinRpcThreadpool;
@@ -26,12 +28,20 @@ int main() {
2628 unique_fd wakeupCountFd{TEMP_FAILURE_RETRY(open(kSysPowerWakeupCount, O_CLOEXEC | O_RDWR))};
2729 if (wakeupCountFd < 0) {
2830 PLOG(ERROR) << "error opening " << kSysPowerWakeupCount;
29- return 1;
3031 }
3132 unique_fd stateFd{TEMP_FAILURE_RETRY(open(kSysPowerState, O_CLOEXEC | O_RDWR))};
3233 if (stateFd < 0) {
3334 PLOG(ERROR) << "error opening " << kSysPowerState;
34- return 1;
35+ }
36+
37+ // If either /sys/power/wakeup_count or /sys/power/state fail to open, we construct
38+ // SystemSuspend with blocking fds. This way this process will keep running, handle wake lock
39+ // requests, collect stats, but won't suspend the device. We want this behavior on devices
40+ // (hosts) where system suspend should not be handles by Android platform e.g. ARC++, Android
41+ // virtual devices.
42+ if (wakeupCountFd < 0 || stateFd < 0) {
43+ // This will block all reads/writes to these fds from the suspend thread.
44+ Socketpair(SOCK_STREAM, &wakeupCountFd, &stateFd);
3545 }
3646
3747 configureRpcThreadpool(1, true /* callerWillJoin */);