Build and configure alternative su binary on userdebug

By setting FP2_USE_APPOPS_SU to true the su binary gets built from
vendor/lineage/su, instead of from the default system/extras/su. This
alternative su binary allows for superuser access by applications.

The alternative su binary is configured by defining a system property
persist.sys.root_access with a default value of 0, which leaves the su
daemon disabled. Also override the file system permissions of the
alternative su binary to remove the setuid bit.

Issue: FP2P-458
Change-Id: I1a6de9017bbe81a1ff3077b5b3ae4aac140e8ee1
diff --git a/device.mk b/device.mk
index d8d3851..a84a45b 100644
--- a/device.mk
+++ b/device.mk
@@ -22,3 +22,19 @@
 ifeq ($(TARGET_BUILD_VARIANT), userdebug)
         PRODUCT_PROPERTY_OVERRIDES += ro.adb.secure=1
 endif
+
+# Build and configure alternative su binary
+# Allows for superuser access for apps on userdebug
+FP2_USE_APPOPS_SU = true
+
+ifeq ($(FP2_USE_APPOPS_SU), true)
+
+# Configure level of superuser access
+# 0 = disabled
+# 1 = Apps only
+# 2 = ADB only
+# 3 = Apps and ADB
+PRODUCT_PROPERTY_OVERRIDES += \
+	persist.sys.root_access=0
+
+endif