Enable color temperature developer setting

Add a switch in Developer Settings to enable "cool" color temperature
mode.

Bug: 26110238
Change-Id: Id2062670fcee48f66a54f970ff7eb61272a59a58
diff --git a/init.bullhead.rc b/init.bullhead.rc
index 5130d38..5837dfd 100644
--- a/init.bullhead.rc
+++ b/init.bullhead.rc
@@ -132,6 +132,10 @@
     chmod 0664 /sys/devices/virtual/graphics/fb1/vendor_name
     chmod 0664 /sys/devices/virtual/graphics/fb1/product_description
 
+    # Grant permission to modify the color_temp setting
+    chown system graphics /sys/class/graphics/fb0/color_temp
+    chmod 0664 /sys/class/graphics/fb0/color_temp
+
     # Allow QMUX daemon to assign port open wait time
     chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
 
diff --git a/overlay/packages/apps/Settings/res/values/config.xml b/overlay/packages/apps/Settings/res/values/config.xml
new file mode 100644
index 0000000..5b12804
--- /dev/null
+++ b/overlay/packages/apps/Settings/res/values/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2016, 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.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+    <!-- Enable color temperature setting. -->
+    <bool name="config_enableColorTemperature">true</bool>
+
+</resources>
diff --git a/sepolicy/file.te b/sepolicy/file.te
index f2ab8f1..dbf1218 100644
--- a/sepolicy/file.te
+++ b/sepolicy/file.te
@@ -56,6 +56,7 @@
 
 #SurfaceFlinger file type for sysfs access
 type sysfs_graphics, sysfs_type, fs_type;
+type sysfs_display, sysfs_type, fs_type;
 
 # Files accessed by qcom-system-daemon
 type sysfs_socinfo, fs_type, sysfs_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 601631e..65e1528 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -132,6 +132,7 @@
 /sys/devices/virtual/graphics/fb([0-2])+/hpd                        u:object_r:sysfs_graphics:s0
 /sys/devices/virtual/graphics/fb([0-2])+/res_info                   u:object_r:sysfs_graphics:s0
 /sys/devices/virtual/graphics/fb([0-2])+/s3d_mode                   u:object_r:sysfs_graphics:s0
+/sys/devices/virtual/graphics/fb0/color_temp                        u:object_r:sysfs_display:s0
 /sys/devices/msm_hsic_host/host_ready                               u:object_r:sysfs_hsic_host_rdy:s0
 /sys/bus/msm_subsys(/.*)?                                           u:object_r:sysfs_ssr:s0
 /sys/bus/msm_subsys/devices/subsys0/restart_level                   u:object_r:sysfs_ssr_toggle:s0
diff --git a/sepolicy/surfaceflinger.te b/sepolicy/surfaceflinger.te
new file mode 100644
index 0000000..1b13fcb
--- /dev/null
+++ b/sepolicy/surfaceflinger.te
@@ -0,0 +1 @@
+allow surfaceflinger sysfs_display:file rw_file_perms;