summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2019-12-10 17:57:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-12-10 17:57:11 +0000
commitebef157495b791fcf659ae35a0a429c3b5dc50a3 (patch)
tree3b98b23b5c8091f3435e459a27ec64c86a68e730
parentd54ae538811b0520abc68cb3206fe68c86e0c0a3 (diff)
parentc32ff4f4711bd85d72409a2cabd6f64651f9242b (diff)
downloadcuttlefish_common-ebef157495b791fcf659ae35a0a429c3b5dc50a3.tar.gz
Merge "cuttlefish: suspend_blocker service"
-rw-r--r--guest/services/suspend_blocker/Android.bp20
-rw-r--r--guest/services/suspend_blocker/suspend_blocker.cpp26
2 files changed, 46 insertions, 0 deletions
diff --git a/guest/services/suspend_blocker/Android.bp b/guest/services/suspend_blocker/Android.bp
new file mode 100644
index 00000000..c87c4da9
--- /dev/null
+++ b/guest/services/suspend_blocker/Android.bp
@@ -0,0 +1,20 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_binary {
+ name: "suspend_blocker",
+ srcs: ["suspend_blocker.cpp"],
+ shared_libs: ["libpower"],
+ defaults: ["cuttlefish_guest_product_only"],
+}
diff --git a/guest/services/suspend_blocker/suspend_blocker.cpp b/guest/services/suspend_blocker/suspend_blocker.cpp
new file mode 100644
index 00000000..120a01b8
--- /dev/null
+++ b/guest/services/suspend_blocker/suspend_blocker.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <signal.h>
+#include <wakelock/wakelock.h>
+
+int main() {
+ android::wakelock::WakeLock wl{"suspend_blocker"}; // RAII object
+
+ sigset_t mask;
+ sigemptyset(&mask);
+ return sigsuspend(&mask); // Infinite sleep
+}