Merge "Seandroid: Enable PP daemon at boot"
diff --git a/Android.mk b/Android.mk
index d2adf8a..0e64b87 100644
--- a/Android.mk
+++ b/Android.mk
@@ -62,6 +62,7 @@
healthd.te \
charger_monitor.te \
surfaceflinger.te \
+ mm-pp-daemon.te \
wpa.te \
bootanim.te \
zygote.te \
diff --git a/common/file.te b/common/file.te
index eb3b586..670e0ee 100755
--- a/common/file.te
+++ b/common/file.te
@@ -77,3 +77,6 @@
type sysfs_usb_uicc, sysfs_type, fs_type;
type qlogd_socket, file_type;
+
+#Define the files written during the operation of mm-pp-daemon
+type display_config, file_type, data_file_type;
diff --git a/common/file_contexts b/common/file_contexts
index c904741..7d33ebb 100644
--- a/common/file_contexts
+++ b/common/file_contexts
@@ -78,6 +78,7 @@
/system/bin/diag_socket_log u:object_r:diag_exec:s0
/system/bin/diag_uart_log u:object_r:diag_exec:s0
/system/bin/irsc_util u:object_r:irsc_util_exec:s0
+/system/bin/mm-pp-daemon u:object_r:mm-pp-daemon_exec:s0
/system/bin/mpdecision u:object_r:mpdecision_exec:s0
/system/bin/msm_irqbalance u:object_r:msm_irqbalanced_exec:s0
/system/bin/netmgrd u:object_r:netmgrd_exec:s0
@@ -153,6 +154,7 @@
/data/nfc(/.*)? u:object_r:nfc_data_file:s0
/data/system/perfd(/.*)? u:object_r:mpctl_data_file:s0
/data/misc/perfd(/.*)? u:object_r:mpctl_socket:s0
+/data/misc/display(/.*)? u:object_r:display_config:s0
###################################
# persist files
diff --git a/common/mm-pp-daemon.te b/common/mm-pp-daemon.te
new file mode 100755
index 0000000..b515c47
--- /dev/null
+++ b/common/mm-pp-daemon.te
@@ -0,0 +1,42 @@
+type mm-pp-daemon, domain;
+type mm-pp-daemon_exec, exec_type, file_type;
+
+init_daemon_domain(mm-pp-daemon)
+
+#============= mm-pp-daemon ==============
+#Need to use fb ioctls to communicate with kernel
+allow mm-pp-daemon graphics_device:chr_file rw_file_perms;
+allow mm-pp-daemon graphics_device:dir search;
+
+# Allow reading calibration data from persist
+allow mm-pp-daemon persist_file:file r_file_perms;
+allow mm-pp-daemon persist_file:dir search;
+
+# Allow pp daemon to save settings to /data
+allow mm-pp-daemon display_config:file rw_file_perms;
+
+#Calibration can only be done on userdebug or eng builds
+userdebug_or_eng(`
+ # Display calibration service opens /dev/diag in order to communicate with the
+ # target device
+ allow mm-pp-daemon diag_device:chr_file rw_file_perms;
+
+ # QDCM needs to trigger screen refreshes in some cases to reach the
+ # convergent state
+ binder_use(mm-pp-daemon)
+ binder_call(mm-pp-daemon, system_server)
+ binder_call(mm-pp-daemon, surfaceflinger)
+
+ # This allows pp-daemon to use shell commands to blank
+ # the display - it uses input keyevent to do this
+ allow mm-pp-daemon shell_exec:file rx_file_perms;
+ allow mm-pp-daemon system_file:file execute_no_trans;
+ allow mm-pp-daemon zygote_exec:file rx_file_perms;
+
+ # Allow writing to persist
+ allow mm-pp-daemon persist_file:file rw_file_perms;
+
+ # Allow mm-pp-daemon to change the brightness of the target during display
+ # calibration
+ allow mm-pp-daemon sysfs:file rw_file_perms;
+')
diff --git a/common/surfaceflinger.te b/common/surfaceflinger.te
index a8c764f..70eb70d 100644
--- a/common/surfaceflinger.te
+++ b/common/surfaceflinger.te
@@ -1,2 +1,8 @@
allow surfaceflinger sysfs_graphics:file rw_file_perms;
allow surfaceflinger shell_data_file:dir search;
+
+# Allows pp-daemon to refresh the screen in calibration mode
+userdebug_or_eng(`
+ allow surfaceflinger mm-pp-daemon:dir search;
+ allow surfaceflinger mm-pp-daemon:file r_file_perms;
+')