vnc: Add system-level integration

 * RC script, included automatically when added to PRODUCT_PACKAGES
 * SELinux policy, add to BOARD_SEPOLICY_DIRS
 * Disable spammy debug output
diff --git a/Android.mk b/Android.mk
index 2d97076..02cc7da 100644
--- a/Android.mk
+++ b/Android.mk
@@ -28,11 +28,14 @@
     libvncserver
 
 LOCAL_CFLAGS := -Ofast -Werror -std=c++11
-LOCAL_CFLAGS += -DLOG_NDEBUG=0
 
+#LOCAL_CFLAGS += -DLOG_NDEBUG=0
 #LOCAL_CXX := /usr/bin/include-what-you-use
 
+LOCAL_INIT_RC := etc/vncflinger.rc
+
 LOCAL_MODULE := vncflinger
+
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_EXECUTABLE)
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..a396709
--- /dev/null
+++ b/TODO
@@ -0,0 +1,8 @@
+Various things that need done:
+
+Orientation change
+FPS reporting
+Copy/paste
+Commandline args for tuning (port, encodings, etc)
+Authentication
+
diff --git a/etc/vncflinger.rc b/etc/vncflinger.rc
new file mode 100644
index 0000000..7d70f26
--- /dev/null
+++ b/etc/vncflinger.rc
@@ -0,0 +1,11 @@
+service vncflinger /system/bin/vncflinger
+    class late_start
+    disabled
+    user system
+    group system input inet readproc
+
+on property:persist.vnc.enable=true
+    start vncflinger
+
+on property:persist.vnc.enable=false
+    stop vncflinger
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
new file mode 100644
index 0000000..9c73aa4
--- /dev/null
+++ b/sepolicy/file_contexts
@@ -0,0 +1 @@
+/system/bin/vncflinger   u:object_r:vncflinger_exec:s0
diff --git a/sepolicy/vncflinger.te b/sepolicy/vncflinger.te
new file mode 100644
index 0000000..21213e0
--- /dev/null
+++ b/sepolicy/vncflinger.te
@@ -0,0 +1,17 @@
+type vncflinger_exec, exec_type, file_type;
+type vncflinger, domain;
+
+init_daemon_domain(vncflinger)
+binder_use(vncflinger)
+net_domain(vncflinger);
+
+# uinput
+allow vncflinger uhid_device:chr_file rw_file_perms;
+
+# read buffers from surfaceflinger
+allow vncflinger ion_device:chr_file r_file_perms;
+allow vncflinger surfaceflinger_service:service_manager find;
+binder_call(vncflinger, surfaceflinger);
+
+# buffer callbacks
+binder_call(surfaceflinger, vncflinger);