Merge "liblog: printable do not escape tabs" into mnc-dr2-dev
diff --git a/include/utils/Errors.h b/include/utils/Errors.h
index 46173db..9d8d92d 100644
--- a/include/utils/Errors.h
+++ b/include/utils/Errors.h
@@ -73,6 +73,7 @@
     UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6),
 #endif    
     FDS_NOT_ALLOWED     = (UNKNOWN_ERROR + 7),
+    UNEXPECTED_NULL     = (UNKNOWN_ERROR + 8),
 };
 
 // Restore define; enumeration is in "android" namespace, so the value defined
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index 46bd5ac..5853fbd 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -61,6 +61,7 @@
 static int fg_cgroup_fd = -1;
 
 // File descriptors open to /dev/cpuset/../tasks, setup by initialize, or -1 on error
+static int system_bg_cpuset_fd = -1;
 static int bg_cpuset_fd = -1;
 static int fg_cpuset_fd = -1;
 static int bg_schedboost_fd = -1;
@@ -128,6 +129,11 @@
         fg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
         filename = "/dev/cpuset/background/tasks";
         bg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
+        filename = "/dev/cpuset/system-background/tasks";
+        system_bg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
+        if (system_bg_cpuset_fd < 0) {
+            SLOGE("initialize of system-bg failed: %s\n", strerror(errno));
+        }
 #ifdef USE_SCHEDBOOST
         filename = "/sys/fs/cgroup/stune/foreground/tasks";
         fg_schedboost_fd = open(filename, O_WRONLY | O_CLOEXEC);
@@ -258,8 +264,8 @@
     policy = _policy(policy);
     pthread_once(&the_once, __initialize);
 
-    int fd;
-    int boost_fd;
+    int fd = -1;
+    int boost_fd = -1;
     switch (policy) {
     case SP_BACKGROUND:
         fd = bg_cpuset_fd;
@@ -271,6 +277,9 @@
         fd = fg_cpuset_fd;
         boost_fd = fg_schedboost_fd;
         break;
+    case SP_SYSTEM:
+        fd = system_bg_cpuset_fd;
+        break;
     default:
         boost_fd = fd = -1;
         break;
diff --git a/rootdir/init.rc b/rootdir/init.rc
index b8df647..92d34d9 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -174,6 +174,9 @@
     chown system system /dev/cpuset/foreground/boost/tasks
     chown system system /dev/cpuset/background/tasks
     chown system system /dev/cpuset/system-background/tasks
+
+    # set system-background to 0775 so SurfaceFlinger can touch it
+    chmod 0775 /dev/cpuset/system-background
     chmod 0664 /dev/cpuset/foreground/tasks
     chmod 0664 /dev/cpuset/foreground/boost/tasks
     chmod 0664 /dev/cpuset/background/tasks
@@ -652,7 +655,6 @@
     user system
     group graphics drmrpc
     onrestart restart zygote
-    writepid /sys/fs/cgroup/stune/foreground/tasks /dev/cpuset/system-background/tasks
 
 service drm /system/bin/drmserver
     class main