• 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ão5617a944cac2d498e2100d24a2e89d87bd5878d7 (tree)
Hora2018-12-22 08:46:15
AutorTri Vo <trong@goog...>
Commiterandroid-build-merger

Mensagem de Log

Handle /sys/power/* interfaces not being available. am: 0dbe3f326d
am: 155dc360a8

Change-Id: I6608aaa31c5e355ebad1b1b0cb35a6264cb85e98

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 */);