cuttlefish: suspend_blocker service

suspend_blocker's purpose is to make sure device never suspends.
Once system suspend is implemented on cuttlefish, suspend_blocker will
no longer be needed.

Bug: 136800571
Test: boot cuttlefish; "suspend_blocker" wakelock present
Change-Id: I91d0cf42f5f278e4b8bb309f0fb300c3e815ffbf
diff --git a/guest/services/suspend_blocker/Android.bp b/guest/services/suspend_blocker/Android.bp
new file mode 100644
index 0000000..c87c4da
--- /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 0000000..120a01b
--- /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
+}