suspend_blocker: Use Cuttlefish's workaround to avoid suspending the device

Reuse Cuttlefish's suspend blocker service to avoid
suspending the device while running CTS tests.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Change-Id: I547f1f635fc0779a58906a147b6cd821c531f4bb
diff --git a/device-common.mk b/device-common.mk
index 4beaf6e..18281e9 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -164,6 +164,10 @@
     android.hardware.health@2.1-impl-cuttlefish \
     android.hardware.health@2.1-service
 
+# TODO: disable this service once we implement system suspend
+PRODUCT_PACKAGES += \
+    suspend_blocker
+
 # mkbootimg host tool to build boot.img separately
 PRODUCT_HOST_PACKAGES := \
     mkbootimg
diff --git a/init.common.rc b/init.common.rc
index 247a161..483b42f 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -61,3 +61,9 @@
     class main
     disabled
     oneshot
+
+# TODO: disable this service once we implement system suspend
+service suspend_blocker /vendor/bin/suspend_blocker
+    class early_hal # Start together with system_suspend HAL
+    group system
+    user root
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index e36d1b2..41b9b28 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -36,6 +36,7 @@
 /vendor/bin/qrtr-ns									u:object_r:qrtr_exec:s0
 /vendor/bin/rmtfs									u:object_r:rmtfs_exec:s0
 /vendor/bin/tqftpserv									u:object_r:tqftpserv_exec:s0
+/vendor/bin/suspend_blocker								u:object_r:suspend_blocker_exec:s0
 
 /vendor/lib(64)?/dri/.*									u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/hw/gralloc\.gbm\.so							u:object_r:same_process_hal_file:s0
diff --git a/sepolicy/suspend_blocker.te b/sepolicy/suspend_blocker.te
new file mode 100644
index 0000000..fa6e02a
--- /dev/null
+++ b/sepolicy/suspend_blocker.te
@@ -0,0 +1,6 @@
+type suspend_blocker, domain;
+type suspend_blocker_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(suspend_blocker);
+
+wakelock_use(suspend_blocker);